/* Tally — tokens follow the dataviz reference palette. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --claude: #eb6834;       /* categorical slot 2 */
  --codex: #2a78d6;        /* categorical slot 1 */
  --claude-track: #fbe1d6;
  --codex-track: #cde2fb;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 8px 24px -12px rgba(11, 11, 11, 0.08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --ring: rgba(255, 255, 255, 0.10);
    --claude: #d95926; --codex: #3987e5;
    --claude-track: #3a2419; --codex-track: #1a2a40;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --ring: rgba(255, 255, 255, 0.10);
  --claude: #d95926; --codex: #3987e5;
  --claude-track: #3a2419; --codex-track: #1a2a40;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--codex); outline-offset: 2px; border-radius: 6px; }

/* ---------- mark (4 rising bars) ---------- */
.mark { display: inline-flex; align-items: flex-end; gap: 4px; height: 36px; }
.mark span { width: 6px; border-radius: 3px; }
.mark span:nth-child(1) { height: 45%; background: var(--claude); }
.mark span:nth-child(2) { height: 80%; background: var(--claude); }
.mark span:nth-child(3) { height: 60%; background: var(--codex); }
.mark span:nth-child(4) { height: 100%; background: var(--codex); }
.mark.sm { height: 18px; gap: 2px; }
.mark.sm span { width: 3px; border-radius: 1.5px; }

/* ---------- gate ---------- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.gate-card { width: min(340px, 100%); text-align: center; }
.gate-title { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; margin: 18px 0 4px; }
.gate-sub { color: var(--ink-2); margin: 0 0 28px; font-size: 15px; }
.pin-input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.pin-dots { display: flex; justify-content: center; gap: 14px; height: 18px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--axis); transition: background .12s, border-color .12s, transform .12s; }
.pin-dots i.on { background: var(--ink); border-color: var(--ink); transform: scale(1.08); }
.pin-dots.bad { animation: shake .38s; }
.pin-dots.bad i { border-color: var(--critical); background: transparent; }
.pin-dots.ok i { background: var(--good); border-color: var(--good); }
@keyframes shake { 20%,60% { transform: translateX(-8px); } 40%,80% { transform: translateX(8px); } }
.pin-msg { min-height: 20px; margin: 16px 0 12px; font-size: 13px; color: var(--ink-2); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; justify-items: center; }
.keypad button { width: 72px; height: 72px; border-radius: 50%; border: 0; background: var(--surface); box-shadow: inset 0 0 0 1px var(--ring); font-size: 26px; font-weight: 450; cursor: pointer; display: grid; place-items: center; transition: background .1s, transform .08s; -webkit-tap-highlight-color: transparent; font-variant-numeric: tabular-nums; }
.keypad button:hover { background: var(--surface-2); }
.keypad button:active { transform: scale(.94); background: var(--grid); }
.keypad button[data-k="del"] { background: transparent; box-shadow: none; color: var(--ink-2); }
.keypad.disabled { opacity: .4; pointer-events: none; }

/* ---------- app shell ---------- */
.app { max-width: 1240px; margin: 0 auto; padding: 0 20px 48px; }
.top { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; padding: 16px 0 14px; background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-weight: 650; font-size: 18px; letter-spacing: -0.01em; }
.brand-sub { color: var(--muted); font-size: 12px; margin-left: 4px; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; padding: 3px; background: var(--surface); border-radius: 10px; box-shadow: inset 0 0 0 1px var(--ring); }
.seg button { border: 0; background: transparent; padding: 6px 11px; font-size: 13px; font-weight: 520; color: var(--ink-2); border-radius: 7px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button:hover { color: var(--ink); }
.seg button[aria-checked="true"] { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--ring); }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 10px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--ring); cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { color: var(--ink); }
.icon-btn:disabled { cursor: progress; }
.icon-btn.spin svg { animation: spin .9s linear infinite; }
.icon-btn.done { color: var(--good); }
.icon-btn.fail { color: var(--critical); }
@keyframes spin { to { transform: rotate(360deg); } }
.sw { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sw.claude { background: var(--claude); }
.sw.codex { background: var(--codex); }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.span2 { grid-column: 1 / -1; }
.panel { background: var(--surface); border-radius: 16px; box-shadow: inset 0 0 0 1px var(--ring), var(--shadow); padding: 20px; min-width: 0; }
.panel-head { display: flex; gap: 12px 16px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; margin-bottom: 14px; }
h2 { font-size: 15px; font-weight: 620; margin: 0; letter-spacing: -0.005em; }
.sub { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.eyebrow { margin: 0; color: var(--ink-2); font-size: 13px; font-weight: 500; }

/* ---------- hero ---------- */
.hero-panel { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 24px; padding: 24px; }
.hero { display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.hero-num { margin: 0; font-size: clamp(48px, 7vw, 68px); font-weight: 640; letter-spacing: -0.035em; line-height: 1.02; }
.hero-num .cents { color: var(--muted); font-weight: 520; }
.hero-split { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.hero-split span { display: inline-flex; align-items: center; gap: 6px; }
.hero-split b { color: var(--ink); font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--grid); border-radius: 12px; overflow: hidden; box-shadow: 0 0 0 1px var(--grid); align-self: center; }
.tile { background: var(--surface); padding: 14px 16px; min-width: 0; }
.tile-label { font-size: 12.5px; color: var(--ink-2); margin: 0 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-value { font-size: 24px; font-weight: 620; letter-spacing: -0.02em; margin: 0; }
.tile-note { font-size: 11.5px; color: var(--muted); margin: 4px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- tool cards ---------- */
.tool-cards { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.tool-card { position: relative; }
.tool-card .tc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.tool-card .tc-name { display: flex; align-items: center; gap: 8px; font-weight: 620; font-size: 15px; }
.tool-card .tc-name .sw { width: 10px; height: 10px; }
.tool-card .tc-cost { font-size: 26px; font-weight: 630; letter-spacing: -0.02em; }
.tc-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.tc-facts div { min-width: 0; }
.tc-facts dt { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.tc-facts dd { margin: 0; font-size: 15px; font-weight: 580; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mix { display: grid; gap: 9px; }
.mix-row { display: grid; grid-template-columns: 104px 1fr 64px 44px; gap: 10px; align-items: center; font-size: 12.5px; }
.mix-row .lbl { color: var(--ink-2); }
.mix-row .val, .mix-row .pct { text-align: right; font-variant-numeric: tabular-nums; }
.mix-row .pct { color: var(--muted); }
.bar-track { height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; min-width: 2px; }
.tool-cards.one { grid-template-columns: 1fr; }

/* ---------- charts ---------- */
.chart { position: relative; height: 240px; }
.chart.short { height: 190px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover, .chart .hit.on { fill: var(--ink); fill-opacity: .045; }
.chart .empty { fill: var(--muted); font-size: 13px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.tip { position: fixed; z-index: 20; pointer-events: none; min-width: 170px; background: var(--surface); color: var(--ink); border-radius: 10px; box-shadow: 0 0 0 1px var(--ring), 0 12px 32px -8px rgba(0,0,0,.25); padding: 10px 12px; font-size: 12.5px; }
.tip h4 { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.tip .r { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 2px 0; }
.tip .r span { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tip .r b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip .r.total { border-top: 1px solid var(--grid); margin-top: 4px; padding-top: 6px; }

/* ---------- limits ---------- */
.limit { margin-bottom: 18px; }
.limit:last-child { margin-bottom: 0; }
.limit-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; gap: 12px; }
.limit-name { font-size: 13px; color: var(--ink-2); }
.limit-pct { font-size: 22px; font-weight: 620; letter-spacing: -0.02em; }
.limits-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; }
.limit-tool { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.limit-tool .tc-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.limit-tool .snap { font-size: 12px; color: var(--muted); }
.meter { height: 10px; border-radius: 5px; background: var(--codex-track); overflow: hidden; }
.meter > div { height: 100%; border-radius: 5px; background: var(--codex); min-width: 3px; transition: width .5s cubic-bezier(.2,.7,.2,1); }
.meter.claude { background: var(--claude-track); }
.meter.claude > div { background: var(--claude); }
.meter.warn > div { background: var(--warning); }
.meter.crit > div { background: var(--critical); }
.limit-foot { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: var(--muted); gap: 8px; }
.status { display: inline-flex; align-items: center; gap: 5px; }
.status svg { flex: none; }
.plan-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 560; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--ring); color: var(--ink-2); text-transform: capitalize; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: right; font-weight: 520; color: var(--muted); font-size: 11.5px; padding: 0 10px 10px; white-space: nowrap; border-bottom: 1px solid var(--grid); cursor: pointer; user-select: none; }
.tbl th:first-child, .tbl td:first-child { text-align: left; padding-left: 0; }
.tbl th:last-child, .tbl td:last-child { padding-right: 0; }
.tbl th[aria-sort] { color: var(--ink); }
.tbl th[aria-sort="descending"]::after { content: " ↓"; }
.tbl th[aria-sort="ascending"]::after { content: " ↑"; }
.tbl td { text-align: right; padding: 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl th.l, .tbl td.l { text-align: left; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.tbl .name { display: inline-flex; align-items: center; gap: 8px; font-weight: 520; }
.tbl .dim { color: var(--muted); }
.tbl .cost-cell { display: inline-flex; align-items: center; gap: 10px; justify-content: flex-end; }
.tbl .share { width: 72px; height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; display: inline-block; }
.tbl .share i { display: block; height: 100%; border-radius: 3px; }
.tbl .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--ink-2); }
.tbl .tag { font-size: 11px; color: var(--muted); margin-left: 6px; font-weight: 400; }
.more { margin-top: 12px; width: 100%; padding: 10px; border: 0; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); cursor: pointer; font-size: 13px; font-weight: 520; }
.more:hover { color: var(--ink); }

.foot { color: var(--muted); font-size: 12px; line-height: 1.6; padding: 4px 4px 0; }
.foot b { color: var(--ink-2); font-weight: 560; }

.loading .hero-num, .loading .tile-value { color: var(--grid); }

/* ---------- responsive ---------- */
@media (max-width: 920px) {
  .hero-panel { grid-template-columns: 1fr; }
  .tool-cards { grid-template-columns: 1fr; }
  .limits-grid { grid-template-columns: 1fr; gap: 24px; }
}
@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  .app { padding: 0 12px 40px; }
  .panel { padding: 16px; border-radius: 14px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tc-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .top { padding: 12px 0; }
  .brand-sub { display: none; }
  .seg button { padding: 6px 9px; }
  .mix-row { grid-template-columns: 92px 1fr 56px 38px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
