:root {
    --sidebar: #111827;
    --sidebar-soft: #1f2937;
    --accent: #2563eb;
    --page: #f3f6fb;
    --line: #d8dee9;
    --text: #111827;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    background: var(--page);
    color: var(--text);
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(440px, 100%);
    border: 0;
    border-radius: 8px;
    box-shadow: 0 18px 60px rgba(17, 24, 39, 0.14);
}

.brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
}

.page-wrapper {
    min-height: 100vh;
    display: flex;
}

.admin-sidebar {
    width: 248px;
    flex: 0 0 248px;
    background: var(--sidebar);
    color: #fff;
    padding: 18px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.admin-sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    margin-bottom: 22px;
    padding: 0 8px;
}

.admin-sidebar .nav-link {
    color: #d1d5db;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 4px;
}

.admin-sidebar .nav-link:hover,
.admin-sidebar .nav-link.active {
    color: #fff;
    background: var(--sidebar-soft);
}

.nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.09);
    margin: 12px 0;
}

.main-content {
    flex: 1;
    padding: 28px;
    min-width: 0;
}

.content-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 4px 18px rgba(17, 24, 39, 0.05);
}

.stat-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    min-height: 118px;
}

.stat-label {
    color: #6b7280;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.85rem;
    font-weight: 800;
    margin-top: 8px;
}

.quick-action {
    display: block;
    height: 100%;
    text-decoration: none;
    color: inherit;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.quick-action:hover {
    border-color: var(--accent);
    color: inherit;
}

.table td,
.table th {
    vertical-align: middle;
}

.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1080;
}

.empty-state {
    padding: 36px 16px;
    color: #6b7280;
    text-align: center;
}

.empty-state i {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
}

.result-table-scroll {
    max-height: 360px;
    overflow: auto;
}

.message-row {
    cursor: pointer;
}

.message-row.unseen td {
    font-weight: 700;
}

.mail-ui-body {
    background: #eef2f7;
    overflow-x: hidden;
}

.mail-app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    grid-template-rows: 58px minmax(0, 1fr);
}

.mail-header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 16px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid #d9e0ea;
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(12px);
}

.mail-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #0f172a;
    font-weight: 800;
    font-size: 1.22rem;
    text-decoration: none;
}

.mail-brand i {
    color: #1d6ff2;
}

.mail-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
}

.mail-search {
    width: min(360px, 42vw);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
}

.mail-search .form-control {
    border-radius: 8px 0 0 8px;
    min-height: 38px;
}

.mail-search .btn {
    border-radius: 0 8px 8px 0;
}

.btn-icon {
    width: 38px;
    height: 38px;
    display: inline-grid;
    place-items: center;
    border: 1px solid #cfd8e3;
    border-radius: 8px;
    background: #fff;
    color: #334155;
}

.btn-icon:hover {
    border-color: #9fb2ca;
    background: #f8fafc;
}

.btn-icon-danger {
    color: #d63f5d;
    border-color: #e6a6b5;
}

.mail-sidebar {
    grid-row: 2;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 58px);
    padding: 16px 12px;
    background: linear-gradient(180deg, #f9fbff 0%, #eef4fb 100%);
    border-right: 1px solid #d9e0ea;
}

.mail-compose-btn {
    min-height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 8px;
    font-weight: 700;
    box-shadow: 0 10px 28px rgba(37, 99, 235, 0.24);
}

.mail-folder-nav {
    display: grid;
    gap: 4px;
    margin-top: 18px;
}

.mail-folder {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 8px 10px;
    color: #283548;
    text-decoration: none;
    border-radius: 8px;
    border: 1px solid transparent;
}

.mail-folder i {
    width: 18px;
    text-align: center;
    color: #536579;
}

.mail-folder:hover,
.mail-folder.active {
    color: #0d2857;
    background: #d9e8ff;
    border-color: #c3dafb;
}

.mail-folder:hover i,
.mail-folder.active i {
    color: #1d6ff2;
}

.mail-quota {
    margin-top: auto;
    padding: 16px 8px 4px;
    color: #667386;
    font-size: 0.82rem;
}

.mail-quota-bar {
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: #dfe7f1;
}

.mail-quota-bar span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #1d6ff2, #12a37f);
    transition: width 0.2s ease;
}

.mail-main {
    grid-column: 2;
    min-width: 0;
    padding: 28px 24px;
}

.mail-main-toolbar {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.mail-page-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 1.24rem;
    font-weight: 800;
    color: #172033;
}

.mail-page-title i {
    color: #334155;
}

.mail-account {
    min-height: 18px;
    margin-top: 7px;
    color: #0f172a;
    font-size: 1.1rem;
    font-weight: 800;
    line-height: 1.25;
    word-break: break-word;
}

.mail-bulk-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.mail-list-panel,
.compose-panel,
.settings-panel,
.settings-quota {
    background: #fff;
    border: 1px solid #d7e0eb;
    border-radius: 8px;
    box-shadow: 0 18px 48px rgba(31, 45, 61, 0.08);
}

.mail-list-panel {
    min-height: calc(100vh - 148px);
    display: flex;
    flex-direction: column;
}

.email-list-table {
    table-layout: fixed;
}

.email-list-table th {
    height: 42px;
    color: #667386;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    border-bottom-color: #dbe4ef;
}

.email-list-table td {
    height: 54px;
    color: #273245;
    border-bottom-color: #edf1f6;
}

.email-list-table .message-row:hover td {
    background: #f6f9fd;
}

.email-checkbox-col {
    width: 48px;
}

.mail-sender,
.mail-subject,
.mail-date {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-sender {
    width: 28%;
}

.mail-subject {
    width: 46%;
}

.mail-date {
    width: 26%;
    color: #667386;
}

.mail-empty {
    flex: 1;
    min-height: 340px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 12px;
    color: #667386;
    text-align: center;
}

.mail-empty i {
    font-size: 2.8rem;
    color: #6f7d8e;
}

.email-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
    padding: 14px 16px;
    color: #667386;
    font-size: 0.84rem;
    border-top: 1px solid #edf1f6;
}

.mail-message-modal {
    border: 0;
    border-radius: 8px;
}

.mail-message-body {
    white-space: pre-wrap;
    margin: 0;
    color: #1f2937;
    font-family: inherit;
}

.mail-message-frame {
    width: 100%;
    min-height: 620px;
    border: 0;
    background: #fff;
}

.compose-panel {
    padding: 26px;
}

.compose-field {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.compose-field label {
    margin: 0;
    color: #667386;
    font-weight: 700;
}

.compose-panel .form-control,
.settings-panel .form-control {
    min-height: 38px;
    border-color: #d8e1ec;
    border-radius: 8px;
}

.compose-subject {
    margin: 8px 0 14px;
}

.compose-body {
    min-height: 300px;
    resize: vertical;
}

.compose-attachments {
    margin-top: 16px;
}

.compose-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.settings-quota {
    padding: 18px;
    margin-bottom: 22px;
}

.settings-tabs {
    gap: 8px;
    margin-bottom: 14px;
}

.settings-tabs .nav-link {
    border: 1px solid transparent;
    border-radius: 8px;
    color: #2563eb;
    background: transparent;
    font-weight: 700;
}

.settings-tabs .nav-link.active {
    color: #172033;
    background: #fff;
    border-color: #d7e0eb;
    box-shadow: 0 10px 24px rgba(31, 45, 61, 0.06);
}

.settings-panel {
    padding: 24px;
}

.settings-title {
    margin-bottom: 14px;
    font-size: 1rem;
    font-weight: 800;
}

.settings-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #273245;
}

@media (max-width: 860px) {
    .page-wrapper {
        display: block;
    }

    .admin-sidebar {
        width: 100%;
        height: auto;
        position: relative;
        display: block;
    }

    .admin-sidebar .nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 4px;
    }

    .main-content {
        padding: 18px;
    }

    .mail-app {
        display: block;
    }

    .mail-header {
        position: relative;
        flex-wrap: wrap;
        height: auto;
        padding: 12px;
    }

    .mail-header-actions {
        width: 100%;
    }

    .mail-search {
        width: 100%;
    }

    .mail-sidebar {
        min-height: 0;
        border-right: 0;
        border-bottom: 1px solid #d9e0ea;
    }

    .mail-folder-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mail-quota {
        margin-top: 14px;
    }

    .mail-main {
        padding: 18px 12px;
    }

    .mail-main-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .mail-bulk-actions {
        justify-content: flex-start;
    }

    .email-list-table {
        min-width: 720px;
    }

    .compose-panel,
    .settings-panel {
        padding: 18px;
    }

    .compose-field {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .email-pagination {
        align-items: flex-start;
        flex-direction: column;
    }
}
