/* =====================================================================
   Payment Tracker — design system
   Single stylesheet, no framework, no CDN. Light + dark via one token set.
   ===================================================================== */

/* ---------- tokens ---------- */
:root {
  --bg:            #f6f7f9;
  --surface:       #ffffff;
  --surface-2:     #fbfbfd;
  --surface-hover: #f4f5f8;
  --border:        #e4e6ec;
  --border-strong: #d2d5de;

  --text:          #14161c;
  --text-muted:    #666d7d;
  --text-faint:    #9aa1b0;

  --accent:        #4f46e5;
  --accent-hover:  #4338ca;
  --accent-soft:   #eef0fe;
  --accent-text:   #ffffff;

  --ok:            #0f9d63;
  --ok-soft:       #e6f6ef;
  --warn:          #b4780a;
  --warn-soft:     #fdf3e0;
  --danger:        #d13b3b;
  --danger-soft:   #fdeded;
  --info:          #2b6cb0;
  --info-soft:     #e8f1fb;

  /* categorical chart palette */
  --c1: #4f46e5;
  --c2: #0f9d63;
  --c3: #d97706;
  --c4: #db4b6a;
  --c5: #0891b2;
  --c6: #7c5cd6;

  --radius:    10px;
  --radius-sm: 7px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(17, 20, 28, .05);
  --shadow:    0 1px 3px rgba(17, 20, 28, .07), 0 6px 16px -6px rgba(17, 20, 28, .09);
  --shadow-lg: 0 12px 32px -8px rgba(17, 20, 28, .18);

  --sidebar-w: 232px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0d0f14;
    --surface:       #161922;
    --surface-2:     #1b1f2a;
    --surface-hover: #1f2430;
    --border:        #262b38;
    --border-strong: #333a4a;

    --text:          #e8eaf0;
    --text-muted:    #98a0b3;
    --text-faint:    #6b7387;

    --accent:        #7c74f5;
    --accent-hover:  #8f88f7;
    --accent-soft:   #23214a;
    --accent-text:   #ffffff;

    --ok:            #34d399;
    --ok-soft:       #12312a;
    --warn:          #fbbf24;
    --warn-soft:     #33280f;
    --danger:        #f87171;
    --danger-soft:   #3a1d1f;
    --info:          #60a5fa;
    --info-soft:     #16283f;

    --c1: #7c74f5;
    --c2: #34d399;
    --c3: #fbbf24;
    --c4: #f472a0;
    --c5: #38bdf8;
    --c6: #a78bfa;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow:    0 1px 3px rgba(0, 0, 0, .45), 0 8px 20px -8px rgba(0, 0, 0, .6);
    --shadow-lg: 0 16px 40px -10px rgba(0, 0, 0, .7);
  }
}

:root[data-theme="dark"] {
  --bg:            #0d0f14;
  --surface:       #161922;
  --surface-2:     #1b1f2a;
  --surface-hover: #1f2430;
  --border:        #262b38;
  --border-strong: #333a4a;
  --text:          #e8eaf0;
  --text-muted:    #98a0b3;
  --text-faint:    #6b7387;
  --accent:        #7c74f5;
  --accent-hover:  #8f88f7;
  --accent-soft:   #23214a;
  --ok: #34d399;      --ok-soft:     #12312a;
  --warn: #fbbf24;    --warn-soft:   #33280f;
  --danger: #f87171;  --danger-soft: #3a1d1f;
  --info: #60a5fa;    --info-soft:   #16283f;
  --c1: #7c74f5; --c2: #34d399; --c3: #fbbf24;
  --c4: #f472a0; --c5: #38bdf8; --c6: #a78bfa;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow:    0 1px 3px rgba(0, 0, 0, .45), 0 8px 20px -8px rgba(0, 0, 0, .6);
  --shadow-lg: 0 16px 40px -10px rgba(0, 0, 0, .7);
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* =====================================================================
   Layout
   ===================================================================== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex; align-items: center; gap: .625rem;
  padding: 1.125rem 1.125rem 1rem;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 30px; height: 30px; flex: 0 0 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--c1), var(--c6));
  color: #fff; font-weight: 700; font-size: 13px;
  display: grid; place-items: center;
}
.brand-name { font-weight: 650; font-size: 14px; letter-spacing: -.01em; }
.brand-sub  { font-size: 11px; color: var(--text-faint); }

.nav { padding: .75rem .625rem; flex: 1; overflow-y: auto; }
.nav-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-faint);
  padding: .875rem .625rem .375rem;
}
.nav a {
  display: flex; align-items: center; gap: .625rem;
  padding: .5rem .625rem; margin-bottom: 1px;
  border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 500; font-size: 13.5px;
  text-decoration: none;
  transition: background .12s, color .12s;
}
.nav a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a .ico { width: 16px; height: 16px; flex: 0 0 16px; opacity: .9; }
.nav a .count {
  margin-left: auto; font-size: 11px; font-weight: 600;
  color: var(--text-faint); font-variant-numeric: tabular-nums;
}

.sidebar-foot { border-top: 1px solid var(--border); padding: .625rem; }
.user-chip {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none;
}
.user-chip:hover { background: var(--surface-hover); text-decoration: none; }
.avatar {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
.user-meta { min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-faint); text-transform: capitalize; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .875rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.content { padding: 1.5rem; max-width: 1360px; width: 100%; }

.menu-toggle { display: none; }

/* =====================================================================
   Buttons
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem .875rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 13px; font-weight: 550;
  cursor: pointer; white-space: nowrap;
  text-decoration: none;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-text);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { padding: .3125rem .5625rem; font-size: 12px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-icon { padding: .4375rem; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* =====================================================================
   Cards & tiles
   ===================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; gap: .75rem;
  padding: .875rem 1.125rem;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 14px; font-weight: 600; }
.card-head .sub { font-size: 12px; color: var(--text-faint); }
.card-head .right { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
.card-body { padding: 1.125rem; }
.card-body.tight { padding: .875rem 1.125rem; }
.card-foot {
  padding: .75rem 1.125rem; border-top: 1px solid var(--border);
  background: var(--surface-2); font-size: 12.5px; color: var(--text-muted);
  border-radius: 0 0 var(--radius) var(--radius);
}

.grid { display: grid; gap: 1rem; }
.grid-kpi   { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-2     { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3     { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-main  { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
@media (max-width: 1080px) { .grid-main { grid-template-columns: 1fr; } }

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.125rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.tile::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--accent); opacity: .85;
}
.tile.t-ok::before     { background: var(--ok); }
.tile.t-warn::before   { background: var(--warn); }
.tile.t-danger::before { background: var(--danger); }
.tile.t-info::before   { background: var(--info); }
.tile-label {
  font-size: 11.5px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-faint);
}
.tile-value {
  font-size: 25px; font-weight: 680; letter-spacing: -.025em;
  margin-top: .3125rem; font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.tile-value.sm { font-size: 20px; }
.tile-meta { font-size: 12px; color: var(--text-muted); margin-top: .3125rem; }
.tile-meta .up   { color: var(--ok); font-weight: 600; }
.tile-meta .down { color: var(--danger); font-weight: 600; }

/* =====================================================================
   Tables
   ===================================================================== */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 11px; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase; color: var(--text-faint);
  padding: .625rem 1rem; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap;
}
table.data th a { color: inherit; }
table.data th a:hover { color: var(--text); }
table.data td {
  padding: .6875rem 1rem; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-hover); }
table.data tfoot td {
  padding: .75rem 1rem; font-weight: 650; background: var(--surface-2);
  border-top: 2px solid var(--border-strong);
}
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 650; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.pos { color: var(--ok); }
.neg { color: var(--danger); }
.row-actions { display: flex; gap: .25rem; justify-content: flex-end; }
td.actions { width: 1%; white-space: nowrap; }

.cell-title { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--text-faint); margin-top: .0625rem; }

/* =====================================================================
   Badges, pills, chips
   ===================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .1875rem .5rem; border-radius: 100px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--surface-hover); color: var(--text-muted);
  border: 1px solid transparent;
}
.badge-ok     { background: var(--ok-soft);     color: var(--ok); }
.badge-warn   { background: var(--warn-soft);   color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info   { background: var(--info-soft);   color: var(--info); }
.badge-muted  { background: var(--surface-hover); color: var(--text-faint); }

.pill-group { display: flex; flex-wrap: wrap; gap: .375rem; }
.pill {
  display: inline-block; padding: .1875rem .5rem;
  border: 1px solid var(--border); border-radius: 100px;
  font-size: 11.5px; color: var(--text-muted); background: var(--surface-2);
}

.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; display: inline-block; }

/* =====================================================================
   Forms
   ===================================================================== */
.form-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.field { display: flex; flex-direction: column; gap: .375rem; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.field .hint { font-size: 11.5px; color: var(--text-faint); }
.field .err  { font-size: 11.5px; color: var(--danger); font-weight: 500; }

input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="number"], input[type="search"],
select, textarea {
  width: 100%; padding: .5rem .625rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 13.5px;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input.is-error, select.is-error, textarea.is-error { border-color: var(--danger); }
textarea { resize: vertical; min-height: 72px; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 8l3-3.5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .5rem center;
  padding-right: 1.75rem;
}
.input-prefix { position: relative; }
.input-prefix > span {
  position: absolute; left: .625rem; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); font-size: 13px; pointer-events: none;
}
.input-prefix input { padding-left: 1.5rem; }

.check { display: flex; align-items: center; gap: .5rem; font-size: 13.5px; cursor: pointer; }
.check input { width: auto; }

.checks { display: flex; flex-wrap: wrap; gap: .5rem; }
.check-pill {
  display: inline-flex; align-items: center; gap: .4375rem;
  padding: .375rem .6875rem;
  border: 1px solid var(--border-strong); border-radius: 100px;
  font-size: 13px; cursor: pointer; user-select: none;
  background: var(--surface); transition: all .12s;
}
.check-pill input { width: auto; margin: 0; }
.check-pill:has(input:checked) {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600;
}

.form-actions {
  display: flex; gap: .5rem; align-items: center;
  padding-top: 1.125rem; margin-top: 1.125rem;
  border-top: 1px solid var(--border);
}
.form-actions .spacer { margin-left: auto; }

fieldset { border: 0; padding: 0; margin: 0 0 1.5rem; }
fieldset legend {
  font-size: 11.5px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-faint);
  padding: 0 0 .75rem;
}

/* filter bar */
.filters {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end;
  padding: .875rem 1.125rem; border-bottom: 1px solid var(--border);
  background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0;
}
.filters .field { flex: 0 1 168px; gap: .25rem; }
.filters .field label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; }
.filters .grow { flex: 1 1 220px; }
.filters .actions { display: flex; gap: .5rem; margin-left: auto; }

/* =====================================================================
   Charts
   ===================================================================== */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--text-faint); font-size: 10.5px; font-family: var(--font); }
.chart .spark { fill: none; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.chart .pt circle:first-child { transition: r .12s; }
.chart .pt:hover circle:first-child { r: 5.5; }
.chart .hit { cursor: pointer; }

.donut-wrap { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.donut { width: 168px; height: 168px; flex: 0 0 168px; }
.donut-track { stroke: var(--border); }
.donut-seg { transition: opacity .12s; cursor: pointer; }
.donut-wrap:hover .donut-seg { opacity: .45; }
.donut-wrap .donut-seg:hover { opacity: 1; }
.donut-total { fill: var(--text); font-size: 21px; font-weight: 680; font-family: var(--font); }
.donut-cap   { fill: var(--text-faint); font-size: 10.5px; font-family: var(--font);
               text-transform: uppercase; letter-spacing: .06em; }

.legend { list-style: none; margin: 0; padding: 0; flex: 1 1 150px; min-width: 0; }
.legend li {
  display: flex; align-items: center; gap: .5rem;
  padding: .3125rem 0; font-size: 12.5px;
  border-bottom: 1px solid var(--border);
}
.legend li:last-child { border-bottom: 0; }
.legend-label { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-value { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }

.hbars { display: flex; flex-direction: column; gap: .625rem; }
.hbar-row { display: grid; grid-template-columns: minmax(72px, 118px) 1fr auto; gap: .75rem; align-items: center; }
.hbar-label {
  font-size: 12.5px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hbar-track { height: 8px; background: var(--surface-hover); border-radius: 100px; overflow: hidden; }
.hbar-fill  { display: block; height: 100%; border-radius: 100px; transition: width .3s ease; }
.hbar-value { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* share meter for partner balances */
.meter { height: 6px; background: var(--surface-hover); border-radius: 100px; overflow: hidden; margin-top: .375rem; }
.meter span { display: block; height: 100%; border-radius: 100px; background: var(--accent); }

/* =====================================================================
   Alerts / flash / empty states
   ===================================================================== */
.alert {
  display: flex; gap: .625rem; align-items: flex-start;
  padding: .75rem 1rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  font-size: 13.5px; margin-bottom: 1rem;
}
.alert-success { background: var(--ok-soft);     border-color: transparent; color: var(--ok); }
.alert-error   { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.alert-info    { background: var(--info-soft);   border-color: transparent; color: var(--info); }
.alert-warn    { background: var(--warn-soft);   border-color: transparent; color: var(--warn); }
.alert strong { font-weight: 650; }
.alert ul { margin: .25rem 0 0; padding-left: 1.125rem; }

.empty { padding: 3rem 1.5rem; text-align: center; color: var(--text-muted); }
.empty-icon { font-size: 28px; opacity: .35; margin-bottom: .5rem; }
.empty h3 { font-size: 15px; margin-bottom: .3125rem; color: var(--text); }
.empty p { font-size: 13px; max-width: 380px; margin: 0 auto .875rem; }
.empty-inline { padding: 1.5rem; text-align: center; color: var(--text-faint); font-size: 13px; }

/* =====================================================================
   Auth screen
   ===================================================================== */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(900px 500px at 15% -5%, var(--accent-soft), transparent 60%),
    radial-gradient(700px 420px at 105% 105%, var(--ok-soft), transparent 55%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 392px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 2rem;
}
.auth-brand { display: flex; align-items: center; gap: .625rem; margin-bottom: 1.5rem; }
.auth-card h1 { font-size: 19px; margin-bottom: .3125rem; }
.auth-card .lead { color: var(--text-muted); font-size: 13.5px; margin-bottom: 1.5rem; }
.auth-card .field { margin-bottom: .875rem; }
.auth-card .btn { width: 100%; padding: .625rem; }
.auth-foot { margin-top: 1.25rem; text-align: center; font-size: 12px; color: var(--text-faint); }

/* =====================================================================
   Misc
   ===================================================================== */
.page-intro { margin-bottom: 1.25rem; }
.page-intro p { color: var(--text-muted); font-size: 13.5px; margin: 0; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.inline { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 1rem; } .mt-2 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 1rem; }
.text-sm { font-size: 12.5px; }
.hide { display: none !important; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: .5rem 1.25rem; font-size: 13.5px; }
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; font-weight: 550; text-align: right; }

.split-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; }
.split-total {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: .875rem; padding: .625rem .75rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px;
}
.split-total .val { font-weight: 650; font-variant-numeric: tabular-nums; }
.split-total.mismatch { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }

.theme-toggle {
  background: transparent; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: .4375rem .5rem;
  cursor: pointer; color: var(--text-muted); line-height: 1;
}
.theme-toggle:hover { background: var(--surface-hover); color: var(--text); }

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open::after {
    content: ''; position: fixed; inset: 0; z-index: 50;
    background: rgba(0, 0, 0, .45);
  }
  .content { padding: 1rem; }
  .topbar { padding: .75rem 1rem; }
  .grid-main { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .tile-value { font-size: 21px; }
  .filters .field { flex: 1 1 100%; }
  .filters .actions { width: 100%; }
  .card-head { flex-wrap: wrap; }
  .donut-wrap { justify-content: center; }
}

@media print {
  .sidebar, .topbar-actions, .filters, .row-actions, .btn, .theme-toggle { display: none !important; }
  .layout { display: block; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}
