/* Mobile-first. Onder 900px worden tabellen kaarten.
   data-label komt uit het script in base.html, ook voor latere pagina's. */

:root {
  --ink: #14211c;
  --muted: #3e5148;
  --paper: #eef2f0;
  --card: #ffffff;
  --line: #d5e0da;
  --pine: #12352b;
  --leaf: #0e6b45;
  --gold: #7a5410;
  --warn: #8d1d1d;
  --ok: #0d5c32;
  --shadow: 0 1px 2px rgba(16, 32, 24, 0.05), 0 8px 24px rgba(16, 32, 24, 0.06);
  --radius: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
}

:focus { outline: none; }
:focus-visible {
  outline: 3px solid #1f8a5b;
  outline-offset: 2px;
}
input:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--leaf);
  box-shadow: 0 0 0 3px rgba(14, 107, 69, 0.25);
}

::selection { background: #cde8da; }

a { color: var(--leaf); }
a:hover { text-decoration-thickness: 2px; }

h1, h2 { font-weight: 700; letter-spacing: -0.03em; line-height: 1.2; }
h1 { margin: 0 0 0.35rem; font-size: clamp(1.45rem, 2.4vw, 1.9rem); }
h2 { margin: 0 0 0.75rem; font-size: 1.05rem; }

.skip {
  position: absolute;
  left: 0.75rem;
  top: -3.2rem;
  z-index: 50;
  background: white;
  color: var(--ink);
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  text-decoration: none;
}
.skip:focus { top: 0.55rem; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.nav-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.nav-toggle:focus { outline: none; }
.nav-toggle:focus-visible ~ .nav-burger {
  outline: 3px solid #f3d7a1;
  outline-offset: 3px;
}

.top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.55rem 0.6rem;
  padding: max(0.7rem, env(safe-area-inset-top)) 0.85rem 0.8rem;
  background: var(--pine);
  color: #f4f7f5;
}
.brand { min-width: 0; }
.brand a {
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
}
.brand span { font-weight: 560; color: #e4d3b0; }
.brand p {
  margin: 0.12rem 0 0;
  color: #d5e4db;
  font-size: 0.8rem;
  line-height: 1.35;
}
.nav-burger {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 48px;
  height: 48px;
  margin: 0;
  padding: 0 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
}
.nav-burger .bar {
  display: block;
  height: 2px;
  width: 18px;
  border-radius: 2px;
  background: #f4f7f5;
  transition: transform 0.16s ease, opacity 0.16s ease;
}
.nav-toggle:checked ~ .nav-burger .bar:nth-child(2) { transform: translateY(7px) rotate(45deg); }
.nav-toggle:checked ~ .nav-burger .bar:nth-child(3) { opacity: 0; }
.nav-toggle:checked ~ .nav-burger .bar:nth-child(4) { transform: translateY(-7px) rotate(-45deg); }

nav {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 40;
  flex-direction: column;
  gap: 0.2rem;
  max-height: min(70vh, 28rem);
  overflow: auto;
  margin: 0;
  padding: 0.45rem 0.75rem 0.85rem;
  background: var(--pine);
  box-shadow: 0 18px 36px rgba(8, 20, 16, 0.28);
}
.nav-toggle:checked ~ nav { display: flex; }
nav a {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0.45rem 0.85rem;
  border-radius: 12px;
  color: #f4f7f5;
  text-decoration: none;
  font-weight: 600;
}
nav a:hover { background: rgba(255, 255, 255, 0.08); text-decoration: none; }
nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.16); }

.userbar {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.6rem;
}
.userbar .who { flex: 1 1 12rem; color: #d5e4db; font-size: 0.85rem; }
.userbar form { margin: 0; }
.scan-form { flex: 1 1 100%; }
.scan-form button { width: 100%; }

button, .textlink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border: 0;
  border-radius: 12px;
  background: var(--leaf);
  color: white;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
button:hover { background: #0c5d3c; }
button:disabled { opacity: 0.62; cursor: wait; }
.top button {
  background: #f3d7a1;
  color: #1c2416;
}
.top button:hover { background: #f8e4bb; }
.top button:disabled { background: #e7d7b8; }
button.ghost {
  width: auto;
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
}
button.ghost:hover { background: #f4faf6; }
.top button.ghost {
  background: transparent;
  color: #f4f7f5;
  border: 1px solid rgba(255, 255, 255, 0.35);
}
.top button.ghost:hover { background: rgba(255, 255, 255, 0.08); }
.textlink {
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
}
.textlink:hover { background: #f4faf6; text-decoration: none; }

.notice {
  margin: 0;
  padding: 0.75rem 1rem;
  background: #fbf1dc;
  color: #3d2c12;
  border-bottom: 1px solid #ead7b0;
}

main {
  width: min(1120px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1.05rem 0 2.75rem;
}

.lede, .empty { color: var(--muted); }
.lede { margin: 0.2rem 0 1rem; }
.runline {
  margin: 0.85rem 0 0;
  padding: 0.75rem 0.95rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  box-shadow: var(--shadow);
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}
.stats article {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--leaf);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 0.8rem 0.9rem 0.85rem;
}
.stats article.kans {
  grid-column: 1 / -1;
  background: var(--pine);
  color: white;
  border: 0;
  box-shadow: 0 10px 24px rgba(18, 53, 43, 0.18);
}
.stats span, .stats em { display: block; color: var(--muted); font-style: normal; }
.stats span { font-size: 0.82rem; font-weight: 700; }
.stats em { margin-top: 0.15rem; font-size: 0.8rem; line-height: 1.35; }
.stats strong {
  display: block;
  margin: 0.12rem 0 0.05rem;
  font-size: 2rem;
  font-weight: 750;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stats article.kans span,
.stats article.kans em { color: #d7e6de; }
.stats article.kans strong { color: white; font-size: 2.75rem; }

.split { display: grid; gap: 0.75rem; margin: 0.9rem 0; }
section { margin: 1.15rem 0; }
.panel, .split article, .profile, .confirm-card, .statusform, .info, .facts {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel, .split article, .profile, .confirm-card, .statusform { padding: 1rem 1.05rem; }
.confirm-card { max-width: 38rem; }
.confirm-card form, .actions { display: flex; flex-wrap: wrap; gap: 0.55rem; align-items: center; }

.bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name count" "track track";
  gap: 0.15rem 0.65rem;
  align-items: center;
  margin: 0.55rem 0;
}
.bar span { grid-area: name; }
.bar b { grid-area: count; font-variant-numeric: tabular-nums; }
.track {
  grid-area: track;
  display: block;
  height: 0.5rem;
  background: #e3ebe6;
  border-radius: 99px;
  overflow: hidden;
}
.track i {
  display: block;
  height: 100%;
  min-width: 4px;
  background: linear-gradient(90deg, #1f8f5a, #147247);
  border-radius: inherit;
}

.chips, ul.flags { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0; margin: 0.35rem 0 0; list-style: none; }
.chips li, .flags li {
  background: #f4f7f5;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.9rem;
}
.reasons { margin: 0.25rem 0 0; padding-left: 1.15rem; color: var(--muted); font-size: 0.88rem; }
.errors { list-style: none; margin: 0; padding: 0; }
.errors li { padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.errors li:last-child { border-bottom: 0; padding-bottom: 0; }
.errors time { display: block; color: var(--muted); font-size: 0.82rem; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.table-scroll table { min-width: 680px; }
th, td {
  text-align: left;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
tr:last-child td { border-bottom: 0; }
th {
  background: #f6f8f7;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}
td a { font-weight: 680; }
small { display: block; color: var(--muted); margin-top: 0.2rem; font-size: 0.85rem; }

.badge, .score-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.55rem;
  padding: 0.08rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.2;
  white-space: nowrap;
  background: #e7eeea;
  color: #16352b;
}
.score-num {
  min-width: 2.35rem;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
}
.score-high, .st-up, .lv-info, .badge-on, .status-benaderd { background: #e3f6ea; color: #0c5c34; }
.score-mid, .st-cooldown, .lv-warning, .status-al_beheerd { background: #fbf1dc; color: #7a5410; }
.score-low, .st-unknown, .badge-off, .status-bekeken { background: #eef1f3; color: #243038; }
.st-down, .lv-error, .status-afgewezen { background: #fde8e8; color: #8d1d1d; }
.status-nieuw { background: #e7f1fb; color: #0f3f73; }
tr.lv-error td { background: #fff7f7; }
tr.lv-warning td { background: #fffaf3; }

form.filters {
  display: grid;
  gap: 0.7rem;
  margin: 0.85rem 0 0.7rem;
}
form.filters button { width: 100%; }
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; font-weight: 650; color: var(--muted); }
input:not([type="checkbox"]):not([type="hidden"]):not([type="radio"]),
select {
  width: 100%;
  min-height: 44px;
  padding: 0.45rem 0.65rem;
  border: 1px solid #c5d2cb;
  border-radius: 10px;
  background: white;
  color: var(--ink);
  font: inherit;
}
p.filters { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.8rem 0 1rem; }
p.filters a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--ink);
  text-decoration: none;
  font-weight: 650;
}
p.filters a.on { background: var(--pine); border-color: var(--pine); color: white; }
.switch { margin: 0.2rem 0 0.9rem; }

.facts {
  display: grid;
  gap: 0.75rem 1.2rem;
  margin: 0;
  padding: 0.35rem 1rem 1rem;
}
.facts div { margin: 0; padding-top: 0.7rem; border-top: 1px solid var(--line); }
.facts div:first-child { border-top: 0; }
.facts dt { color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.facts dd { margin: 0.12rem 0 0; overflow-wrap: anywhere; }
.info { white-space: pre-wrap; overflow-wrap: anywhere; padding: 1rem 1.05rem; margin: 0; }
.profile { margin: 0.85rem 0; display: grid; gap: 0.7rem; max-width: 40rem; }
.check { flex-direction: row; align-items: flex-start; gap: 0.65rem; min-height: 44px; color: var(--ink); }
.check input { width: 1.2rem; height: 1.2rem; margin-top: 0.2rem; flex: 0 0 auto; accent-color: var(--leaf); }
.check span { font-weight: 500; color: var(--ink); }
.places { color: var(--muted); margin: 0; }
.crumb { margin: 0 0 0.45rem; }
.crumb a { font-weight: 700; text-decoration: none; }
.crumb a:hover { text-decoration: underline; }
.score { display: flex; flex-wrap: wrap; gap: 0.4rem 0.55rem; align-items: center; color: var(--muted); margin: 0.35rem 0 0.9rem; }
.detail { display: flex; flex-direction: column; gap: 1rem; }
.detail-main { display: grid; gap: 1rem; }
.detail-main h2 { margin-top: 0.25rem; }
.statusform { display: grid; gap: 0.7rem; align-content: start; }
.detail .statusform { order: -1; }

@media (min-width: 700px) {
  .bar {
    grid-template-columns: 9.5rem minmax(0, 1fr) auto;
    grid-template-areas: "name track count";
    gap: 0.55rem;
  }
  .facts { grid-template-columns: 1fr 1fr; padding: 0.4rem 1.05rem 1.05rem; }
  .facts div:nth-child(2) { border-top: 0; }
  form.filters { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; align-items: end; }
  form.filters button { width: auto; }
}

@media (min-width: 900px) {
  .stats { grid-template-columns: 1.4fr repeat(4, minmax(0, 1fr)); }
  .stats article.kans { grid-column: auto; }
  .split { grid-template-columns: 1fr 1fr; }
  .detail { display: grid; grid-template-columns: minmax(0, 1fr) 17.5rem; align-items: start; }
  .detail .statusform { order: 0; position: sticky; top: 6.5rem; }
}

@media (min-width: 1180px) {
  .top {
    display: flex;
    align-items: center;
    gap: 1rem 1.25rem;
    padding: 0.75rem 1.25rem;
  }
  .brand { min-width: 0; }
  .brand p { max-width: 16rem; }
  .nav-burger { display: none; }
  .userbar { width: auto; flex: 0 1 auto; }
  .userbar .who { flex: 0 1 auto; }
  .scan-form { flex: 0 0 auto; }
  .scan-form button, .top button { width: auto; white-space: nowrap; }
  nav,
  .nav-toggle:checked ~ nav {
    display: flex;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.15rem;
    max-height: none;
    overflow: visible;
    flex: 1 1 auto;
    min-width: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
  }
  nav a {
    min-height: 40px;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
  }
}

@media (max-width: 900px) {
  .table-scroll { overflow: visible; }
  .table-scroll table { min-width: 0; }
  table, tbody, tr, td { display: block; width: auto; }
  table {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  tr {
    margin: 0 0 0.75rem;
    padding: 0.85rem 0.95rem 0.7rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
  }
  td {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.2rem 0.75rem;
    padding: 0.32rem 0;
    border-bottom: 0;
    background: transparent;
  }
  td { overflow-wrap: anywhere; }
  td::before {
    content: attr(data-label);
    flex: 1 0 38%;
    max-width: 9rem;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 750;
  }
  td:not([data-label])::before,
  td[colspan]::before,
  td:first-child:has(a, strong)::before { content: none; }
  td:first-child:has(a, strong) {
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    padding-bottom: 0.5rem;
    margin-bottom: 0.15rem;
    border-bottom: 1px solid var(--line);
    font-size: 1.02rem;
  }
  td[colspan] { border-bottom: 0; }
  td .reasons, td .flags, td small, td form { flex: 1 0 100%; }
  td form button { width: 100%; }
  tr.lv-error { background: #fff7f7; }
  tr.lv-warning { background: #fffaf3; }
  tr.lv-error td, tr.lv-warning td { background: transparent; }
}

@media (hover: hover) and (min-width: 901px) {
  tbody tr:hover td { background: #f5faf7; }
  tr.lv-error:hover td { background: #fff1f1; }
  tr.lv-warning:hover td { background: #fff6e8; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

.maplink { margin: 0 0 0.9rem; }
a.map-button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.45rem 0.95rem;
  border-radius: 12px;
  background: white;
  color: var(--pine);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-weight: 700;
  text-decoration: none;
}
a.map-button:hover { background: #f4faf6; text-decoration: none; }
a.map-button svg { width: 1.15rem; height: 1.15rem; display: block; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
  background:
    radial-gradient(circle at 18% 12%, #d7e7dc 0, transparent 42%),
    radial-gradient(circle at 90% 0%, #f3e6cf 0, transparent 36%),
    var(--paper);
}
main.login-box {
  width: min(24rem, calc(100% - 0.5rem));
  margin: 0;
  padding: 1.4rem 1.25rem 1.5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.login-box h1 { margin: 0; color: var(--pine); }
.login-box h1 span { color: #8a6230; }
.stack-form { display: grid; gap: 0.75rem; }
.stack-form button { justify-self: stretch; }
@media (min-width: 700px) {
  .stack-form button { justify-self: start; }
}
.form-error {
  margin: 0.8rem 0 0;
  color: var(--warn);
  background: #fde8e8;
  border: 1px solid #f0c4c4;
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
}
.profile .notice, main .notice {
  border-radius: 12px;
  margin: 0 0 0.9rem;
}
