/* Eindtijden — kleuren afgestemd op Van Duijn AI Hub, met extra contrast voor gebruik buiten op de ijsbaan. */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --border: #c9cee0;
  --fg: #0b0d14;
  --muted: #4a5166;
  --accent: #5b4bf0;
  --accent-fg: #ffffff;
  --danger: #c81e3c;
  --success: #0f7a50;
  --warning: #9a5b00;
  --start: #0f8a4f;
  --finish: #c81e3c;
  --lane-binnen: #1d5fe0;
  --lane-midden: #b7791f;
  --lane-buiten: #c81e3c;
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e16;
    --surface: #131826;
    --surface-2: #1a2032;
    --border: #2c3450;
    --fg: #f1f3fa;
    --muted: #a3aac0;
    --accent: #8b7dff;
    --accent-fg: #0b0e16;
    --danger: #ff5c77;
    --success: #3fd49a;
    --warning: #f2b14c;
    --start: #1fae6a;
    --finish: #e5304f;
    --lane-binnen: #4c8dff;
    --lane-midden: #f2b14c;
    --lane-buiten: #ff5c77;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
button, input, select { font: inherit; color: inherit; }
.tabular, .clock, td.t { font-variant-numeric: tabular-nums; }
.boot { padding: 40px 16px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.wrap { max-width: 640px; margin: 0 auto; padding: 12px 16px calc(96px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .title { flex: 1; min-width: 0; }
.topbar .title b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title span { font-size: 13px; color: var(--muted); }

.conn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 99px; font-size: 14px; font-weight: 700; white-space: nowrap; }
.conn::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.conn.ok { color: var(--success); background: color-mix(in srgb, var(--success) 14%, transparent); }
.conn.wait { color: var(--warning); background: color-mix(in srgb, var(--warning) 16%, transparent); }
.conn.off { color: #fff; background: var(--danger); }
.banner { margin: 10px 0 0; padding: 10px 14px; border-radius: 12px; font-weight: 600; }
.banner.off { background: var(--danger); color: #fff; }
.banner.warn { background: color-mix(in srgb, var(--warning) 18%, var(--surface)); color: var(--fg); border: 1px solid var(--warning); }
.banner.info { background: var(--surface-2); }

.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; border: 0; background: none; padding: 12px 4px 14px; font-size: 14px; font-weight: 600; color: var(--muted);
  min-height: 56px;
}
.tabs button[aria-current="page"] { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }

/* ---------- Bouwstenen ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.card h2 { margin: 0 0 10px; font-size: 19px; }
h1 { font-size: 26px; margin: 8px 0; }
label { display: block; font-weight: 600; margin: 12px 0 6px; }
input[type=text], input[type=password], input[type=date], input[type=number], input:not([type]), select {
  width: 100%; min-height: 52px; padding: 10px 14px; border-radius: 12px;
  border: 2px solid var(--border); background: var(--bg); font-size: 18px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 10px 18px; border-radius: 12px; border: 2px solid transparent;
  background: var(--accent); color: var(--accent-fg); font-weight: 700; font-size: 17px; text-decoration: none; cursor: pointer;
  touch-action: manipulation;
}
.btn.block { width: 100%; }
.btn.secondary { background: var(--surface-2); color: var(--fg); border-color: var(--border); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: none; color: var(--fg); border-color: var(--border); }
.btn.sm { min-height: 40px; padding: 6px 12px; font-size: 15px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; }
.error { color: var(--danger); font-weight: 600; margin: 10px 0 0; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 700; background: var(--surface-2); }
.badge.ok { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.badge.closed { background: var(--surface-2); color: var(--muted); }
a.link, button.link { color: var(--accent); background: none; border: 0; padding: 8px 0; font-weight: 600; cursor: pointer; text-decoration: underline; }

/* Baankleuren */
.lane-binnen { --lane: var(--lane-binnen); }
.lane-midden { --lane: var(--lane-midden); }
.lane-buiten { --lane: var(--lane-buiten); }
.lane-starter { --lane: var(--start); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--lane); flex: none; }

/* ---------- Functies ---------- */
.roles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.role-chip {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); border-left: 6px solid var(--lane); min-width: 0; font-size: 15px;
}
.role-chip div { min-width: 0; }
.role-chip b { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.role-chip span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.role-chip.free span { color: var(--muted); font-weight: 600; }
.role-chip.lost span { color: var(--warning); }
.role-chip.mine { outline: 3px solid var(--accent); }

.pick { display: grid; gap: 10px; }
.pick button {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  min-height: 76px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--surface); border: 2px solid var(--border); border-left: 10px solid var(--lane); cursor: pointer;
}
.pick button b { font-size: 21px; display: block; }
.pick button span { color: var(--muted); font-size: 15px; }
.pick button:disabled { opacity: .55; cursor: not-allowed; }
.pick button .go { margin-left: auto; font-weight: 800; color: var(--accent); }

/* ---------- Rit-status ---------- */
.heatbar { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.heatbar .heatno { font-size: 30px; font-weight: 800; }
.state { padding: 6px 12px; border-radius: 99px; font-weight: 800; font-size: 15px; }
.state.wait { background: var(--surface-2); color: var(--fg); }
.state.run { background: var(--start); color: #fff; animation: pulse 1.2s infinite; }
.state.done { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
@keyframes pulse { 50% { opacity: .75; } }

.lanes { display: grid; gap: 8px; margin: 12px 0; }
.lanestat {
  display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--border); border-left: 8px solid var(--lane);
}
.lanestat .ln { font-weight: 800; width: 70px; }
.lanestat .nm { flex: 1; min-width: 0; color: var(--muted); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lanestat .val { font-size: 22px; font-weight: 800; }
.lanestat .val.missing { color: var(--muted); font-size: 16px; font-weight: 600; }
.lanestat .val.ok::after { content: " ✓"; color: var(--success); }

.clock { font-size: clamp(56px, 20vw, 104px); font-weight: 800; text-align: center; letter-spacing: -1px; line-height: 1.1; margin: 8px 0; }
.clock.idle { color: var(--muted); }

/* Grote knoppen */
.bigbtn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%;
  border: 0; border-radius: 24px; color: #fff; font-weight: 900; letter-spacing: 1px; cursor: pointer;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  box-shadow: 0 6px 0 rgba(0,0,0,.25);
}
.bigbtn:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.bigbtn:disabled { opacity: .4; box-shadow: none; transform: none; }
.bigbtn small { font-size: 16px; font-weight: 600; letter-spacing: 0; opacity: .9; margin-top: 4px; }
.btn-start { background: var(--start); min-height: 42vh; font-size: clamp(48px, 16vw, 80px); }
.btn-finish { background: var(--finish); min-height: 40vh; font-size: clamp(48px, 16vw, 80px); }
.btn-split { background: var(--accent); min-height: 84px; font-size: 26px; margin-bottom: 14px; border-radius: 18px; }

.lanehead {
  margin-top: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--lane); color: #fff;
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
}
.lanehead b { font-size: 30px; letter-spacing: 1px; }
.lanehead span { font-size: 19px; font-weight: 700; }

.recorded {
  border-radius: var(--radius); padding: 18px; text-align: center; margin: 12px 0;
  background: color-mix(in srgb, var(--success) 15%, var(--surface)); border: 3px solid var(--success);
}
.recorded.pending { background: color-mix(in srgb, var(--warning) 15%, var(--surface)); border-color: var(--warning); }
.recorded .big { font-size: clamp(44px, 15vw, 72px); font-weight: 900; font-variant-numeric: tabular-nums; }
.recorded .lbl { font-weight: 800; font-size: 19px; }

.splits { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; justify-content: center; }
.splits span { background: var(--surface-2); padding: 4px 10px; border-radius: 8px; font-variant-numeric: tabular-nums; font-size: 15px; }

/* ---------- Uitslag ---------- */
table.res { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
table.res th, table.res td { padding: 10px 6px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.res th { background: var(--surface-2); font-size: 14px; }
table.res th .dot { margin-right: 4px; vertical-align: -1px; }
table.res td.t { font-weight: 700; font-size: 17px; cursor: pointer; }
table.res td.t small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
table.res td.t .miss { color: var(--muted); font-weight: 500; }
table.res td.t .run { color: var(--start); font-weight: 700; font-size: 14px; }
table.res tr.current td { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
table.res td.rit { font-weight: 700; white-space: nowrap; }
.edited { color: var(--warning); font-size: 12px; }
.place { font-weight: 900; font-size: 20px; width: 44px; text-align: center !important; }

/* ---------- Dialoog & melding ---------- */
dialog {
  width: min(560px, calc(100vw - 24px)); max-height: 90vh; border: 1px solid var(--border); border-radius: 20px;
  background: var(--surface); color: var(--fg); padding: 20px;
}
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog h2 { margin-top: 0; }
#toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 14px; background: var(--fg); color: var(--bg);
  font-weight: 700; opacity: 0; transition: .2s; pointer-events: none; z-index: 50; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--danger); color: #fff; }

.list { display: grid; gap: 10px; }
.comp { display: grid; gap: 8px; }
.comp .row b { font-size: 18px; }
.audit { font-size: 14px; }
.audit div { padding: 6px 0; border-bottom: 1px solid var(--border); }
.login-hero { text-align: center; padding: 28px 0 8px; }
.login-hero img { width: 64px; height: 64px; }

/* Hulpklassen (geen inline styles i.v.m. de Content-Security-Policy) */
[data-mt10] { margin-top: 10px; }
[data-mt12] { margin-top: 12px; }
[data-mt16] { margin-top: 16px; }
[data-mt20] { margin: 20px 0 0; }
[data-my10] { margin: 10px 0; }
[data-py6] { padding: 6px 0; }
[data-center] { text-align: center; }
[data-f20] { font-size: 20px; }
[data-bold] { font-weight: 700; }
[data-w80] { width: 80px; }
[data-tall] { min-height: 64px; font-size: 20px; }
.ml-auto { margin-left: auto; }
.nocursor { cursor: default !important; }
.bigval { font-size: 28px; font-weight: 800; margin: 0; }
#cc { flex: 1 1 0; width: auto; min-width: 0; }
.row:has(#cc) { flex-wrap: nowrap; }

/* Gevallen (FL) en ritten zonder Midden */
.btn.fell { background: var(--surface-2); color: var(--fg); border: 2px solid var(--lane-midden); }
.btn.fell.on { background: var(--lane-midden); color: #111; }
.fltag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; font-size: 0.7em; font-weight: 800; vertical-align: middle; background: var(--lane-midden); color: #111; }
table.res td.t.none { color: var(--muted); cursor: default; background: var(--surface-2); }
.heatrow { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.heatrow:last-child { border-bottom: 0; }
.heatrow label { margin: 0; flex: 1; display: flex; align-items: center; gap: 12px; font-weight: 600; cursor: pointer; }
.heatrow input[type=checkbox], .check input[type=checkbox] { width: 28px; height: 28px; accent-color: var(--accent); flex: none; }
.check { display: flex; align-items: center; gap: 12px; margin: 12px 0; font-weight: 600; }

/* Koptekst boven uitslag en klassement */
.doc-head { display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; gap: 8px; background: #fff; color: #000; border-radius: var(--radius); padding: 12px 10px 0; margin: 4px 0 12px; }
.doc-head img { max-width: 64px; max-height: 52px; object-fit: contain; }
.doc-head .logo-r { justify-self: end; }
.doc-head .mid { text-align: center; min-width: 0; padding-bottom: 6px; border-bottom: 1px solid #9aa0ad; }
.doc-head .mid b { display: block; font-size: 19px; line-height: 1.2; }
.doc-head .mid span { display: block; font-size: 13px; font-weight: 700; }
.doc-head .sub { grid-column: 1 / -1; text-align: center; font-weight: 700; font-size: 15px; padding: 6px 0 8px; border-bottom: 2px solid #000; }
.logo-edit { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; flex-wrap: wrap; }
.logo-edit img { max-width: 80px; max-height: 50px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 4px; }
.logo-edit input[type=file] { flex: 1 1 160px; min-width: 0; font-size: 14px; }
