/* ── Custom properties ───────────────────────────────────────────── */
:root {
  --kleur-primair:     #1A1A2E;
  --kleur-accent:      #2C5F8A;
  --kleur-accent-h:    #1e4a6e;
  --kleur-licht:       #EEF2F7;
  --kleur-achtergrond: #F8FAFC;
  --kleur-oppervlak:   #FFFFFF;
  --kleur-tekst:       #1A1A2E;
  --kleur-tekst-sub:   #6B7280;
  --kleur-rand:        #D1D9E0;
  --kleur-groen:       #2E7D52;
  --kleur-blauw:       #2C5F8A;
  --kleur-oranje:      #D97706;
  --kleur-rood:        #C0392B;
  --font:              system-ui, -apple-system, sans-serif;
  --radius:            8px;
  --shadow:            0 1px 3px rgba(0,0,0,.1);
}

[data-theme="donker"] {
  --kleur-achtergrond: #0F0F1A;
  --kleur-oppervlak:   #1A1A2E;
  --kleur-tekst:       #F1F5F9;
  --kleur-tekst-sub:   #94A3B8;
  --kleur-rand:        #2D3748;
}

/* ── Reset & basis ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--kleur-achtergrond);
  color: var(--kleur-tekst);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--kleur-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navigatie ───────────────────────────────────────────────────── */
.nav {
  background: var(--kleur-primair);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.nav-logo {
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  letter-spacing: .03em;
}
.nav-logo:hover { text-decoration: none; opacity: .85; }

.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-links a {
  color: rgba(255,255,255,.85);
  font-size: .9rem;
}
.nav-links a:hover,
.nav-links a.actief { color: #fff; text-decoration: none; }
.nav-links a.actief { border-bottom: 2px solid var(--kleur-accent); padding-bottom: 2px; }

.nav-burger { display: none; }

.knop-thema {
  background: none;
  border: none;
  color: rgba(255,255,255,.8);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
}
.knop-thema:hover { color: #fff; }

/* ── Mobiel nav ──────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .nav-burger {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
  }
  .nav-burger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
  }
  .nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--kleur-primair);
    padding: .5rem 0;
  }
  .nav-links.is-open { display: flex; }
  .nav-links li { width: 100%; }
  .nav-links a { display: block; padding: .75rem 1.5rem; }
}

/* ── Hoofd ───────────────────────────────────────────────────────── */
.hoofd {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Meldingen (flash) ───────────────────────────────────────────── */
.melding {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.melding--fout    { background: #fee2e2; color: var(--kleur-rood); border: 1px solid #fca5a5; }
.melding--succes  { background: #d1fae5; color: var(--kleur-groen); border: 1px solid #6ee7b7; }
.melding--info    { background: #dbeafe; color: var(--kleur-blauw); border: 1px solid #93c5fd; }

/* ── Knoppen ─────────────────────────────────────────────────────── */
.knop {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: .9rem;
  font-family: var(--font);
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.knop--primair  { background: var(--kleur-accent); color: #fff; }
.knop--primair:hover { background: var(--kleur-accent-h); text-decoration: none; }
.knop--secundair { background: var(--kleur-oppervlak); color: var(--kleur-tekst); border-color: var(--kleur-rand); }
.knop--secundair:hover { background: var(--kleur-licht); }
.knop--gevaar   { background: var(--kleur-rood); color: #fff; }
.knop--gevaar:hover { opacity: .88; }
.knop--vol      { width: 100%; justify-content: center; }

/* ── Formuliervelden ─────────────────────────────────────────────── */
.veld { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.veld label { font-size: .85rem; font-weight: 600; color: var(--kleur-tekst-sub); }
.veld input,
.veld select,
.veld textarea {
  padding: .55rem .75rem;
  border: 1px solid var(--kleur-rand);
  border-radius: var(--radius);
  background: var(--kleur-oppervlak);
  color: var(--kleur-tekst);
  font-family: var(--font);
  font-size: .95rem;
  transition: border-color .15s;
}
.veld input:focus,
.veld select:focus,
.veld textarea:focus { outline: none; border-color: var(--kleur-accent); }

/* ── Login ───────────────────────────────────────────────────────── */
.login-wrap {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-kaart {
  background: var(--kleur-oppervlak);
  border: 1px solid var(--kleur-rand);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
}
.login-titel { font-size: 1.5rem; font-weight: 700; margin-bottom: .25rem; }
.login-sub   { color: var(--kleur-tekst-sub); font-size: .9rem; margin-bottom: 1.75rem; }

/* ── Kaart ───────────────────────────────────────────────────────── */
.kaart {
  background: var(--kleur-oppervlak);
  border: 1px solid var(--kleur-rand);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
.kaart-titel { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; }
.kaart-rij   { font-size: .9rem; }

/* ── Portaal ─────────────────────────────────────────────────────── */
.portaal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.portaal-titel { font-size: 1.4rem; font-weight: 700; }
.portaal-sub   { color: var(--kleur-tekst-sub); font-size: .85rem; margin-top: .15rem; }

/* ── Tabs ────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 2px solid var(--kleur-rand);
  margin-bottom: 1.75rem;
}
.tab-knop {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: .6rem 1.1rem;
  font-size: .9rem;
  font-family: var(--font);
  color: var(--kleur-tekst-sub);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.tab-knop:hover    { color: var(--kleur-tekst); }
.tab-knop.actief   { color: var(--kleur-accent); border-bottom-color: var(--kleur-accent); font-weight: 600; }

[x-cloak] { display: none !important; }

/* ── KPI blokken ─────────────────────────────────────────────────── */
.kpi-raster {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
}
@media (max-width: 640px) {
  .kpi-raster { grid-template-columns: repeat(2, 1fr); }
}

.kpi-blok {
  background: var(--kleur-oppervlak);
  border: 1px solid var(--kleur-rand);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  text-align: center;
}
.kpi-waarde {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--kleur-tekst);
}
.kpi-label  { font-size: .78rem; color: var(--kleur-tekst-sub); text-transform: uppercase; letter-spacing: .05em; }

.kpi--groen { color: var(--kleur-groen); }
.kpi--blauw { color: var(--kleur-accent); }
.kpi--oranje{ color: var(--kleur-oranje); }
.kpi--rood  { color: var(--kleur-rood); }
.kpi--sub   { color: var(--kleur-tekst-sub); }

/* ── Trend kaarten ───────────────────────────────────────────────── */
.trend-rij {
  display: flex;
  gap: .75rem;
  margin-top: .75rem;
  flex-wrap: wrap;
}
.trend-kaart {
  flex: 1;
  min-width: 140px;
  background: var(--kleur-oppervlak);
  border: 1px solid var(--kleur-rand);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.trend-kaart--groen { border-left: 4px solid var(--kleur-groen); }
.trend-kaart--rood  { border-left: 4px solid var(--kleur-rood); }
.trend-getal { font-size: 1.5rem; font-weight: 700; }
.trend-lbl   { font-size: .8rem; color: var(--kleur-tekst-sub); }
.trend-kaart--groen .trend-getal { color: var(--kleur-groen); }
.trend-kaart--rood  .trend-getal { color: var(--kleur-rood); }

/* ── Badges ──────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
}
.badge--groen { background: #d1fae5; color: var(--kleur-groen); }
.badge--rood  { background: #fee2e2; color: var(--kleur-rood); }
.badge--grijs { background: var(--kleur-licht); color: var(--kleur-tekst-sub); }

/* ── Placeholder (tijdelijk) ─────────────────────────────────────── */
.placeholder {
  padding: 3rem;
  text-align: center;
  color: var(--kleur-tekst-sub);
  font-style: italic;
}

/* ── Positietabel ────────────────────────────────────────────────── */
.tabel-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: .75rem;
}
.tabel-zoek {
  padding: .45rem .75rem;
  border: 1px solid var(--kleur-rand);
  border-radius: var(--radius);
  background: var(--kleur-oppervlak);
  color: var(--kleur-tekst);
  font-family: var(--font);
  font-size: .9rem;
  width: 260px;
}
.tabel-zoek:focus { outline: none; border-color: var(--kleur-accent); }
.tabel-teller { font-size: .82rem; color: var(--kleur-tekst-sub); }

.tabel-wrap { overflow-x: auto; }

.pos-tabel {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.pos-tabel thead th {
  background: var(--kleur-primair);
  color: #fff;
  padding: .55rem .75rem;
  text-align: left;
  white-space: nowrap;
  user-select: none;
}
.th-sorteer { cursor: pointer; }
.th-sorteer:hover { background: var(--kleur-accent); }
.th-pos { width: 70px; text-align: center; }
.th-url { width: 220px; }
.th-term { min-width: 200px; }

.pos-tabel tbody tr {
  border-bottom: 1px solid var(--kleur-rand);
  transition: background .1s;
}
.pos-tabel tbody tr:hover { background: var(--kleur-licht); }
.tabel-rij-klikbaar { cursor: pointer; }
.tabel-rij-klikbaar:hover { background: var(--kleur-licht) !important; }
.td-acties { text-align: right; white-space: nowrap; padding: .45rem .75rem; }
.rij--top10 { background: #f0fdf4 !important; }
[data-theme="donker"] .rij--top10 { background: #0d2818 !important; }
.rij--top10:hover { background: #dcfce7 !important; }
[data-theme="donker"] .rij--top10:hover { background: #14391f !important; }

.td-term {
  padding: .55rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .1rem;
}
.matched-query {
  font-size: .75rem;
  color: var(--kleur-tekst-sub);
  font-style: italic;
}
.td-pos {
  padding: .55rem .5rem;
  text-align: center;
  font-weight: 600;
  white-space: nowrap;
}
.td-pos--nu { font-size: 1rem; }
.td-url {
  padding: .55rem .75rem;
  font-size: .8rem;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.td-url a { color: var(--kleur-tekst-sub); }
.td-url a:hover { color: var(--kleur-accent); }
.td-leeg {
  padding: 2rem;
  text-align: center;
  color: var(--kleur-tekst-sub);
  font-style: italic;
}

/* Positiekleur-klassen */
.pos--groen  { color: var(--kleur-groen); }
.pos--blauw  { color: var(--kleur-accent); }
.pos--oranje { color: var(--kleur-oranje); }
.pos--rood   { color: var(--kleur-rood); }
.pos--geen   { color: var(--kleur-tekst-sub); }

/* Trend-klassen (in de tabel) */
.trend--groen { color: var(--kleur-groen); font-weight: 700; }
.trend--rood  { color: var(--kleur-rood);  font-weight: 700; }
.trend--geen  { color: var(--kleur-tekst-sub); }

/* Sorteer-icoon */
.sort-icon        { opacity: .35; font-size: .75rem; margin-left: .2rem; }
.sort-icon--actief{ opacity: 1; color: #fff; }

/* Legenda onder de tabel */
.legenda {
  margin-top: .6rem;
  font-size: .78rem;
  color: var(--kleur-tekst-sub);
}

/* ── Grafiek tab ─────────────────────────────────────────────────── */
.grafiek-wrap {
  background: var(--kleur-oppervlak);
  border: 1px solid var(--kleur-rand);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  max-height: 420px;
}
.grafiek-toolbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}

.grafiek-legenda {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .35rem .5rem;
  max-height: 260px;
  overflow-y: auto;
  padding: .5rem;
  background: var(--kleur-oppervlak);
  border: 1px solid var(--kleur-rand);
  border-radius: var(--radius);
}
.grafiek-label {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .3rem .5rem;
  border-radius: 5px;
  cursor: pointer;
  font-size: .83rem;
  color: var(--kleur-tekst-sub);
  transition: background .1s;
}
.grafiek-label:hover { background: var(--kleur-licht); }
.grafiek-label--actief { color: var(--kleur-tekst); font-weight: 500; }

.grafiek-check { display: none; }

.grafiek-kleurbol {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: .35;
  transition: opacity .1s;
}
.grafiek-label--actief .grafiek-kleurbol { opacity: 1; }

.grafiek-termnaam {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.grafiek-pos {
  font-weight: 700;
  font-size: .8rem;
  min-width: 24px;
  text-align: right;
}

/* ── Stap-indicator ─────────────────────────────────────────────── */
.stap-indicator {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 1.25rem 0 .25rem;
}
.stap {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .82rem;
  color: var(--kleur-tekst-sub);
}
.stap-nr {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--kleur-rand);
  color: var(--kleur-tekst-sub);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
  flex-shrink: 0;
}
.stap--klaar .stap-nr  { background: var(--kleur-groen); color: #fff; }
.stap--actief .stap-nr { background: var(--kleur-accent); color: #fff; }
.stap--klaar  { color: var(--kleur-groen); }
.stap--actief { color: var(--kleur-accent); font-weight: 600; }
.stap-lijn {
  flex: 1; height: 2px;
  background: var(--kleur-rand);
  margin: 0 .5rem;
  min-width: 24px;
}

/* ── Tag chips ───────────────────────────────────────────────────── */
.tag-chip {
  display: inline-block;
  padding: .15rem .5rem;
  background: var(--kleur-licht);
  border: 1px solid var(--kleur-rand);
  border-radius: 999px;
  font-size: .75rem;
  color: var(--kleur-tekst-sub);
}

/* ── Project-selector (klantportaal) ────────────────────────────── */
.project-selector {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  align-items: center;
}
.project-knop {
  padding: .35rem .75rem;
  border-radius: var(--radius);
  border: 1px solid var(--kleur-rand);
  background: var(--kleur-oppervlak);
  color: var(--kleur-tekst-sub);
  font-size: .82rem;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.project-knop:hover { background: var(--kleur-licht); color: var(--kleur-tekst); text-decoration: none; }
.project-knop--actief { background: var(--kleur-accent); color: #fff; border-color: var(--kleur-accent); font-weight: 600; }
.project-knop--actief:hover { background: var(--kleur-accent-h); color: #fff; }

/* ── Admin layout ────────────────────────────────────────────────── */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: .75rem;
}
.admin-acties { display: flex; gap: .5rem; flex-wrap: wrap; }
.admin-raster {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 768px) { .admin-raster { grid-template-columns: 1fr; } }

/* Zoektermen editor */
.zoek-textarea {
  width: 100%;
  font-family: 'Menlo', 'Monaco', monospace;
  font-size: .82rem;
  line-height: 1.5;
  padding: .6rem .75rem;
  border: 1px solid var(--kleur-rand);
  border-radius: var(--radius);
  background: var(--kleur-achtergrond);
  color: var(--kleur-tekst);
  resize: vertical;
}
.zoek-textarea:focus { outline: none; border-color: var(--kleur-accent); }
.zoek-dl { display: grid; grid-template-columns: auto 1fr; gap: .35rem .75rem; font-size: .88rem; }
.zoek-dl dt { color: var(--kleur-tekst-sub); }
.zoek-dl dd { font-weight: 700; }
.zoek-formaat {
  font-family: 'Menlo', 'Monaco', monospace;
  font-size: .78rem;
  background: var(--kleur-achtergrond);
  border: 1px solid var(--kleur-rand);
  border-radius: var(--radius);
  padding: .6rem .75rem;
  white-space: pre;
  overflow-x: auto;
}

/* ── Rapporten tab ───────────────────────────────────────────────── */
.rap-kaart { margin-bottom: 1rem; }

.rap-recent {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.rap-datum   { font-weight: 700; font-size: 1.05rem; }
.rap-bestand { font-size: .8rem; color: var(--kleur-tekst-sub); margin-top: .15rem; }

.rap-info {
  font-size: .9rem;
  color: var(--kleur-tekst-sub);
  margin-bottom: .85rem;
}

.rap-lijst { list-style: none; display: flex; flex-direction: column; gap: .4rem; }
.rap-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .75rem;
  background: var(--kleur-achtergrond);
  border: 1px solid var(--kleur-rand);
  border-radius: var(--radius);
}
.rap-item-datum { font-size: .82rem; color: var(--kleur-tekst-sub); min-width: 90px; }
.rap-item-link  { flex: 1; font-size: .82rem; color: var(--kleur-tekst-sub);
                  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rap-item-link:hover { color: var(--kleur-accent); }
.rap-item-knop  { padding: .25rem .6rem; font-size: .82rem; }

/* Toggle schakelaar */
.maand-toggle {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  cursor: pointer;
}
.toggle-wrap     { flex-shrink: 0; position: relative; width: 44px; height: 24px; }
.toggle-input    { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--kleur-rand);
  border-radius: 24px;
  transition: background .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.toggle-input:checked + .toggle-slider { background: var(--kleur-accent); }
.toggle-input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle-tekst { font-size: .9rem; line-height: 1.5; padding-top: .15rem; }
