:root {
    color-scheme: light;
    --bg: #f1f5f9;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --panel-3: #f1f5f9;
    --ink: #0f172a;
    --ink-soft: #475569;
    --ink-body: #334155;
    --muted: #64748b;
    --ink-faint: #94a3b8;
    --line: #e2e8f0;
    --line-soft: #f1f5f9;
    --line-strong: #cbd5e1;
    --topbar-bg: rgba(241, 245, 249, 0.9);
    --logo-bg: #ffffff;
    --brand: #0f766e;
    --brand-dark: #115e59;
    --brand-soft: #ccfbf1;
    --amber: #b45309;
    --amber-soft: #fef3c7;
    --danger: #be123c;
    --danger-soft: #ffe4e6;
    --blue: #1d4ed8;
    --blue-soft: #dbeafe;
    --green: #047857;
    --green-soft: #d1fae5;
    --tint-brand-line: #99f6e4;
    --tint-blue-line: #bfdbfe;
    --tint-amber-line: #fde68a;
    --tint-green-line: #a7f3d0;
    --dot-ok: #059669;
    --dot-warn: #d97706;
    --dot-error: #e11d48;
    --on-brand: #ffffff;
    --on-danger: #ffffff;
    --brand-hover: #115e59;
    --danger-hover: #9f1239;
    --blue-hover: #1e40af;
    --shadow: 0 18px 45px -30px rgba(15, 23, 42, 0.45);
    --radius: 16px;
}

/* Tema gelap dipilih manual lewat tombol di bilah atas dan disimpan di
   localStorage; pilihan awal mengikuti prefers-color-scheme. Semua warna
   permukaan memakai token di atas agar satu set aturan cukup. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b1220;
    --panel: #111a2b;
    --panel-2: #16202f;
    --panel-3: #1c2739;
    --ink: #e6edf6;
    --ink-soft: #c3cede;
    --ink-body: #cbd5e1;
    --muted: #94a3b8;
    --ink-faint: #7c8aa0;
    --line: #243147;
    --line-soft: #1b2637;
    --line-strong: #33425c;
    --topbar-bg: rgba(11, 18, 32, 0.9);
    --logo-bg: #f8fafc;
    --brand: #2dd4bf;
    --brand-dark: #5eead4;
    --brand-soft: #0d3b36;
    --amber: #fbbf24;
    --amber-soft: #3b2a0b;
    --danger: #fda4af;
    --danger-soft: #3d1220;
    --blue: #93c5fd;
    --blue-soft: #16233f;
    --green: #6ee7b7;
    --green-soft: #0d2e21;
    --tint-brand-line: #17564f;
    --tint-blue-line: #24406b;
    --tint-amber-line: #5a3f10;
    --tint-green-line: #1a5541;
    --dot-ok: #34d399;
    --dot-warn: #fbbf24;
    --dot-error: #fb7185;
    --on-brand: #04201d;
    --on-danger: #2a0810;
    --brand-hover: #5eead4;
    --danger-hover: #fecdd3;
    --blue-hover: #bfdbfe;
    --shadow: 0 18px 45px -30px rgba(0, 0, 0, 0.75);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }

.boot, .access {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 15% 10%, rgba(13, 148, 136, 0.16), transparent 42%),
        radial-gradient(circle at 85% 90%, rgba(14, 116, 144, 0.14), transparent 40%),
        var(--bg);
}

.boot-card, .access-card {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 32px;
    text-align: center;
    box-shadow: var(--shadow);
}

.boot-title { font-size: 20px; font-weight: 700; margin: 16px 0 4px; }
.boot-text { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.boot-bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.boot-bar span { display: block; height: 100%; width: 40%; border-radius: inherit; background: var(--brand); animation: load 1.2s ease-in-out infinite; }
@keyframes load { 0% { transform: translateX(-100%); } 100% { transform: translateX(320%); } }

.access-icon {
    width: 62px;
    height: 62px;
    display: inline-grid;
    place-items: center;
    border-radius: 20px;
    background: var(--amber-soft);
    color: var(--amber);
    font-size: 24px;
    margin-bottom: 14px;
}
.access-card h1 { font-size: 22px; margin: 0 0 8px; }
.access-card p { color: var(--muted); font-size: 14px; line-height: 1.6; }
.access-actions { display: flex; gap: 10px; justify-content: center; margin: 22px 0 10px; flex-wrap: wrap; }
.access-hint { font-size: 12px; }

.brand-logo {
    width: 42px;
    height: 42px;
    display: block;
    border-radius: 13px;
    object-fit: contain;
    flex: none;
    background: var(--logo-bg);
    box-shadow: 0 4px 12px -6px rgba(15, 23, 42, 0.4);
}
.boot-card .brand-logo { width: 72px; height: 72px; margin: 0 auto; border-radius: 20px; }

.app { min-height: 100vh; display: flex; }
.sidebar {
    width: 252px;
    flex: none;
    background: var(--panel);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    z-index: 30;
}
.sidebar-head { display: flex; align-items: center; gap: 12px; padding: 4px 6px 20px; }
.brand-name { font-size: 16px; font-weight: 800; margin: 0; letter-spacing: -0.02em; }
.brand-sub { font-size: 11px; color: var(--muted); margin: 2px 0 0; text-transform: uppercase; letter-spacing: 0.08em; }
.sidebar-close { display: none; margin-left: auto; }

/* Menu kiri dapat digulir sendiri agar seluruh item tetap terjangkau pada
   layar pendek (mis. saat membuka halaman Audit dengan banyak baris). */
.nav {
    display: grid;
    gap: 4px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding-right: 2px;
}
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--ink-soft);
    border-radius: 11px;
    padding: 10px 12px;
    font-size: 13.5px;
    font-weight: 600;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-item i { width: 18px; text-align: center; font-size: 14px; }
.nav-item:hover { background: var(--panel-3); color: var(--ink); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-dark); }
.nav-group {
    margin: 14px 0 4px; padding: 0 10px;
    font-size: 9.5px; font-weight: 800; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--ink-faint);
}
.nav-item[disabled] { opacity: 0.45; cursor: not-allowed; }
.nav-item[disabled]:hover { background: transparent; color: var(--ink-soft); }

.sidebar-foot { margin-top: 12px; flex: none; padding-top: 14px; border-top: 1px solid var(--line); }
.session-card { display: flex; align-items: center; gap: 10px; padding: 8px 4px; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--line); color: var(--ink-soft); flex: none;
}
.session-info { min-width: 0; }
.session-info p { margin: 0; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-info span { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-badge {
    display: inline-flex; align-items: center; gap: 5px;
    margin: 4px;
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--blue-soft);
    color: var(--blue);
    font-size: 10.5px;
    font-weight: 700;
}
.build-info { margin: 10px 4px 0; font-size: 10px; color: var(--ink-faint); line-height: 1.5; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 14px;
    padding: 16px 24px;
    background: var(--topbar-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar-title { min-width: 0; }
.topbar-title h1 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.topbar-title p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.menu-btn { display: none; }

.sync-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 10px; border-radius: 999px;
    background: var(--panel); border: 1px solid var(--line);
    font-size: 11px; color: var(--muted); white-space: nowrap;
}
.sync-pill.ok { color: var(--green); background: var(--green-soft); border-color: transparent; }
.sync-pill.warn { color: var(--amber); background: var(--amber-soft); border-color: transparent; }
.sync-pill.error { color: var(--danger); background: var(--danger-soft); border-color: transparent; }

.page { padding: 24px; max-width: 1440px; width: 100%; margin: 0 auto; }
/* #page difokuskan secara programatik setelah dialog ditutup; bukan bagian
   urutan Tab, jadi garis fokus tidak perlu ditampilkan. */
.page[tabindex="-1"]:focus { outline: none; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 8px 13px;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.2;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    text-decoration: none;
}
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-ghost { background: var(--panel); border-color: var(--line); color: var(--ink-body); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-danger { background: var(--danger); color: var(--on-danger); }
.btn-danger:hover { background: var(--danger-hover); }
.btn-blue { background: var(--blue); color: var(--on-brand); }
.btn-blue:hover { background: var(--blue-hover); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
/* Tombol berwarna yang nonaktif dibuat netral agar tidak terlihat bisa
   ditekan (mis. "Setujui pilihan" saat belum ada yang dipilih). */
.btn-primary:disabled, .btn-blue:disabled, .btn-danger:disabled {
    background: var(--line); border-color: var(--line); color: var(--muted); opacity: 1;
}
.btn.icon-only { padding: 8px 10px; }

.icon-btn {
    width: 34px; height: 34px;
    display: inline-grid; place-items: center;
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 9px;
    color: var(--ink-soft);
}
.icon-btn:hover { background: var(--panel-2); color: var(--ink); }

.grid { display: grid; gap: 16px; }
.kpi-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: 0 10px 30px -28px rgba(15, 23, 42, 0.4);
    min-width: 0;
}
.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.kpi-label { font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.kpi-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-dark); font-size: 14px; }
.kpi-value { font-size: 25px; font-weight: 800; letter-spacing: -0.03em; margin: 0; line-height: 1.1; }
.kpi-value.money { font-size: 21px; }
.kpi-note { margin: 6px 0 0; font-size: 11.5px; color: var(--muted); }

.kpi-link {
    display: block;
    width: 100%;
    text-align: left;
    font: inherit;
    color: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.kpi-link:hover { border-color: var(--brand); box-shadow: 0 16px 34px -26px rgba(15, 118, 110, 0.55); transform: translateY(-1px); }
.kpi-link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.kpi-link .kpi-value { display: block; margin: 0; }
.kpi-link .kpi-note { display: flex; align-items: center; gap: 6px; margin: 6px 0 0; }
/* Penanda kesegaran per kartu: titik hijau bila data masih dalam TTL,
   kuning bila sudah melewatinya. */
.kpi-fresh {
    display: inline-flex; align-items: center; gap: 5px;
    margin-top: 8px; font-size: 10.5px; font-weight: 600; color: var(--muted);
}
.kpi-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex: none; }
.kpi-fresh.stale { color: var(--amber); }
.kpi-fresh.stale .kpi-dot { background: var(--amber); }
.kpi-go { font-size: 10px; opacity: 0; transition: opacity 0.15s ease; }
.kpi-link:hover .kpi-go,
.kpi-link:focus-visible .kpi-go { opacity: 0.75; }

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px -28px rgba(15, 23, 42, 0.4);
    overflow: hidden;
}
.card-head {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}
.card-head h2 { margin: 0; font-size: 14.5px; }
.card-head p { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }
.card-hint {
    display: flex; align-items: center; gap: 7px;
    padding: 10px 18px 4px; font-size: 11.5px; color: var(--muted);
}
.card-hint i { color: var(--brand); }

.toolbar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-bottom: 16px;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.control {
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 10px;
    padding: 8px 11px;
    font-size: 13px;
    color: var(--ink);
    min-width: 150px;
    outline: none;
}
.control:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12); }
.search-wrap { position: relative; }
.search-wrap i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); font-size: 12px; }
.search-wrap .control { padding-left: 31px; min-width: 240px; }
.textarea { min-height: 108px; width: 100%; resize: vertical; line-height: 1.55; }
.form-hint { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.form-grid .field { min-width: 0; }
.form-grid .control { width: 100%; min-width: 0; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th {
    background: var(--panel-2);
    color: var(--muted);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--panel-2); }
tbody tr.kk-head td { background: var(--panel-2); }
tbody tr.kk-head .cell-main { font-weight: 700; }
.cell-main { font-weight: 700; color: var(--ink); }
.cell-sub { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.cell-sub.cell-warn { color: var(--amber); font-weight: 600; }
.digest-actions {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-top: 14px;
}
.digest-preview {
    margin: 14px 0 0;
    padding: 14px 16px;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 10px;
    font-size: 11.5px;
    line-height: 1.6;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    white-space: pre-wrap;
    overflow-x: auto;
}
.th-stack { display: block; }
.th-sub { display: block; margin-top: 2px; color: var(--ink-faint); font-size: 9.5px; letter-spacing: 0.04em; text-transform: none; font-weight: 600; }

/* Header yang bisa diurutkan: seluruh area <th> menjadi tombol agar mudah
   diklik, dengan panah kecil sebagai penanda arah aktif. */
th.th-sort { padding: 0; }
.th-sort-btn {
    display: flex; align-items: center; gap: 6px;
    width: 100%;
    padding: 10px 14px;
    background: none; border: 0;
    color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit;
    text-align: inherit; cursor: pointer;
}
th.th-sort.num .th-sort-btn { justify-content: flex-end; }
.th-sort-btn:hover { color: var(--ink); background: var(--panel-3); }
.th-sort-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.th-sort-icon { margin-left: auto; font-size: 9px; color: var(--line-strong); }
th.th-sort.num .th-sort-icon { margin-left: 6px; }
th.is-active .th-sort-btn { color: var(--brand); }
th.is-active .th-sort-icon { color: var(--brand); }

/* Pilihan massal surat: bar aksi menempel di atas kartu, dengan penghitung
   yang ikut berubah saat kotak centang diklik. */
.bulk-bar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel-2);
}
.bulk-count { font-size: 12px; font-weight: 700; color: var(--ink); margin-right: 4px; }
.bulk-hint { flex: 1 1 220px; min-width: 0; font-size: 11.5px; color: var(--muted); }
.bulk-bar .btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.bulk-col { width: 38px; }
.row-check { width: 15px; height: 15px; cursor: pointer; accent-color: var(--brand); }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.pager {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 12px 18px; border-top: 1px solid var(--line); background: var(--panel);
}
.pager-info { font-size: 11.5px; color: var(--muted); }
.pager-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pager-page { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.btn-sm { padding: 6px 10px; font-size: 11.5px; }
.cell-muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    white-space: nowrap;
}
.badge-neutral { background: var(--panel-3); color: var(--ink-soft); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--danger-soft); color: var(--danger); }

.empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}
.empty i { display: block; font-size: 26px; color: var(--line-strong); margin-bottom: 10px; }
.empty p { margin: 0; }

.loading-row { padding: 28px; text-align: center; color: var(--muted); font-size: 13px; }
.loading-row i { margin-right: 7px; }

.offline-banner {
    display: flex; align-items: center; gap: 9px;
    margin: 12px 24px -8px;
    padding: 10px 14px;
    border-radius: 11px;
    background: var(--amber-soft);
    color: var(--amber);
    font-size: 12.5px;
    font-weight: 600;
}
.offline-banner i { font-size: 13px; }

.notice {
    display: flex; gap: 10px;
    padding: 11px 13px;
    border-radius: 11px;
    font-size: 12px;
    line-height: 1.5;
    margin-bottom: 14px;
}
.notice i { margin-top: 1px; }
.notice-info { background: var(--blue-soft); color: var(--blue); }
.notice-warn { background: var(--amber-soft); color: var(--amber); }
.notice-error { background: var(--danger-soft); color: var(--danger); }
.notice-ok { background: var(--green-soft); color: var(--green); }

.rt-health { display: flex; align-items: center; gap: 7px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); flex: none; }
.dot.ok { background: var(--dot-ok); }
.dot.warn { background: var(--dot-warn); }
.dot.error { background: var(--dot-error); }

.two-col { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr); gap: 16px; }

.detail-list { display: grid; gap: 0; }
.detail-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; }
.detail-row:last-child { border-bottom: 0; }
.detail-row dt { color: var(--muted); font-weight: 600; }
.detail-row dd { margin: 0; color: var(--ink); word-break: break-word; }

.drawer { position: fixed; inset: 0; z-index: 60; display: flex; justify-content: flex-end; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.42); }
.drawer-panel {
    position: relative;
    width: min(560px, 100%);
    height: 100%;
    background: var(--panel);
    box-shadow: -20px 0 50px -30px rgba(15, 23, 42, 0.6);
    display: flex;
    flex-direction: column;
    animation: slidein 0.22s ease-out;
}
@keyframes slidein { from { transform: translateX(30px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 2px 0 0; font-size: 17px; }
.drawer-eyebrow { margin: 0; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.drawer-body { padding: 20px 22px 40px; overflow-y: auto; }
.drawer-back { margin-bottom: 14px; }
.drawer-back .btn { gap: 6px; }
.drawer-section { margin-bottom: 22px; }
.drawer-section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin: 0 0 8px; }
.drawer-section.tint {
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 14px;
    margin-bottom: 14px;
}
.drawer-section.tint h3 { margin-bottom: 10px; }
.tint-brand { background: var(--brand-soft); border-color: var(--tint-brand-line); }
.tint-blue { background: var(--blue-soft); border-color: var(--tint-blue-line); }
.tint-amber { background: var(--amber-soft); border-color: var(--tint-amber-line); }
.tint-green { background: var(--green-soft); border-color: var(--tint-green-line); }
.tint-slate { background: var(--panel-2); border-color: var(--line); }
.drawer-photo { margin-top: 4px; }
.drawer-photo img { display: block; width: 100%; max-width: 320px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); }
.drawer-photo .photo-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--brand-dark); }
.timeline { display: grid; gap: 0; }
.timeline-item { position: relative; padding: 0 0 16px 20px; border-left: 2px solid var(--line); }
.timeline-item:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline-item:before { content: ""; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.timeline-meta { font-size: 11px; color: var(--muted); margin: 0 0 3px; }
.timeline-text { font-size: 12.5px; margin: 0; line-height: 1.55; }

.action-panel {
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 14px;
}
.action-panel h3 { margin-bottom: 10px; }
.action-current { margin: 0 0 12px; font-size: 12px; color: var(--muted); }
.action-current .badge { margin-left: 5px; }
.action-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.action-buttons .btn { flex: 1 1 140px; }

.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.5); }
.modal-card {
    position: relative;
    width: min(500px, 100%);
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border-radius: 18px;
    box-shadow: 0 30px 80px -30px rgba(15, 23, 42, 0.7);
    animation: modalin 0.18s ease-out;
}
@keyframes modalin { from { transform: translateY(8px); opacity: 0.5; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 14px; }
.modal-heading { min-width: 0; flex: 1; }
.modal-head h2 { margin: 2px 0 0; font-size: 17px; }
.modal-eyebrow { margin: 0; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.modal-icon {
    width: 38px; height: 38px; flex: none;
    display: grid; place-items: center;
    border-radius: 12px;
    background: var(--brand-soft); color: var(--brand-dark);
    font-size: 16px;
}
.modal-icon.danger { background: var(--danger-soft); color: var(--danger); }
.modal-icon.blue { background: var(--blue-soft); color: var(--blue); }
.modal-icon.primary { background: var(--brand-soft); color: var(--brand-dark); }
.modal-body { padding: 0 20px 8px; overflow-y: auto; color: var(--ink-body); font-size: 12.5px; line-height: 1.6; }
.modal-body p { margin: 0 0 9px; }
.modal-body p:last-child { margin-bottom: 0; }
.warning-summary { background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px; margin: 10px 0; }
.warning-summary p { margin: 0 0 5px; }
.warning-summary p:last-child { margin-bottom: 0; }
.modal-note { color: var(--muted); font-size: 11.5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 20px; flex-wrap: wrap; }
body.modal-open { overflow: hidden; }

.toast {
    position: fixed; right: 20px; bottom: 20px; z-index: 80;
    display: flex; align-items: center; gap: 10px;
    max-width: min(420px, calc(100vw - 40px));
    background: #0f172a; color: #fff;
    border-radius: 12px;
    padding: 11px 12px;
    font-size: 12.5px;
    box-shadow: 0 20px 50px -20px rgba(15, 23, 42, 0.7);
}
.toast.error { background: #9f1239; }
.toast.success { background: #065f46; }
.toast .icon-btn { border-color: transparent; background: transparent; color: #fff; width: 26px; height: 26px; }

@media (max-width: 1180px) {
    .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-105%); transition: transform 0.2s ease; box-shadow: 20px 0 50px -30px rgba(15, 23, 42, 0.6); }
    .sidebar.open { transform: none; }
    .sidebar-close, .menu-btn { display: inline-grid; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .page { padding: 18px 16px 30px; }
    .topbar { padding: 13px 16px; }
    .hide-sm { display: none; }
    .search-wrap .control { min-width: 0; width: 100%; }
    .search-wrap { width: 100%; }
    /* Toolbar tetap terbaca di tablet: periode cepat dan tanggal tidak
       memaksa halaman menggulir mendatar. */
    .toolbar .field { flex: 1 1 180px; min-width: 0; }
    .toolbar .field .control { width: 100%; min-width: 0; }
}
@media (max-width: 520px) {
    .offline-banner { margin: 10px 14px -6px; }
    .kpi-grid { grid-template-columns: 1fr; }
    .topbar-title h1 { font-size: 17px; }
    .topbar-title p { font-size: 11px; }
    .detail-row { grid-template-columns: 1fr; gap: 3px; }
    .sync-pill span { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .modal-actions .btn { flex: 1 1 100%; }
}

body.drawer-open { overflow: hidden; }
