/* Sportcoach: één leeskolom op de telefoon, twee kolommen vanaf tabletbreedte.
   Kleuren: blauw = data (20-kg-schijf), geel = PR (15-kg-schijf); statuskleuren alleen voor het stoplicht. */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --sunk: #e9edf3;
  --ink: #141922;
  --muted: #586273;
  --line: #d9dee6;
  --grid: #e8ebf0;
  --axis: #b9c0cb;
  --accent: #1d4ed8;
  --accent-soft: #9db4ee;
  --accent-wash: rgba(29, 78, 216, .10);
  --accent-ink: #ffffff;
  --pr: #f2b705;
  --pr-ink: #3a2c00;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --good-text: #006300;
  --warn-text: #8a5300;
  --crit-text: #a32020;
  --f-display: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --f-body: "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --surface: #171b23; --sunk: #1e232d; --ink: #e8ebf1; --muted: #9aa4b5;
    --line: #2a313d; --grid: #232934; --axis: #3a4250;
    --accent: #7d9cff; --accent-soft: #3a4d86; --accent-wash: rgba(125, 156, 255, .12); --accent-ink: #0b1020;
    --pr: #f5c84a; --pr-ink: #2a2000;
    --good-text: #4cc38a; --warn-text: #f5c84a; --crit-text: #ff8a8a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1218; --surface: #171b23; --sunk: #1e232d; --ink: #e8ebf1; --muted: #9aa4b5;
  --line: #2a313d; --grid: #232934; --axis: #3a4250;
  --accent: #7d9cff; --accent-soft: #3a4d86; --accent-wash: rgba(125, 156, 255, .12); --accent-ink: #0b1020;
  --pr: #f5c84a; --pr-ink: #2a2000;
  --good-text: #4cc38a; --warn-text: #f5c84a; --crit-text: #ff8a8a;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--f-body);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
h1, h2, h3 { font-family: var(--f-display); font-weight: 700; margin: 0; line-height: 1.05; letter-spacing: .01em; text-wrap: balance; }
h2 { font-size: 30px; text-transform: uppercase; }
h3 { font-size: 20px; font-weight: 600; }
p { margin: 0; }
button { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono, .num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- topbalk ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--f-display); font-weight: 700; font-size: 24px; text-transform: uppercase; letter-spacing: .02em; }
.plates { display: flex; gap: 3px; align-items: center; }
.plates i { display: block; width: 6px; border-radius: 2px; }
.plates i:nth-child(1) { height: 22px; background: var(--accent); }
.plates i:nth-child(2) { height: 18px; background: var(--pr); }
.plates i:nth-child(3) { height: 14px; background: var(--good); }
.plates b { display: block; height: 3px; width: 26px; background: var(--muted); border-radius: 2px; }
/* tabs tussen Training en Voeding */
.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.tabs a { display: inline-flex; align-items: center; min-height: 34px; padding: 0 14px; color: var(--ink); text-decoration: none; font-size: 14px; }
.tabs a + a { border-left: 1px solid var(--line); }
.tabs a[aria-current="page"] { background: var(--ink); color: var(--surface); font-weight: 600; }
@media (max-width: 420px) { .brand { font-size: 20px; gap: 8px; } .plates i:nth-child(1) { height: 18px; } .plates i:nth-child(2) { height: 15px; } .plates i:nth-child(3) { height: 12px; } .plates b { width: 18px; } .tabs a { padding: 0 11px; } }
.controls { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.daynav { display: flex; align-items: center; gap: 4px; }
.daynav button, .seg button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  min-height: 34px; padding: 0 10px; cursor: pointer;
}
.daynav button:disabled { opacity: .4; cursor: default; }
.daynav #prev, .daynav #next { font-size: 20px; line-height: 1; width: 36px; padding: 0; }
.daynav .ghost { background: transparent; }
.day { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 9.5em; min-height: 34px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-weight: 600; cursor: pointer; }
.day input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.day:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; border-radius: 0; font-size: 13px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--surface); font-weight: 600; }

/* ---------- inhoud ---------- */
main {
  max-width: 1160px; margin: 0 auto;
  padding: 20px max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left));
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 40px; transition: opacity .15s;
}
main.loading { opacity: .55; }
section { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; }
.sec-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; border-top: 2px solid var(--ink); padding-top: 10px; }
.sub { color: var(--muted); font-size: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-content: start; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; }
.card-head .src { font-size: 12.5px; color: var(--muted); }
.two { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 820px) { .two { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.error { background: var(--surface); border: 1px solid var(--critical); border-left-width: 4px; border-radius: 8px; padding: 12px 14px; }
.empty { color: var(--muted); font-size: 14px; }

/* vandaag */
.today { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 820px) { .today { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); } .today .quarter { grid-column: 1 / -1; } }
.status { display: flex; align-items: center; gap: 10px; }
.status .light { width: 16px; height: 16px; border-radius: 50%; flex: none; box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--line); }
.status[data-level="groen"] .light { background: var(--good); }
.status[data-level="oranje"] .light { background: var(--warning); }
.status[data-level="rood"] .light { background: var(--critical); }
.status[data-level="onbekend"] .light { background: var(--surface); box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--line), inset 0 0 0 2px var(--muted); }
.status .lvl { font-family: var(--f-display); font-weight: 700; font-size: 28px; text-transform: uppercase; line-height: 1; }
.status .pts { font-size: 13px; color: var(--muted); }
.advice { font-size: 16px; font-weight: 500; }
.reasons { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.eyebrow { font-family: var(--f-mono); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.weekstrip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.wd { display: grid; justify-items: center; gap: 3px; padding: 6px 0 5px; border-radius: 8px; background: var(--sunk); font-size: 12px; color: var(--muted); min-width: 0; }
.wd b { font-weight: 600; color: var(--ink); font-size: 13px; }
.wd .mk { height: 18px; display: flex; gap: 2px; align-items: center; justify-content: center; font-size: 11px; }
.wd .k { width: 14px; height: 14px; border-radius: 4px; }
.wd .k.done { background: var(--accent); }
.wd .k.plan { background: var(--accent-soft); }
.wd .k.missed { background: transparent; box-shadow: inset 0 0 0 1.5px var(--warn-text); }
.wd .r { width: 6px; height: 6px; border-radius: 50%; background: var(--ink); }
.wd.is-today { background: var(--surface); box-shadow: inset 0 0 0 2px var(--accent); }
.wd.is-today b { color: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--muted); align-items: center; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .sw.done { background: var(--accent); }
.legend .sw.plan { background: var(--accent-soft); }
.legend .sw.missed { box-shadow: inset 0 0 0 1.5px var(--warn-text); }
.legend .sw.run { width: 7px; height: 7px; border-radius: 50%; background: var(--ink); }
.legend .sw.line { width: 14px; height: 2px; border-radius: 1px; background: var(--accent); vertical-align: 3px; }
.legend .sw.band { background: var(--accent-wash); box-shadow: inset 0 0 0 1px var(--accent-soft); }
.legend .sw.target { width: 14px; height: 0; border-top: 1.5px dashed var(--ink); border-radius: 0; vertical-align: 3px; }

.plan { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.plan-title { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.plan-title h3 { font-size: 22px; }
.callout { border-left: 3px solid var(--warning); padding: 4px 0 4px 10px; font-size: 14px; }
.callout.info { border-left-color: var(--accent); }
.prchip { display: inline-block; background: var(--pr); color: var(--pr-ink); font-family: var(--f-mono); font-size: 10.5px; font-weight: 500; padding: 1px 6px; border-radius: 3px; letter-spacing: .03em; white-space: nowrap; }
.tag { display: inline-block; font-family: var(--f-mono); font-size: 11px; letter-spacing: .03em; padding: 1px 6px; border-radius: 4px; border: 1px solid currentColor; white-space: nowrap; }
.tag.good { color: var(--good-text); }
.tag.warn { color: var(--warn-text); }
.tag.crit { color: var(--crit-text); }

/* kwartaal */
.goals { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .goals { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.goal { display: grid; gap: 6px; }
.goal-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.goal-top .v { font-weight: 600; font-size: 22px; }
.goal-top .v small { font-size: 14px; color: var(--muted); font-weight: 500; }
.meter { position: relative; height: 10px; border-radius: 5px; background: var(--sunk); overflow: hidden; display: flex; gap: 2px; }
.meter span { display: block; height: 100%; }
.meter .done { background: var(--accent); border-radius: 5px 0 0 5px; }
.meter .plan { background: var(--accent-soft); }
.meter .done:last-child, .meter .plan:last-child { border-radius: 5px; }
.goal p { font-size: 13.5px; color: var(--muted); }

/* tegels */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 820px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 2px; align-content: start; min-width: 0; }
.tile .k { font-size: 13px; color: var(--muted); }
.tile .v { font-size: 30px; font-weight: 600; line-height: 1.1; }
.tile .v small { font-size: 15px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.tile .d { font-size: 12.5px; color: var(--muted); }
.tile .d .up-bad, .tile .d .down-bad { color: var(--warn-text); }
.tile .d .up-good, .tile .d .down-good { color: var(--good-text); }

/* grafieken */
.multiples { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) { .multiples { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chart-head .read { font-size: 13px; color: var(--muted); text-align: right; }
.chart-head .read b { color: var(--ink); font-weight: 600; font-size: 15px; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.chart .grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .base { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .ax { fill: var(--muted); font: 10.5px var(--f-mono); }
.chart .lbl { fill: var(--ink); font: 500 11px var(--f-body); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .band { fill: var(--accent-wash); }
.chart .band-edge { fill: none; stroke: var(--accent-soft); stroke-width: 1; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .cross { stroke: var(--muted); stroke-width: 1; shape-rendering: crispEdges; }
.chart .bar { fill: var(--accent); }
.chart .bar.plan { fill: var(--accent-soft); }
.chart .target { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .col:hover .bar, .chart .col:focus .bar { filter: brightness(1.12); }
.chart .col .hit { fill: transparent; }
.chart .col:hover .hit, .chart .col:focus .hit { fill: var(--sunk); fill-opacity: .55; }
.chart .col:focus { outline: none; }
.chart .zero { stroke: var(--axis); stroke-width: 2; stroke-linecap: round; }
details.table { font-size: 13px; }
details.table summary { cursor: pointer; color: var(--muted); font-size: 12.5px; width: max-content; }
details.table .scroll { max-height: 260px; overflow: auto; margin-top: 8px; }

/* tabellen */
.tbl { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding: 0 10px 6px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.n, th.n { font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-size: 13px; }
@media (min-width: 640px) { td.n { white-space: nowrap; } }
th.n { font-family: var(--f-body); }
td .why { display: block; color: var(--muted); font-size: 12.5px; }
.pct { display: grid; grid-template-columns: minmax(48px, 1fr) 3.2em; gap: 8px; align-items: center; min-width: 110px; }
.pct .track { height: 8px; border-radius: 0 4px 4px 0; background: var(--sunk); }
.pct .fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--accent); }
.pct .fill.full { background: var(--pr); }
.pct span { font-family: var(--f-mono); font-size: 12.5px; text-align: right; }
.trend { font-family: var(--f-mono); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.trend b { color: var(--ink); font-weight: 500; }
tr.stale td:first-child { color: var(--muted); }

.acts { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.acts li { display: grid; grid-template-columns: 4.6em minmax(0, 1fr) auto; gap: 2px 12px; padding: 9px 0; border-top: 1px solid var(--line); align-items: baseline; }
.acts li:first-child { border-top: 0; padding-top: 0; }
.acts .when { font-size: 12.5px; color: var(--muted); }
.acts .what { min-width: 0; }
.acts .what span { display: block; font-size: 12.5px; color: var(--muted); }
.acts .how { font-family: var(--f-mono); font-size: 12.5px; text-align: right; white-space: nowrap; }

/* laatste 7 dagen in het stoplicht */
table.mini { font-size: 12.5px; }
table.mini th, table.mini td { text-align: center; padding: 5px 2px; }
table.mini th { text-transform: none; letter-spacing: 0; font-size: 11.5px; }
table.mini th:first-child, table.mini td:first-child { text-align: left; color: var(--muted); font-family: var(--f-body); white-space: nowrap; padding-right: 8px; }
table.mini td { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
table.mini .now { font-weight: 600; color: var(--ink); }
table.mini .hd { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 3px; vertical-align: 1px; }
.legend .hd { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.hd.good { background: var(--good); } .hd.warn { background: var(--warning); } .hd.crit { background: var(--critical); }
.more { justify-self: start; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 13.5px; }

/* tooltip */
.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  box-shadow: 0 8px 24px -10px rgba(10, 14, 22, .35); border-radius: 8px; padding: 7px 10px; font-size: 12.5px; max-width: 240px; }
.tip b { font-size: 15px; font-weight: 600; display: block; }
.tip span { color: var(--muted); }

.foot { max-width: 1160px; margin: 0 auto; padding: 0 max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left)); color: var(--muted); font-size: 12.5px; display: grid; gap: 4px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (forced-colors: active) { .chart .bar, .meter .done, .wd .k.done { forced-color-adjust: none; } }
