/* VeriSky Scoreboard — locked design (plan.md §8). Dark-only, tokens copied
   from the app's constants/theme.ts. Verify grammar: blue #4c8dff = forecast,
   green #3ddc97 = observed, amber #f4b740 = past run. Confidence tones (same
   as the app's scoreTone): ≥80 green, ≥55 amber, else red. Type: system-ui for
   UI, ui-monospace + tabular-nums for every number — no webfont payload. */

:root {
  color-scheme: dark;
  --bg: #05080f;
  --sheet: #0b101c;
  --surface: #101727;
  --surface-mid: #161f33;
  --surface-light: #1f2a40;
  --text: #f2f6fc;
  --text-2: #94a3b8;
  --text-3: #7c8fa3;
  --accent: #4c8dff;
  --observed: #3ddc97;
  --past-run: #f4b740;
  --grid: #334155;
  --tone-good: #3ddc97;
  --tone-ok: #f4b740;
  --tone-bad: #f4647d;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

main {
  max-width: 68rem;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

a { color: var(--accent); }
code { font-family: var(--mono); font-size: 0.92em; color: var(--text-2); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.error { color: #f4647d; }
.empty { color: var(--text-3); padding: 1rem 0; }

/* ── Top bar ─────────────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  max-width: 68rem;
  margin: 0 auto;
  padding: 0.9rem 1rem;
}

.brand { font-weight: 700; font-size: 1.05rem; letter-spacing: 0.01em; }
.brand-sub { color: var(--accent); font-weight: 500; }

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-2);
  text-decoration: none;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--surface-light);
  border-radius: 999px;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.nav-link svg { width: 18px; height: 11px; color: var(--accent); }
.nav-link:hover, .nav-link:focus-visible {
  color: var(--text);
  border-color: var(--accent);
  outline: none;
}

.city-controls { display: flex; gap: 0.5rem; align-items: center; }

#city-select, #city-search {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--surface-light);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  font: inherit;
}
#city-select:focus-visible, #city-search:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
#city-search { width: 9.5rem; }
#city-search::placeholder { color: var(--text-3); }

.search-wrap { position: relative; }
#search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 10;
  min-width: 15rem;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  background: var(--surface-mid);
  border: 1px solid var(--surface-light);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
#search-results li {
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}
#search-results li:hover { background: var(--surface-light); }
#search-results .geo-admin { color: var(--text-3); font-size: 0.85em; margin-left: 0.4rem; }
#search-results .geo-none { color: var(--text-3); cursor: default; }

.unit-toggle { display: inline-flex; }
.unit-toggle button {
  background: var(--surface);
  border: 1px solid var(--surface-light);
  color: var(--text-2);
  font: inherit;
  font-size: 0.82rem;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
}
.unit-toggle button:first-child { border-radius: 8px 0 0 8px; border-right: none; }
.unit-toggle button:last-child { border-radius: 0 8px 8px 0; }
.unit-toggle button.active { background: var(--surface-light); color: var(--text); }
.unit-toggle button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.window-wrap { margin-left: auto; text-align: right; }
.window-label { color: var(--text-3); font-size: 0.82rem; display: block; }
.status { font-size: 0.75rem; color: var(--text-3); }
.status-live { color: var(--observed); }
.status-refreshing, .status-loading { color: var(--past-run); }
.status-stale { color: var(--tone-bad); }

/* ── Cards ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--sheet);
  border: 1px solid var(--surface-mid);
  border-radius: 12px;
  padding: 0.9rem 1rem 1rem;
  margin-top: 1rem;
}
.card h2 {
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
}
.card-sub {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--text-3);
  margin-left: 0.35rem;
}

.two-up { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 880px) {
  .two-up { grid-template-columns: 1fr 1fr; }
}

.skeleton {
  height: 2rem;
  margin: 0.5rem 0;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-mid) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Standings table ─────────────────────────────────────────────────────── */

#standings { overflow-x: auto; }

.standings {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}
.standings th {
  text-align: left;
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--text-3);
  padding: 0.3rem 0.65rem 0.45rem 0;
  border-bottom: 1px solid var(--surface-mid);
}
.standings td { padding: 0.55rem 0.65rem 0.55rem 0; }
tr.standing { cursor: pointer; }
tr.standing:hover td { background: rgba(76, 141, 255, 0.05); }
tr.standing[aria-expanded="true"] td { background: var(--surface); }
tr.standing:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
tr.standing.standing-static { cursor: default; }
tr.standing.standing-static:hover td { background: transparent; }
tr.standing + .lab-row td { padding: 0; }

.c-rank { width: 1.6rem; color: var(--text-2); }
.c-move { width: 1.8rem; }
.move-up { color: var(--tone-good); }
.move-down { color: var(--tone-bad); }
.move-flat { color: var(--text-3); }

.c-model .mprov { color: var(--text-3); font-size: 0.82em; margin-left: 0.25rem; }
.mdot {
  display: inline-block;
  width: 0.62em;
  height: 0.62em;
  border-radius: 50%;
  margin-right: 0.35em;
  vertical-align: baseline;
}
.mlabel { font-weight: 600; }

.c-skill { min-width: 9rem; }
.skill-num { font-weight: 700; font-size: 1.02rem; margin-right: 0.55rem; }
.tone-good { color: var(--tone-good); }
.tone-ok { color: var(--tone-ok); }
.tone-bad { color: var(--tone-bad); }
.tone-none { color: var(--text-3); }
.bar {
  display: inline-block;
  width: 5.2rem;
  height: 5px;
  border-radius: 3px;
  background: var(--surface-mid);
  vertical-align: 0.12em;
  overflow: hidden;
}
.bar-fill { display: block; height: 100%; border-radius: 3px; }
.tone-bg-good { background: var(--tone-good); }
.tone-bg-ok { background: var(--tone-ok); }
.tone-bg-bad { background: var(--tone-bad); }
.tone-bg-none { background: var(--surface-light); }

.c-metric { text-align: right; }
th.c-metric, th.c-record { text-align: right; }
.c-record { text-align: right; color: var(--text-2); }

.c-form { padding-left: 0.9rem; }
.fdot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 3px;
}
.fdot-hit { background: var(--tone-good); }
.fdot-miss { background: none; box-shadow: inset 0 0 0 1.5px var(--surface-light); }
.fdot-na { background: none; box-shadow: inset 0 0 0 1px var(--surface-mid); opacity: 0.6; }

.foot-note { color: var(--text-3); font-size: 0.78rem; margin: 0.5rem 0 0; }
.retry {
  background: var(--surface-mid);
  border: 1px solid var(--surface-light);
  color: var(--text);
  border-radius: 6px;
  padding: 0.2rem 0.7rem;
  margin-left: 0.5rem;
  cursor: pointer;
  font: inherit;
}

/* ── Lab panel (row expand) ──────────────────────────────────────────────── */

.lab {
  background: var(--surface);
  border-radius: 10px;
  margin: 0.15rem 0 0.7rem;
  padding: 0.75rem 0.85rem 0.85rem;
  cursor: default;
  white-space: normal;
}
.lab-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.lab-title { font-size: 0.82rem; color: var(--text-2); }

.lead-toggle button, .metric-tabs button {
  background: var(--surface-mid);
  border: 1px solid transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 0.78rem;
  padding: 0.18rem 0.6rem;
  cursor: pointer;
}
.lead-toggle button:first-child, .metric-tabs button:first-child { border-radius: 6px 0 0 6px; }
.lead-toggle button:last-child, .metric-tabs button:last-child { border-radius: 0 6px 6px 0; }
.lead-toggle button.active, .metric-tabs button.active {
  background: var(--surface-light);
  color: var(--text);
  border-color: var(--grid);
}

.lab-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 880px) {
  .lab-grid { grid-template-columns: 1fr 300px; }
}
.lab svg, .card-body svg { display: block; width: 100%; height: auto; }

.chart-caption { color: var(--text-3); font-size: 0.76rem; margin: 0.35rem 0 0; }
.key {
  display: inline-block;
  width: 12px;
  height: 3px;
  border-radius: 2px;
  vertical-align: 0.18em;
  margin: 0 0.3em 0 0.6em;
}
.key:first-child { margin-left: 0; }
.key-obs { background: var(--observed); }
.key-ghost { background: var(--past-run); }
.key-median {
  background: repeating-linear-gradient(90deg, var(--text-3) 0 3px, transparent 3px 6px);
}

.habits { margin: 0.6rem 0 0; padding-left: 1.1rem; color: var(--text-2); font-size: 0.82rem; }
.habits li { margin: 0.2rem 0; }
.habits-none { color: var(--text-3); font-size: 0.8rem; margin: 0.6rem 0 0; }

/* ── Receipt ─────────────────────────────────────────────────────────────── */

.receipt-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.calls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 1.2rem;
  margin-top: 0.6rem;
}
@media (max-width: 560px) { .calls-grid { grid-template-columns: 1fr; } }
.call {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  font-size: 0.85rem;
  padding: 0.18rem 0;
}
.call-label { font-weight: 600; min-width: 2.6rem; }
.call .num { margin-left: auto; }
.call-delta { color: var(--text-3); min-width: 3.2rem; text-align: right; }
.call-verdict { width: 1.1rem; text-align: center; }
.call-win .call-verdict { color: var(--tone-good); }
.call-loss .call-verdict { color: var(--tone-bad); }
.call-dim { opacity: 0.65; }
.call-star { color: var(--tone-good); font-size: 0.8em; }

/* ── Lead-time card ──────────────────────────────────────────────────────── */

.lead-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.legend { display: flex; gap: 0.7rem; flex-wrap: wrap; }
.legend-item { color: var(--text-2); font-size: 0.78rem; }

/* ── Other-calls strip ───────────────────────────────────────────────────── */

.strip {
  margin-top: 1rem;
  padding: 0.55rem 1rem;
  background: var(--surface);
  border-radius: 10px;
  font-size: 0.82rem;
  color: var(--text-2);
}
.strip:empty, .strip div:empty { display: none; }
.call-date {
  color: var(--text-3);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  margin-right: 0.5rem;
}
.call-kind { color: var(--text-3); }
.call-sep { margin: 0 0.55rem; color: var(--surface-light); }
.call-bit b { font-weight: 600; }

/* ── Methodology footer ──────────────────────────────────────────────────── */

.methodology {
  margin-top: 1.6rem;
  color: var(--text-2);
  font-size: 0.85rem;
}
.method-lede { margin: 0 0 0.5rem; }
.methodology summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 500;
}
.method-body {
  margin-top: 0.5rem;
  padding: 0.8rem 1rem;
  background: var(--sheet);
  border: 1px solid var(--surface-mid);
  border-radius: 10px;
}
.method-body p { margin: 0.5rem 0; }
.method-body ul { margin: 0.4rem 0; padding-left: 1.2rem; }
.method-body li { margin: 0.3rem 0; }
.colophon { color: var(--text-3); font-size: 0.78rem; margin-top: 1rem; }

/* ── App-store badges ────────────────────────────────────────────────────── */

.app-cta { margin-top: 1.6rem; text-align: center; }
.app-cta-label {
  display: block;
  color: var(--text-3);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.55rem;
}
.app-cta-free {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: rgba(61, 220, 151, 0.14);
  color: var(--tone-good);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  vertical-align: 0.05em;
}
.app-badges { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.app-badge {
  display: inline-block;
  height: 46px;
  border-radius: 8px;
  transition: opacity 0.15s;
}
.app-badge svg { display: block; height: 100%; width: auto; }
.app-badge:hover { opacity: 0.82; }
.app-badge:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
