:root {
  color-scheme: light;
  --plane: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --wash: rgba(11, 11, 11, 0.04);
  --s-actual: #2a78d6;
  --s-plan: #eb6834;
  --s-target: #1baf7a;
  --track-plan: #fbd9cc;
  --track-target: #c9efe0;
  --good: #0ca30c;
  --bad: #d03b3b;
  --good-text: #006300;
  --bad-text: #b02a2a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --wash: rgba(255, 255, 255, 0.05);
    --s-actual: #3987e5;
    --s-plan: #d95926;
    --s-target: #199e70;
    --track-plan: #4a1f0f;
    --track-target: #0c3d2c;
    --good-text: #0ca30c;
    --bad-text: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --wash: rgba(255, 255, 255, 0.05);
  --s-actual: #3987e5;
  --s-plan: #d95926;
  --s-target: #199e70;
  --track-plan: #4a1f0f;
  --track-target: #0c3d2c;
  --good-text: #0ca30c;
  --bad-text: #e66767;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.page { max-width: 1120px; margin: 0 auto; padding: 24px 16px 48px; display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
h1 { font-size: 20px; margin: 0; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 2px; font-weight: 650; }
p { margin: 0; }
.muted { color: var(--muted); }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.badge {
  font-size: 12px; color: var(--ink-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 10px; white-space: nowrap;
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px 20px;
}
.label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: -4px; }

/* hero */
.hero { display: flex; flex-wrap: wrap; gap: 16px 40px; align-items: center; }
.hero-value { font-size: 52px; line-height: 1.1; font-weight: 650; letter-spacing: -0.02em; }
.split { color: var(--ink-2); font-size: 13px; margin-top: 4px; display: flex; gap: 14px; flex-wrap: wrap; }
.split b { color: var(--ink); font-weight: 600; }
.verdict { flex: 1 1 320px; display: grid; gap: 8px; justify-items: start; }
.verdict-text { font-size: 17px; line-height: 1.4; text-wrap: pretty; }
.verdict-text b { font-weight: 650; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; padding: 3px 10px 3px 8px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--wash);
  white-space: nowrap;
}
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.chip.good::before { background: var(--good); }
.chip.bad::before { background: var(--bad); }

/* tiles */
.tiles { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.tile { display: grid; gap: 6px; align-content: start; }
.tile .value { font-size: 28px; font-weight: 650; line-height: 1.15; letter-spacing: -0.01em; }
.tile .value small { font-size: 14px; font-weight: 600; margin-left: 6px; }
.tile .sub { font-size: 12.5px; color: var(--ink-2); }
.tile .sub b { color: var(--ink); font-weight: 600; white-space: nowrap; }
.up { color: var(--good-text); }
.down { color: var(--bad-text); }

.meter { position: relative; height: 10px; border-radius: 5px; margin: 8px 0 16px; }
.meter-fill { height: 100%; border-radius: 5px; min-width: 0; }
.meter.plan { background: var(--track-plan); }
.meter.plan .meter-fill { background: var(--s-plan); }
.meter.target { background: var(--track-target); }
.meter.target .meter-fill { background: var(--s-target); }
.key { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.meter-mark { position: absolute; top: -4px; width: 2px; height: 18px; background: var(--ink); border-radius: 1px; transform: translateX(-1px); }
.meter-mark span {
  position: absolute; top: 19px; left: 50%; transform: translateX(-50%);
  font-size: 10.5px; color: var(--muted); white-space: nowrap;
}

/* chart */
.chart-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.chart-head p { font-size: 12.5px; max-width: 640px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button {
  font: inherit; font-size: 12.5px; color: var(--ink-2); background: transparent;
  border: 0; padding: 5px 12px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--wash); color: var(--ink); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 14px 0 6px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 18px; height: 0; border-top: 2px solid; display: inline-block; }
.legend i.dash { border-top-style: dashed; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; touch-action: pan-y; }
.chart text { font: 11px system-ui, -apple-system, "Segoe UI", sans-serif; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart text.end { fill: var(--ink-2); }
.chart text.now { fill: var(--ink); font-size: 12.5px; font-weight: 650; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.tip {
  position: absolute; top: 8px; pointer-events: none; min-width: 190px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18); padding: 8px 10px; font-size: 12.5px;
}
.tip-date { font-weight: 600; margin-bottom: 4px; }
.tip-row { display: flex; justify-content: space-between; gap: 16px; color: var(--ink-2); }
.tip-row span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.tip-row i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.tip-row b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-sep { border-top: 1px solid var(--border); margin: 5px 0; }

/* table */
.table-wrap { overflow-x: auto; margin-top: 10px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; white-space: nowrap; }
th, td { padding: 9px 8px; text-align: right; border-bottom: 1px solid var(--grid); }
th { font-size: 12px; font-weight: 500; color: var(--muted); }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
tr:last-child td { border-bottom: 0; }
td.month { font-weight: 600; }
tr.groups th { text-align: left; border-bottom: 0; padding-bottom: 0; color: var(--ink-2); font-weight: 600; }
.grp { border-left: 1px solid var(--grid); }
.chart-head p b { color: var(--ink-2); font-weight: 600; }
tr.current td { background: var(--wash); }
tr.current td:first-child { padding-left: 10px; border-radius: 8px 0 0 8px; }
tr.current td:last-child { padding-right: 10px; border-radius: 0 8px 8px 0; }

@media (max-width: 560px) {
  .hero-value { font-size: 42px; }
  .card { padding: 16px; }

  /* months table becomes one card per month so goal statuses stay on screen */
  table { white-space: normal; }
  thead { display: none; }
  tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; padding: 12px 0; border-bottom: 1px solid var(--grid); }
  tbody tr:last-child { border-bottom: 0; }
  tbody td, tr.current td:first-child, tr.current td:last-child { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0; border: 0; border-radius: 0; background: none; }
  tbody td::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
  tbody td.month, tbody td.goal { grid-column: 1 / -1; }
  tbody td.month { font-size: 14px; }
  tbody td.month::before { content: none; }
  tbody tr.current td { background: none; }
  tbody .grp { border-left: 0; }
  tr.current { background: var(--wash); border-radius: 8px; padding: 12px 10px; margin: 0 -10px; }
}
