/* DIDEALS design system v2 (2026-10-16) — one stylesheet, one set of tokens.
   Replaces app.css + glass.css v1. Calm finance look: neutral canvas, white surfaces with hairline
   borders, ONE accent (indigo-blue) for actions / active state, semantic green / amber / red for money
   and status only. Glass (translucency + blur) is reserved for the sticky chrome (sidebar, top bar,
   dialogs) so data stays crisp. No external resources (CSP 'self'). Page files (programs.css …) only
   add layout and must use these tokens — no raw colours. */

:root {
  --bg: #f2f4fb;
  --bg-tint: #e3e9ff;
  --bg-tint-2: #ffe9f3;
  --bg-tint-3: #e2f8ef;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #f1f3f7;
  --glass: rgba(255, 255, 255, .78);
  --border: #e3e6ec;
  --border-strong: #cfd4dd;
  --text: #111827;
  --text-2: #4b5565;
  --text-3: #6b7383;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-2: #db2777;
  --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #db2777 100%);
  --accent-soft: #eef2ff;
  --accent-text: #3249c4;
  --good: #087443;  --good-soft: #e9f8ef;
  --warn: #a15c07;  --warn-soft: #fff6e5;
  --bad: #b42318;   --bad-soft: #fdeeec;
  --info: #3249c4;  --info-soft: #eef2ff;
  --neutral-soft: #eef0f4;
  --bar-1: #4f46e5; --bar-2: #06b6d4; --bar-3: #10b981; --bar-4: #f59e0b; --bar-5: #ec4899; --bar-6: #8b5cf6; --bar-7: #ef4444; --bar-8: #84cc16;
  --t1: #4f46e5; --t1-soft: #eef0ff; --t2: #0891b2; --t2-soft: #e3f7fb; --t3: #059669; --t3-soft: #e3f8ef; --t4: #d97706; --t4-soft: #fff4e0;
  --t5: #db2777; --t5-soft: #fde8f2; --t6: #7c3aed; --t6-soft: #f1eafe;
  --shadow-1: 0 1px 2px rgba(17, 24, 39, .05);
  --shadow-2: 0 1px 3px rgba(17, 24, 39, .07), 0 1px 2px rgba(17, 24, 39, .04);
  --shadow-3: 0 12px 32px -8px rgba(17, 24, 39, .18), 0 4px 8px -4px rgba(17, 24, 39, .08);
  --ring: 0 0 0 3px rgba(59, 91, 219, .28);
  --r-lg: 12px; --r-md: 8px; --r-sm: 6px; --r-pill: 999px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --side-w: 248px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1018; --bg-tint: #1a1f45; --bg-tint-2: #2a1430; --bg-tint-3: #0f2a24;
    --surface: #161b25; --surface-2: #1b212d; --surface-3: #212836;
    --glass: rgba(22, 27, 37, .80);
    --border: #2a3140; --border-strong: #3a4354;
    --text: #e8ebf1; --text-2: #b4bccb; --text-3: #8d97a8;
    --accent: #818cf8; --accent-hover: #a5b4fc; --accent-2: #f472b6;
    --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%); --accent-soft: #1d2747; --accent-text: #9db1ff;
    --good: #4cc68d; --good-soft: #12291f;
    --warn: #f0b44c; --warn-soft: #2d2412;
    --bad: #ff8a80;  --bad-soft: #321a19;
    --info: #9db1ff; --info-soft: #1d2747;
    --neutral-soft: #232a37;
    --bar-1: #818cf8; --bar-2: #22d3ee; --bar-3: #34d399; --bar-4: #fbbf24; --bar-5: #f472b6; --bar-6: #a78bfa; --bar-7: #f87171; --bar-8: #a3e635;
    --t1: #a5b4fc; --t1-soft: #1f2250; --t2: #67e8f9; --t2-soft: #0f2f38; --t3: #6ee7b7; --t3-soft: #0f2d24; --t4: #fcd34d; --t4-soft: #33270f;
    --t5: #f9a8d4; --t5-soft: #3a1528; --t6: #c4b5fd; --t6-soft: #2a1f4a;
    --shadow-1: none; --shadow-2: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-3: 0 16px 40px -10px rgba(0, 0, 0, .7);
    --ring: 0 0 0 3px rgba(112, 144, 255, .35);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text);
  background: radial-gradient(900px 480px at 90% -140px, var(--bg-tint), transparent 70%),
    radial-gradient(700px 420px at -10% 30%, var(--bg-tint-2), transparent 65%),
    radial-gradient(800px 500px at 60% 120%, var(--bg-tint-3), transparent 70%), var(--bg);
  background-attachment: fixed; min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { color: var(--text); line-height: 1.25; }
p { margin: 0 0 var(--s3); }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
img, svg, video { max-width: 100%; height: auto; }
code, pre, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.n, td.n, th.n, .num, .kpi .v, .mini-kpi .val { font-variant-numeric: tabular-nums; }
td.n, th.n { text-align: right; }
.muted, .s, small { color: var(--text-3); }
.neg, .err { color: var(--bad); }
.pos, .ok, .sum-ok { color: var(--good); }
.warn { color: var(--warn); }
.sum-err { color: var(--bad); font-weight: 600; }
.mt { margin-top: var(--s4); }
.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

/* ---------- app shell ---------- */
.layout { display: flex; min-height: 100vh; }
.side {
  width: var(--side-w); flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--glass); border-right: 1px solid var(--border);
  -webkit-backdrop-filter: blur(16px) saturate(160%); backdrop-filter: blur(16px) saturate(160%);
  padding: var(--s4) var(--s3) var(--s5); display: flex; flex-direction: column; gap: 2px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 16px; letter-spacing: .02em; color: var(--text); }
.brand .logo {
  width: 28px; height: 28px; border-radius: 8px; display: inline-grid; place-items: center; font-size: 14px;
  color: #fff; background: linear-gradient(135deg, var(--accent), #6c5ce7); box-shadow: var(--shadow-2);
}
.side .grp { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); padding: 16px 10px 6px; }
.side a {
  display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 7px 10px; border-radius: var(--r-md);
  color: var(--text-2); font-weight: 500; text-decoration: none; position: relative;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.side a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.side a.on, .side a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.side a.on::before, .side a[aria-current="page"]::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.side a.sub { font-size: 13px; padding-left: 14px; }
.side .ico { width: 18px; text-align: center; color: var(--text-3); flex-shrink: 0; }
.side a.on .ico { color: var(--accent); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  min-height: 64px; padding: 12px var(--s5);
  background: var(--glass); border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: blur(16px) saturate(160%); backdrop-filter: blur(16px) saturate(160%);
}
.top h1 { flex: 1 1 260px; min-width: 0; margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -.01em; overflow-wrap: anywhere; }
.top .crumb { display: block; font-size: 12px; font-weight: 500; color: var(--text-3); letter-spacing: 0; margin-bottom: 2px; }
.top .actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.user { display: flex; align-items: center; gap: var(--s2); padding-left: var(--s3); margin-left: var(--s1); border-left: 1px solid var(--border); }
.user .who { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: 12px;
  color: var(--accent-text); background: var(--accent-soft); border: 1px solid var(--border); text-transform: uppercase; }
.hamburger { display: none; width: 40px; height: 40px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 18px; cursor: pointer; }
.content { width: 100%; max-width: 1360px; padding: var(--s5); display: flex; flex-direction: column; gap: var(--s4); }
.content > * { margin-top: 0; margin-bottom: 0; }
.foot { margin-top: auto; padding: var(--s4) var(--s5); font-size: 12px; color: var(--text-3); }

.flash { padding: var(--s3) var(--s5) 0; display: flex; flex-direction: column; gap: var(--s2); }
.flash-item { padding: 10px 14px; border-radius: var(--r-md); background: var(--info-soft); color: var(--info); border: 1px solid var(--border); font-weight: 500; }

/* ---------- surfaces ---------- */
.card, .kpi, .panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2); padding: var(--s4) var(--s5); min-width: 0;
}
.card > :last-child { margin-bottom: 0; }
.card h2 { font-size: 16px; font-weight: 650; margin: 0 0 var(--s3); }
.card h3, .kpi h3, .section-title {
  margin: 0 0 var(--s3); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s3); }
.card-head h2, .card-head h3 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: var(--s4) var(--s5) 0; }
.card.flush > .table-wrap { border: 0; border-radius: 0; box-shadow: none; }
.card .table-wrap { box-shadow: none; }
.warn-card { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); background: var(--warn-soft); }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.danger-zone h3 { color: var(--bad); }

.grid { display: grid; gap: var(--s4); align-items: stretch; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.top-align { align-items: start; }
.stack { }
.stack-gap > * + * { margin-top: var(--s4); }
.row { display: flex; gap: var(--s3); flex-wrap: wrap; }
.row > * { flex: 1 1 0; min-width: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; }

/* KPIs */
.kpi { padding: var(--s4); display: flex; flex-direction: column; gap: 4px; }
.kpi h3 { margin: 0; }
.kpi .v { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; overflow-wrap: anywhere; }
.kpi .s { font-size: 12px; color: var(--text-3); }
.kpi .v.pos { color: var(--good); } .kpi .v.neg { color: var(--bad); } .kpi .v.warn { color: var(--warn); }
.kpi-strip, .kpis { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.mini-kpi { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 12px; min-width: 0; }
.mini-kpi .lab { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.mini-kpi .val { font-size: 18px; font-weight: 700; margin-top: 2px; }
.grid.g3.lior { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); margin-bottom: var(--s3); }

/* ---------- buttons ---------- */
.btn, button.btn, a.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: var(--r-md); border: 1px solid transparent;
  font: inherit; font-size: 13.5px; font-weight: 600; line-height: 1; white-space: nowrap; cursor: pointer; text-decoration: none;
  background: var(--accent); color: #fff; box-shadow: var(--shadow-1);
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease), transform .1s var(--ease);
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.sec { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.sec:hover { background: var(--surface-3); }
.btn.ghost { background: transparent; color: var(--text-2); box-shadow: none; }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger:hover { filter: brightness(.92); background: var(--bad); }
.btn.sec.danger, .btn.ghost.danger { background: var(--surface); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.btn.sec.danger:hover, .btn.ghost.danger:hover { background: var(--bad-soft); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn[disabled], .btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn.is-busy { opacity: .7; cursor: progress; }
.btn-row, .actions-row, .form-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.form-actions { margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--border); }
.form-actions .spacer, .btn-row .spacer { flex: 1; }

/* overflow menu (no-JS <details>) */
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu > .menu-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 40; min-width: 180px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-3);
  display: flex; flex-direction: column;
}
details.menu > .menu-list > a, details.menu > .menu-list > button {
  appearance: none; border: 0; background: transparent; font: inherit; text-align: left; cursor: pointer;
  padding: 8px 10px; border-radius: var(--r-sm); color: var(--text); text-decoration: none; white-space: nowrap;
}
details.menu > .menu-list > a:hover, details.menu > .menu-list > button:hover { background: var(--surface-3); text-decoration: none; }
details.menu > .menu-list > .danger { color: var(--bad); }
details.menu > .menu-list > .danger:hover { background: var(--bad-soft); }
details.menu > .menu-list > hr { border: 0; border-top: 1px solid var(--border); margin: 4px 2px; }

/* ---------- forms ---------- */
.inp, .sel, textarea,
input[type="text"], input[type="password"], input[type="search"], input[type="number"], input[type="date"], input[type="email"], select {
  appearance: none; width: 100%; min-width: 0; max-width: 100%; min-height: 36px; padding: 7px 10px;
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-md); box-shadow: var(--shadow-1);
  transition: border-color .15s, box-shadow .15s;
}
select, .sel {
  padding-right: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}
textarea { min-height: 80px; resize: vertical; }
.inp:focus, .sel:focus, textarea:focus, input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: .8; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; vertical-align: middle; }
input[readonly], .inp[readonly] { background: var(--surface-2); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; }
.field > label, .field .lbl { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--text-3); }
.field.full { grid-column: 1 / -1; }
.form-grid { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
fieldset { min-width: 0; max-width: 100%; margin: 0; padding: var(--s3) var(--s4) var(--s4); border: 1px solid var(--border); border-radius: var(--r-md); }
legend { padding: 0 6px; font-weight: 600; font-size: 13px; color: var(--text-2); }
.radio, .check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.errs, .errors, [data-error] { color: var(--bad); font-size: 13px; min-height: 1em; }
.errors .err-item { padding: 2px 0; }
.bar-form { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.bar-form .sel, .bar-form .inp, .top .actions .sel, .top .actions .inp { width: auto; }

/* filter toolbars: a plain flex row, NEVER a second card inside a card */
.filters, form.filters {
  display: flex; flex-wrap: wrap; gap: var(--s3); align-items: flex-end; margin: 0; padding: 0;
  background: none; border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none;
}
.filters .field { flex: 1 1 150px; min-width: 130px; max-width: 260px; }
.filters .field.grow { flex: 2 1 240px; max-width: 420px; }
.filters .field.btns { flex: 0 0 auto; min-width: 0; flex-direction: row; gap: var(--s2); }
.filters-bar, .filters-card { padding: var(--s3) var(--s4); }
.filters-toggle { display: none; }

/* ---------- chips / badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; line-height: 18px; white-space: nowrap; margin: 0;
  background: var(--neutral-soft); color: var(--text-2); border: 1px solid transparent;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.chip.plain::before, .tag::before { display: none; }
.c-g { background: var(--good-soft); color: var(--good); }
.c-a { background: var(--warn-soft); color: var(--warn); }
.c-b { background: var(--info-soft); color: var(--info); }
.c-r { background: var(--bad-soft); color: var(--bad); }
.c-n { background: var(--neutral-soft); color: var(--text-2); }
.tag { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: var(--r-sm); font-size: 11.5px; font-weight: 600;
  letter-spacing: .02em; color: var(--text-2); background: var(--surface-3); border: 1px solid var(--border); white-space: nowrap; }
.dir { display: inline-grid; place-items: center; min-width: 38px; padding: 1px 6px; border-radius: var(--r-sm); font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.dir.in { background: var(--good-soft); color: var(--good); }
.dir.out { background: var(--bad-soft); color: var(--bad); }

/* removable token chips (multi-select pickers) */
.tokens { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 36px; padding: 4px 6px;
  border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); }
.tokens:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.token { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: var(--r-pill);
  background: var(--accent-soft); color: var(--accent-text); font-size: 13px; font-weight: 600; }
.token button { appearance: none; border: 0; background: transparent; color: inherit; width: 22px; height: 22px; border-radius: 50%;
  cursor: pointer; font-size: 14px; line-height: 1; display: inline-grid; place-items: center; }
.token button:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.tokens select { flex: 1 1 140px; width: auto; min-height: 28px; border: 0; box-shadow: none; padding-top: 2px; padding-bottom: 2px; background-color: transparent; }
.tokens select:focus { box-shadow: none; }

/* ---------- tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
table.dt th, table.dt td, .card table th, .card table td { padding: 10px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
table.dt th, .card table th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--text-3);
  font-size: 12px; font-weight: 600; letter-spacing: .02em; white-space: nowrap;
}
table.dt th.n, table.dt td.n { text-align: right; }
table.dt th[data-sort] { cursor: pointer; user-select: none; }
table.dt th[data-sort]:hover { color: var(--text); }
table.dt th[aria-sort="ascending"], table.dt th[aria-sort="descending"] { color: var(--accent-text); }
table.dt th[aria-sort="ascending"]::after { content: " ↑"; }
table.dt th[aria-sort="descending"]::after { content: " ↓"; }
table.dt tbody tr:last-child td { border-bottom: 0; }
table.dt tbody tr { transition: background .12s; }
table.dt tbody tr:hover td { background: var(--surface-2); }
table.dt td a { font-weight: 600; }
table.dt tr.tot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border-strong); border-bottom: 0; }
table.dt td.actions-cell, table.dt th.actions-cell { text-align: right; white-space: nowrap; width: 1%; }
table.dt td .sub, .cell-sub { display: block; font-size: 12px; color: var(--text-3); font-weight: 400; }
tr.fee-child td { background: var(--surface-2); color: var(--text-2); font-size: 13px; }
tr.fee-child td:first-child { padding-left: 28px; }
tr.is-void td { color: var(--text-3); }
tr.is-void td .amt { text-decoration: line-through; }
table.kv { width: 100%; }
table.kv th, table.kv td { position: static; background: none; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
table.kv th { width: 38%; color: var(--text-3); font-weight: 500; letter-spacing: 0; padding-right: var(--s3); white-space: normal; }
table.kv tr:last-child th, table.kv tr:last-child td { border-bottom: 0; }
.dt-tools { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin: 0 0 var(--s3); font-size: 12.5px; color: var(--text-3); }
.dt-tools input[type="search"] { flex: 0 1 280px; }
.card.flush .dt-tools { padding: var(--s3) var(--s5) 0; margin-bottom: var(--s3); }
.amt-in { color: var(--good); font-weight: 600; }
.amt-out { color: var(--text); font-weight: 600; }

.pager { display: flex; gap: 4px; flex-wrap: wrap; margin-top: var(--s3); }
.pager .page { min-width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0 10px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); text-decoration: none; font-weight: 600; }
.pager .page:hover { background: var(--surface-3); text-decoration: none; }
.pager .page.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* tabs (segmented) */
.tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tabs a, .tabs .tab { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; margin-bottom: -1px; color: var(--text-2);
  font-weight: 600; text-decoration: none; border-bottom: 2px solid transparent; }
.tabs a:hover, .tabs .tab:hover { color: var(--text); text-decoration: none; }
.tabs a.on, .tabs .tab.on, .tabs a[aria-current="page"] { color: var(--accent-text); border-bottom-color: var(--accent); }
.tabs .count { font-size: 11.5px; padding: 0 7px; border-radius: var(--r-pill); background: var(--surface-3); color: var(--text-3); }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-md); background: var(--surface-3); border: 1px solid var(--border); }
.seg a { padding: 5px 12px; border-radius: var(--r-sm); color: var(--text-2); font-weight: 600; font-size: 13px; text-decoration: none; }
.seg a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-2); }

/* ---------- bars / legend ---------- */
.bar { display: flex; height: 12px; border-radius: var(--r-pill); overflow: hidden; margin: var(--s2) 0 var(--s3); background: var(--surface-3); }
.bar i { display: block; height: 100%; width: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw[data-color="navy"] { background: var(--bar-1); }
.sw[data-color="blue"] { background: var(--bar-2); }
.sw[data-color="green"] { background: var(--bar-3); }
.sw[data-color="amber"] { background: var(--bar-4); }

/* ---------- empty, banners, timeline ---------- */
.empty { padding: var(--s6) var(--s4); text-align: center; color: var(--text-3); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--r-lg); }
.empty h3 { margin: 0 0 6px; font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--text); }
.empty .btn { margin-top: var(--s3); }
.banner, .warn-banner { padding: 10px 14px; border-radius: var(--r-md); border: 1px solid var(--border); font-size: 13.5px; }
.banner.info { background: var(--info-soft); color: var(--info); }
.banner.error { background: var(--bad-soft); color: var(--bad); }
.warn-banner, .banner.warn { background: var(--warn-soft); color: var(--warn); }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2); counter-reset: tl; }
.timeline li { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-3); font-size: 13px; }
.timeline li::before { counter-increment: tl; content: counter(tl); width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 11px; font-weight: 700; background: var(--surface-3); color: var(--text-3); }
.timeline li .chip { background: none; padding: 0; color: inherit; }
.timeline li .chip::before { display: none; }
.timeline li.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.timeline li.on::before { background: var(--accent); color: #fff; }
.timeline li.voided { opacity: .5; text-decoration: line-through; }
dl.meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
dl.meta dt { color: var(--text-3); }
dl.meta dd { margin: 0; color: var(--text); min-width: 0; overflow-wrap: anywhere; }

/* ---------- dialogs & toasts ---------- */
dialog {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; padding: var(--s5);
  color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-3);
}
dialog::backdrop { background: rgba(10, 14, 24, .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog h3, dialog h2 { margin: 0 0 var(--s2); font-size: 17px; font-weight: 650; text-transform: none; letter-spacing: 0; color: var(--text); }
dialog p { color: var(--text-2); }
dialog .field { margin: 0 0 var(--s3); }
dialog menu, dialog .dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--s2); margin: var(--s4) 0 0; padding: 0; }
dialog menu button:not(.btn) { appearance: none; min-height: 36px; padding: 0 14px; border-radius: var(--r-md); font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
dialog menu button[value="ok"]:not(.btn) { background: var(--accent); border-color: var(--accent); color: #fff; }
.impact { margin: var(--s3) 0; padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--bad-soft); color: var(--bad); font-size: 13.5px; }
.impact ul { margin: 6px 0 0 18px; padding: 0; }
.toast-host { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: var(--s2); max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 12px 14px; border-radius: var(--r-md); background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-left: 4px solid var(--bad); box-shadow: var(--shadow-3); animation: pop-in .2s var(--ease); }
.toast.ok { border-left-color: var(--good); }
.toast.out { opacity: 0; transform: translateY(6px); transition: all .3s var(--ease); }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- signed-out ---------- */
body.signed-out .layout { display: grid; place-items: center; min-height: 100vh; }
body.signed-out .main { width: min(420px, calc(100vw - 32px)); }
body.signed-out .top { position: static; background: transparent; border: 0; -webkit-backdrop-filter: none; backdrop-filter: none; justify-content: center; padding: 0 0 var(--s4); min-height: 0; }
body.signed-out .top h1 { text-align: center; font-size: 22px; flex: none; }
body.signed-out .content { padding: 0 0 var(--s5); }
body.signed-out .foot { text-align: center; }
.login .card, body.signed-out .card { padding: var(--s5); box-shadow: var(--shadow-3); }

/* ---------- responsive ---------- */
.side-mobile-only, .side a.side-mobile-only, .side .grp.side-mobile-only { display: none; }
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .hamburger { display: inline-grid; place-items: center; }
  .side { position: fixed; z-index: 30; left: 0; top: 0; bottom: 0; width: min(300px, 84vw); height: 100vh; transform: translateX(-100%);
    transition: transform .2s var(--ease); background: var(--surface); box-shadow: var(--shadow-3); }
  .layout[data-nav-open="true"] .side { transform: none; }
  .layout[data-nav-open="true"]::before { content: ""; position: fixed; inset: 0; z-index: 25; background: rgba(10, 14, 24, .4); }
  .top { padding: 10px var(--s4); min-height: 56px; }
  .top h1 { font-size: 18px; flex-basis: 0; }
  .user { display: none; }
  .side-mobile-only, .side a.side-mobile-only { display: flex; }
  .side .grp.side-mobile-only { display: block; }
  .content { padding: var(--s4); }
  .g2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .content { padding: var(--s3) var(--s3) var(--s5); gap: var(--s3); }
  .top .actions { order: 3; width: 100%; }
  .top .actions .btn { flex: 1 1 auto; }
  .g2, .g3, .g4, .grid.g3.lior { grid-template-columns: minmax(0, 1fr); }
  .card { padding: var(--s4); border-radius: var(--r-md); }
  .kpi .v { font-size: 21px; }
  .btn { min-height: 42px; }
  .btn.sm { min-height: 36px; }
  .filters-toggle { display: inline-flex; align-self: flex-start; }
  form.filters:not([data-open="true"]) { display: none; }
  .filters .field { max-width: none; flex: 1 1 100%; }
  .row > * { flex: 1 1 100%; }
  /* tables → cards */
  .table-wrap:has(.dt.stack) { border: 0; background: transparent; overflow: visible; }
  .dt.stack thead { display: none; }
  .dt.stack, .dt.stack tbody, .dt.stack tr, .dt.stack td { display: block; width: 100%; }
  .dt.stack tr { margin-bottom: var(--s2); padding: 4px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-1); }
  .dt.stack td { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); padding: 8px 0; text-align: right; border-bottom: 1px solid var(--border); }
  .dt.stack td::before { content: attr(data-label); flex: 0 0 auto; max-width: 45%; text-align: left; color: var(--text-3); font-size: 12px; font-weight: 600; }
  .dt.stack td:last-child { border-bottom: 0; }
  .dt.stack td.actions-cell { justify-content: flex-end; width: 100%; }
  .dt.stack tr.tot td.blank { display: none; }
  table.dt tbody tr:hover td { background: none; }
}
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .side, .top { background: var(--surface); }
}
@media (prefers-reduced-transparency: reduce) {
  .side, .top { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  body { background: #fff; color: #000; }
  .side, .top .actions, .user, .hamburger, .filters, .filters-toggle, .dt-tools, .pager, .foot, details.menu { display: none !important; }
  .top { position: static; border: 0; }
  .content { max-width: none; padding: 0; }
  .card, .kpi, .table-wrap { box-shadow: none; break-inside: avoid; }
}
.kpi-plain .v-lg { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-plain { margin-bottom: var(--s4); }
.top .actions .chip { margin-right: var(--s1); }
.row-inline { display: flex; gap: var(--s2); align-items: center; }
.row-inline > select, .row-inline > .inp { flex: 1 1 auto; }
.field .hint a { font-weight: 600; }
.btn.filters-toggle { display: none; }
@media (max-width: 640px) { .btn.filters-toggle { display: inline-flex; } }
.table-wrap + h3, .table-wrap + .section-title { margin-top: var(--s5); }
/* user menu */
.user details.menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: var(--r-pill); color: var(--text-2); font-size: 13px; }
.user details.menu > summary:hover { background: var(--surface-3); }
.user details.menu > summary::-webkit-details-marker { display: none; }
.user .menu-list .menu-head { padding: 8px 10px; font-size: 12px; color: var(--text-3); border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.field.form-actions { flex-direction: row; flex-wrap: wrap; }
@media (max-width: 640px) { .ledger-desc { text-align: right; } .ledger-desc b { display: inline; } }
@media (max-width: 640px) {
  .dt.stack td { flex-wrap: wrap; justify-content: flex-end; gap: 6px var(--s2); }
  .dt.stack td::before { margin-right: auto; }
}

/* sign-in history note inside a flush card */
.card.flush > p.pad { padding: 0 16px 10px; margin: 0; }
