:root {
  color-scheme: light;
  --bg: #f4f4f1; --surface: #fcfcfb; --surface-2: #efeeea; --border: #e2e1dc;
  --text: #0b0b0b; --text-2: #52514e; --muted: #8a8984;
  --accent: #2a78d6;
  --cycling: #2a78d6; --running: #eb6834; --swimming: #1baf7a; --other: #eda100;
  --ctl: #2a78d6; --atl: #eb6834; --form: #1baf7a;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --z1: #8fd0a8; --z2: #4fb573; --z3: #eda100; --z4: #eb6834; --z5: #e34948;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #242423; --border: #2e2e2c;
    --text: #ffffff; --text-2: #c3c2b7; --muted: #8d8c86;
    --accent: #3987e5;
    --cycling: #3987e5; --running: #d95926; --swimming: #199e70; --other: #c98500;
    --ctl: #3987e5; --atl: #d95926; --form: #199e70;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }

.top { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 2; }
.top nav { display: flex; gap: 14px; align-items: center; }
@media (max-width: 520px) { .toggle span { display: none; } .top { padding: 10px 12px; } }
.brand { font-weight: 700; display: inline-flex; align-items: center; gap: 8px; letter-spacing: .01em; }
.zone-bars { display: inline-flex; gap: 2px; align-items: flex-end; height: 18px; }
.zone-bars i { display: block; width: 4px; border-radius: 2px; }
.zone-bars i:nth-child(1) { height: 6px; background: var(--z1); }
.zone-bars i:nth-child(2) { height: 9px; background: var(--z2); }
.zone-bars i:nth-child(3) { height: 12px; background: var(--z3); }
.zone-bars i:nth-child(4) { height: 15px; background: var(--z4); }
.zone-bars i:nth-child(5) { height: 18px; background: var(--z5); }
.toggle { font-size: 13px; color: var(--text-2); display: inline-flex; gap: 6px; align-items: center; }
.ghost { background: none; border: 1px solid var(--border); color: var(--text-2); border-radius: 8px; padding: 6px 10px; }
.ghost:hover { border-color: var(--text-2); }
.primary { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 600; }

main { max-width: 1120px; margin: 0 auto; padding: 20px 16px 48px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 12px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* Overzicht */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.card, .tile, .cols > *, .grid > * { min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.athlete { display: block; transition: border-color .15s; }
.athlete:hover { border-color: var(--accent); }
.athlete .name { font-weight: 700; font-size: 17px; }
.athlete .id { font-size: 12px; color: var(--muted); font-family: ui-monospace, Menlo, monospace; }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 14px 0 12px; }
.kpi { min-width: 0; }
.kpi .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .l { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi .d { font-size: 12px; color: var(--text-2); }
.spark { display: flex; gap: 3px; align-items: flex-end; height: 34px; }
.spark .b { flex: 1; min-height: 2px; display: flex; flex-direction: column-reverse; gap: 1px; border-radius: 3px 3px 0 0; overflow: hidden; }
.spark .b i { display: block; flex: var(--share) 1 0; min-height: 0; }
.spark .b.cur { outline: 1px dashed var(--muted); outline-offset: 1px; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.pill.status-good { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.pill.status-warning { background: color-mix(in srgb, var(--warning) 22%, transparent); color: var(--text); }
.pill.status-critical { background: color-mix(in srgb, var(--critical) 15%, transparent); color: var(--critical); }
.pill.status-muted { background: var(--surface-2); color: var(--muted); }
.goal { font-size: 13px; color: var(--text-2); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.dot.cycling { background: var(--cycling); } .dot.running { background: var(--running); }
.dot.swimming { background: var(--swimming); } .dot.other { background: var(--other); }

/* Detail */
.detail-head { margin-bottom: 18px; overflow-wrap: anywhere; }
.detail-head input.name { font: inherit; font-size: 22px; font-weight: 700; background: transparent; border: 0; border-bottom: 1px dashed var(--border); color: var(--text); padding: 2px 0; width: min(100%, 420px); }
.detail-head input.name:focus { outline: none; border-bottom-color: var(--accent); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.tile { min-width: 0; overflow-wrap: anywhere; }
.tile .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile .l { font-size: 12px; color: var(--muted); margin-top: 4px; }
.tile .d { font-size: 12px; color: var(--text-2); margin-top: 4px; }
.cols { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 14px; }
@media (min-width: 900px) { .cols.two { grid-template-columns: 1fr 1fr; } }
.chart-wrap { position: relative; height: 240px; min-width: 0; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; background: var(--c); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.today td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
tr.future td { color: var(--text-2); }
.zone { display: inline-block; min-width: 26px; text-align: center; font-size: 11px; font-weight: 700; padding: 1px 5px; border-radius: 6px; color: #111; }
.zone.z1 { background: var(--z1); } .zone.z2 { background: var(--z2); } .zone.z3 { background: var(--z3); }
.zone.z4 { background: var(--z4); color: #fff; } .zone.z5 { background: var(--z5); color: #fff; }
.done { color: var(--good); font-weight: 600; } .missed { color: var(--critical); font-weight: 600; }
.sess { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin: 2px 0; }
.sess .struct { color: var(--text-2); font-size: 13px; }
textarea.notes { width: 100%; min-height: 70px; font: inherit; font-size: 14px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px; resize: vertical; }
.readiness { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 14px; color: var(--text-2); }
.chat .msg { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.chat .msg b { color: var(--text-2); font-weight: 600; margin-right: 6px; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

/* Login */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; width: 100%; max-width: 360px; }
.login-card .brand { font-size: 18px; margin-bottom: 18px; }
.login-card label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.login-card input { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); margin-bottom: 12px; }
.login-card button { width: 100%; background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 10px; font-weight: 600; }
.error { color: var(--critical); font-size: 13px; }
