/* ==========================================================================
   Luchtwasser dashboard
   ========================================================================== */
:root {
  --bg: #f3f6f5;
  --bg-accent-1: rgba(52, 211, 153, .18);
  --bg-accent-2: rgba(14, 116, 144, .14);
  --surface: #ffffff;
  --surface-2: #f7faf9;
  --border: #e3e9e7;
  --text: #0f1f1c;
  --muted: #5d706b;
  --accent: #0f766e;
  --accent-2: #14b8a6;
  --accent-soft: rgba(20, 184, 166, .12);
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(16, 40, 34, .04), 0 8px 24px rgba(16, 40, 34, .06);
  --shadow-lg: 0 24px 60px rgba(16, 40, 34, .18);
  --radius: 18px;
  --radius-sm: 10px;
  --grid: rgba(15, 31, 28, .07);

  --st-ok: #22c55e;
  --st-rein: #38bdf8;
  --st-ond: #f59e0b;
  --st-bg: #64748b;
  --st-err: #ef4444;
  --st-leeg: #cbd5d1;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1412;
    --bg-accent-1: rgba(52, 211, 153, .10);
    --bg-accent-2: rgba(14, 116, 144, .16);
    --surface: #111d1a;
    --surface-2: #0e1816;
    --border: #1f2f2b;
    --text: #e6f0ed;
    --muted: #8ea39d;
    --accent: #2dd4bf;
    --accent-2: #14b8a6;
    --accent-soft: rgba(45, 212, 191, .12);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
    --grid: rgba(230, 240, 237, .07);
    --st-leeg: #2a3a36;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--bg-accent-1), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, var(--bg-accent-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 0; height: 0; overflow: hidden; }
.muted { color: var(--muted); }
.center { text-align: center; }
h1, h2 { margin: 0; letter-spacing: -.02em; }
h1 { font-size: 28px; font-weight: 800; }
h2 { font-size: 15px; font-weight: 700; }
small { font-weight: 500; color: var(--muted); }

/* ---------- Knoppen & velden ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
}
.btn:hover { border-color: var(--accent-2); box-shadow: 0 4px 14px rgba(20, 184, 166, .18); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.primary {
  background: linear-gradient(135deg, #10b981, #0e7490);
  color: #fff; border-color: transparent;
}
.btn.primary:hover { box-shadow: 0 8px 22px rgba(14, 116, 144, .35); }
.btn.ghost { background: transparent; }
.btn-block { width: 100%; justify-content: center; height: 44px; }
.btn[disabled] { opacity: .55; cursor: default; }

.input, .select, .field input {
  height: 38px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font: inherit;
}
.input:focus, .select:focus, .field input:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; font-weight: 600; }
.field input { height: 44px; width: 100%; }
.form-error { color: var(--danger); margin: 0 0 12px; font-weight: 500; }

/* ---------- Aanmelden ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.login-bg span {
  position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55;
  animation: zweef 18s ease-in-out infinite alternate;
}
.login-bg span:nth-child(1) { width: 480px; height: 480px; background: #34d399; top: -120px; left: -80px; }
.login-bg span:nth-child(2) { width: 420px; height: 420px; background: #0e7490; bottom: -140px; right: -60px; animation-delay: -6s; }
.login-bg span:nth-child(3) { width: 300px; height: 300px; background: #a7f3d0; top: 40%; left: 55%; animation-delay: -12s; opacity: .35; }
@keyframes zweef { to { transform: translate(60px, 40px) scale(1.1); } }
.login-card {
  position: relative; width: min(400px, 100%);
  padding: 36px 32px 28px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow-lg);
}
.login-card .brand { margin-bottom: 28px; }
.hint { color: var(--muted); font-size: 13px; margin: 18px 0 0; text-align: center; }

/* ---------- Topbalk ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; flex: none; }
.brand-lg .logo { width: 52px; height: 52px; }
.brand-title { font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.brand-lg .brand-title { font-size: 22px; }
.brand-sub { color: var(--muted); font-size: 12.5px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--border);
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.demo-badge { font-weight: 800; font-size: 11px; letter-spacing: .08em; padding: 4px 10px; border-radius: 999px; background: #f59e0b; color: #1c1300; }
.menu { position: relative; }
.menu-btn { padding: 0 12px 0 4px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, #34d399, #0e7490); color: #fff; font-weight: 800; font-size: 13px;
}
.menu-email { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
}
.menu-list button {
  display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-radius: 10px;
  background: none; color: var(--text); font: inherit; cursor: pointer;
}
.menu-list button:hover { background: var(--accent-soft); }

.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 50; overflow: hidden; }
.progress span { display: block; height: 100%; width: 40%; background: linear-gradient(90deg, #34d399, #0e7490); animation: laad 1.1s ease-in-out infinite; }
@keyframes laad { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* ---------- Inhoud ---------- */
.wrap { max-width: 1320px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 40px) 40px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.wrap > *, .charts > * { min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }

.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.hero p { margin: 6px 0 0; }
.laatste {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow); font-weight: 600;
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--st-ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--st-ok) 22%, transparent); }
.dot.oud { background: var(--st-ond); box-shadow: 0 0 0 4px color-mix(in srgb, var(--st-ond) 22%, transparent); }

/* KPI-kaarten */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 16px 0; display: flex; flex-direction: column; min-height: 140px;
}
.kpi::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--kleur, var(--accent-2)); }
.kpi-label { color: var(--muted); font-weight: 600; font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.kpi-waarde { font-size: 28px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.kpi-waarde small { font-size: 13px; font-weight: 600; margin-left: 4px; }
.kpi-sub { color: var(--muted); font-size: 12px; }
.kpi-spark { height: 44px; margin: auto -16px 0; }
.kpi-status { justify-content: space-between; padding-bottom: 16px; }
.kpi-status .pill { align-self: flex-start; font-size: 14px; padding: 6px 12px; margin-top: 8px; }

/* Filters */
.filters { display: grid; gap: 16px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: flex-end; }
.filter-group { display: grid; gap: 8px; }
.filter-group.grow { flex: 1; }
.filter-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; transition: all .15s ease;
}
.chip:hover { border-color: var(--accent-2); }
.chip.actief { background: var(--accent-soft); border-color: var(--accent-2); color: var(--accent); }
.chip .kleur { width: 9px; height: 9px; border-radius: 50%; background: var(--kleur); opacity: .35; }
.chip.actief .kleur { opacity: 1; }
.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; }
.segmented button {
  height: 30px; padding: 0 16px; border: 0; border-radius: 999px; background: none; color: var(--muted);
  font: inherit; font-weight: 600; cursor: pointer;
}
.segmented button.actief { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.filter-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 14px; border-top: 1px dashed var(--border); }
.periode-label { font-weight: 700; }
.actions { display: flex; gap: 10px; }

/* Samenvatting */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat-waarde { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }
.meter { height: 6px; border-radius: 99px; background: var(--surface-2); margin-top: 10px; overflow: hidden; border: 1px solid var(--border); }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, #34d399, #0e7490); border-radius: 99px; }

/* Statusbalk */
.timeline { display: flex; height: 30px; border-radius: 10px; overflow: hidden; background: var(--st-leeg); gap: 1px; }
.seg { min-width: 1px; transition: filter .15s ease; }
.seg:hover { filter: brightness(1.15) saturate(1.2); }
.timeline-as { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.st-operationeel   { background: var(--st-ok); }
.st-in_reiniging   { background: var(--st-rein); }
.st-onderhoud      { background: var(--st-ond); }
.st-buiten_gebruik { background: var(--st-bg); }
.st-storing        { background: var(--st-err); }
.st-leeg           { background: var(--st-leeg); }
.st-toekomst       { background: repeating-linear-gradient(135deg, var(--surface-2) 0 6px, var(--st-leeg) 6px 8px); }
.kpi-klein         { font-size: 18px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-weight: 700; font-size: 12px; white-space: nowrap; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.operationeel   { color: #15803d; background: color-mix(in srgb, var(--st-ok) 16%, transparent); }
.pill.in_reiniging   { color: #0369a1; background: color-mix(in srgb, var(--st-rein) 18%, transparent); }
.pill.onderhoud      { color: #b45309; background: color-mix(in srgb, var(--st-ond) 18%, transparent); }
.pill.buiten_gebruik { color: #475569; background: color-mix(in srgb, var(--st-bg) 18%, transparent); }
.pill.storing        { color: #b91c1c; background: color-mix(in srgb, var(--st-err) 16%, transparent); }
@media (prefers-color-scheme: dark) {
  .pill.operationeel { color: #4ade80; } .pill.in_reiniging { color: #7dd3fc; } .pill.onderhoud { color: #fbbf24; }
  .pill.buiten_gebruik { color: #cbd5e1; } .pill.storing { color: #f87171; }
}

/* Grafieken */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 20px; }
.chart-card .card-head { margin-bottom: 6px; }
.chart-titel { display: flex; align-items: center; gap: 10px; }
.chart-titel i { width: 10px; height: 10px; border-radius: 50%; background: var(--kleur); box-shadow: 0 0 0 4px color-mix(in srgb, var(--kleur) 20%, transparent); }
.chart-kerncijfers { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.chart-kerncijfers b { color: var(--text); }
.chart-box { position: relative; height: 230px; }
.leeg { display: grid; place-items: center; height: 100%; color: var(--muted); }

/* Tabel */
.table-wrap { overflow: auto; max-height: 620px; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; }
th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
th .eenheid { text-transform: none; letter-spacing: 0; font-weight: 500; }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
tbody tr:hover td { background: var(--accent-soft); }
td .bereik { display: block; color: var(--muted); font-size: 11.5px; }
td.links { text-align: left; }

/* Dialoog & toast */
.dialog { border: 1px solid var(--border); border-radius: 20px; padding: 28px; width: min(420px, 92vw); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.dialog::backdrop { background: rgba(5, 15, 12, .45); backdrop-filter: blur(3px); }
.dialog h2 { margin-bottom: 18px; font-size: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 60; max-width: 420px;
  padding: 12px 18px; border-radius: 14px; background: #0f1f1c; color: #fff; box-shadow: var(--shadow-lg); font-weight: 600;
}
.toast.fout { background: #b91c1c; }

.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; max-width: 1320px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px) 32px; color: var(--muted); font-size: 12px; }

@media (max-width: 640px) {
  .charts { grid-template-columns: 1fr; }
  .menu-email { display: none; }
  h1 { font-size: 22px; }
  .filter-actions .actions { width: 100%; }
  .filter-actions .btn { flex: 1; justify-content: center; }
}

/* ---------- Afdrukrapport ---------- */
.rapport { display: none; }
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body { background: #fff !important; color: #000; font-size: 10.5px; }
  #app, #login, .toast, dialog { display: none !important; }
  .rapport { display: block; color: #000; }
  .rapport h1 { font-size: 20px; }
  .rapport h2 { font-size: 13px; margin: 16px 0 6px; }
  .rapport .r-kop { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #0e7490; padding-bottom: 10px; margin-bottom: 12px; }
  .rapport .r-meta { text-align: right; color: #333; }
  .rapport table { width: 100%; border-collapse: collapse; }
  .rapport th, .rapport td { border: 1px solid #ccd6d3; padding: 3px 6px; position: static; background: none !important; color: #000; }
  .rapport th { background: #eef4f2 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rapport .r-grafieken { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .rapport .r-grafieken figure { margin: 0; border: 1px solid #ccd6d3; padding: 6px; break-inside: avoid; }
  .rapport .r-grafieken figcaption { font-weight: 700; margin-bottom: 4px; }
  .rapport .r-grafieken img { width: 100%; }
  .rapport tr { break-inside: avoid; }
  .rapport .r-voet { margin-top: 12px; color: #555; font-size: 9px; }
}
