:root {
            --bg: #f6f8fb;
            --panel: #ffffff;
            --text: #172033;
            --muted: #65758b;
            --line: #dbe3ec;
            --brand: #0f766e;
            --brand-dark: #115e59;
            --accent: #2563eb;
            --warning: #b45309;
            --danger: #dc2626;
            --shadow: 0 16px 38px rgba(23, 32, 51, .07);
        }
        [data-theme="dark"] {
            --bg: #0f172a;
            --panel: #111827;
            --text: #e5e7eb;
            --muted: #94a3b8;
            --line: #243244;
            --brand: #14b8a6;
            --brand-dark: #5eead4;
            --accent: #60a5fa;
            --warning: #f59e0b;
            --danger: #ef4444;
            --shadow: 0 16px 38px rgba(0, 0, 0, .24);
        }
        * { box-sizing: border-box; }
        body {
            margin: 0;
            font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
            color: var(--text);
            background: var(--bg);
        }
        @keyframes fadeUp {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
        @keyframes growBar {
            from { transform: scaleY(.08); }
            to { transform: scaleY(1); }
        }
        @keyframes panelIn {
            from { opacity: 0; transform: translateY(-6px); }
            to { opacity: 1; transform: translateY(0); }
        }
        a { color: var(--brand-dark); font-weight: 700; text-decoration: none; }
        header {
            position: sticky;
            top: 0;
            z-index: 10;
            background: rgba(255, 255, 255, .92);
            border-bottom: 1px solid rgba(219, 227, 236, .85);
            backdrop-filter: blur(14px);
        }
        [data-theme="dark"] header { background: rgba(15, 23, 42, .92); border-bottom-color: #243244; }
        .topbar {
            max-width: 1280px;
            margin: 0 auto;
            padding: 12px 22px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 14px;
            min-height: 72px;
        }
        .brand { display: flex; align-items: center; gap: 12px; flex: 0 1 360px; min-width: 210px; color: inherit; text-decoration: none; }
        .brand:hover h1 { color: var(--brand-dark); }
        .brand-mark {
            width: 40px;
            height: 40px;
            border-radius: 999px;
            display: grid;
            place-items: center;
            background: #1f2937;
            color: white;
            font-weight: 900;
            box-shadow: 0 12px 24px rgba(15, 118, 110, .22);
            overflow: hidden;
        }
        .brand-mark img { width: 100%; height: 100%; display: block; object-fit: cover; }
        .brand h1 { margin: 0; font-size: 18px; line-height: 1.1; letter-spacing: 0; }
        .brand small { color: var(--muted); font-weight: 700; display: block; max-width: 330px; line-height: 1.25; }
.main-menu { display: flex; gap: 6px; flex: 1 1 auto; flex-wrap: nowrap; align-items: center; justify-content: center; min-width: 0; }
.nav-dropdown { position: relative; }
.nav-dropdown summary { list-style: none; }
.nav-dropdown summary::-webkit-details-marker { display: none; }
.nav-dropdown summary::after {
    content: "";
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    margin-left: 8px;
    color: currentColor;
    opacity: .72;
    transition: transform .16s ease;
}
.nav-dropdown[open] summary::after { transform: rotate(180deg); }
.nav-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 230px;
    display: grid;
    gap: 4px;
    padding: 10px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 30;
    animation: panelIn .16s ease both;
}
.nav-panel .menu-link { justify-content: flex-start; }
.nav-panel .menu-link { min-height: 36px; padding: 8px 10px; border-radius: 6px; }
.profile-menu { display: flex; gap: 10px; flex: 0 0 auto; align-items: center; justify-content: flex-end; }
        .menu-toggle { display: none; }
        .menu-button {
            display: none;
            border: 1px solid var(--line);
            border-radius: 8px;
            background: white;
            color: #334155;
            min-height: 40px;
            padding: 8px 12px;
            font-weight: 900;
            cursor: pointer;
        }
        [data-theme="dark"] .menu-button,
        [data-theme="dark"] .profile-panel,
        [data-theme="dark"] .main-menu,
        [data-theme="dark"] input,
        [data-theme="dark"] select,
        [data-theme="dark"] textarea,
        [data-theme="dark"] .table-wrap {
            background: #111827;
            color: var(--text);
        }
        .menu-link, .button {
            background: var(--brand);
            color: white;
            border: 0;
            border-radius: 8px;
            padding: 10px 14px;
            text-decoration: none;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-height: 40px;
            font: inherit;
            font-weight: 800;
            white-space: nowrap;
            box-shadow: 0 8px 18px rgba(15, 118, 110, .18);
            transition: transform .18s ease, box-shadow .18s ease, background .18s ease, color .18s ease;
        }
        .button:hover { transform: translateY(-1px); box-shadow: 0 12px 22px rgba(15, 118, 110, .22); }
        .menu-link { background: transparent; color: #334155; box-shadow: none; position: relative; }
        [data-theme="dark"] .menu-link { color: #cbd5e1; }
        .menu-link:hover, .menu-link.active { background: #e6f3ef; color: var(--brand-dark); }
        .menu-link.secondary, .button.secondary { background: #334155; color: white; box-shadow: none; }
        .profile-card {
            display: flex;
            align-items: center;
            gap: 10px;
            min-width: 190px;
            justify-content: flex-end;
            border: 0;
            background: transparent;
            cursor: pointer;
            padding: 0;
            color: var(--text);
        }
        .profile-dropdown { position: relative; }
        .profile-dropdown summary { list-style: none; }
        .profile-dropdown summary::-webkit-details-marker { display: none; }
        .profile-panel {
            position: absolute;
            right: 0;
            top: calc(100% + 10px);
            width: 230px;
            background: white;
            border: 1px solid var(--line);
            border-radius: 8px;
            box-shadow: var(--shadow);
            padding: 10px;
            z-index: 20;
            animation: panelIn .16s ease both;
        }
        .profile-panel p { margin: 4px 8px 10px; }
        .profile-panel .button { width: 100%; }
        .avatar {
            width: 38px;
            height: 38px;
            border-radius: 999px;
            display: grid;
            place-items: center;
            background: #dbeafe;
            color: #1d4ed8;
            font-weight: 900;
        }
        .profile-text { line-height: 1.15; text-align: right; }
        .profile-text strong { display: block; font-size: 13px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .profile-text span { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: capitalize; }
        main { max-width: 1280px; margin: 28px auto; padding: 0 22px 42px; }
        h2 { margin: 26px 0 14px; font-size: 24px; letter-spacing: 0; }
        h3 { margin: 6px 0 0; font-size: 24px; letter-spacing: 0; }
        .grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
        .analytics-grid { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); align-items: start; }
        .card, table, form {
            background: var(--panel);
            border: 1px solid var(--line);
            border-radius: 8px;
            box-shadow: var(--shadow);
            animation: fadeUp .24s ease both;
        }
        .card { padding: 20px; }
        .card p { margin: 0; }
        .card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
        .card-head h3 { margin: 0; font-size: 20px; line-height: 1.2; }
        .button.compact { min-height: 32px; padding: 6px 10px; font-size: 12px; white-space: nowrap; }
        .metric { border-top: 4px solid var(--brand); }
        .metric:nth-child(2) { border-top-color: var(--accent); }
        .metric:nth-child(3) { border-top-color: var(--warning); }
        .table-wrap { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: white; box-shadow: var(--shadow); }
        table { width: 100%; border-collapse: collapse; overflow: hidden; box-shadow: none; border: 0; border-radius: 0; }
        th, td { text-align: left; padding: 14px 16px; border-bottom: 1px solid #edf2f7; vertical-align: top; }
        .card table td { padding: 10px 8px; }
        .card table td:last-child { text-align: right; white-space: nowrap; width: 1%; }
        th { background: #f8fafc; font-size: 12px; text-transform: uppercase; color: #64748b; letter-spacing: .04em; }
        [data-theme="dark"] th { background: #172033; color: #94a3b8; }
        [data-theme="dark"] tr:hover td { background: #162033; }
        tr:hover td { background: #fbfdfc; transition: background .16s ease; }
        form { padding: 22px; }
        .filter-form { margin-bottom: 16px; padding: 16px; box-shadow: none; }
        .filter-panel summary { cursor: pointer; font-weight: 900; list-style: none; }
        .filter-panel summary::-webkit-details-marker { display: none; }
        .filter-panel-body { margin-top: 14px; }
        label { display: block; margin: 14px 0 7px; font-weight: 800; color: #334155; }
        input, select, textarea {
            width: 100%;
            border: 1px solid #cbd5e1;
            border-radius: 8px;
            padding: 11px 12px;
            font: inherit;
            background: #fff;
            color: var(--text);
            outline: none;
        }
        input[type="checkbox"] { width: auto; margin-right: 8px; accent-color: var(--brand); }
        [data-theme="dark"] .qr-grid,
        [data-theme="dark"] .qr-cell.off { background: #fff; }
        [data-theme="dark"] .qr-cell.on { background: #0f172a; }
        input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(15, 118, 110, .12); }
        textarea { min-height: 104px; resize: vertical; }
        .row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
        .actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
        .page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
        .page-head h2 { margin: 0; }
        .badge { border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 900; display: inline-flex; align-items: center; white-space: nowrap; }
        .badge.low { background: #fee2e2; color: #991b1b; }
        .badge.ok { background: #dcfce7; color: #166534; }
        .badge.in { background: #dbeafe; color: #1d4ed8; }
        .badge.out { background: #ffedd5; color: #9a3412; }
        .badge.role { background: #e6f3ef; color: var(--brand-dark); }
        .badge.pending { background: #fef3c7; color: #92400e; }
        .badge.approved { background: #dcfce7; color: #166534; }
        .badge.rejected { background: #fee2e2; color: #991b1b; }
        .nav-badge { margin-left: 6px; background: #fee2e2; color: #991b1b; border-radius: 999px; padding: 2px 7px; font-size: 11px; font-weight: 900; }
        .alert { padding: 13px 15px; border-radius: 8px; margin-bottom: 16px; font-weight: 700; }
        .alert.success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
        .alert.error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
        .back-row { display: flex; justify-content: flex-start; margin: 0 0 16px; }
        .pagination { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 16px 0 0; padding: 0; list-style: none; }
        .page-link {
            min-width: 34px;
            min-height: 34px;
            padding: 6px 10px;
            border: 1px solid var(--line);
            border-radius: 8px;
            background: var(--panel);
            color: var(--text);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-size: 13px;
            font-weight: 900;
            line-height: 1;
            box-shadow: none;
        }
        .page-item.active .page-link { background: var(--brand); border-color: var(--brand); color: white; }
        .page-item.disabled .page-link { color: var(--muted); cursor: not-allowed; opacity: .55; }
        .page-link:hover { border-color: var(--brand); color: var(--brand-dark); }
        .muted { color: var(--muted); }
        .danger { background: var(--danger); box-shadow: 0 8px 18px rgba(220, 38, 38, .18); }
.mini-bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: end; min-height: 150px; }
.wide-bars { grid-template-columns: repeat(auto-fit, minmax(18px, 1fr)); overflow-x: auto; }
.monthly-bars { grid-template-columns: repeat(6, 1fr); }
.chart-tabs { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: flex-end; margin-bottom: 12px; }
.chart-tab { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 8px; min-height: 34px; padding: 7px 11px; font-weight: 900; cursor: pointer; }
.chart-tab.active { background: var(--brand); color: white; border-color: var(--brand); }
.chart-panel { display: none; }
.chart-panel.active { display: block; }
.report-card .table-wrap { box-shadow: none; margin-top: 10px; }
.report-list { display: grid; grid-template-columns: 1fr; gap: 16px; }
.report-card { width: 100%; }
.simple-report-table { overflow-x: auto; }
.help-dot {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    margin-left: 6px;
    border-radius: 999px;
    background: #e6f3ef;
    color: var(--brand-dark);
    font-size: 12px;
    font-weight: 900;
    cursor: help;
}
.help-dot:hover::after,
.help-dot:focus::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    width: 260px;
    transform: translateX(-50%);
    padding: 10px 12px;
    border-radius: 8px;
    background: #172033;
    color: white;
    font-size: 12px;
    line-height: 1.45;
    box-shadow: var(--shadow);
    z-index: 40;
}
        .bar-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; align-items: end; height: 120px; }
        .bar { border-radius: 6px 6px 0 0; min-height: 8px; }
        .bar { transform-origin: bottom; animation: growBar .55s ease both; }
        .bar.in { background: #2563eb; }
        .bar.out { background: #f97316; }
        .bar-label { font-size: 11px; color: var(--muted); margin-top: 6px; text-align: center; }
        .auth-shell { max-width: 980px; margin: 46px auto; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(360px, .95fr); gap: 18px; align-items: stretch; }
        .auth-intro { background: #0f766e; color: white; border-radius: 8px; padding: 34px 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
        .auth-intro h2 { margin: 0 auto; max-width: 560px; font-size: 25px; line-height: 1.28; font-weight: 900; }
        .auth-intro p { color: #d9fbf2; line-height: 1.6; }
        .auth-visual { margin: 26px auto 0; width: min(220px, 70%); aspect-ratio: 1; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22); border-radius: 999px; padding: 10px; box-shadow: 0 18px 36px rgba(0, 0, 0, .18); }
        .auth-visual img { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: 999px; }
        .icon { width: 17px; height: 17px; margin-right: 8px; flex: 0 0 auto; }
        .empty-state { padding: 34px 18px; text-align: center; color: var(--muted); }
        .empty-state svg { width: 70px; height: 70px; color: #94a3b8; margin-bottom: 10px; }
        .qr-grid { display: grid; grid-template-columns: repeat(21, 8px); grid-auto-rows: 8px; gap: 0; width: max-content; padding: 10px; background: white; border: 1px solid var(--line); border-radius: 8px; }
        .qr-cell.on { background: #0f172a; }
        .qr-cell.off { background: #fff; }
        .qr-scanner { display: grid; gap: 14px; align-content: start; }
        .scanner-frame {
            position: relative;
            width: 100%;
            aspect-ratio: 4 / 3;
            overflow: hidden;
            border-radius: 8px;
            background: #0f172a;
            border: 1px solid var(--line);
        }
        .scanner-frame video { width: 100%; height: 100%; object-fit: cover; display: block; }
        .scanner-guide {
            position: absolute;
            inset: 18%;
            border: 3px solid rgba(20, 184, 166, .95);
            border-radius: 8px;
            box-shadow: 0 0 0 999px rgba(15, 23, 42, .28);
            pointer-events: none;
        }
        @media print {
            header, .no-print { display: none !important; }
            body { background: white; }
            main { max-width: none; margin: 0; padding: 0; }
            .card, table, form, .table-wrap { box-shadow: none; }
        }
        .logout-form { padding: 0; border: 0; box-shadow: none; background: transparent; }
        @media (max-width: 1180px) {
            .topbar { gap: 10px; padding-inline: 16px; }
            .brand { flex-basis: 250px; min-width: 185px; }
            .brand small { max-width: 220px; font-size: 11px; }
            .menu-link, .button { min-height: 36px; padding: 8px 10px; font-size: 14px; }
            .profile-card { min-width: 150px; }
            .profile-text strong { max-width: 115px; }
            .icon { width: 15px; height: 15px; margin-right: 6px; }
        }
        @media (max-width: 1040px) {
            .brand { flex-basis: auto; min-width: 150px; }
            .brand small { display: none; }
            .brand h1 { font-size: 17px; }
            .profile-text strong, .profile-text span { display: none; }
            .profile-card { min-width: 0; }
        }
        @media (max-width: 900px) {
            .topbar { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; min-height: 0; }
            .brand { min-width: 0; }
            .brand small { display: none; }
            .menu-button { display: inline-flex; align-items: center; justify-content: center; grid-column: 1; grid-row: 1; }
            .brand { grid-column: 2; grid-row: 1; }
            .profile-menu { grid-column: 3; grid-row: 1; }
            .main-menu {
                display: none;
                grid-column: 1 / -1;
                width: 100%;
                flex: none;
                padding: 12px;
                background: white;
                border: 1px solid var(--line);
                border-radius: 8px;
                box-shadow: var(--shadow);
            }
            .menu-toggle:checked ~ .main-menu { display: grid; grid-template-columns: 1fr; }
            .main-menu .menu-link, .main-menu .button { justify-content: flex-start; width: 100%; box-shadow: none; }
            .nav-dropdown { width: 100%; }
            .nav-panel { position: static; box-shadow: none; border: 0; padding: 4px 0 0 18px; }
            .nav-dropdown > summary { width: 100%; }
            .profile-card { justify-content: flex-end; min-width: 0; }
            .profile-text { text-align: left; }
            .profile-text strong, .profile-text span { display: none; }
            .profile-panel { right: 0; }
        }
        @media (max-width: 760px) {
            .topbar { padding: 10px 14px; }
            main { margin-top: 18px; padding: 0 14px 34px; }
            .brand h1 { font-size: 16px; }
            .brand-mark { width: 36px; height: 36px; }
            .menu-link, .button { width: auto; }
            .page-head { align-items: flex-start; flex-direction: column; }
            .page-head .button { width: 100%; }
            .filter-form .button, form .button { width: 100%; }
            .filter-panel:not([open]) { padding: 14px 16px; }
            .actions { width: 100%; }
            .auth-shell { grid-template-columns: 1fr; margin-top: 16px; }
            .auth-intro { padding: 22px; }
            .auth-intro h2 { font-size: 21px; }
            .auth-visual { width: min(190px, 68%); }
            .grid { grid-template-columns: 1fr; }
            .mini-bars { gap: 6px; }
            th, td { padding: 12px 10px; }
            .table-wrap { overflow-x: auto; }
        }
