:root {
  --blauw: #2f6fed;
  --blauw-licht: #e6efff;
  --groen: #2e9e5b;
  --rood: #e03b3b;
  --rood-licht: #ffe3e3;
  --grijs: #6b7280;
  --grijs-licht: #f1f3f7;
  --rand: #d8dce6;
  --jongen: #2f6fed;
  --meisje: #d6457f;
  --tekst: #1f2430;
  --radius: 12px;
  --schaduw: 0 2px 8px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f6f7fb;
  color: var(--tekst);
  font-size: 15px;
  line-height: 1.3;
}

/* ---------- Header ---------- */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid var(--rand);
  position: sticky;
  top: 0;
  z-index: 10;
}
header h1 { font-size: 18px; margin: 0; }

.tabs { display: flex; gap: 8px; }
.tab {
  border: none;
  background: var(--grijs-licht);
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  color: var(--grijs);
  cursor: pointer;
}
.tab.actief { background: var(--blauw); color: #fff; }

.backup-knoppen { margin-left: auto; display: flex; gap: 8px; }
.btn-klein {
  border: 1px solid var(--rand);
  background: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.btn-klein:hover { background: var(--grijs-licht); }

/* ---------- Tab inhoud ---------- */
.tab-inhoud { display: none; padding: 12px; max-width: 1100px; margin: 0 auto; }
.tab-inhoud.actief { display: block; }

.kaart {
  background: #fff;
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
  box-shadow: var(--schaduw);
}
.kaart h2 { margin: 0 0 10px; font-size: 16px; }
.kaart h2 small, h1 small { font-weight: 400; color: var(--grijs); font-size: 14px; }

/* ---------- Tellers ---------- */
.tellers { display: flex; gap: 14px; justify-content: space-around; }
.teller { text-align: center; flex: 1; }
.teller span { display: block; font-size: 30px; font-weight: 700; color: var(--blauw); }
.teller label { font-size: 13px; color: var(--grijs); }

/* ---------- Formulier ---------- */
.rij { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.veld { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.veld.groot { flex: 1; min-width: 240px; }
.veld-label { font-weight: 600; font-size: 14px; }
input[type="text"], select {
  padding: 11px 12px;
  border: 1px solid var(--rand);
  border-radius: 8px;
  font-size: 16px;
  font-weight: 400;
  background: #fff;
}
input[type="text"]:focus, select:focus { outline: 2px solid var(--blauw); border-color: var(--blauw); }

.toggle { display: flex; border: 1px solid var(--rand); border-radius: 8px; overflow: hidden; }
.toggle-knop {
  border: none;
  background: #fff;
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  color: var(--grijs);
}
.toggle-knop.actief[data-waarde="J"] { background: var(--jongen); color: #fff; }
.toggle-knop.actief[data-waarde="M"] { background: var(--meisje); color: #fff; }

.checkbox-veld { flex-direction: row; align-items: center; gap: 8px; font-weight: 600; }
.checkbox-veld input { width: 20px; height: 20px; }
.checkbox-veld small { color: var(--grijs); font-weight: 400; }

.vriendjes-blok { margin: 6px 0 16px; }
.vriendje-rij { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.vriendje-rij select { flex: 1; }
.vriendje-rang {
  min-width: 120px;
  font-size: 13px;
  font-weight: 600;
  color: var(--grijs);
  white-space: nowrap;
}

.form-acties { display: flex; gap: 10px; }
.btn-primair, .btn-grijs {
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primair { background: var(--blauw); color: #fff; }
.btn-primair:hover { background: #245ad0; }
.btn-grijs { background: var(--grijs-licht); color: var(--tekst); }
.btn-grijs:hover { background: #e3e6ee; }
.groot-knop { font-size: 16px; padding: 10px 22px; }

.plus { font-size: 22px; font-weight: 700; color: var(--grijs); align-self: center; }

/* ---------- Lijsten ---------- */
.lijst { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.lijst-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--rand);
  border-radius: 8px;
  background: #fff;
}
.lijst-item .naam { font-weight: 600; }
.lijst-item .badges { display: flex; gap: 6px; margin-left: auto; align-items: center; }
.lijst-acties { display: flex; gap: 6px; }
.icoon-knop {
  border: 1px solid var(--rand);
  background: #fff;
  width: 34px; height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
}
.icoon-knop:hover { background: var(--grijs-licht); }
.icoon-knop.verwijder:hover { background: var(--rood-licht); border-color: var(--rood); }

.badge { font-size: 12px; padding: 3px 9px; border-radius: 999px; font-weight: 600; }
.badge.jongen { background: var(--blauw-licht); color: var(--jongen); }
.badge.meisje { background: #ffe3ee; color: var(--meisje); }
.badge.anders { background: #fff3d6; color: #9a6a00; }
.badge.vriendjes { background: var(--grijs-licht); color: var(--grijs); }

.leeg { color: var(--grijs); font-style: italic; padding: 6px 0; }

/* ---------- Indeling ---------- */
.actie-balk { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hint { color: var(--grijs); font-size: 13px; margin: 0; flex-basis: 100%; }

.waarschuwing {
  background: var(--rood-licht);
  border: 1px solid var(--rood);
  color: #a01b1b;
  padding: 8px 12px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  font-weight: 600;
  font-size: 13px;
}

.klassen { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.klas h2 { display: flex; justify-content: space-between; align-items: center; }
.klas-stats { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.stat-chip {
  font-size: 12px;
  background: var(--grijs-licht);
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--grijs);
  font-weight: 600;
}
.stat-chip.vr { background: #e3f5e9; color: var(--groen); }
.stat-chip.vr.waarschuw { background: var(--rood-licht); color: var(--rood); }

.klas-leerlingen {
  min-height: 50px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 3px;
  border-radius: 8px;
}
.dropzone.over { background: var(--blauw-licht); outline: 2px dashed var(--blauw); }

.leerling-kaart {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 2px 8px;
  border: 1px solid var(--rand);
  border-left: 4px solid var(--jongen);
  border-radius: 5px;
  background: #fff;
  cursor: grab;
  font-size: 13px;
  line-height: 1.15;
}
.leerling-kaart.meisje { border-left-color: var(--meisje); }
.leerling-kaart:active { cursor: grabbing; }
.leerling-kaart.sleept { opacity: 0.4; }
.leerling-kaart.gesplitst { background: #f0e7ff; border-color: #8b5cf6; }
.leerling-kaart.eenzaam { background: #fff3d6; border-color: #e0a300; }
.leerling-kaart.conflict { background: var(--rood-licht); border-color: var(--rood); }
.leerling-kaart.conflict.eenzaam,
.leerling-kaart.conflict.gesplitst { background: var(--rood-licht); border-color: var(--rood); }
.leerling-kaart .k-top { display: flex; align-items: center; gap: 6px; }
.leerling-kaart .k-naam { font-weight: 600; }
.leerling-kaart .k-badges { margin-left: auto; display: flex; gap: 3px; align-items: center; }
.leerling-kaart .k-vrienden {
  font-size: 10px;
  color: var(--grijs);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.mini-badge { font-size: 9px; padding: 1px 5px; }
.mini-badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; font-weight: 700; }
.mini-badge.anders { background: #fff3d6; color: #9a6a00; }
.mini-badge.vriend { background: #e3f5e9; color: var(--groen); }
.mini-badge.conflict { background: var(--rood); color: #fff; }
.mini-badge.eenzaam { background: #e0a300; color: #fff; }
.mini-badge.gesplitst { background: #8b5cf6; color: #fff; }
.mini-badge.vriend.slechts1 { background: var(--rood); color: #fff; }

/* ---------- Detail-popup ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.overlay[hidden] { display: none; }
.detail-kaart {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px 24px;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  position: relative;
}
.detail-sluit {
  position: absolute;
  top: 12px; right: 12px;
  border: none;
  background: var(--grijs-licht);
  width: 32px; height: 32px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  color: var(--grijs);
}
.detail-sluit:hover { background: #e3e6ee; }
.detail-naam { margin: 0 0 10px; font-size: 22px; }
.detail-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.detail-kop { margin: 18px 0 8px; font-size: 14px; color: var(--grijs); text-transform: uppercase; letter-spacing: 0.03em; }
.detail-lijst { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.detail-lijst li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--rand);
  border-radius: 8px;
}
.detail-rang { font-size: 13px; font-weight: 700; color: var(--grijs); min-width: 24px; }
.detail-vnaam { font-weight: 600; flex: 1; }
.detail-status { font-size: 13px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.detail-status.ok { background: #e3f5e9; color: var(--groen); }
.detail-status.nok { background: var(--rood-licht); color: var(--rood); }
.detail-samenvatting { margin: 10px 0 0; font-weight: 600; font-size: 14px; }
.detail-samenvatting.ok { color: var(--groen); }
.detail-samenvatting.nok { color: var(--rood); }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .klassen { grid-template-columns: 1fr; }
  header h1 { font-size: 18px; width: 100%; }
  .backup-knoppen { margin-left: 0; }
}
