@import url("../fontawesome/css/fontawesome.min.css");
@import url("../fontawesome/css/solid.min.css");

:root {
    color-scheme: dark;
    --admin-bg: #101411;
    --admin-panel: #171e19;
    --admin-panel-light: #202a22;
    --admin-text: #edf4ee;
    --admin-muted: #a3b0a5;
    --admin-green: #58d68d;
    --admin-border: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--admin-bg);
    color: var(--admin-text);
    font-family: Inter, Arial, sans-serif;
}

a { color: var(--admin-green); }

.admin-layout { min-height: 100vh; }

.admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    display: flex;
    width: 250px;
    flex-direction: column;
    padding: 28px 18px;
    background: #151b16;
    border-right: 1px solid var(--admin-border);
}

.admin-brand {
    display: block;
    color: var(--admin-muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-decoration: none;
    text-transform: uppercase;
}

.admin-brand strong { color: var(--admin-green); }

.admin-topbar {
    display: flex;
    min-height: 70px;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: -40px calc(clamp(22px, 5vw, 64px) * -1) 32px;
    padding: 12px clamp(22px, 5vw, 64px);
    border-bottom: 1px solid var(--admin-border);
    background: rgba(21, 27, 22, 0.96);
}

.admin-topbar-brand,
.admin-topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.admin-topbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--admin-text);
    font-weight: 800;
    letter-spacing: 0.06em;
    text-decoration: none;
}

.admin-topbar-brand img {
    display: block;
    width: 48px;
    height: 34px;
    object-fit: contain;
}

.admin-topbar-brand strong { color: var(--admin-green); }
.admin-user { color: var(--admin-muted); font-size: 0.92rem; }
.admin-topbar-public { font-size: 0.9rem; text-decoration: none; }

.admin-sidebar nav {
    display: grid;
    gap: 7px;
    margin-top: 42px;
}

.admin-sidebar nav a,
.admin-logout button {
    display: block;
    width: 100%;
    padding: 12px 14px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--admin-muted);
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.admin-sidebar nav a:hover,
.admin-sidebar nav a.active,
.admin-logout button:hover {
    background: rgba(88, 214, 141, 0.12);
    color: var(--admin-green);
}

.admin-logout { margin-top: auto; }

.admin-main {
    width: min(1200px, calc(100% - 250px));
    margin-left: 250px;
    padding: 40px clamp(22px, 5vw, 64px);
}

.admin-main .page-wrapper {
    max-width: none;
    margin: 0;
    padding: 0;
}

.admin-main .panel {
    border-color: var(--admin-border);
    background: var(--admin-panel);
    box-shadow: none;
}

.admin-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 30px;
}

.admin-header h1,
.login-card h1 { margin: 0 0 8px; }

.eyebrow {
    margin: 0 0 9px;
    color: var(--admin-green);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.muted { color: var(--admin-muted); }

.admin-card,
.login-card {
    padding: 24px;
    border: 1px solid var(--admin-border);
    border-radius: 15px;
    background: var(--admin-panel);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
}

.stat-card {
    position: relative;
    min-height: 174px;
    overflow: hidden;
    background: linear-gradient(145deg, var(--admin-panel), rgba(32, 42, 34, .72));
}

.stat-card::after {
    position: absolute;
    right: -28px;
    bottom: -52px;
    width: 138px;
    height: 138px;
    border: 1px solid rgba(130, 201, 150, .13);
    border-radius: 50%;
    box-shadow: 0 0 0 18px rgba(130, 201, 150, .025), 0 0 0 38px rgba(130, 201, 150, .02);
    content: "";
}

.stat-card strong { position: relative; z-index: 1; color: #d5e8c0; font-size: 2.25rem; letter-spacing: -.04em; }
.stat-card small { display: block; margin-top: 7px; color: var(--admin-muted); font-size: .78rem; }
.stat-icon { position: absolute; top: 20px; right: 22px; color: rgba(213, 232, 192, .28); font-size: .72rem; font-weight: 700; letter-spacing: .1em; }

.dashboard-charts {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(280px, .9fr);
    gap: 16px;
    margin-top: 18px;
}

.chart-card { min-width: 0; padding: 24px; }
.chart-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.chart-heading h2 { margin: 0 0 6px; font-size: 1.15rem; }
.chart-heading .eyebrow { margin-bottom: 8px; font-size: .65rem; }
.chart-heading .muted { margin: 0; font-size: .82rem; }
.chart-period { flex: 0 0 auto; padding: 7px 9px; border: 1px solid var(--admin-border); border-radius: 999px; color: var(--admin-muted); font-size: .63rem; font-weight: 700; letter-spacing: .1em; }
.chart-canvas { position: relative; width: 100%; }
.chart-canvas-line { height: 270px; margin-top: 22px; }
.chart-canvas-doughnut { width: min(100%, 210px); height: 190px; margin: 16px auto 12px; }
.chart-empty { display: grid; height: 100%; margin: 0; place-items: center; color: var(--admin-muted); font-size: .86rem; text-align: center; }
.chart-legend { display: grid; gap: 9px; margin: 16px 0 0; padding: 0; list-style: none; }
.chart-legend li { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; align-items: center; gap: 9px; color: var(--admin-muted); font-size: .8rem; }
.legend-swatch { width: 8px; height: 8px; border-radius: 50%; }
.chart-legend strong { color: var(--admin-text); font-size: .8rem; }

.stat-card strong {
    display: block;
    margin-top: 10px;
    color: var(--admin-green);
    font-size: 2rem;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.admin-card h2 { margin-top: 0; font-size: 1.15rem; }

.admin-form {
    display: grid;
    gap: 10px;
}

.admin-form label { margin-top: 8px; font-weight: 600; }

.admin-form input,
.admin-form textarea,
.admin-form select,
.search-form input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    background: #0f1410;
    color: var(--admin-text);
    font: inherit;
}

.admin-form textarea { min-height: 110px; resize: vertical; }

.password-field { position: relative; display: block; width: 100%; }
.password-field input { padding-right: 3.1rem !important; }
.password-visibility-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    display: grid;
    width: 36px;
    height: 36px;
    transform: translateY(-50%);
    place-items: center;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #71839a;
    cursor: pointer;
}
.password-visibility-toggle:hover { background: rgba(44, 127, 192, .1); color: #216ea9; }
.password-visibility-toggle:focus-visible { outline: 2px solid #3888c3; outline-offset: 1px; }
.password-visibility-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.password-eye-slash { display: none; }
.password-visibility-toggle[aria-pressed="true"] .password-eye-slash { display: block; }
:root[data-theme="dark"] .password-visibility-toggle { color: #a0afc0; }
:root[data-theme="dark"] .password-visibility-toggle:hover { background: rgba(120, 191, 240, .12); color: #8bc9f2; }
:root[data-theme="dark"] .password-visibility-toggle:focus-visible { outline-color: #78bff0; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    padding: 10px 15px;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    background: var(--admin-panel-light);
    color: var(--admin-text);
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.button.primary {
    border-color: var(--admin-green);
    background: var(--admin-green);
    color: #102116;
}

.button.full-width { width: 100%; margin-top: 12px; }
.button:hover { filter: brightness(1.08); }

.notice {
    margin: 0 0 18px;
    padding: 12px 14px;
    border-radius: 8px;
}

.notice.error { background: rgba(231, 76, 60, 0.15); color: #ffaaa0; }
.notice.info { background: rgba(56, 136, 195, 0.15); color: #b6dcf4; }
.notice.success { background: rgba(46, 204, 113, 0.14); color: #a0f0bd; }
.recovery-code code {
    display: block;
    margin-top: 12px;
    padding: 12px;
    overflow-wrap: anywhere;
    border-radius: 7px;
    background: rgba(0, 0, 0, 0.25);
    color: var(--admin-text);
}

.recovery-card { margin-top: 20px; }

.table-wrap { overflow-x: auto; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.admin-table th,
.admin-table td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--admin-border);
    vertical-align: top;
}

.admin-table th { color: var(--admin-muted); font-size: 0.82rem; }

.search-form {
    display: flex;
    max-width: 550px;
    gap: 10px;
    margin-bottom: 20px;
}

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

.login-card {
    width: min(100%, 440px);
    padding: 36px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}

.login-brand { width: fit-content; margin-bottom: 32px; }
.login-card .muted { line-height: 1.6; }
.login-card .admin-form { margin-top: 24px; }
.login-public-link { display: inline-block; margin-top: 20px; font-size: 0.9rem; }
.login-public-link:hover { text-decoration: none; }

.activity-success { color: var(--admin-green); font-weight: 700; }
.activity-failed { color: #ffaaa0; font-weight: 700; }

@media (max-width: 760px) {
    .admin-sidebar {
        position: static;
        width: 100%;
        padding: 16px;
        border-right: 0;
        border-bottom: 1px solid var(--admin-border);
    }

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

    .admin-sidebar nav a,
    .admin-logout button { padding: 10px; font-size: 0.9rem; }

    .admin-logout { margin-top: 8px; }

    .admin-main {
        width: 100%;
        margin-left: 0;
        padding: 24px 16px;
    }

    .admin-topbar {
        min-height: 60px;
        margin: -24px -16px 24px;
        padding: 10px 16px;
    }

    .admin-topbar-brand img { width: 42px; height: 30px; }
    .admin-topbar-actions { gap: 10px; }
    .admin-user { display: none; }
    .admin-brand img { width: 42px; height: 30px; }
    .admin-header { flex-direction: column; }
    .login-card { padding: 26px 22px; }
    .search-form { flex-direction: column; }
}

/* Shared workspace layout */
:root {
    color-scheme: light;
    --admin-bg: #f2f5f9;
    --admin-panel: #ffffff;
    --admin-panel-light: #eaf1f8;
    --admin-text: #132b43;
    --admin-muted: #71839a;
    --admin-green: #2776b9;
    --admin-border: #dce5ee;
    --admin-navy: #0d2135;
    --admin-sidebar: #12314d;
    --admin-sidebar-hover: #24445e;
    --admin-accent: #f2b24b;
}

body {
    background: var(--admin-bg);
    color: var(--admin-text);
}

a { color: #2476b8; }

.admin-sidebar {
    width: 270px;
    height: 100vh;
    overflow-y: auto;
    padding: 30px 18px 18px;
    background: linear-gradient(180deg, #12314d 0%, #0d263e 100%);
    border: 0;
    color: #eaf2f9;
}

.admin-sidebar-head,
.admin-sidebar-panel {
    display: contents;
}

.admin-sidebar-toggle {
    display: none;
}

.admin-brand {
    display: flex;
    min-height: 58px;
    align-items: center;
    gap: 13px;
    padding: 0 10px;
    color: #fff;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.admin-brand img {
    display: block;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    object-fit: contain;
}

.admin-brand-copy {
    display: grid;
    gap: 3px;
}

.admin-brand strong {
    color: var(--admin-accent);
    font-size: 0.68rem;
    letter-spacing: 0.16em;
}

.sidebar-section-label {
    margin: 28px 12px 12px;
    color: #8fa6ba;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.admin-sidebar nav {
    gap: 5px;
    margin-top: 0;
}

.admin-sidebar nav a,
.admin-logout button,
.sidebar-public-link {
    display: flex;
    min-height: 46px;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    border-radius: 9px;
    color: #c5d2df;
    font-size: 0.91rem;
    font-weight: 600;
    transition: background-color 150ms ease, color 150ms ease;
}

.nav-icon {
    display: inline-grid;
    width: 22px;
    place-items: center;
    color: #b8cad9;
    font-size: 1.05rem;
}

.admin-sidebar nav a:hover,
.admin-sidebar nav a.active {
    background: var(--admin-sidebar-hover);
    color: var(--admin-accent);
}

.admin-sidebar nav a.active .nav-icon,
.admin-sidebar nav a:hover .nav-icon {
    color: var(--admin-accent);
}

.admin-sidebar-footer {
    display: grid;
    gap: 4px;
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(220, 233, 245, 0.14);
}

.sidebar-public-link,
.admin-logout button {
    width: 100%;
    border: 0;
    background: transparent;
    color: #c5d2df;
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.sidebar-public-link:hover,
.admin-logout button:hover {
    background: var(--admin-sidebar-hover);
    color: #fff;
}

.admin-account {
    position: relative;
    z-index: 30;
}

.admin-account-trigger {
    display: flex;
    min-height: 42px;
    align-items: center;
    gap: 9px;
    padding: 5px 9px;
    border-radius: 9px;
    color: #d2dce6;
    font-size: 0.85rem;
    font-weight: 700;
    list-style: none;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease;
}

.admin-account-trigger:hover,
.admin-account:focus-within > .admin-account-trigger {
    background: var(--admin-sidebar-hover);
    color: #fff;
}

.admin-account-trigger:focus-visible {
    outline: 2px solid var(--admin-accent);
    outline-offset: 2px;
}

.admin-account-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-account-menu {
    position: absolute;
    right: 0;
    top: 100%;
    min-width: 210px;
    z-index: 20;
    display: none;
    padding: 6px;
    border: 1px solid rgba(220, 233, 245, 0.14);
    border-radius: 10px;
    background: #0d263e;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
}

.admin-account:hover .admin-account-menu,
.admin-account:focus-within .admin-account-menu {
    display: block;
}

.admin-account-menu a,
.admin-account-menu button {
    display: flex;
    width: 100%;
    min-height: 42px;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #d2deea;
    font: inherit;
    font-size: 0.88rem;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.admin-account-menu a:hover,
.admin-account-menu button:hover {
    background: var(--admin-sidebar-hover);
    color: #fff;
}

.admin-account-menu form {
    margin: 0;
}

.user-avatar {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 50%;
    background: var(--admin-accent);
    color: #17334b;
    font-weight: 800;
}

.admin-main {
    width: auto;
    min-height: 100vh;
    margin-left: 270px;
    padding: 0 clamp(26px, 4vw, 64px) 48px;
    background: var(--admin-bg);
}

.admin-topbar {
    min-height: 74px;
    margin: 0 calc(clamp(26px, 4vw, 64px) * -1) 46px;
    padding: 0 clamp(26px, 4vw, 64px);
    border: 0;
    background: #07131f;
    color: #f5f8fb;
}

.topbar-title {
    color: #f5f8fb;
    font-size: 0.96rem;
    font-weight: 800;
}

.admin-topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.theme-toggle {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid rgba(210, 220, 230, 0.2);
    border-radius: 8px;
    background: transparent;
    color: #d2dce6;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}

.theme-toggle:hover {
    border-color: rgba(210, 220, 230, 0.45);
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--admin-accent);
    outline-offset: 2px;
}

.theme-toggle-icon {
    font-size: 1rem;
}

.admin-topbar-public {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #d2dce6;
    font-size: 0.83rem;
    font-weight: 700;
    text-decoration: none;
}

.admin-topbar-public:hover { color: #fff; }

.admin-header {
    align-items: center;
    margin-bottom: 30px;
}

.admin-header h1 {
    color: #122c46;
    font-size: clamp(2rem, 3.4vw, 2.65rem);
    font-weight: 500;
    letter-spacing: -0.035em;
}

.admin-header .eyebrow {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #2776b9;
    letter-spacing: 0.15em;
}

.admin-header .eyebrow::before {
    width: 22px;
    height: 2px;
    background: var(--admin-accent);
    content: "";
}

.muted { color: var(--admin-muted); }

.admin-card,
.login-card {
    border-color: #e1e8ef;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(21, 47, 72, 0.06);
}

.stats-grid { gap: 18px; }

.stat-card {
    min-height: 130px;
    border-top: 3px solid #2c7fc0;
}

.stat-card strong {
    color: #1e6fae;
    font-size: 2.1rem;
}

.stat-card:nth-child(2) { border-top-color: #238b70; }
.stat-card:nth-child(2) strong { color: #238b70; }
.stat-card:nth-child(3) { border-top-color: #a36cb0; }
.stat-card:nth-child(3) strong { color: #875593; }

.admin-grid { gap: 18px; }
.admin-card h2 { color: #17334d; }

.button {
    border-color: #d5e1eb;
    background: #f5f8fb;
    color: #266fa8;
}

.button.primary {
    border-color: #216ea9;
    background: #216ea9;
    color: #fff;
}

.button.primary:hover { background: #185c91; }

.admin-form input,
.admin-form textarea,
.admin-form select,
.search-form input {
    border-color: #cbd8e4;
    background: #fff;
    color: #18334c;
}

.admin-form input:focus,
.admin-form textarea:focus,
.admin-form select:focus,
.search-form input:focus {
    border-color: #3888c3;
    outline: 3px solid rgba(56, 136, 195, 0.15);
}

.admin-table th { color: #71839a; }
.admin-table td { color: #243d55; }
.activity-success { color: #187857; }
.activity-failed { color: #b13d36; }

.notice.error { background: #fff0ee; color: #a53630; }
.notice.info { background: #edf6fd; color: #245d86; }
.notice.success { background: #eaf7f0; color: #176747; }

.login-page {
    background:
        radial-gradient(circle at 15% 15%, rgba(56, 136, 195, 0.13), transparent 28rem),
        var(--admin-bg);
}

.login-theme-toggle {
    position: fixed;
    top: 18px;
    right: 18px;
    color: var(--admin-text);
    border-color: var(--admin-border);
}

.login-theme-toggle:hover {
    background: var(--admin-panel-light);
    color: var(--admin-text);
}

.login-card { padding: 38px; }
.login-card h1 { color: #132e48; }
.login-brand { display: block; }
.login-brand img { width: 170px; height: 90px; object-fit: contain; }
.login-card .eyebrow { color: #2776b9; }
.login-card .admin-form { margin-top: 20px; }

.admin-main .panel {
    border-color: #e1e8ef;
    background: #fff;
}

.upload-panel { margin-bottom: 0; }
.upload-panel .page-subtitle { color: var(--admin-muted); }
.upload-panel code { color: #216ea9; }
.upload-panel .form-control,
.upload-panel .form-select,
.upload-panel .select2-container--default .select2-selection--single {
    border-color: #cbd8e4;
    background: #fff;
    color: #18334c;
}

.upload-panel .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #18334c;
}

.upload-panel .select2-container--default .select2-dropdown,
.upload-panel .select2-container--classic .select2-dropdown {
    border-color: #cbd8e4 !important;
    background: #fff !important;
}

.upload-panel .select2-container--default .select2-results__option,
.upload-panel .select2-container--classic .select2-results__option {
    background: #fff !important;
    color: #18334c !important;
}

.upload-panel .select2-container--default .select2-results__option--highlighted,
.upload-panel .select2-container--classic .select2-results__option--highlighted {
    background: #e9f2fa !important;
    color: #18334c !important;
}

.upload-panel .menu-preview {
    border-color: #e1e8ef;
    background: #f8fafc;
}

.upload-panel .menu-preview h2 { color: #216ea9; }
.upload-panel .form-text { color: var(--admin-muted) !important; }
.upload-panel .btn-primary { border-color: #216ea9; background: #216ea9; color: #fff; }
.upload-panel .btn-secondary { border-color: #6c7d8e; background: #6c7d8e; color: #fff; }
.upload-panel .alert-danger { color: #842029; }

@media (max-width: 760px) {
    .admin-sidebar {
        position: relative;
        z-index: 40;
        width: 100%;
        height: auto;
        overflow: visible;
        padding: 0;
        background: transparent;
    }

    .admin-sidebar-head {
        display: flex;
        min-height: 68px;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 8px 14px;
        background: linear-gradient(180deg, #12314d 0%, #0d263e 100%);
    }

    .admin-brand {
        min-width: 0;
        min-height: 48px;
        gap: 8px;
        padding: 0;
    }

    .admin-brand img {
        width: 36px;
        height: 36px;
        flex-basis: 36px;
    }

    .admin-brand-copy {
        font-size: 0.9rem;
        white-space: nowrap;
    }

    .admin-sidebar-toggle {
        display: inline-flex;
        flex: 0 0 auto;
        min-height: 42px;
        align-items: center;
        gap: 7px;
        padding: 8px 9px;
        border: 1px solid rgba(220, 233, 245, 0.2);
        border-radius: 8px;
        color: #eaf2f9;
        background: transparent;
        font: inherit;
        font-size: 0.9rem;
        font-weight: 700;
        cursor: pointer;
        transition: background-color 150ms ease, color 150ms ease;
    }

    .admin-sidebar-toggle:hover,
    .admin-sidebar-toggle[aria-expanded="true"] {
        background: var(--admin-sidebar-hover);
        color: var(--admin-accent);
    }

    .admin-sidebar-toggle:focus-visible {
        outline: 2px solid var(--admin-accent);
        outline-offset: 2px;
    }

    .sidebar-toggle-icon {
        font-size: 1.1rem;
    }

    .admin-sidebar-panel {
        display: none;
    }

    .admin-sidebar.menu-open .admin-sidebar-panel {
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        z-index: 40;
        display: block;
        max-height: calc(100vh - 68px);
        overflow-y: auto;
        padding: 0 14px 14px;
        background: linear-gradient(180deg, #12314d 0%, #0d263e 100%);
        box-shadow: 0 14px 24px rgba(0, 0, 0, 0.28);
    }

    .sidebar-section-label {
        margin: 8px 10px;
    }

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

    .admin-sidebar nav a {
        min-height: 42px;
        padding: 8px 12px;
        white-space: nowrap;
    }

    .admin-sidebar-footer {
        margin-top: 10px;
        padding-top: 10px;
    }

    .admin-main {
        width: 100%;
        min-height: auto;
        margin-left: 0;
        padding: 0 16px 32px;
    }

    .admin-topbar {
        min-height: 60px;
        margin: 0 -16px 28px;
        padding: 0 16px;
    }

    .admin-header { align-items: flex-start; }
}

@media (max-width: 480px) {
    .admin-topbar {
        gap: 8px;
    }

    .topbar-title {
        white-space: nowrap;
    }

    .admin-account-name {
        display: none;
    }
}

@media (max-width: 380px) {
    .theme-toggle {
        padding: 6px 8px;
    }

    .theme-toggle-label {
        display: none;
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --admin-bg: #0c1420;
    --admin-panel: #151f2e;
    --admin-panel-light: #1c2a3c;
    --admin-text: #e7edf5;
    --admin-muted: #a0afc0;
    --admin-green: #67b7ec;
    --admin-border: #2b3b4f;
    --admin-sidebar-hover: #24445e;
}

:root[data-theme="dark"] body {
    background: var(--admin-bg);
    color: var(--admin-text);
}

:root[data-theme="dark"] a {
    color: #8bc9f2;
}

:root[data-theme="dark"] .admin-sidebar {
    background: linear-gradient(180deg, #10283f 0%, #0b1d30 100%);
}

:root[data-theme="dark"] .admin-topbar {
    background: #070d16;
}

:root[data-theme="dark"] .admin-header h1,
:root[data-theme="dark"] .admin-card h2,
:root[data-theme="dark"] .login-card h1 {
    color: #e7edf5;
}

:root[data-theme="dark"] .admin-header .eyebrow,
:root[data-theme="dark"] .login-card .eyebrow {
    color: #78bff0;
}

:root[data-theme="dark"] .admin-card,
:root[data-theme="dark"] .login-card,
:root[data-theme="dark"] .admin-main .panel {
    border-color: var(--admin-border);
    background: var(--admin-panel);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
}

:root[data-theme="dark"] .stat-card strong,
:root[data-theme="dark"] .stat-card:nth-child(2) strong,
:root[data-theme="dark"] .stat-card:nth-child(3) strong {
    color: #8bc9f2;
}

:root[data-theme="dark"] .stat-card:nth-child(2) strong {
    color: #6bd0a8;
}

:root[data-theme="dark"] .stat-card:nth-child(3) strong {
    color: #c49be0;
}

:root[data-theme="dark"] .button {
    border-color: #3a4d63;
    background: var(--admin-panel-light);
    color: #dce7f2;
}

:root[data-theme="dark"] .button.primary {
    border-color: #287db5;
    background: #287db5;
    color: #fff;
}

:root[data-theme="dark"] .button.primary:hover {
    background: #3691ca;
}

:root[data-theme="dark"] .admin-form input,
:root[data-theme="dark"] .admin-form textarea,
:root[data-theme="dark"] .admin-form select,
:root[data-theme="dark"] .search-form input,
:root[data-theme="dark"] .upload-panel .form-control,
:root[data-theme="dark"] .upload-panel .form-select {
    border-color: #3a4c60;
    background-color: #101a28;
    color: #e7edf5;
}

:root[data-theme="dark"] .admin-form input::placeholder,
:root[data-theme="dark"] .admin-form textarea::placeholder,
:root[data-theme="dark"] .search-form input::placeholder {
    color: #8c9daf;
}

:root[data-theme="dark"] .admin-form input:focus,
:root[data-theme="dark"] .admin-form textarea:focus,
:root[data-theme="dark"] .admin-form select:focus,
:root[data-theme="dark"] .search-form input:focus,
:root[data-theme="dark"] .upload-panel .form-control:focus,
:root[data-theme="dark"] .upload-panel .form-select:focus {
    border-color: #55a8dd;
    outline-color: rgba(85, 168, 221, 0.22);
}

:root[data-theme="dark"] .admin-table th,
:root[data-theme="dark"] .admin-table td {
    border-color: var(--admin-border);
}

:root[data-theme="dark"] .admin-table th {
    color: #a0afc0;
}

:root[data-theme="dark"] .admin-table td {
    color: #d5deea;
}

:root[data-theme="dark"] .notice.error,
:root[data-theme="dark"] .upload-panel .alert-danger {
    background: #3b2025;
    color: #ffb4ac;
}

:root[data-theme="dark"] .notice.success {
    background: #17372f;
    color: #a5e7c7;
}

:root[data-theme="dark"] .notice.info {
    background: #182f42;
    color: #b6dcf4;
}

:root[data-theme="dark"] .upload-panel .page-subtitle,
:root[data-theme="dark"] .upload-panel .form-label {
    color: #dce7f2;
}

:root[data-theme="dark"] .upload-panel code {
    color: #8bc9f2;
}

:root[data-theme="dark"] .upload-panel .menu-preview {
    border-color: var(--admin-border);
    background: #101a28;
    color: #d5deea;
}

:root[data-theme="dark"] .upload-panel .menu-preview h2 {
    color: #8bc9f2;
}

:root[data-theme="dark"] .upload-panel .select2-container--default .select2-selection--single,
:root[data-theme="dark"] .upload-panel .select2-container--default .select2-dropdown,
:root[data-theme="dark"] .upload-panel .select2-container--classic .select2-dropdown {
    border-color: #3a4c60 !important;
    background: #101a28 !important;
    color: #e7edf5 !important;
}

:root[data-theme="dark"] .upload-panel .select2-container--default .select2-selection__rendered,
:root[data-theme="dark"] .upload-panel .select2-container--default .select2-results__option,
:root[data-theme="dark"] .upload-panel .select2-container--classic .select2-results__option {
    background: #101a28 !important;
    color: #e7edf5 !important;
}

:root[data-theme="dark"] .upload-panel .select2-container--default .select2-results__option--highlighted,
:root[data-theme="dark"] .upload-panel .select2-container--classic .select2-results__option--highlighted {
    background: #24445e !important;
    color: #fff !important;
}

:root[data-theme="dark"] .upload-panel .btn-secondary {
    border-color: #53677c;
    background: #40566c;
    color: #fff;
}

/* Dashboard charts and summary cards */
.stats-grid .stat-card {
    min-height: 154px;
    border-top: 3px solid #2c7fc0;
    background: linear-gradient(145deg, #fff, #f7fafc);
}
.stats-grid .stat-card:nth-child(2) { border-top-color: #238b70; }
.stats-grid .stat-card:nth-child(3) { border-top-color: #a36cb0; }
.stats-grid .stat-card strong { color: #1e6fae; font-size: 2.25rem; }
.stats-grid .stat-card:nth-child(2) strong { color: #238b70; }
.stats-grid .stat-card:nth-child(3) strong { color: #875593; }
.stats-grid .stat-card::after { border-color: rgba(44, 127, 192, .13); box-shadow: 0 0 0 18px rgba(44, 127, 192, .025), 0 0 0 38px rgba(44, 127, 192, .02); }
.stats-grid .stat-card:nth-child(2)::after { border-color: rgba(35, 139, 112, .13); }
.stats-grid .stat-card:nth-child(3)::after { border-color: rgba(163, 108, 176, .13); }
.dashboard-charts { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .9fr); gap: 18px; margin-top: 18px; }
.dashboard-charts .chart-card { min-width: 0; padding: 24px; }
.dashboard-charts .chart-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.dashboard-charts .chart-heading h2 { margin: 0 0 6px; font-size: 1.15rem; }
.dashboard-charts .chart-heading .eyebrow { margin-bottom: 8px; font-size: .65rem; }
.dashboard-charts .chart-heading .muted { margin: 0; font-size: .82rem; }
.chart-period { flex: 0 0 auto; padding: 7px 9px; border: 1px solid #dce5ec; border-radius: 999px; color: #71839a; font-size: .63rem; font-weight: 700; letter-spacing: .1em; }
.chart-canvas { position: relative; width: 100%; }
.chart-canvas-line { height: 270px; margin-top: 22px; }
.chart-canvas-doughnut { width: min(100%, 210px); height: 190px; margin: 16px auto 12px; }
.chart-empty { display: grid; height: 100%; margin: 0; place-items: center; color: var(--admin-muted); font-size: .86rem; text-align: center; }
.chart-legend { display: grid; gap: 9px; margin: 16px 0 0; padding: 0; list-style: none; }
.chart-legend li { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; align-items: center; gap: 9px; color: var(--admin-muted); font-size: .8rem; }
.legend-swatch { width: 8px; height: 8px; border-radius: 50%; }
.chart-legend strong { color: var(--admin-text); font-size: .8rem; }

:root[data-theme="dark"] .stats-grid .stat-card { background: linear-gradient(145deg, var(--admin-panel), var(--admin-panel-light)); }
:root[data-theme="dark"] .stats-grid .stat-card strong,
:root[data-theme="dark"] .stats-grid .stat-card:nth-child(2) strong,
:root[data-theme="dark"] .stats-grid .stat-card:nth-child(3) strong { color: #8bc9f2; }
:root[data-theme="dark"] .stats-grid .stat-card:nth-child(2) strong { color: #6bd0a8; }
:root[data-theme="dark"] .stats-grid .stat-card:nth-child(3) strong { color: #c49be0; }
:root[data-theme="dark"] .chart-period { border-color: var(--admin-border); color: var(--admin-muted); }

@media (max-width: 900px) {
    .dashboard-charts { grid-template-columns: minmax(0, 1fr); }
    .chart-canvas-doughnut { width: min(100%, 240px); height: 210px; }
}
@media (max-width: 480px) {
    .dashboard-charts .chart-card { padding: 19px; }
    .chart-canvas-line { height: 230px; }
}

.upload-panel .upload-previews {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin: 8px 0 24px;
}
.upload-panel form > .mb-3:first-of-type { position: relative; z-index: 5; }
.upload-panel .menu-search-results {
    position: absolute;
    top: calc(100% - 1px);
    right: 0;
    left: 0;
    z-index: 10;
    max-height: 280px;
    overflow-y: auto;
    margin: 0;
    padding: 5px;
    border: 1px solid #cbd8e4;
    border-radius: 0 0 9px 9px;
    background: #fff;
    box-shadow: 0 12px 24px rgba(21, 47, 72, .14);
    list-style: none !important;
    padding-left: 5px !important;
}
.upload-panel .menu-search-option,
.upload-panel .menu-search-empty { padding: 10px 12px; border-radius: 6px; color: #18334c; font-size: .9rem; }
.upload-panel .menu-search-option { cursor: pointer; }
.upload-panel .menu-search-option:hover,
.upload-panel .menu-search-option[aria-selected="true"] { background: #e9f2fa; color: #18334c; }
.upload-panel .menu-search-empty { color: #71839a; }
.upload-panel #menuSearch[aria-expanded="true"] { border-bottom-right-radius: 0; border-bottom-left-radius: 0; }
.upload-panel .image-preview-card {
    min-width: 0;
    padding: 16px;
    border: 1px solid #e1e8ef;
    border-radius: 12px;
    background: #f8fafc;
}
.upload-panel .image-preview-card h2 { margin: 0 0 12px; color: #17334d; font-size: .98rem; }
.upload-panel .image-preview-frame {
    display: grid;
    min-height: 190px;
    place-items: center;
    overflow: hidden;
    border: 1px dashed #cbd8e4;
    border-radius: 8px;
    background: #fff;
}
.upload-panel .image-preview-frame img { display: block; width: 100%; height: 220px; object-fit: contain; }
.upload-panel [hidden] { display: none !important; }
.upload-panel .image-preview-frame p { margin: 0; padding: 18px; color: #71839a; font-size: .84rem; text-align: center; }
.upload-panel .image-preview-caption { min-height: 1.2em; margin: 10px 0 0; overflow-wrap: anywhere; color: #71839a; font-size: .78rem; }
.upload-panel .replacement-note { margin: 0 0 16px; padding: 11px 13px; border-left: 3px solid #a36cb0; border-radius: 5px; background: #f6eff8; color: #593863; font-size: .88rem; }
.upload-panel .upload-validation { margin-top: 8px; color: #b42318; font-size: .84rem; }
.upload-panel .upload-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.upload-panel .upload-actions .btn { margin: 0 !important; }

:root[data-theme="dark"] .upload-panel .image-preview-card { border-color: var(--admin-border); background: var(--admin-panel-light); }
:root[data-theme="dark"] .upload-panel .menu-search-results { border-color: var(--admin-border); background: var(--admin-panel); box-shadow: 0 12px 24px rgba(0, 0, 0, .32); }
:root[data-theme="dark"] .upload-panel .menu-search-option,
:root[data-theme="dark"] .upload-panel .menu-search-empty { color: var(--admin-text); }
:root[data-theme="dark"] .upload-panel .menu-search-option:hover,
:root[data-theme="dark"] .upload-panel .menu-search-option[aria-selected="true"] { background: var(--admin-panel-light); color: var(--admin-text); }
:root[data-theme="dark"] .upload-panel .image-preview-card h2 { color: var(--admin-text); }
:root[data-theme="dark"] .upload-panel .image-preview-frame { border-color: #3a4c60; background: #101a28; }
:root[data-theme="dark"] .upload-panel .image-preview-frame p,
:root[data-theme="dark"] .upload-panel .image-preview-caption { color: var(--admin-muted); }
:root[data-theme="dark"] .upload-panel .replacement-note { border-left-color: #c49be0; background: #2b2234; color: #eadcf2; }
:root[data-theme="dark"] .upload-panel .upload-validation { color: #ffb4ac; }

@media (max-width: 600px) {
    .upload-panel .upload-previews { grid-template-columns: minmax(0, 1fr); }
    .upload-panel .image-preview-frame { min-height: 160px; }
    .upload-panel .image-preview-frame img { height: 180px; }
}
.admin-form .password-field input { padding-right: 3.1rem !important; }
