* { box-sizing: border-box; margin: 0; padding: 0; border-radius: 0; }

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--plane);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  overflow-x: clip;
  min-height: 100vh;
}
::selection { background: var(--accent); color: var(--accent-ink); }

/* ---------- bovenbalk ---------- */
.top {
  position: sticky; top: 0; z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: clip;
}
.top-in {
  max-width: 1180px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 22px; min-height: 58px;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex: 0 0 auto; }
.logo-mark { width: 20px; height: 20px; display: block; }
.logo-txt { font-weight: 640; letter-spacing: .13em; font-size: 13px; text-transform: uppercase; }
nav { display: flex; gap: 2px; flex: 1 1 auto; overflow-x: auto; scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
nav a {
  color: var(--ink-2); text-decoration: none; font-size: 13.5px; font-weight: 500;
  padding: 8px 12px; white-space: nowrap; border-bottom: 2px solid transparent;
}
nav a:hover { color: var(--ink); background: var(--shade); }
nav a.on { color: var(--ink); border-bottom-color: var(--accent); }
.top-right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

.live { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.live.on .dot { background: var(--good); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }
@media (prefers-reduced-motion: reduce) { .live.on .dot { animation: none } }

/* ---------- pagina ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 26px 20px 80px; }
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
h1 { font-size: 21px; font-weight: 620; letter-spacing: -.01em; }
h2 { font-size: 14px; font-weight: 600; letter-spacing: .02em; }
.sub { color: var(--muted); font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--border); padding: 18px; }
.card > h2 { margin-bottom: 4px; }
.card > h2 + .sub { margin-bottom: 14px; }

.grid { display: grid; gap: 14px; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1100px) { .g5 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) { .g3, .g4, .g5 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .g3, .g4, .g5, .g2 { grid-template-columns: 1fr; } }

/* ---------- knoppenrij ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.seg { display: inline-flex; border: 1px solid var(--border); background: var(--surface); overflow: hidden; max-width: 100%; flex-wrap: wrap; }
.seg button {
  font: inherit; font-size: 12.5px; color: var(--ink-2); background: none; border: 0;
  padding: 7px 12px; cursor: pointer; white-space: nowrap; border-right: 1px solid var(--border);
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--shade); color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-right: 2px; align-self: center; }

button.btn {
  font: inherit; font-size: 13px; padding: 8px 14px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); font-weight: 560;
}
button.btn.ghost { background: none; color: var(--ink-2); border-color: var(--border); }
button.btn.ghost:hover { background: var(--shade); color: var(--ink); }
button.btn:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  font: inherit; font-size: 13.5px; background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--border); padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }

/* ---------- meters ---------- */
.gauge { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 18px 16px 16px; }
.gauge-svg { width: 100%; max-width: 210px; height: auto; display: block; }
.gauge-name { font-size: 12.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.gauge-meta { font-size: 12px; color: var(--muted); margin-top: 8px; min-height: 32px; }
.gauge-tag { font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--border); padding: 2px 6px; display: inline-block; margin-top: 8px; }

/* ---------- stat-tegels ---------- */
.stat { padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 27px; font-weight: 620; letter-spacing: -.02em; margin-top: 4px; line-height: 1.1; }
.stat .u { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 3px; }
.stat .d { font-size: 12px; margin-top: 5px; color: var(--muted); }
.stat .d b { font-weight: 600; }
.up { color: var(--good); }
.down { color: var(--crit); }

/* De enige afgeronde hoek op de pagina: rechtsboven op het accentblok. */
.accent-block { border-top-right-radius: 18px; }

/* ---------- grafieken ---------- */
.chart-wrap { position: relative; width: 100%; overflow-x: auto; }
svg.chart { display: block; width: 100%; height: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; font-size: 12.5px; color: var(--ink-2); }
.legend i { width: 10px; height: 10px; display: inline-block; margin-right: 7px; vertical-align: -1px; }
.tip {
  position: absolute; pointer-events: none; z-index: 20;
  background: var(--raise); border: 1px solid var(--border); color: var(--ink);
  padding: 8px 10px; font-size: 12.5px; min-width: 120px; box-shadow: 0 6px 20px rgba(0,0,0,.28);
  opacity: 0; transition: opacity .1s linear;
}
.tip.on { opacity: 1; }
.tip .th { font-weight: 620; margin-bottom: 5px; }
.tip .tr { display: flex; justify-content: space-between; gap: 14px; }
.tip .tr span:last-child { font-variant-numeric: tabular-nums; }

/* ---------- tabel ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
td { font-variant-numeric: tabular-nums; color: var(--ink-2); }
td:first-child { color: var(--ink); font-variant-numeric: normal; }
tbody tr:hover { background: var(--shade); }
.table-scroll { overflow-x: auto; }

.bar-row { display: grid; grid-template-columns: minmax(88px, 168px) 1fr auto; gap: 14px; align-items: center; padding: 7px 0; }
.bar-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 14px; background: var(--surface-2); position: relative; }
.bar-fill { height: 100%; }
.bar-val { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-row.click { cursor: pointer; }
.bar-row.click:hover .bar-name { color: var(--accent); }

.note { font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.note b { color: var(--ink-2); font-weight: 600; }
.spacer { height: 22px; }
.hr { height: 1px; background: var(--border); margin: 22px 0; }

.badge { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; padding: 2px 7px; border: 1px solid var(--border); color: var(--muted); }
.badge.est { border-color: var(--warn); color: var(--warn); }

/* ---------- inloggen ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-box { width: 100%; max-width: 330px; background: var(--surface); border: 1px solid var(--border); padding: 26px; }
.gate-box h1 { font-size: 17px; margin-bottom: 6px; }
.err { color: var(--crit); font-size: 12.5px; margin-top: 10px; min-height: 18px; }

/* ---------- thema-kiezer ---------- */
.theme-pop { position: relative; }
.theme-menu {
  position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface);
  border: 1px solid var(--border); padding: 6px; display: none; min-width: 178px;
  box-shadow: 0 10px 34px rgba(0,0,0,.3); z-index: 60;
}
.theme-menu.on { display: block; }
.theme-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; font: inherit; font-size: 13px;
  background: none; border: 0; color: var(--ink-2); padding: 7px 9px; cursor: pointer; text-align: left;
}
.theme-menu button:hover { background: var(--shade); color: var(--ink); }
.theme-menu button[aria-pressed="true"] { color: var(--ink); font-weight: 600; }
.swatch { width: 30px; height: 14px; display: flex; border: 1px solid var(--border); flex: 0 0 auto; }
.swatch i { flex: 1; }
.icon-btn { background: none; border: 1px solid var(--border); color: var(--ink-2); padding: 6px 9px; cursor: pointer; font: inherit; font-size: 12.5px; }
.icon-btn:hover { background: var(--shade); color: var(--ink); }

@media (max-width: 620px) {
  .top-in { gap: 12px; padding: 0 14px; min-height: 52px; }
  main { padding: 18px 14px 70px; }
  .logo-txt { display: none; }
  .live span:not(.dot) { display: none; }
  .stat .v { font-size: 23px; }
  .bar-row { grid-template-columns: minmax(72px, 110px) 1fr auto; gap: 10px; }
}
