:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e6e8ef;
  --border-strong: #d5d9e3;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #8a93a6;
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --accent-soft: #eef0ff;
  --sidebar: #0f172a;
  --sidebar-2: #1e293b;
  --sidebar-text: #cbd5e1;

  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --sub: #4ade80;
  --late: #dc2626;
  --late-soft: #fee2e2;
  --rework: #ea580c;
  --rework-soft: #ffedd5;
  --soon: #f59e0b;
  --soon-soft: #fef3c7;
  --notdue: #cbd2dc;
  --notdue-soft: #f1f3f7;
  --na: #e5e7eb;
  --line: #f0f1f5;
  --hover: #fafbff;
  --muted-bg: #eef0f5;
  --chip: #f1f3f7;
  --group-row: #fafbfd;
  --seg-bg: #eceef4;
  --hole: #ffffff;
  --switch-off: #d1d5db;
  --icon-muted: #c7cdd9;
  --ok-text: #15803d;
  --sub-soft: #e7fbe9;
  --sub-text: #16803c;
  --late-text: #b91c1c;
  --late-line: #fecaca;
  --soon-text: #b45309;
  --soon-line: #fde68a;
  --notdue-text: #64748b;
  --na-text: #6b7280;
  --info-text: #3730a3;
  --warn-text: #9a3412;
  --bad-text: #991b1b;
  --good-text: #166534;
  --doc-pdf: #fef2f2;
  --doc-proof: #ecfdf5;
  --doc-other: #f1f5f9;
  --filed-late: #86efac;
  color-scheme: light;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .06);
}

/* ---------- Dark theme (explicit choice, or follows the OS when set to "System") ---------- */
:root[data-theme="dark"] {
  --bg: #0b1020;
  --surface: #121a2c;
  --surface-2: #172036;
  --border: #243049;
  --border-strong: #33415e;
  --text: #e6eaf2;
  --text-2: #b4bdd0;
  --muted: #7f8aa3;
  --accent: #6366f1;
  --accent-2: #818cf8;
  --accent-soft: rgba(99, 102, 241, .16);
  --sidebar: #080c18;
  --sidebar-2: #161e33;
  --ok: #22c55e;
  --ok-soft: rgba(34, 197, 94, .14);
  --sub: #4ade80;
  --late: #ef4444;
  --late-soft: rgba(239, 68, 68, .15);
  --rework: #f97316;
  --rework-soft: rgba(249, 115, 22, .15);
  --soon: #fbbf24;
  --soon-soft: rgba(251, 191, 36, .14);
  --notdue: #4a5672;
  --notdue-soft: rgba(148, 163, 184, .12);
  --na: #2a3550;
  --line: #1c2540;
  --hover: #18213a;
  --muted-bg: #222c45;
  --chip: #1f2942;
  --group-row: #151e33;
  --seg-bg: #0e1526;
  --hole: #121a2c;
  --switch-off: #3a4763;
  --icon-muted: #46526d;
  --ok-text: #4ade80;
  --sub-soft: rgba(74, 222, 128, .12);
  --sub-text: #86efac;
  --late-text: #fca5a5;
  --late-line: rgba(239, 68, 68, .35);
  --soon-text: #fcd34d;
  --soon-line: rgba(251, 191, 36, .35);
  --notdue-text: #94a3b8;
  --na-text: #94a3b8;
  --info-text: #c7d2fe;
  --warn-text: #fdba74;
  --bad-text: #fca5a5;
  --good-text: #86efac;
  --doc-pdf: rgba(239, 68, 68, .14);
  --doc-proof: rgba(34, 197, 94, .14);
  --doc-other: #1f2942;
  --filed-late: #15803d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .3);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020;
    --surface: #121a2c;
    --surface-2: #172036;
    --border: #243049;
    --border-strong: #33415e;
    --text: #e6eaf2;
    --text-2: #b4bdd0;
    --muted: #7f8aa3;
    --accent: #6366f1;
    --accent-2: #818cf8;
    --accent-soft: rgba(99, 102, 241, .16);
    --sidebar: #080c18;
    --sidebar-2: #161e33;
    --ok: #22c55e;
    --ok-soft: rgba(34, 197, 94, .14);
    --sub: #4ade80;
    --late: #ef4444;
    --late-soft: rgba(239, 68, 68, .15);
    --rework: #f97316;
    --rework-soft: rgba(249, 115, 22, .15);
    --soon: #fbbf24;
    --soon-soft: rgba(251, 191, 36, .14);
    --notdue: #4a5672;
    --notdue-soft: rgba(148, 163, 184, .12);
    --na: #2a3550;
    --line: #1c2540;
    --hover: #18213a;
    --muted-bg: #222c45;
    --chip: #1f2942;
    --group-row: #151e33;
    --seg-bg: #0e1526;
    --hole: #121a2c;
    --switch-off: #3a4763;
    --icon-muted: #46526d;
    --ok-text: #4ade80;
    --sub-soft: rgba(74, 222, 128, .12);
    --sub-text: #86efac;
    --late-text: #fca5a5;
    --late-line: rgba(239, 68, 68, .35);
    --soon-text: #fcd34d;
    --soon-line: rgba(251, 191, 36, .35);
    --notdue-text: #94a3b8;
    --na-text: #94a3b8;
    --info-text: #c7d2fe;
    --warn-text: #fdba74;
    --bad-text: #fca5a5;
    --good-text: #86efac;
    --doc-pdf: rgba(239, 68, 68, .14);
    --doc-proof: rgba(34, 197, 94, .14);
    --doc-other: #1f2942;
    --filed-late: #15803d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; color: #fff; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #6366f1, #4338ca); display: grid; place-items: center; box-shadow: 0 4px 12px rgba(79,70,229,.45); }
.brand b { font-size: 16px; display: block; }
.brand span { font-size: 11.5px; color: #94a3b8; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 14px 12px 6px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px;
  color: var(--sidebar-text); font-weight: 500; margin-bottom: 2px; text-decoration: none;
}
.nav a svg { width: 18px; height: 18px; opacity: .8; flex: none; }
.nav a:hover { background: var(--sidebar-2); color: #fff; }
.nav a.active { background: rgba(99, 102, 241, .18); color: #fff; }
.nav a.active svg { color: #a5b4fc; opacity: 1; }
.nav .count { margin-left: auto; background: #ef4444; color: #fff; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; }
.nav .count.blue { background: #6366f1; }
.sidebar-foot { margin-top: auto; border-top: 1px solid #1e293b; padding: 14px 8px 0; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #334155; color: #e2e8f0; display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
.sidebar-foot .who { min-width: 0; flex: 1; }
.sidebar-foot .who b { color: #fff; font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .who span { font-size: 11.5px; color: #94a3b8; text-transform: capitalize; }
.icon-btn { background: none; border: 0; color: #94a3b8; cursor: pointer; padding: 6px; border-radius: 6px; display: grid; place-items: center; }
.icon-btn:hover { background: var(--sidebar-2); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 20px 32px 8px; flex-wrap: wrap;
}
.topbar h1 { font-size: 22px; }
.topbar .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.topbar .spacer { flex: 1; }
.content { padding: 16px 32px 48px; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(79,70,229,.3); }
.btn.primary:hover { background: #4338ca; }
.btn.success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.success:hover { background: #15803d; }
.btn.danger { color: var(--late); }
.btn.danger:hover { background: var(--late-soft); border-color: var(--late-line); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--muted-bg); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.input, select.input, textarea.input {
  height: 36px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface);
  font: inherit; color: var(--text); width: 100%; outline: none; transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; min-height: 76px; padding: 9px 11px; resize: vertical; }
.input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.input.sm { height: 30px; font-size: 12.5px; padding: 0 8px; }
select.input { padding-right: 28px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
label.field { display: block; }
label.field > span { display: block; font-size: 12.5px; font-weight: 550; color: var(--text-2); margin-bottom: 6px; }
label.field > small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.seg { display: inline-flex; background: var(--seg-bg); padding: 3px; border-radius: 9px; gap: 2px; }
.seg button { border: 0; background: none; font: inherit; font-weight: 550; font-size: 12.5px; color: var(--text-2); padding: 6px 12px; border-radius: 7px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-h h3 { font-size: 15px; }
.card-h .sub { color: var(--muted); font-size: 12.5px; }
.card-b { padding: 18px 20px; }
.card-b.flush { padding: 0; }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; position: relative; overflow: hidden; cursor: default; }
.kpi[data-go] { cursor: pointer; }
.kpi[data-go]:hover { border-color: var(--border-strong); }
.kpi .label { color: var(--text-2); font-size: 12.5px; font-weight: 550; display: flex; align-items: center; gap: 7px; }
.kpi .label i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 14px; color: var(--muted); font-weight: 550; margin-left: 4px; }
.kpi .foot { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kpi .bar { height: 6px; background: var(--muted-bg); border-radius: 99px; margin-top: 10px; overflow: hidden; }
.kpi .bar > div { height: 100%; background: linear-gradient(90deg, #22c55e, #16a34a); border-radius: 99px; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-items: start; }
.dash-side { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }

/* ---------- Status ---------- */
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex: none; position: relative; }
.dot.approved { background: var(--ok); }
.dot.submitted { background: var(--sub); box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--sub) 45%, var(--surface)); }
.dot.rejected { background: var(--hole); box-shadow: inset 0 0 0 3.5px var(--late); }
.dot.late { background: var(--late); }
.dot.due_soon { background: var(--soon); }
.dot.not_due { background: var(--notdue); }
.dot.na { background: repeating-linear-gradient(45deg, var(--na) 0 3px, var(--chip) 3px 6px); border: 1px solid var(--border-strong); }
.dot.slate::after { content: ""; position: absolute; right: -3px; top: -3px; width: 7px; height: 7px; border-radius: 50%; background: var(--hole); border: 2px solid var(--late); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 7px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; box-shadow: none; }
.pill.approved { background: var(--ok-soft); color: var(--ok-text); }
.pill.submitted { background: var(--sub-soft); color: var(--sub-text); }
.pill.rejected { background: var(--late-soft); color: var(--late-text); }
.pill.late { background: var(--late-soft); color: var(--late-text); }
.pill.due_soon { background: var(--soon-soft); color: var(--soon-text); }
.pill.not_due { background: var(--notdue-soft); color: var(--notdue-text); }
.pill.na { background: var(--chip); color: var(--na-text); }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: var(--chip); color: var(--text-2); white-space: nowrap; }
.tag .sw { width: 8px; height: 8px; border-radius: 2px; }
.flag, .fi { line-height: 1; }
.fi { width: 1.33em; height: 1em; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.08); vertical-align: -2px; flex: none; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { width: 10px; height: 10px; }

/* ---------- Timeline matrix ---------- */
.tl-tools { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tl-tools .input, .tl-tools select.input { width: auto; min-width: 140px; height: 32px; font-size: 13px; }
.tl-wrap { overflow-x: auto; }
table.tl { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 900px; }
.tl th, .tl td { padding: 0; }
.tl thead th {
  position: sticky; top: 0; background: var(--surface-2); font-size: 11.5px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; height: 38px; border-bottom: 1px solid var(--border); text-align: center;
}
.tl thead th:first-child { text-align: left; padding-left: 20px; }
.tl thead th.now { color: var(--accent); }
.tl td.label { padding: 9px 12px 9px 20px; white-space: nowrap; border-bottom: 1px solid var(--line); width: 1%; min-width: 290px; }
.tl td.cell { text-align: center; border-bottom: 1px solid var(--line); border-left: 1px dashed var(--line); height: 42px; min-width: 52px; }
.tl td.cell.now { background: linear-gradient(180deg, rgba(99,102,241,.06), rgba(99,102,241,.04)); }
.tl tr.area td { background: var(--surface-2); border-bottom: 1px solid var(--border); border-top: 1px solid var(--border); }
.tl tr.area td.label { font-weight: 700; font-size: 14px; padding-top: 12px; padding-bottom: 12px; box-shadow: inset 3px 0 0 var(--accent); }
.tl tr.area .rate { font-weight: 600; font-size: 12px; margin-left: 8px; }
.area-ic { width: 15px; height: 15px; vertical-align: -3px; margin-right: 6px; color: var(--accent-2); }
.tl tr.country td { background: var(--group-row); border-bottom: 1px solid var(--border); }
.tl tr.country td.label { padding-left: 34px; }
.tl tr.entity td.label { padding-left: 56px !important; }
.tl tr.ob td.label { padding-left: 74px !important; }
.tl tr.country td.label { font-weight: 650; padding-top: 11px; padding-bottom: 11px; }
.tl tr.country .rate { font-weight: 600; font-size: 12px; margin-left: 8px; }
.tl tr.entity td.label { padding-left: 20px; font-weight: 600; color: var(--text-2); font-size: 12.5px; }
.tl tr.ob td.label { padding-left: 40px; }
.tl tr.ob:hover td { background: var(--hover); }
.tl .ob-name { display: flex; align-items: center; gap: 8px; }
.tl .ob-name .meta { color: var(--muted); font-size: 11.5px; }
.cell-dots { display: inline-flex; gap: 4px; align-items: center; justify-content: center; }
.cell-dots button { border: 0; background: none; padding: 3px; cursor: pointer; border-radius: 50%; display: grid; place-items: center; transition: transform .1s; }
.cell-dots button:hover { transform: scale(1.25); }
.cell-dots button:focus-visible { outline: 2px solid var(--accent); }
.cell-dots .dot.approved::before { content: ""; position: absolute; inset: 0; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E") center / 10px no-repeat; }
.collapse-btn { border: 0; background: none; cursor: pointer; padding: 2px; color: var(--muted); display: inline-grid; place-items: center; vertical-align: middle; margin-right: 4px; transition: transform .15s; }
.collapse-btn.closed { transform: rotate(-90deg); }

#tip {
  position: fixed; z-index: 60; pointer-events: none; background: #0f172a; color: #e2e8f0; padding: 10px 12px; border-radius: 9px;
  font-size: 12px; box-shadow: var(--shadow-lg); max-width: 280px; line-height: 1.5; opacity: 0; transition: opacity .1s;
}
#tip.show { opacity: 1; }
#tip b { color: #fff; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list li:last-child { border-bottom: 0; }
.list li:hover { background: var(--hover); }
.list .grow { flex: 1; min-width: 0; }
.list .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .s { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .r { text-align: right; font-size: 12px; white-space: nowrap; }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 30px; height: 30px; color: var(--icon-muted); display: block; margin: 0 auto 8px; }

.score { padding: 6px 20px 16px; }
.score-row { display: grid; grid-template-columns: 120px 1fr 44px; gap: 10px; align-items: center; padding: 7px 0; font-size: 13px; cursor: pointer; }
.score-row:hover .nm { color: var(--accent); }
.score-row .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.score-track { height: 8px; border-radius: 99px; background: var(--muted-bg); overflow: hidden; display: flex; }
.score-track > div { height: 100%; }
.score-h { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 10px 0 2px; }
.score-row.strong .nm { font-weight: 650; }
.tree-area { padding: 12px 16px 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-top: 1px solid var(--border); }
.tree-area:first-child { border-top: 0; }
.score-row .pct { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- Tables ---------- */
table.data { width: 100%; border-collapse: collapse; }
.data th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data tr.click { cursor: pointer; }
.data tr.click:hover td { background: var(--hover); }
.data th:first-child, .data td:first-child { padding-left: 20px; }
.data th:last-child, .data td:last-child { padding-right: 20px; }
.data .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Drawer / modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .38); z-index: 40; animation: fade .15s; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw); background: var(--surface); z-index: 41;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .2s ease-out;
}
.drawer-h { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); }
.drawer-h .top { display: flex; align-items: flex-start; gap: 12px; }
.drawer-h h2 { font-size: 19px; }
.drawer-h .crumbs { color: var(--muted); font-size: 12.5px; margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.drawer-b { padding: 20px 24px 32px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 22px; }
.drawer-b > * { flex-shrink: 0; }
.drawer .close { margin-left: auto; color: var(--muted); }
.drawer .close:hover { background: var(--muted-bg); color: var(--text); }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.facts > div { background: var(--surface); padding: 11px 14px; }
.facts .k { font-size: 11.5px; color: var(--muted); font-weight: 550; }
.facts .v { font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; }
.section-t { font-size: 12px; font-weight: 650; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.doc { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; }
.doc .ic { width: 36px; height: 36px; border-radius: 8px; background: var(--doc-pdf); color: var(--late); display: grid; place-items: center; font-size: 10px; font-weight: 700; flex: none; }
.doc .ic.proof { background: var(--doc-proof); color: var(--ok); }
.doc .ic.other { background: var(--doc-other); color: var(--text-2); }
.doc .grow { flex: 1; min-width: 0; }
.doc .n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc .m { color: var(--muted); font-size: 12px; }
.callout { border-radius: 10px; padding: 12px 14px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.callout svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.callout.warn { background: var(--rework-soft); color: var(--warn-text); }
.callout.bad { background: var(--late-soft); color: var(--bad-text); }
.callout.info { background: var(--accent-soft); color: var(--info-text); }
.callout.good { background: var(--ok-soft); color: var(--good-text); }

.drop {
  border: 1.5px dashed var(--border-strong); border-radius: 10px; padding: 16px; text-align: center; color: var(--text-2);
  cursor: pointer; transition: border-color .12s, background .12s; background: var(--surface-2);
}
.drop:hover, .drop.over { border-color: var(--accent-2); background: var(--accent-soft); }
.drop b { color: var(--accent); }
.drop .files { margin-top: 8px; font-size: 12.5px; color: var(--text); font-weight: 550; }
.drop .req { font-size: 11px; font-weight: 600; color: var(--late); margin-left: 4px; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--muted-bg); }
.timeline li { position: relative; padding: 0 0 14px 14px; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: -21px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--icon-muted); }
.timeline li.mail::before { border-color: #f59e0b; }
.timeline li.good::before { border-color: var(--ok); }
.timeline li.bad::before { border-color: var(--rework); }
.timeline .when { color: var(--muted); font-size: 12px; }

.modal-wrap { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; animation: pop .16s ease-out; }
.modal.wide { width: min(760px, 100%); }
.modal-h { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-h h3 { font-size: 16px; }
.modal-b { padding: 20px 22px; overflow-y: auto; }
.modal-f { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: var(--surface-2); border-radius: 0 0 14px 14px; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }

#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #0f172a; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; display: flex; gap: 9px; align-items: center; animation: pop .16s; }
.toast.err { background: #b91c1c; }
.toast svg { width: 17px; height: 17px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: radial-gradient(1200px 600px at 0% 0%, #312e81 0%, #0f172a 55%); color: #e2e8f0; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art h1 { font-size: 36px; line-height: 1.15; color: #fff; max-width: 460px; letter-spacing: -.02em; }
.login-art p { color: #a5b4fc; max-width: 440px; font-size: 15px; line-height: 1.6; }
.login-art .demo-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 9px; max-width: 440px; margin-top: 36px; }
.login-art .demo-grid i { width: 100%; aspect-ratio: 1; border-radius: 50%; display: block; }
.login-form { display: grid; place-items: center; padding: 40px; background: var(--surface); }
.login-form form { width: min(360px, 100%); }
.login-form h2 { font-size: 24px; margin-bottom: 6px; }

/* ---------- Setup ---------- */
.setup { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
.tree .c { display: flex; align-items: center; gap: 8px; padding: 10px 16px; font-weight: 650; border-top: 1px solid var(--line); }
.tree .c:first-child { border-top: 0; }
.tree .c .btn { margin-left: auto; }
.tree .e { display: flex; align-items: center; gap: 8px; padding: 8px 16px 8px 40px; cursor: pointer; color: var(--text-2); font-weight: 500; }
.tree .e:hover { background: var(--hover); }
.tree .e.on { background: var(--accent-soft); color: var(--accent); }
.tree .e .n { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.ob-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; transition: border-color .12s, opacity .12s; }
.ob-card.off { opacity: .6; background: var(--surface-2); }
.ob-card .head { display: flex; align-items: center; gap: 10px; }
.ob-card .head h4 { font-size: 14px; }
.ob-card .rule { display: grid; grid-template-columns: 130px 90px 110px 1fr; gap: 10px; margin-top: 12px; align-items: end; }
.ob-card .preview { margin-top: 10px; font-size: 12px; color: var(--text-2); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ob-card .preview .chip { background: var(--chip); border-radius: 6px; padding: 2px 7px; font-variant-numeric: tabular-nums; }
.switch { position: relative; width: 36px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--switch-off); border-radius: 99px; cursor: pointer; transition: background .15s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(16px); }

.portal-hero { background: linear-gradient(120deg, #4f46e5, #6366f1 60%, #818cf8); color: #fff; border-radius: 16px; padding: 24px 28px; display: flex; align-items: center; gap: 24px; margin-bottom: 18px; box-shadow: 0 8px 24px rgba(79,70,229,.25); }
.portal-hero h2 { font-size: 22px; }
.portal-hero p { margin: 6px 0 0; color: #e0e7ff; }
.portal-hero .stat { text-align: center; background: rgba(255,255,255,.14); border-radius: 12px; padding: 10px 18px; min-width: 96px; }
.portal-hero .stat b { font-size: 24px; display: block; }
.portal-hero .stat span { font-size: 12px; color: #e0e7ff; }
.task { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task .when { width: 64px; text-align: center; flex: none; border-radius: 10px; padding: 6px 0; background: var(--surface-2); border: 1px solid var(--border); }
.task .when b { display: block; font-size: 18px; line-height: 1.1; }
.task .when span { font-size: 11px; color: var(--muted); text-transform: uppercase; font-weight: 600; }
.task .when.late { background: var(--late-soft); border-color: var(--late-line); color: var(--late-text); }
.task .when.soon { background: var(--soon-soft); border-color: var(--soon-line); color: var(--soon-text); }

@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-side { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; gap: 6px; }
  .brand { padding: 4px 8px; }
  .nav-label, .sidebar-foot .who { display: none; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav a span.lbl { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .setup, .grid2, .grid3, .login, .dash-side { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .facts { grid-template-columns: 1fr 1fr; }
  .ob-card .rule { grid-template-columns: 1fr 1fr; }
  .portal-hero { flex-wrap: wrap; }
}

/* ---------- Theme switch (Light / Dark / Auto) ---------- */
.theme-switch { display: flex; gap: 2px; padding: 3px; border-radius: 10px; }
.theme-switch button {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 8px;
  border: 0; border-radius: 8px; background: none; font: inherit; font-size: 12.5px; font-weight: 550; cursor: pointer;
}
.theme-switch svg { width: 15px; height: 15px; }
.theme-switch.in-sidebar { margin-top: auto; margin-bottom: 12px; background: var(--sidebar-2); }
.theme-switch.in-sidebar button { color: #94a3b8; }
.theme-switch.in-sidebar button:hover { color: #fff; }
.theme-switch.in-sidebar button.on { background: #334155; color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.theme-switch.on-login { position: absolute; top: 18px; right: 18px; background: var(--seg-bg); }
.theme-switch.on-login button { color: var(--text-2); }
.theme-switch.on-login button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.sidebar-foot { margin-top: 0; }
.sidebar-foot .who b { white-space: normal; line-height: 1.25; }
@media (max-width: 860px) {
  .theme-switch.in-sidebar { margin: 0 0 0 auto; }
  .theme-switch.in-sidebar span { display: none; }
}
