:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #fcfcfb;
  --surface-2: #efeee9;
  --line: #e2e0d9;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #7a7974;
  --hero-bg: #111110;
  --hero-ink: #f6f5f0;
  --hero-ink-2: #b9b8b0;
  --accent: #fab219;
  --good: #0ca30c;
  --good-ink: #067a06;
  --good-bg: #e3f5e3;
  --bad: #d03b3b;
  --bad-ink: #b42828;
  --bad-bg: #fbe5e5;
  --na-bg: #ecebe6;
  --plan: #8d8c86;
  --p1: #2a78d6;
  --p2: #eb6834;
  --p3: #1baf7a;
  --p4: #eda100;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Unbounded", "Inter", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --line: #2e2e2b;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --ink-3: #8e8d86;
    --hero-bg: #0a0a09;
    --good-ink: #4fd04f;
    --good-bg: #173117;
    --bad-ink: #f07a7a;
    --bad-bg: #3a1c1c;
    --na-bg: #2a2a27;
    --plan: #8e8d86;
    --p1: #3987e5;
    --p2: #d95926;
    --p3: #199e70;
    --p4: #c98500;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --surface-2: #232321;
  --line: #2e2e2b;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --ink-3: #8e8d86;
  --hero-bg: #0a0a09;
  --good-ink: #4fd04f;
  --good-bg: #173117;
  --bad-ink: #f07a7a;
  --bad-bg: #3a1c1c;
  --na-bg: #2a2a27;
  --plan: #8e8d86;
  --p1: #3987e5;
  --p2: #d95926;
  --p3: #199e70;
  --p4: #c98500;
  --shadow: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
h2 { font-family: var(--font-display); font-weight: 800; font-size: 22px; letter-spacing: -.01em; margin-bottom: 6px; }
h3 { font-size: 15px; font-weight: 700; }
code { font-size: .9em; background: rgba(127,127,127,.15); padding: 1px 5px; border-radius: 5px; }
.hint { color: var(--ink-3); font-size: 13px; margin: 2px 0 14px; }
.num { font-variant-numeric: tabular-nums; }

/* hero */
.hero { background: var(--hero-bg); color: var(--hero-ink); padding: 28px 0 22px; }
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.eyebrow { margin: 0 0 6px; color: var(--accent); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
h1 { font-family: var(--font-display); font-weight: 800; font-size: clamp(26px, 7vw, 44px); letter-spacing: -.02em; }
.hero-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 14px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06);
  color: var(--hero-ink); font: 600 14px var(--font); cursor: pointer;
}
.btn:hover { background: rgba(255,255,255,.12); }
.btn:focus-visible, .seg button:focus-visible, .grid-table button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-icon { width: 38px; padding: 0; justify-content: center; }
.btn.loading svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 480px) { .btn span { display: none; } .btn { width: 38px; padding: 0; justify-content: center; } }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 22px; }
@media (max-width: 720px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.09); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.kpi .k-label { font-size: 12px; color: var(--hero-ink-2); }
.kpi .k-value { font-family: var(--font-display); font-weight: 600; font-size: clamp(18px, 4.6vw, 26px); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .k-sub { font-size: 12px; color: var(--hero-ink-2); margin-top: 2px; }
.progress-track { height: 4px; border-radius: 4px; background: rgba(255,255,255,.12); margin-top: 8px; overflow: hidden; }
.progress-track span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.updated { margin: 12px 0 0; font-size: 12px; color: var(--hero-ink-2); min-height: 18px; }

.banner { background: #fff4cc; color: #5c4400; padding: 10px 16px; font-size: 14px; text-align: center; }
.banner-error { background: var(--bad-bg); color: var(--bad-ink); }

/* tabs */
.tabs { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.tabs-inner { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-top: 8px; padding-bottom: 8px; }
.tabs-inner::-webkit-scrollbar { display: none; }
.tabs a { flex-shrink: 0; padding: 6px 12px; border-radius: 999px; color: var(--ink-2); text-decoration: none; font-size: 14px; font-weight: 600; }
.tabs a:hover { background: var(--surface-2); color: var(--ink); }

.section { padding: 28px 0 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; min-width: 0; }
.card h3 + .hint { margin-bottom: 8px; }
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* leaders */
.leaders { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 640px) { .leaders { grid-template-columns: 1fr; } }
.leader { display: grid; grid-template-columns: 40px 1fr; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.leader::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--pc); }
.rank { font-family: var(--font-display); font-weight: 800; font-size: 26px; color: var(--ink-3); line-height: 1; padding-top: 2px; }
.leader.first .rank { color: var(--accent); }
.leader-name { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.leader-name strong { font-size: 17px; }
.leader-paid { font-weight: 700; font-size: 14px; white-space: nowrap; }
.leader-paid.zero { color: var(--good-ink); }
.leader-paid.some { color: var(--bad-ink); }
.leader-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.stat .s-label { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.stat .s-value { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.stat .s-sub { font-size: 12px; color: var(--ink-3); }

/* grid */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.grid-table { border-collapse: separate; border-spacing: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; min-width: 100%; }
.grid-table th { font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 4px 2px; text-align: center; white-space: nowrap; }
.grid-table th.wk-test { color: var(--ink); }
.grid-table th.wk-now { color: var(--accent); }
.grid-table th.name { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; padding-right: 8px; color: var(--ink); font-size: 14px; }
.grid-table th.name i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--pc); margin-right: 6px; }
.grid-table td { padding: 0; }
.grid-table td.month-gap { width: 6px; }
.wcell { display: flex; flex-direction: column; gap: 2px; width: 44px; border: 0; padding: 0; background: none; cursor: pointer; font: inherit; }
.wcell.now { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 7px; }
.mini { display: flex; align-items: center; justify-content: center; gap: 3px; height: 22px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.mini.ok { background: var(--good-bg); color: var(--good-ink); }
.mini.bad { background: var(--bad-bg); color: var(--bad-ink); }
.mini.na { background: var(--na-bg); color: var(--ink-3); }
.pill { display: inline-block; min-width: 20px; padding: 0 5px; border-radius: 5px; font-weight: 700; text-align: center; font-size: 12px; }
.pill.ok { background: var(--good-bg); color: var(--good-ink); }
.pill.bad { background: var(--bad-bg); color: var(--bad-ink); }
.pill.na { background: var(--na-bg); color: var(--ink-3); }
.cell-detail { margin-top: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; font-size: 14px; }
.cell-detail h4 { margin: 0 0 8px; font-size: 15px; }
.kv { display: grid; grid-template-columns: auto auto auto; gap: 4px 16px; align-items: center; justify-content: start; }
.kv .lbl { color: var(--ink-3); }

/* charts */
.chart { position: relative; width: 100%; min-height: 220px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .zero { stroke: var(--ink-3); stroke-width: 1; }
.chart .crosshair { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dlabel { font-size: 11px; font-weight: 600; fill: var(--ink-2); font-family: var(--font); }
.chart .empty { fill: var(--ink-3); font-size: 13px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; background: var(--c); display: inline-block; }
.legend i.dash { background: repeating-linear-gradient(90deg, var(--c) 0 4px, transparent 4px 7px); }
.legend i.sq { width: 10px; height: 10px; border-radius: 3px; }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: var(--surface); border-radius: 10px; padding: 8px 10px; font-size: 12px; line-height: 1.45; box-shadow: 0 6px 24px rgba(0,0,0,.2); max-width: 240px; }
.tooltip b { font-weight: 700; }
.tooltip .tt-row { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.tooltip .tt-row i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.tooltip .tt-row span:last-child { margin-left: auto; padding-left: 10px; font-variant-numeric: tabular-nums; font-weight: 600; }

/* person */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 999px; margin-bottom: 14px; max-width: 100%; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 999px; font: 600 14px var(--font); color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button i { width: 8px; height: 8px; border-radius: 50%; background: var(--pc); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.person-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.person-grid > .card { margin-bottom: 0; }
.person-grid .wide { grid-column: 1 / -1; }
@media (max-width: 760px) { .person-grid { grid-template-columns: 1fr; } }
.strength { display: grid; gap: 14px; }
.str-row .str-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.str-row .str-head b { font-variant-numeric: tabular-nums; }
.bar-track { position: relative; height: 10px; border-radius: 6px; background: var(--surface-2); margin-top: 6px; }
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; background: var(--pc); }
.bar-target { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); border-radius: 1px; }
.str-row .str-foot { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--surface); }
.data-table th, .data-table td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table thead th { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.data-table tfoot td { font-weight: 700; border-bottom: 0; }
.miss { color: var(--bad-ink); font-weight: 700; }
.hit { color: var(--good-ink); font-weight: 600; }
.muted { color: var(--ink-3); }
.status-tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status-tag.ok { background: var(--good-bg); color: var(--good-ink); }
.status-tag.bad { background: var(--bad-bg); color: var(--bad-ink); }
.status-tag.na { background: var(--na-bg); color: var(--ink-3); }

/* pot */
.pot-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
@media (max-width: 760px) { .pot-tiles { grid-template-columns: repeat(2, 1fr); } }
.pot-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.pot-tile.total { background: var(--hero-bg); color: var(--hero-ink); border-color: transparent; }
.pot-tile .t-label { font-size: 12px; color: var(--ink-3); }
.pot-tile.total .t-label, .pot-tile.total .t-sub { color: var(--hero-ink-2); }
.pot-tile .t-value { font-family: var(--font-display); font-weight: 600; font-size: clamp(18px, 4.5vw, 24px); margin: 2px 0; white-space: nowrap; }
.pot-tile .t-sub { font-size: 12px; color: var(--ink-3); }

/* rules */
.rules { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 18px 14px; }
.rules h3 { margin: 16px 0 6px; }
.rules p, .rules li { color: var(--ink-2); font-size: 14px; }
.rules ul { padding-left: 18px; margin: 6px 0; }
.rules .data-table { font-size: 13px; }
.rules .data-table td, .rules .data-table th { white-space: normal; text-align: left; }

.footer { color: var(--ink-3); font-size: 12px; padding-top: 24px; padding-bottom: 32px; }
.rules .data-table { min-width: 560px; }
