:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #fcfcfb;
  --border: #e4e2dc;
  --grid: #ebe9e4;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --accent: #2a78d6;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --accent-track: #cde2fb;
  --good: #008300;
  --bad: #c0392b;
  --btn-text: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --border: #2c2c2a;
    --grid: #2a2a28;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #8f8e86;
    --accent: #3987e5;
    --accent-wash: rgba(57, 135, 229, 0.14);
    --accent-track: #184f95;
    --good: #4cb34c;
    --bad: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --border: #2c2c2a;
  --grid: #2a2a28;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --muted: #8f8e86;
  --accent: #3987e5;
  --accent-wash: rgba(57, 135, 229, 0.14);
  --accent-track: #184f95;
  --good: #4cb34c;
  --bad: #e66767;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; font-weight: 600; }
h2 { font-size: 15px; margin-bottom: 12px; }
.muted { color: var(--muted); font-size: 13px; }
.label { color: var(--text-2); font-size: 13px; }
.error { color: var(--bad); min-height: 1.2em; font-size: 13px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

button {
  font: inherit;
  border: 0;
  border-radius: 8px;
  padding: 8px 16px;
  background: var(--accent);
  color: var(--btn-text);
  cursor: pointer;
}
button:disabled { opacity: .6; cursor: default; }
.link-button { background: none; color: var(--text-2); padding: 4px 0; }
input {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; display: grid; gap: 10px; }
.login-card h1 { font-size: 20px; margin-bottom: 8px; }

/* layout */
.app { max-width: 1080px; margin: 0 auto; padding: 16px 16px 48px; display: grid; gap: 16px; }
.topbar { display: flex; justify-content: space-between; align-items: center; }
.brand { font-weight: 600; color: var(--text-2); }

.hero { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; }
.score-value {
  font-size: clamp(56px, 12vw, 96px);
  font-weight: 650;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin: 6px 0 8px;
}
.focus-form { display: grid; gap: 8px; min-width: 0; }
.focus-row { display: flex; gap: 8px; align-items: center; }
.focus-row input { width: 88px; font-size: 18px; font-variant-numeric: tabular-nums; }
.unit { color: var(--text-2); }
.quick { display: flex; gap: 6px; }
.quick button, .seg button {
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border); padding: 4px 10px; font-size: 13px;
}
.seg button.on { color: var(--text); border-color: var(--text-2); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.tile { display: grid; gap: 6px; align-content: start; }
.tile-value { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.meter { height: 8px; border-radius: 4px; background: var(--accent-track); overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); border-radius: 4px; width: 0; transition: width .4s; }

.chart-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.chart-head h2 { margin: 0; }
.seg { display: flex; gap: 6px; }
.chart { position: relative; height: 240px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent-wash); }
.chart .cross { stroke: var(--text-2); stroke-width: 1; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .end-label { fill: var(--text); font-size: 12px; font-weight: 600; }
.tooltip {
  position: absolute; pointer-events: none; transform: translate(-50%, -110%);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.tooltip b { font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); display: grid; place-items: center; height: 100%; font-size: 13px; }

.lists { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rows li {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px;
  padding: 8px 0; border-bottom: 1px solid var(--grid);
}
.rows li:last-child { border-bottom: 0; }
.rows .what { font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.rows .when { color: var(--muted); font-size: 12px; grid-column: 1; }
.rows .pts { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; grid-row: 1 / span 2; grid-column: 2; align-self: center; }
.pts.pos { color: var(--good); }
.pts.neg { color: var(--bad); }
.pts.zero { color: var(--muted); font-weight: 400; }
.rows .undo { background: none; color: var(--accent); padding: 0; font-size: 12px; justify-self: start; }

@media (max-width: 820px) {
  .tiles, .lists { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; }
}
