/* ==========================================================================
   PayGuard — operations dashboard theme
   One layout, two themes. Every colour below is a token; components never
   hard-code colours, so light and dark share the same hierarchy.
   Spacing follows an 8px grid (4px allowed for tight inline gaps).
   ========================================================================== */

@font-face {
  font-family: "Hanken";
  src: url("/fonts/hanken.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* ---------- Tokens: light (slate canvas, white surfaces) ---------- */
:root {
  --canvas: #f1f4f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;        /* table headers, footers, inset areas */
  --surface-3: #eef2f7;        /* chips, tracks */
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #64748b;

  --brand: #8a2be2;
  --brand-hover: #7622c4;
  --brand-ink: #6f1fbf;        /* accent used as text on surfaces */
  --brand-tint: #f3eafd;       /* selected nav, subtle highlights */
  --focus: #8a2be2;
  --on-brand: #ffffff;

  /* Status: text/icon colour, tinted background, chart fill */
  --match: #047857;  --match-bg: #ecfdf5;  --match-fill: #10b981;
  --wait: #1d4ed8;   --wait-bg: #eff6ff;   --wait-fill: #3b82f6;
  --hold: #a16207;   --hold-bg: #fefce8;   --hold-fill: #f59e0b;
  --risk: #b91c1c;   --risk-bg: #fef2f2;   --risk-fill: #ef4444;
  --neutral: #475569; --neutral-bg: #f1f5f9;
  --diff-bg: #fff7ed;          /* highlighted differing field */

  --overlay: rgba(15, 23, 42, 0.32);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px -12px rgba(15, 23, 42, 0.25);

  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 8px;

  --font: "Hanken", Inter, system-ui, -apple-system, "Segoe UI", "Noto Sans Bengali", sans-serif;
  --display: var(--font);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

/* ---------- Tokens: dark (matte navy, elevated slate surfaces) ---------- */
html[data-theme="dark"] {
  --canvas: #0b1220;
  --surface: #121b2c;
  --surface-2: #172234;
  --surface-3: #1e2a3f;
  --line: #233047;
  --line-strong: #33425c;
  --ink: #e5eaf2;
  --ink-2: #a3b0c2;
  --ink-3: #8593a8;

  --brand: #8a2be2;
  --brand-hover: #9b45ec;
  --brand-ink: #c9a5f7;
  --brand-tint: rgba(138, 43, 226, 0.18);
  --focus: #b583f2;

  --match: #4ade80;  --match-bg: rgba(74, 222, 128, 0.12);  --match-fill: #22c55e;
  --wait: #7cb1ff;   --wait-bg: rgba(96, 165, 250, 0.13);   --wait-fill: #3b82f6;
  --hold: #facc15;   --hold-bg: rgba(250, 204, 21, 0.12);   --hold-fill: #eab308;
  --risk: #f87171;   --risk-bg: rgba(248, 113, 113, 0.13);  --risk-fill: #ef4444;
  --neutral: #a3b0c2; --neutral-bg: rgba(148, 163, 184, 0.12);
  --diff-bg: rgba(250, 204, 21, 0.10);

  --overlay: rgba(2, 6, 15, 0.55);
  --shadow-sm: none;
  --shadow-md: 0 12px 32px -12px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--ink); -webkit-font-smoothing: antialiased; }
body { margin: 0; background: var(--canvas); }
.hidden { display: none !important; }
a { color: var(--brand-ink); text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--font); letter-spacing: -0.01em; }
h1 { font-size: 20px; font-weight: 650; line-height: 28px; margin: 0; }
h2 { font-size: 15px; font-weight: 650; line-height: 24px; margin: 0 0 16px; }
h3 { font-size: 13px; font-weight: 650; line-height: 20px; margin: 24px 0 8px; color: var(--ink); }
p { margin: 0 0 8px; }
.num, td, .kpi-value, .amount, .stat-card__value { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.error-text { color: var(--risk); min-height: 20px; font-size: 13px; margin: 0; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--brand-tint); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Brand mark ---------- */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--ink); padding: 16px 16px 8px; letter-spacing: -0.01em; }
.logo { width: 24px; height: 24px; border-radius: 7px; background: var(--brand); position: relative; flex: none; }
.logo::after { content: ""; position: absolute; left: 9px; top: 5px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--canvas); }
.login-art { display: none; }
.login-side { width: 100%; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 384px; display: grid; gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 32px; box-shadow: var(--shadow-sm); }
.login-card .brand { padding: 0 0 8px; }
.login-card h1 { font-size: 22px; }
.login-card .sub { color: var(--ink-2); margin: -8px 0 0; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex: none; }
#nav { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.nav-group { font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 12px 8px 4px; }
.nav-link { display: flex; align-items: center; gap: 8px; padding: 6px 8px; min-height: 32px; border-radius: var(--r-sm); color: var(--ink-2); text-decoration: none; font-size: 13.5px; font-weight: 500; }
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.active { background: var(--brand-tint); color: var(--brand-ink); font-weight: 600; }
.nav-link.danger { color: var(--risk); }
.nav-link.danger.active { background: var(--risk-bg); color: var(--risk); }
.nav-ico { width: 16px; height: 16px; flex: none; }
.nav-label { flex: 1; min-width: 0; }
.nav-count { font-size: 11.5px; font-weight: 600; min-width: 24px; text-align: center; padding: 0 8px; line-height: 20px; border-radius: 99px; background: var(--surface-3); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.nav-link.active .nav-count { background: var(--surface); color: var(--brand-ink); }
.sidebar-foot { padding: 8px 16px 16px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; padding-top: 16px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-tint); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; flex: none; text-transform: uppercase; }
.whoami { font-size: 13px; line-height: 18px; min-width: 0; flex: 1; }
.whoami b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whoami span { color: var(--ink-3); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; height: 56px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
#menu-toggle { display: none; }
.view { padding: 24px; display: grid; gap: 16px; align-content: start; max-width: 1440px; width: 100%; }

/* ---------- Layout grids ---------- */
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.grid.wide-left { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.grid.split { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }

/* ---------- Buttons ---------- */
.btn { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); height: 36px; padding: 0 16px; border-radius: var(--r-sm); font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.danger { background: var(--surface); border-color: var(--risk); color: var(--risk); }
.btn.danger:hover { background: var(--risk-bg); }
.btn.danger.solid { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn.ok { background: var(--surface); border-color: var(--match); color: var(--match); }
.btn.ok:hover { background: var(--match-bg); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.small { height: 28px; padding: 0 8px; font-size: 12.5px; border-radius: 6px; gap: 4px; }
.btn.icon { width: 36px; padding: 0; }
.btn.icon.small { width: 28px; }
.btn.block { width: 100%; }
.btn.large { height: 40px; padding: 0 16px; font-size: 14px; }
.icon-btn { border: 0; background: transparent; color: var(--ink-3); width: 24px; height: 24px; border-radius: 6px; display: inline-grid; place-items: center; cursor: pointer; padding: 0; flex: none; }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn svg { width: 14px; height: 14px; }

/* ---------- Forms ---------- */
label { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
input, select, textarea { font: inherit; font-size: 13.5px; height: 36px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); width: 100%; }
textarea { height: auto; min-height: 80px; padding: 8px 12px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input[type=checkbox] { width: 16px; height: 16px; padding: 0; accent-color: var(--brand); flex: none; }
input[type=file] { height: auto; padding: 6px; background: var(--surface-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--brand-tint); }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.hint { font-size: 12.5px; color: var(--ink-2); font-weight: 400; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 140px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.toolbar .count { margin-left: auto; color: var(--ink-2); font-size: 13px; }
.search { padding-left: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m14 14-3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 10px center; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-weight: 600; font-size: 12px; color: var(--ink-2); padding: 8px 12px; height: 36px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
td { padding: 8px 12px; height: 44px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th:first-child, td:first-child { padding-left: var(--card-px, 16px); }
th:last-child, td:last-child { padding-right: var(--card-px, 16px); }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
tr.is-selected td { background: var(--brand-tint) !important; }
tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
.amount { font-weight: 600; white-space: nowrap; }
.amount.neg { color: var(--risk); }
.amount.pos { color: var(--hold); }
.id { font-weight: 650; white-space: nowrap; }
.cell-sub { display: block; font-size: 12px; color: var(--ink-3); font-weight: 400; margin-top: 2px; max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trx { display: inline-flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; border-top: 1px solid var(--line); padding: 8px var(--card-px, 16px) 0; color: var(--ink-2); font-size: 13px; }
.empty { padding: 32px 16px; text-align: center; color: var(--ink-2); }
.skeleton { display: grid; gap: 8px; padding: 16px 0; }
.skeleton i { display: block; height: 32px; border-radius: 6px; background: var(--surface-3); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* ---------- Status ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral); }
.badge svg { width: 12px; height: 12px; flex: none; }
.badge.ok { background: var(--match-bg); color: var(--match); }
.badge.warn { background: var(--hold-bg); color: var(--hold); }
.badge.bad { background: var(--risk-bg); color: var(--risk); }
.badge.info { background: var(--wait-bg); color: var(--wait); }
.badge.brand { background: var(--brand-tint); color: var(--brand-ink); }
.badge.plain { background: transparent; padding: 0; }
.pill { font-size: 12.5px; height: 28px; padding: 0 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; color: var(--ink-2); }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.pill.ok::before { background: var(--match-fill); }
.pill.warn::before { background: var(--hold-fill); }
.pill.bad { color: var(--risk); border-color: var(--risk-bg); background: var(--risk-bg); }
.pill.bad::before { background: var(--risk-fill); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--ink-3); margin-right: 8px; flex: none; }
.dot.ok { background: var(--match-fill); }
.dot.bad { background: var(--risk-fill); }

/* ---------- Lists, key/value ---------- */
.list { display: grid; }
.list-item { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.kv { display: grid; grid-template-columns: 160px 1fr; font-size: 13.5px; margin: 0; }
.kv dt, .kv dd { padding: 8px 0; border-top: 1px solid var(--line); }
.kv dt:first-of-type, .kv dd:first-of-type { border-top: 0; padding-top: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; word-break: break-word; font-weight: 500; }

/* ---------- Banners & callouts ---------- */
.banner { padding: 8px 24px; font-weight: 600; font-size: 13.5px; }
.banner.danger { background: var(--risk-bg); color: var(--risk); border-bottom: 1px solid var(--risk); }
.callout { display: flex; gap: 8px; align-items: flex-start; padding: 8px 12px; border-radius: var(--r-sm); background: var(--wait-bg); color: var(--ink); font-size: 13.5px; margin-bottom: 16px; border: 1px solid transparent; }
.callout:last-child { margin-bottom: 0; }
.callout > svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--wait); }
.callout.good { background: var(--match-bg); } .callout.good > svg { color: var(--match); }
.callout.warn { background: var(--hold-bg); } .callout.warn > svg { color: var(--hold); }
.callout.bad { background: var(--risk-bg); } .callout.bad > svg { color: var(--risk); }
.callout ul { margin: 4px 0 0; padding-left: 16px; }
.steps { margin: 0; padding-left: 24px; display: grid; gap: 8px; }
.steps li::marker { font-weight: 700; color: var(--brand-ink); }
.emergency-box { display: grid; gap: 16px; justify-items: start; max-width: 640px; }
.emergency-box > div { width: 100%; }
.emergency-box .state { font-size: 28px; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
.emergency-box .state.running { color: var(--match); }
.emergency-box .state.stopped { color: var(--risk); }
.emergency-box .hint { font-size: 13.5px; max-width: 64ch; }
.code-big { font-family: var(--mono); font-size: 32px; letter-spacing: .16em; font-weight: 700; padding: 16px; text-align: center; background: var(--brand-tint); color: var(--brand-ink); border-radius: var(--r-md); }
pre.raw { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); padding: 8px 12px; border-radius: var(--r-sm); margin: 0; font-size: 12.5px; font-family: var(--mono); line-height: 1.6; }

/* ---------- Overview ---------- */
.queue-panel { gap: 16px; }
.queue-count { display: flex; align-items: baseline; gap: 8px; }
.queue-count b { font-size: 40px; line-height: 44px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.queue-count span { color: var(--ink-2); }
.breakdown { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; margin: 0; padding: 0; list-style: none; }
.breakdown li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.breakdown li:nth-child(-n+2) { border-top: 0; padding-top: 0; }
.breakdown b { font-variant-numeric: tabular-nums; }
.breakdown a { color: inherit; text-decoration: none; display: contents; }
.queue-panel .btn { align-self: flex-start; margin-top: auto; }

.segbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-3); gap: 2px; }
.segbar span { display: block; height: 100%; }
.f-match { background: var(--match-fill); } .f-wait { background: var(--wait-fill); }
.f-hold { background: var(--hold-fill); } .f-risk { background: var(--risk-fill); }
.seg-legend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 16px; margin: 0; }
.seg-legend a { display: grid; gap: 0; text-decoration: none; color: inherit; padding: 8px 0 0; border-top: 2px solid var(--line); }
.seg-legend a:hover .seg-label { color: var(--ink); text-decoration: underline; }
.seg-legend .seg-label { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--ink-2); }
.seg-legend .seg-label i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.seg-legend b { font-size: 20px; line-height: 28px; font-variant-numeric: tabular-nums; }
.seg-legend .pct { font-size: 12px; color: var(--ink-3); }
.today-total { display: flex; align-items: baseline; gap: 8px; }
.today-total b { font-size: 28px; line-height: 36px; font-weight: 700; font-variant-numeric: tabular-nums; }
.today-total span { color: var(--ink-2); }

.health-rows { display: grid; margin: 0; padding: 0; list-style: none; }
.health-rows li { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.health-rows li:first-child { border-top: 0; padding-top: 0; }
.health-rows li:last-child { padding-bottom: 0; }
.health-ico { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.health-ico svg { width: 16px; height: 16px; }
.health-name { font-weight: 600; }
.health-detail { display: block; font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chart { display: grid; gap: 12px; }
.chart-bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 16px; height: 200px; }
.chart-col { display: grid; grid-template-rows: 1fr auto; gap: 8px; height: 100%; text-align: center; min-width: 0; }
.chart-stack { display: flex; flex-direction: column-reverse; align-items: center; gap: 2px; height: 100%; }
.chart-stack i { display: block; width: min(100%, 40px); min-height: 0; border-radius: 3px; }
.chart-stack .empty-bar { height: 4px; background: var(--surface-3); }
.chart-label { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.chart-label b { display: block; color: var(--ink); font-size: 13px; font-variant-numeric: tabular-nums; }
.chart-legend { display: flex; gap: 4px 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 4px; }
.chart-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* ---------- Drawer (request details) ---------- */
.drawer { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
.drawer-backdrop { position: absolute; inset: 0; background: var(--overlay); pointer-events: auto; }
.drawer-panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(648px, 100%); background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-md); display: flex; flex-direction: column; pointer-events: auto; animation: slide-in .16s ease-out; }
.drawer-close { position: absolute; right: 16px; top: 16px; z-index: 2; }
#drawer-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.drawer-inner { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.drawer-section .card__header { margin-bottom: 8px; }
.min0 { min-width: 0; }
.drawer-scroll { flex: 1; overflow-y: auto; padding: 24px; }
.drawer-scroll > h2:first-child { padding-right: 48px; }
.drawer-head { padding-right: 48px; margin-bottom: 16px; }
.drawer-head h2 { font-size: 20px; line-height: 28px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 4px; }
.drawer-head p { color: var(--ink-2); margin: 0; }
.drawer-section { margin-top: 24px; }
.drawer-section > h3 { margin: 0 0 8px; }
.drawer-foot { position: sticky; bottom: 0; border-top: 1px solid var(--line); background: var(--surface); padding: 16px 24px; display: grid; gap: 8px; }
.drawer-foot textarea { min-height: 56px; }
.drawer-foot .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.drawer .table-wrap { border: 1px solid var(--line); border-radius: var(--r-sm); }
.drawer th:first-child, .drawer td:first-child { padding-left: 12px; }
.drawer th:last-child, .drawer td:last-child { padding-right: 12px; }
@keyframes slide-in { from { transform: translateX(24px); } to { transform: none; } }

.amount-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.amount-summary > div { padding: 12px 16px; border-left: 1px solid var(--line); }
.amount-summary > div:first-child { border-left: 0; }
.amount-summary span { display: block; font-size: 12px; color: var(--ink-2); }
.amount-summary b { font-size: 18px; line-height: 28px; font-variant-numeric: tabular-nums; }
.amount-summary .neg { color: var(--risk); } .amount-summary .pos { color: var(--hold); }

.compare { width: 100%; border: 1px solid var(--line); border-radius: var(--r-md); border-collapse: separate; border-spacing: 0; overflow: hidden; }
.compare th, .compare td { padding: 8px 12px; height: 40px; border-bottom: 1px solid var(--line); position: static; }
.compare tr:last-child td { border-bottom: 0; }
.compare td:first-child { color: var(--ink-2); width: 30%; }
.compare tr.diff td { background: var(--diff-bg); }
.compare tr.diff td:first-child { color: var(--ink); font-weight: 600; }
.compare .diff-flag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; color: var(--hold); margin-left: 4px; }
.compare .diff-flag svg { width: 12px; height: 12px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 8px 16px; border-radius: var(--r-sm); z-index: 40; box-shadow: var(--shadow-md); max-width: 90vw; font-weight: 500; font-size: 13.5px; }
.toast.bad { background: #b91c1c; color: #fff; }
.bar { height: 6px; border-radius: 3px; background: var(--brand); min-width: 2px; margin-top: 4px; }
.theme-toggle svg { width: 16px; height: 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Responsive: 1024 ---------- */
@media (max-width: 1180px) {
  .grid.wide-left { grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr); }
  .chart-bars { gap: 8px; }
}
@media (max-width: 1100px) {
  .sidebar { width: 224px; }
  .nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .view { padding: 16px; }
}

/* ---------- Responsive: phones ---------- */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 20; width: 264px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-md); }
  #menu-toggle { display: inline-flex; }
  .topbar { padding: 0 12px; gap: 8px; }
  h1 { font-size: 17px; }
  .view { padding: 12px; gap: 12px; }
  .grid.two, .grid.wide-left, .grid.split { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { padding-bottom: 0; }
  .kv dd { border-top: 0; padding-top: 0; }
  .toolbar input, .toolbar select { min-width: 0; flex: 1 1 140px; }
  .toolbar .count { width: 100%; margin-left: 0; }
  .seg-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-bars { height: 160px; gap: 4px; }
  .chart-label { font-size: 11px; }
  .drawer-panel { width: 100%; border-left: 0; }
  .drawer-scroll { padding: 16px; }
  .drawer-foot { padding: 12px 16px; }
  .amount-summary > div { padding: 8px 12px; }
  .amount-summary b { font-size: 15px; }
  .pill { padding: 0 8px; font-size: 12px; }
  .pill-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
.action-shot { display: block; max-width: 100%; margin-top: 8px; border: 1px solid var(--line); border-radius: var(--r-sm); }
