:root {
    --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    --text: #1e3c52;
    --muted: #5e7d92;
    --muted2: #7f97a8;
    --panel: #ffffff;
    --panel-2: #f5f8fb;
    --border: #d7e2ea;
    --brand: #1e88ff;
    --brand2: #14b8a6;
    --danger: #ef4444;
    --shadow: 0 10px 26px rgba(13, 41, 64, .08);
    --shadow-strong: 0 18px 44px rgba(13, 41, 64, .14);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background: #eef3f7;
}

    /* Optional hook for future dark pages */
    body.dark-theme {
        --text: rgba(255,255,255,0.90);
        --muted: rgba(255,255,255,0.65);
        --muted2: rgba(255,255,255,0.50);
        --panel: rgba(255,255,255,0.06);
        --panel-2: rgba(255,255,255,0.08);
        --border: rgba(255,255,255,0.10);
        --shadow: 0 20px 60px rgba(0,0,0,.45);
        --shadow-strong: 0 24px 70px rgba(0,0,0,.50);
        color: var(--text);
        background: radial-gradient(1200px 600px at 20% -10%, rgba(30,136,255,.35), transparent 60%), radial-gradient(900px 500px at 90% 10%, rgba(20,184,166,.22), transparent 55%), linear-gradient(180deg, #050914 0%, #0b1220 55%, #070b14 100%);
    }

.muted {
    color: var(--muted);
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    color: var(--muted);
}

/* Shared layout */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(10px);
    background: rgba(255,255,255,0.72);
    border-bottom: 1px solid var(--border);
}

body.dark-theme .topbar {
    background: rgba(5,9,20,0.65);
}

.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

    .brand h1 {
        margin: 0;
        font-size: 20px;
        line-height: 1.2;
        letter-spacing: .2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

.version {
    display: flex;
    align-items: center;
    gap: 10px;
}

.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 18px 20px 26px;
}

/* Shared cards */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 14px 16px 12px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    background: linear-gradient(180deg, rgba(0,0,0,0.025), transparent);
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

body.dark-theme .card-header {
    background: linear-gradient(180deg, rgba(255,255,255,0.06), transparent);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.card-title {
    margin: 0;
    font-size: 16px;
    font-weight: 900;
    letter-spacing: .2px;
}

.card-sub {
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
}

/* Small shared UI elements */
.pill,
.count,
.badge {
    border-radius: 999px;
    font-weight: 800;
}

.pill {
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted2);
    padding: 7px 10px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    font-weight: 900;
}

.count {
    padding: 7px 10px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    font-size: 12px;
    color: var(--text);
}

.badge {
    padding: 8px 12px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    font-size: 13px;
    color: var(--text);
    box-shadow: 0 6px 14px rgba(13,41,64,.08);
}

body.dark-theme .badge {
    box-shadow: 0 10px 20px rgba(0,0,0,.25);
}

.btn {
    font: inherit;
    color: inherit;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    padding: 10px 12px;
    cursor: pointer;
    transition: transform .08s ease, background .15s ease, border-color .15s ease;
    font-weight: 850;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    user-select: none;
}

    .btn:hover {
        background: #edf4f9;
        border-color: #bfd3e1;
        transform: translateY(-1px);
    }

    .btn:active {
        transform: translateY(0);
    }

    .btn.primary {
        background: linear-gradient(135deg, rgba(30,136,255,.16), rgba(30,136,255,.06));
        border-color: rgba(30,136,255,.35);
    }

        .btn.primary:hover {
            border-color: rgba(30,136,255,.52);
        }

    .btn.warn {
        background: linear-gradient(135deg, rgba(239,68,68,.14), rgba(239,68,68,.05));
        border-color: rgba(239,68,68,.28);
    }

        .btn.warn:hover {
            border-color: rgba(239,68,68,.44);
        }

    .btn.ghost {
        background: rgba(255,255,255,0.55);
        border-color: var(--border);
        padding: 9px 10px;
        border-radius: 12px;
        font-size: 12px;
    }

        .btn.ghost:hover {
            background: #f3f8fc;
            border-color: #bfd3e1;
        }

body.dark-theme .btn {
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.06);
}

    body.dark-theme .btn:hover {
        background: rgba(255,255,255,0.10);
        border-color: rgba(255,255,255,0.22);
    }

    body.dark-theme .btn.ghost {
        background: rgba(255,255,255,0.03);
        border-color: rgba(255,255,255,0.12);
    }

        body.dark-theme .btn.ghost:hover {
            background: rgba(255,255,255,0.06);
            border-color: rgba(255,255,255,0.18);
        }

/* Search + tables, if used later */
.filterbar {
    margin-top: 12px;
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.search {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.72);
    min-width: min(720px, 100%);
}

    .search .icon {
        width: 28px;
        height: 28px;
        border-radius: 10px;
        border: 1px solid var(--border);
        background: rgba(255,255,255,0.8);
        display: grid;
        place-items: center;
        flex: 0 0 auto;
        color: var(--muted);
    }

    .search input {
        border: none;
        outline: none;
        background: transparent;
        color: var(--text);
        font-size: 13px;
        width: 100%;
    }

        .search input::placeholder {
            color: var(--muted2);
        }

body.dark-theme .search {
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.04);
}

    body.dark-theme .search .icon {
        border: 1px solid rgba(255,255,255,0.10);
        background: rgba(0,0,0,0.20);
        color: rgba(255,255,255,0.70);
    }

    body.dark-theme .search input {
        color: rgba(255,255,255,0.92);
    }

        body.dark-theme .search input::placeholder {
            color: rgba(255,255,255,0.45);
        }

.table-wrap {
    overflow: auto;
    border-top: 1px solid rgba(0,0,0,0.05);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 1100px;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f3f7fb;
    border-bottom: 1px solid var(--border);
    padding: 10px;
    text-align: left;
    font-size: 12px;
    letter-spacing: .10em;
    text-transform: uppercase;
    color: #577489;
    white-space: nowrap;
}

tbody td {
    padding: 10px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    font-size: 13px;
    color: var(--text);
    vertical-align: top;
}

tbody tr:nth-child(odd) {
    background: rgba(255,255,255,0.82);
}

tbody tr:nth-child(even) {
    background: #f8fbfd;
}

tbody tr.alert {
    background: rgba(239,68,68,0.10) !important;
    box-shadow: inset 4px 0 0 rgba(239,68,68,0.85);
}

body.dark-theme .table-wrap {
    border-top: 1px solid rgba(255,255,255,0.06);
}

body.dark-theme thead th {
    background: rgba(5,9,20,0.85);
    border-bottom: 1px solid rgba(255,255,255,0.10);
    color: rgba(255,255,255,0.75);
}

body.dark-theme tbody td {
    border-bottom: 1px solid rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.88);
}

body.dark-theme tbody tr:nth-child(odd) {
    background: rgba(255,255,255,0.03);
}

body.dark-theme tbody tr:nth-child(even) {
    background: rgba(255,255,255,0.05);
}

.footer-note {
    padding: 14px 16px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
    border-top: 1px solid rgba(0,0,0,0.05);
    background: #f6fafc;
}

body.dark-theme .footer-note {
    border-top: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.03);
}

select[multiple] option:checked {
    background: rgba(30,136,255,0.20);
    color: var(--text);
}

body.dark-theme select[multiple] option:checked {
    background: rgba(30,136,255,0.35);
    color: rgba(255,255,255,0.95);
}

/* Compact header */
.topbar.compact .topbar-inner {
    padding: 10px 20px;
}

.topbar.compact .brand h1 {
    font-size: 18px;
}

.topbar.compact .logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
}

.topbar.compact .brand img {
    max-height: 54px;
    width: auto;
}

/* Drawer support for home page */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.40);
    backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
    z-index: 900;
}

    .overlay.open {
        opacity: 1;
        pointer-events: auto;
    }

.drawer {
    position: fixed;
    top: 14px;
    right: 14px;
    height: calc(100vh - 28px);
    width: min(560px, 92vw);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow-strong);
    display: flex;
    flex-direction: column;
    transform: translateX(110%);
    transition: transform .22s ease;
    z-index: 950;
    pointer-events: none;
    outline: none;
}

    .drawer.open {
        transform: translateX(0);
        pointer-events: auto;
    }

.drawer-header {
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    background: linear-gradient(180deg, rgba(0,0,0,0.03), rgba(0,0,0,0.01));
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.drawer-title {
    margin: 0;
    font-size: 16px;
    letter-spacing: .2px;
    color: var(--text);
}

.drawer-sub {
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
}

.drawer-close {
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    border-radius: 12px;
    width: 40px;
    height: 40px;
    cursor: pointer;
}

    .drawer-close:hover {
        background: #eef4f8;
        border-color: #bfd3e1;
    }

.drawer-body {
    padding: 14px 16px 18px;
    overflow: auto;
    flex: 1 1 auto;
}

.drawer-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(0,0,0,0.06);
    background: #f8fbfd;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.drawer-section + .drawer-section {
    margin-top: 16px;
}

.drawer-section h3 {
    margin: 0 0 8px;
    font-size: 13px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
}

.input {
    width: 100%;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    padding: 10px 12px;
    font: inherit;
}

.listbox {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
}

.pick {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-top: 1px solid rgba(0,0,0,0.05);
    cursor: pointer;
}

    .pick:first-child {
        border-top: none;
    }

    .pick:hover {
        background: #f5f9fc;
    }

    .pick strong {
        color: var(--text);
    }

    .pick span, .mini {
        color: var(--muted);
        font-size: 12px;
    }

body.dark-theme .drawer {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
}

body.dark-theme .drawer-header {
    background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
    border-bottom: 1px solid rgba(255,255,255,0.10);
}

body.dark-theme .drawer-title {
    color: rgba(255,255,255,0.92);
}

body.dark-theme .drawer-sub {
    color: rgba(255,255,255,0.65);
}

body.dark-theme .drawer-close {
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.88);
}

    body.dark-theme .drawer-close:hover {
        background: rgba(255,255,255,0.10);
        border-color: rgba(255,255,255,0.22);
    }

body.dark-theme .drawer-footer {
    border-top: 1px solid rgba(255,255,255,0.10);
    background: rgba(255,255,255,0.04);
}

body.dark-theme .input {
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(0,0,0,0.20);
    color: rgba(255,255,255,0.88);
}

body.dark-theme .listbox {
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(0,0,0,0.18);
}

body.dark-theme .pick {
    border-top: 1px solid rgba(255,255,255,0.08);
}

    body.dark-theme .pick:hover {
        background: rgba(255,255,255,0.06);
    }

    body.dark-theme .pick strong {
        color: rgba(255,255,255,0.92);
    }

    body.dark-theme .pick span,
    body.dark-theme .mini {
        color: rgba(255,255,255,0.65);
    }

/* Print */
@media print {
    body {
        background: #fff !important;
        color: #000 !important;
    }

    .topbar, .filterbar, .toolbar {
        display: none !important;
    }

    .card {
        box-shadow: none !important;
        border: 0 !important;
    }

    thead th {
        position: static;
        background: #eee !important;
        color: #000 !important;
    }

    tbody tr {
        background: #fff !important;
    }

        tbody tr.alert {
            background: #ffe3e3 !important;
            box-shadow: none !important;
        }

    tbody td {
        color: #000 !important;
    }
}

@media (max-width: 640px) {
    .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .filterbar {
        align-items: stretch;
    }

    .search {
        min-width: 100%;
    }

    .topbar.compact .topbar-inner {
        padding: 10px 14px;
    }

    .drawer {
        top: 0;
        right: 0;
        height: 100vh;
        width: 100vw;
        border-radius: 0;
    }
}
