/* Palette: validated reference palette. Groups use categorical slots 1-3 (blue, orange, aqua),
   the only slots that validate when all pairs are on screen at once. */
:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb;
  --text: #0b0b0b; --text-2: #52514e; --muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --ring: rgba(11,11,11,.10);
  --g1: #2a78d6; --g2: #eb6834; --g3: #1baf7a;
  --good: #0ca30c; --warning: #fab219; --critical: #d03b3b;
  --accent: #2a78d6; --on-accent: #fff;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19;
    --text: #f0efec; --text-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --ring: rgba(255,255,255,.10);
    --g1: #3987e5; --g2: #d95926; --g3: #199e70;
    --accent: #3987e5;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--page); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 14px; }

header { position: sticky; top: 0; z-index: 5; background: var(--page); padding: calc(10px + env(safe-area-inset-top)) 0 8px; border-bottom: 1px solid var(--grid); }
.top { display: flex; align-items: center; gap: 10px; }
.top h1 { font-size: 18px; margin: 0; flex: 1; }
.chip { font-size: 12px; color: var(--text-2); border: 1px solid var(--ring); border-radius: 99px; padding: 3px 9px; background: var(--surface); white-space: nowrap; }
.chip.err { color: var(--critical); border-color: var(--critical); }
.months { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 0; scrollbar-width: none; }
.months button { flex: none; border: 1px solid var(--ring); background: var(--surface); border-radius: 99px; padding: 5px 12px; font-size: 14px; color: var(--text-2); }
.months button[aria-pressed=true] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.card { background: var(--surface); border: 1px solid var(--ring); border-radius: 14px; padding: 14px; margin: 12px 0; }
.card h2 { font-size: 14px; font-weight: 600; color: var(--text-2); margin: 0 0 8px; }
.hero { font-size: 38px; font-weight: 650; letter-spacing: -.5px; }
.sub { color: var(--text-2); font-size: 14px; }
.muted { color: var(--muted); }

.stack { display: flex; gap: 2px; height: 16px; margin: 12px 0 10px; }
.stack > i { display: block; min-width: 3px; }
.stack > i:first-child { border-radius: 0 4px 4px 0; }   /* RTL: first = right edge */
.stack > i:last-child { border-radius: 4px 0 0 4px; }
.stack > i:only-child { border-radius: 4px; }
.legend { display: grid; gap: 6px; }
.legend div { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend b { margin-inline-start: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.legend span.pct { color: var(--text-2); font-size: 13px; width: 38px; text-align: end; }

.meter { height: 10px; border-radius: 5px; background: var(--grid); overflow: hidden; margin: 8px 0; }
.meter > i { display: block; height: 100%; border-radius: 5px; }
.status { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.status .ic { font-weight: 800; }

.grp { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 0 6px; font-weight: 650; }
.grp .tot { font-variant-numeric: tabular-nums; }
.row { background: var(--surface); border: 1px solid var(--ring); border-radius: 12px; margin-bottom: 6px; overflow: hidden; }
.row > button { all: unset; display: block; width: 100%; padding: 10px 12px; cursor: pointer; box-sizing: border-box; }
.row .l { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; }
.row .l b { font-variant-numeric: tabular-nums; font-weight: 600; }
.bar { height: 6px; border-radius: 3px; background: var(--grid); margin-top: 7px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; }
.det { border-top: 1px solid var(--grid); padding: 6px 12px 8px; background: var(--page); }
.det div { display: flex; justify-content: space-between; font-size: 14px; color: var(--text-2); padding: 3px 0; gap: 10px; }
.det div span:last-child { font-variant-numeric: tabular-nums; }

.tx { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid var(--grid); }
.tx .m { font-size: 15px; overflow-wrap: anywhere; }
.tx .a { font-variant-numeric: tabular-nums; font-weight: 600; text-align: end; }
.tx .s { font-size: 12.5px; color: var(--text-2); grid-column: 1 / -1; }
.tx .dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-inline-end: 5px; }
input[type=text], input[type=number], input[type=url], select { width: 100%; font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--axis); background: var(--surface); color: var(--text); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chips button { border: 1px solid var(--ring); background: var(--surface); border-radius: 99px; padding: 4px 11px; font-size: 13px; color: var(--text-2); }
.chips button[aria-pressed=true] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.btn { display: inline-block; border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); border-radius: 10px; padding: 10px 16px; font-weight: 600; cursor: pointer; }
.btn.alt { background: transparent; color: var(--accent); }
.btn.sm { padding: 6px 12px; font-size: 14px; }
.btn.danger { background: transparent; color: var(--critical); border-color: var(--critical); }
.stackv { display: grid; gap: 10px; }
label.f { display: grid; gap: 4px; font-size: 14px; color: var(--text-2); }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > * { flex: 1; }

nav { position: fixed; bottom: 0; inset-inline: 0; background: var(--surface); border-top: 1px solid var(--grid); display: flex; padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
nav button { all: unset; flex: 1; text-align: center; padding: 10px 0 9px; font-size: 13px; color: var(--muted); cursor: pointer; position: relative; }
nav button[aria-current=page] { color: var(--accent); font-weight: 650; }
nav .badge { position: absolute; top: 4px; margin-inline-start: 16px; background: var(--critical); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 6px; }

.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 640px; border-radius: 18px 18px 0 0; padding: 16px 14px calc(16px + env(safe-area-inset-bottom)); max-height: 85vh; overflow: auto; }
.toast { position: fixed; bottom: calc(80px + env(safe-area-inset-bottom)); inset-inline: 14px; margin: auto; max-width: 420px; background: var(--text); color: var(--page); padding: 11px 14px; border-radius: 12px; z-index: 30; text-align: center; font-size: 15px; }
.empty { text-align: center; padding: 40px 10px; color: var(--text-2); }
.empty .btn { margin-top: 12px; }
.note { font-size: 12.5px; color: var(--muted); margin: 14px 0; }
@media (forced-colors: active) { .stack > i, .bar > i, .meter > i { forced-color-adjust: none; } }
