*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--ht-font); font-size: 15px; line-height: 1.45;
  background: var(--ht-bg); color: var(--ht-text);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: var(--ht-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.05rem; } h3 { font-size: .95rem; }
.zacht { color: var(--ht-text-zacht); }
.klein { font-size: .82rem; }
.mono { font-family: Consolas, "Cascadia Mono", ui-monospace, monospace; }
.verborgen { display: none !important; }
:focus-visible { outline: 2px solid var(--ht-accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- header met merkstreep ---------- */
.kop {
  position: sticky; top: 0; z-index: 20; background: var(--ht-surface);
  box-shadow: var(--ht-schaduw);
}
.kop-binnen { display: flex; align-items: center; gap: 12px; padding: 8px 16px; min-height: 56px; }
.logo { height: 36px; border-radius: 6px; background: #fff; padding: 2px 4px; display: block; }
.app-naam { font-weight: 600; color: var(--ht-primary); font-size: 1.05rem; letter-spacing: .02em; }
.kop .ruimte { flex: 1; }
.merkstreep { display: grid; grid-template-columns: repeat(4, 1fr); height: 4px; }
.merkstreep span:nth-child(1) { background: var(--ht-oranje); }
.merkstreep span:nth-child(2) { background: var(--ht-blauw); }
.merkstreep span:nth-child(3) { background: var(--ht-groen); }
.merkstreep span:nth-child(4) { background: var(--ht-rood); }
.icoonknop {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  border: 0; background: transparent; cursor: pointer; color: var(--ht-text-zacht);
}
.icoonknop:hover { background: var(--ht-surface-2); color: var(--ht-text); }
.icoonknop svg { width: 22px; height: 22px; }
.terug { display: none; }

/* ---------- layout ---------- */
.kolommen { display: block; }
.kolom { padding: 16px; max-width: 900px; margin: 0 auto; }
.kolom[hidden] { display: none; }
@media (min-width: 1100px) {
  .kolommen {
    display: grid; grid-template-columns: 300px 400px minmax(0, 1fr);
    height: calc(100vh - 60px); overflow: hidden;
  }
  .kolom { max-width: none; margin: 0; overflow-y: auto; border-right: 1px solid var(--ht-rand); }
  .kolom[hidden] { display: block; }
  .kolom.detail { border-right: 0; }
  .kolom .leeg-detail { display: grid; }
}
@media (max-width: 1099px) {
  .terug.zichtbaar { display: inline-grid; }
}

/* ---------- kaarten & lijsten ---------- */
.kaart {
  background: var(--ht-surface); border: 1px solid var(--ht-rand); border-radius: var(--ht-radius);
  padding: 14px 16px; margin-bottom: 14px; box-shadow: var(--ht-schaduw);
}
.kaart > h2, .kaart-kop { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.kaart-kop h2 { flex: 1; }
.sectie-titel { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ht-text-zacht); margin: 18px 0 8px; font-weight: 600; }
.lijst { list-style: none; margin: 0; padding: 0; }
.rij {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; cursor: pointer;
  background: var(--ht-surface); border: 1px solid var(--ht-rand); margin-bottom: 8px;
}
.rij:hover { border-color: var(--ht-accent); }
.rij.actief { border-color: var(--ht-primary); box-shadow: inset 3px 0 0 var(--ht-primary); }
.rij .hoofd { flex: 1; min-width: 0; }
.rij .titel { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rij .sub { font-size: .82rem; color: var(--ht-text-zacht); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leeg { text-align: center; padding: 32px 16px; color: var(--ht-text-zacht); }
.leeg-detail { display: none; place-items: center; height: 100%; color: var(--ht-text-zacht); text-align: center; }

/* ---------- status ---------- */
.stip { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--st-onbekend); }
.stip.online { background: var(--st-online); }
.stip.waarschuwing { background: var(--st-waarschuwing); }
.stip.offline { background: var(--st-offline); box-shadow: 0 0 0 4px var(--st-offline-bg); }
.pil {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 600; background: var(--st-onbekend-bg); color: var(--ht-text-zacht); white-space: nowrap;
}
.pil.online { background: var(--st-online-bg); color: var(--st-online-tekst); }
.pil.waarschuwing { background: var(--st-waarschuwing-bg); color: var(--st-waarschuwing-tekst); }
.pil.offline { background: var(--st-offline-bg); color: var(--st-offline-tekst); }
.tellers { display: flex; gap: 6px; flex-wrap: wrap; }
.teller { font-size: .78rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; }
.teller.online { background: var(--st-online-bg); color: var(--st-online-tekst); }
.teller.waarschuwing { background: var(--st-waarschuwing-bg); color: var(--st-waarschuwing-tekst); }
.teller.offline { background: var(--st-offline-bg); color: var(--st-offline-tekst); }
.teller.onbekend { background: var(--st-onbekend-bg); color: var(--ht-text-zacht); }

/* ---------- meters ---------- */
.meters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 6px; max-width: 320px; }
.meter { font-size: .7rem; color: var(--ht-text-zacht); }
.meter .balk { height: 5px; border-radius: 3px; background: var(--ht-surface-2); border: 1px solid var(--ht-rand); overflow: hidden; margin-top: 2px; }
.meter .vul { height: 100%; background: var(--ht-blauw); }
.meter .vul.hoog { background: var(--ht-oranje); }
.meter .vul.kritiek { background: var(--ht-rood); }
.grote-meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.grote-meter .label { display: flex; justify-content: space-between; font-size: .85rem; }
.grote-meter .waarde { font-size: 1.4rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.grote-meter .balk { height: 8px; border-radius: 4px; background: var(--ht-surface-2); border: 1px solid var(--ht-rand); overflow: hidden; margin-top: 4px; }
.grote-meter .vul { height: 100%; background: var(--ht-blauw); }
.grote-meter .vul.hoog { background: var(--ht-oranje); }
.grote-meter .vul.kritiek { background: var(--ht-rood); }

/* ---------- tijdlijn ---------- */
.mini-tijdlijn { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin-top: 6px; background: var(--st-onbekend-bg); }
.tl-wrap { position: relative; user-select: none; }
.tl-balk { position: relative; height: 34px; border-radius: 8px; overflow: hidden; background: var(--st-onbekend-bg); border: 1px solid var(--ht-rand); touch-action: pan-y; }
.tl-seg { position: absolute; top: 0; bottom: 0; }
.tl-seg.online, .mini-tijdlijn .online { background: var(--st-online); }
.tl-seg.waarschuwing, .mini-tijdlijn .waarschuwing { background: var(--st-waarschuwing); }
.tl-seg.offline, .mini-tijdlijn .offline { background: var(--st-offline); }
.tl-seg.onbekend, .mini-tijdlijn .onbekend { background: var(--st-onbekend-bg); }
.tl-seg.offline, .tl-seg.waarschuwing { min-width: 2px; }
.tl-nu { position: absolute; top: -4px; bottom: -4px; right: 0; width: 2px; background: var(--ht-primary); }
.tl-assen { position: relative; height: 18px; font-size: .72rem; color: var(--ht-text-zacht); font-variant-numeric: tabular-nums; }
.tl-assen span { position: absolute; transform: translateX(-50%); top: 2px; }
.tl-cursor { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--ht-text); opacity: .6; pointer-events: none; }
.tl-tip {
  position: absolute; z-index: 5; bottom: calc(100% + 6px); transform: translateX(-50%);
  background: var(--ht-text); color: var(--ht-surface); font-size: .8rem; padding: 6px 10px; border-radius: 8px;
  white-space: nowrap; pointer-events: none; max-width: 90vw; overflow: hidden; text-overflow: ellipsis;
}
.tl-nav { display: flex; align-items: center; gap: 6px; }
.tl-legenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: .78rem; color: var(--ht-text-zacht); margin-top: 6px; }
.tl-legenda i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.periodes { margin-top: 10px; }
.periode { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-top: 1px solid var(--ht-rand); font-size: .88rem; }
.periode .tijd { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }

/* ---------- grafieken ---------- */
.grafiek { position: relative; width: 100%; height: 150px; margin-bottom: 6px; }
.grafiek svg { width: 100%; height: 100%; display: block; overflow: visible; }
.grafiek .as { stroke: var(--ht-rand); stroke-width: 1; }
.grafiek .astekst { fill: var(--ht-text-zacht); font-size: 11px; font-family: var(--ht-font); }
.grafiek .band { fill: var(--st-offline); opacity: .14; }
.grafiek .lijn { fill: none; stroke-width: 1.8; stroke-linejoin: round; }
.grafiek-titel { display: flex; gap: 12px; align-items: center; font-size: .85rem; margin: 10px 0 2px; }
.grafiek-titel .sleutel i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.grafiek-tip {
  position: absolute; pointer-events: none; background: var(--ht-surface); border: 1px solid var(--ht-rand);
  box-shadow: var(--ht-schaduw); border-radius: 8px; padding: 4px 8px; font-size: .78rem; white-space: nowrap; z-index: 4;
}

/* ---------- knoppen & formulieren ---------- */
.knop {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--ht-rand); background: var(--ht-surface); cursor: pointer; font-weight: 600;
  white-space: nowrap;
}
.knop:hover { border-color: var(--ht-accent); text-decoration: none; }
.knop.primair { background: var(--ht-primary); color: var(--ht-primary-tekst); border-color: var(--ht-primary); }
.knop.primair:hover { filter: brightness(1.1); }
.knop.gevaar { color: var(--st-offline-tekst); }
.knop.klein { min-height: 30px; padding: 0 10px; font-size: .85rem; }
.knop:disabled { opacity: .5; cursor: default; }
.knop svg { width: 18px; height: 18px; }
.knoppen { display: flex; gap: 8px; flex-wrap: wrap; }
.segment { display: inline-flex; border: 1px solid var(--ht-rand); border-radius: 9px; overflow: hidden; }
.segment button { border: 0; background: var(--ht-surface); padding: 5px 12px; cursor: pointer; font-size: .85rem; }
.segment button.aan { background: var(--ht-primary); color: var(--ht-primary-tekst); }
label.veld { display: block; margin-bottom: 12px; font-size: .88rem; }
label.veld span { display: block; margin-bottom: 4px; color: var(--ht-text-zacht); }
input[type=text], input[type=password], input[type=number], input[type=time], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--ht-rand);
  background: var(--ht-surface-2);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ht-accent); outline-offset: 0; }
.rij-velden { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.dagen { display: flex; gap: 4px; flex-wrap: wrap; }
.dagen label { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border: 1px solid var(--ht-rand); border-radius: 8px; font-size: .82rem; cursor: pointer; }
.melding { padding: 10px 12px; border-radius: 9px; background: var(--st-offline-bg); color: var(--st-offline-tekst); margin-bottom: 12px; font-size: .9rem; }
.melding.ok { background: var(--st-online-bg); color: var(--st-online-tekst); }
.melding.info { background: var(--ht-surface-2); color: var(--ht-text); }

/* ---------- details ---------- */
.detail-kop { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.detail-kop .hoofd { flex: 1; min-width: 200px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: .9rem; }
.kv dt { color: var(--ht-text-zacht); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.item { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--ht-rand); }
.item:first-child { border-top: 0; }
.item .hoofd { flex: 1; min-width: 0; }
.gebeurtenis { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--ht-rand); font-size: .88rem; }
.gebeurtenis:first-child { border-top: 0; }
.gebeurtenis .tijd { color: var(--ht-text-zacht); white-space: nowrap; font-variant-numeric: tabular-nums; min-width: 84px; }
.gebeurtenis .tekst { white-space: pre-line; overflow-wrap: anywhere; }
.gebeurtenis.fout .tekst { color: var(--st-offline-tekst); }
.gebeurtenis.waarschuwing .tekst { color: var(--st-waarschuwing-tekst); }
.geheim { font-family: Consolas, ui-monospace, monospace; letter-spacing: .1em; }
.raster-2 { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 1400px) { .raster-2 { grid-template-columns: 1fr 1fr; } }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .kaart { width: 100%; max-width: 380px; padding: 28px 24px; }
.login .logo { height: 64px; margin: 0 auto 6px; }
.login h1 { text-align: center; color: var(--ht-primary); margin-bottom: 18px; font-size: 1.1rem; }

/* ---------- dialoog ---------- */
dialog {
  border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  background: var(--ht-surface); color: var(--ht-text); box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(13, 19, 36, .55); }
.dialoog-kop { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--ht-rand); }
.dialoog-kop h2 { flex: 1; }
.dialoog-inhoud { padding: 16px; overflow-y: auto; max-height: calc(100vh - 180px); }
.dialoog-voet { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--ht-rand); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; background: var(--ht-text); color: var(--ht-surface);
  padding: 10px 16px; border-radius: 10px; font-size: .9rem; box-shadow: 0 6px 24px rgba(0,0,0,.25); max-width: calc(100vw - 32px);
}
.tabel { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tabel th { text-align: left; font-weight: 600; color: var(--ht-text-zacht); font-size: .78rem; padding: 6px 8px; border-bottom: 1px solid var(--ht-rand); }
.tabel td { padding: 8px; border-bottom: 1px solid var(--ht-rand); vertical-align: middle; }
.scroll-x { overflow-x: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--ht-rand); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 12px; cursor: pointer; color: var(--ht-text-zacht); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.aan { color: var(--ht-primary); border-bottom-color: var(--ht-primary); }
.periode .zacht { white-space: nowrap; }
