:root {
  color-scheme: light;
  --bg: #f3f5f7; --surface: #ffffff; --surface-2: #eef1f4; --border: #dde2e8;
  --text: #0d1318; --text-2: #4c5862; --text-3: #7a8691; --accent: #1f6fd1; --accent-ink: #ffffff;
  --good: #1e9e4a; --warning: #f0a81c; --critical: #d23c3c;
  --good-bg: #e6f5ec; --warning-bg: #fdf3dd; --critical-bg: #fbe7e7;
  --good-ink: #136b33; --warning-ink: #7d5400; --critical-ink: #a42626;
  --shadow: 0 10px 36px rgba(0,0,0,.18);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1317; --surface: #171c21; --surface-2: #1f262c; --border: #2d363e;
    --text: #f2f5f7; --text-2: #b8c2cb; --text-3: #85919b; --accent: #4a90e8;
    --good-bg: #13301f; --warning-bg: #33280f; --critical-bg: #3a1a1a;
    --good-ink: #6ad38d; --warning-ink: #f5c45e; --critical-ink: #f29191;
    --shadow: 0 10px 36px rgba(0,0,0,.55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1317; --surface: #171c21; --surface-2: #1f262c; --border: #2d363e;
  --text: #f2f5f7; --text-2: #b8c2cb; --text-3: #85919b; --accent: #4a90e8;
  --good-bg: #13301f; --warning-bg: #33280f; --critical-bg: #3a1a1a;
  --good-ink: #6ad38d; --warning-ink: #f5c45e; --critical-ink: #f29191;
  --shadow: 0 10px 36px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif; }
a { color: var(--accent); }
.wrap { max-width: 1320px; margin: 0 auto; padding: 16px 16px 48px; }
header.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 12px; }
h1 { font-size: 21px; margin: 0; font-weight: 650; display: flex; align-items: center; gap: 8px; }
h1 .logo { width: 26px; height: 26px; }
h1 small { font-weight: 400; color: var(--text-3); font-size: 14px; }
h2 { font-size: 16px; margin: 0 0 10px; font-weight: 600; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 600; }
.meta { color: var(--text-2); font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }

.banner { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--warning); padding: 10px 14px; border-radius: 8px; margin-bottom: 10px; color: var(--text-2); }
.banner.crit { border-left-color: var(--critical); }
.banner.info { border-left-color: var(--accent); }
.banner.good { border-left-color: var(--good); }
.banner ul { margin: 4px 0 0; padding-left: 18px; }

button, .btn {
  font: inherit; font-size: 13px; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 7px; padding: 6px 12px; cursor: pointer; min-height: 34px; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:hover, .btn:hover { background: var(--surface-2); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover, .btn.primary:hover { filter: brightness(1.08); }
button.danger { background: var(--critical); border-color: var(--critical); color: #fff; }
button.good { background: var(--good); border-color: var(--good); color: #fff; }
button.small, .btn.small { padding: 2px 8px; min-height: 28px; font-size: 12px; }
button.icon { padding: 2px 7px; min-height: 28px; min-width: 28px; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 7px; padding: 6px 10px; min-height: 34px; max-width: 100%;
}
textarea { min-height: 70px; width: 100%; resize: vertical; }
select.small, input.small { min-height: 28px; padding: 2px 6px; font-size: 12px; }
input[type="checkbox"] { min-height: 0; width: 16px; height: 16px; accent-color: var(--accent); }
label { color: var(--text-2); }

nav.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: thin; }
nav.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 9px 14px; color: var(--text-2); white-space: nowrap; min-height: 40px; }
nav.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: 10px; background: var(--surface-2); font-size: 11px; line-height: 18px; text-align: center; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.grid { display: grid; gap: 12px; }
.grid.cols-5 { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stack > * + * { margin-top: 8px; }

/* Niveaus */
.lv { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.lv::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.lv.groen { background: var(--good-bg); color: var(--good-ink); }
.lv.oranje { background: var(--warning-bg); color: var(--warning-ink); }
.lv.rood { background: var(--critical-bg); color: var(--critical-ink); }
.lv.onbekend { background: var(--surface-2); color: var(--text-3); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--text-3); }
.dot.groen { background: var(--good); } .dot.oranje { background: var(--warning); } .dot.rood { background: var(--critical); }

.hero { border-radius: 12px; padding: 16px 18px; margin-bottom: 14px; border: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; justify-content: space-between; }
.hero.groen { background: var(--good-bg); } .hero.oranje { background: var(--warning-bg); } .hero.rood { background: var(--critical-bg); } .hero.onbekend { background: var(--surface-2); }
.hero .big { font-size: 22px; font-weight: 700; }
.hero.groen .big { color: var(--good-ink); } .hero.oranje .big { color: var(--warning-ink); } .hero.rood .big { color: var(--critical-ink); }

.prov { border-top: 4px solid var(--border); }
.prov.groen { border-top-color: var(--good); } .prov.oranje { border-top-color: var(--warning); } .prov.rood { border-top-color: var(--critical); }
.prov header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 12px; font-size: 13px; margin-bottom: 8px; }
.stats b { font-weight: 600; }
.reasons { margin: 0; padding-left: 18px; font-size: 13px; }
.reasons li { margin: 2px 0; }
details summary { cursor: pointer; color: var(--text-2); font-size: 13px; margin-top: 6px; }

.nights { display: flex; gap: 6px; flex-wrap: wrap; }
.nights button { flex-direction: column; align-items: flex-start; gap: 0; min-width: 130px; }
.nights button .lbl { font-weight: 600; }

/* Tabellen */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 600; color: var(--text-2); background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
tr.off td { opacity: .5; }
tr.done td { color: var(--text-3); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
table.hours td, table.hours th { padding: 3px 6px; text-align: right; }
table.hours td:first-child, table.hours th:first-child { text-align: left; }
td.c-rood { background: var(--critical-bg); color: var(--critical-ink); }
td.c-oranje { background: var(--warning-bg); color: var(--warning-ink); }
.scrollbox { max-height: 520px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }

/* Kaart */
.map { height: 460px; border-radius: 10px; border: 1px solid var(--border); margin-bottom: 14px; z-index: 0; }
.map.small { height: 280px; margin: 8px 0; }
.leaflet-container { font: inherit; }

/* Routes */
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; }
.rc0 { background: #1f6fd1; } .rc1 { background: #d23c3c; } .rc2 { background: #1e9e4a; } .rc3 { background: #c76a00; } .rc4 { background: #8a3ffc; }
.rc5 { background: #00838f; } .rc6 { background: #d12771; } .rc7 { background: #6b7a00; } .rc8 { background: #7a5230; } .rc9 { background: #34495e; }
.route header { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.route .title { font-weight: 650; font-size: 15px; display: flex; align-items: center; gap: 8px; }
progress { width: 140px; height: 10px; accent-color: var(--good); vertical-align: middle; }
progress.wide { width: 100%; }
.tag { display: inline-block; padding: 0 7px; border-radius: 9px; font-size: 11px; background: var(--surface-2); color: var(--text-2); line-height: 18px; white-space: nowrap; }
.tag.warn { background: var(--warning-bg); color: var(--warning-ink); }
.tag.crit { background: var(--critical-bg); color: var(--critical-ink); }
.tag.good { background: var(--good-bg); color: var(--good-ink); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.kpi .v { font-size: 22px; font-weight: 700; }
.kpi .l { color: var(--text-3); font-size: 12px; }
.links { display: flex; flex-wrap: wrap; gap: 6px; }

/* Dialoog */
dialog { border: 1px solid var(--border); border-radius: 12px; padding: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow); width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog form { padding: 16px 18px; }
dialog .fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 14px; }
dialog .field { display: flex; flex-direction: column; gap: 3px; }
dialog .field.wide { grid-column: 1 / -1; }
dialog .field.check { flex-direction: row; align-items: center; gap: 8px; }
dialog .help { font-size: 12px; color: var(--text-3); }
dialog footer { display: flex; justify-content: space-between; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); z-index: 1000; max-width: calc(100vw - 32px); }
#toast.err { background: var(--critical); color: #fff; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.login { max-width: 360px; margin: 12vh auto; }
.login form { display: flex; flex-direction: column; gap: 10px; }

#toast { display: flex; align-items: center; gap: 12px; }
#toast.hidden { display: none; }
#toast button { background: transparent; color: inherit; border-color: currentColor; }

/* Studentenpagina: grote knoppen, één duidelijke volgende stop */
.student .sbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0 6px; }
.student .sbar b { font-size: 16px; }
.student progress.wide { height: 8px; margin-bottom: 10px; }
.btn-xl { width: 100%; min-height: 56px !important; font-size: 18px !important; font-weight: 600; border-radius: 12px !important; margin-top: 10px; }
.hero-stop { border: 2px solid var(--accent); border-radius: 14px; }
.hero-stop.done-all { border-color: var(--good); }
.hero-stop .eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }
.hero-stop .name { font-size: 22px; font-weight: 700; line-height: 1.2; margin-top: 4px; }
.hero-stop .addr { font-size: 16px; color: var(--text-2); margin-top: 2px; }
.note { background: var(--warning-bg); color: var(--warning-ink); border-radius: 8px; padding: 8px 10px; margin-top: 8px; white-space: pre-wrap; }
.row.between { justify-content: space-between; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.row3.two { grid-template-columns: 1fr 1fr; margin-top: 14px; }
.row3 button { min-height: 46px; font-size: 15px; }
h3.sec, details.sec { margin: 16px 0 6px; }
details.sec summary { font-size: 15px; font-weight: 600; color: var(--text); padding: 6px 0; }
.list { display: flex; flex-direction: column; gap: 6px; }
.li { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; text-align: left; width: 100%; min-height: 48px; font: inherit; color: var(--text); }
.li .nr { font-weight: 700; min-width: 22px; color: var(--text-3); }
.li .grow { flex: 1; min-width: 0; }
.footer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 18px 0 8px; }
.footer-actions button { min-height: 48px; }
.sheet { width: min(560px, 100vw); max-height: 92vh; margin: auto auto 0; border-radius: 16px 16px 0 0; }
.sheet form { padding: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip { min-height: 42px; border-radius: 21px; padding: 6px 14px; font-size: 14px; }
.chip.sel { background: var(--accent); border-color: var(--accent); color: #fff; }
.fotobtn { margin-top: 8px; width: 100%; min-height: 46px; }
.preview { max-width: 100%; max-height: 220px; border-radius: 8px; margin-top: 8px; display: block; }
.preview.hidden { display: none; }

/* Studentenpagina (oud) */
.student .wrap { max-width: 640px; padding-top: 12px; }
.student .head { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0; }
.stop { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.stop.next { border: 2px solid var(--accent); }
.stop.done { opacity: .6; }
.stop .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.stop .nr { font-weight: 700; font-size: 18px; }
.stop .name { font-weight: 650; font-size: 16px; }
.stop .addr { color: var(--text-2); }
.stop .note { background: var(--warning-bg); color: var(--warning-ink); border-radius: 8px; padding: 6px 10px; margin-top: 8px; white-space: pre-wrap; }
.stop .actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; }
.stop .actions button, .stop .actions .btn { min-height: 46px; font-size: 15px; }
.bigbtn { min-height: 48px !important; font-size: 15px !important; width: 100%; }
.mapsbtns { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }

@media (max-width: 640px) {
  .wrap { padding: 10px 12px 40px; }
  .map { height: 340px; }
  .hide-sm { display: none; }
  th, td { padding: 5px 6px; }
}
.count.crit { background: var(--critical); color: #fff; }
img.thumb { max-width: 140px; max-height: 100px; border-radius: 6px; margin-top: 4px; border: 1px solid var(--border); }
