:root {
  --navy: #1e2744; /* gelijk aan de achtergrond van het logo */
  --navy-2: #2b3560;
  --goud: #b38613;
  --goud-licht: #d9b65a;
  --blauw: #4058b0;
  --blauw-hover: #33489a;
  --blauw-zacht: #e8ecf8;
  --bg: #f3f4f8;
  --kaart: #ffffff;
  --tekst: #1d2233;
  --tekst-2: #5b6274;
  --lijn: #dfe2ea;
  --rood: #c0392b;
  --groen: #2e8b57;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--tekst);
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }

/* ---------- Header ---------- */
.topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 76px;
  padding-left: 20px;
  flex-shrink: 0;
}
.brand-logo { height: 60px; width: auto; display: block; flex-shrink: 0; }
.app-title { font-size: 24px; font-weight: 600; margin: 0; white-space: nowrap; }
.tabs { display: flex; gap: 6px; margin-left: auto; }
.tabs a {
  color: #cfd5ea; text-decoration: none; font-size: 18px; font-weight: 600;
  padding: 12px 20px; border-radius: 10px; min-height: 48px; display: flex; align-items: center;
}
.tabs a:hover { background: var(--navy-2); color: #fff; }
.tabs a.active { background: #fff; color: var(--navy); }
.taal-switch { display: flex; background: var(--navy-2); border-radius: 10px; padding: 3px; flex-shrink: 0; }
.taal-switch button {
  border: none; background: transparent; color: #cfd5ea; font-weight: 700; font-size: 15px;
  min-width: 44px; min-height: 40px; border-radius: 8px; letter-spacing: .04em;
}
.taal-switch button.active { background: var(--goud); color: #fff; }
.brand-b { width: 52px; height: 52px; margin: 0 20px 0 8px; flex-shrink: 0; display: block; }
.demo-banner { background: #fff4d6; color: #6b5310; padding: 8px 20px; font-size: 14px; }
.demo-banner code { background: #fbe7a8; padding: 1px 5px; border-radius: 4px; }

main { flex: 1; min-height: 0; position: relative; overflow-y: auto; }
.footbar { background: var(--navy); color: #cfd5ea; text-align: center; font-size: 13px; padding: 8px; flex-shrink: 0; }

.laden { position: absolute; inset: 0; display: grid; place-items: center; font-size: 20px; color: var(--tekst-2); }

.panel, .card { background: var(--kaart); border-radius: var(--radius); box-shadow: var(--shadow); }
h2 { font-size: 20px; margin: 0 0 12px; }
h2 .sub { font-weight: 400; color: var(--tekst-2); font-size: 15px; }

/* ---------- Invoer ---------- */
.view-invoer {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px 320px;
  gap: 16px;
  padding: 16px;
}
.view-invoer .panel { padding: 16px; min-height: 0; display: flex; flex-direction: column; }
.soort-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  grid-auto-rows: max-content; /* rij groeit mee met lange soortnamen */
  gap: 12px;
  overflow-y: auto;
  padding: 2px 4px 4px 2px;
  align-content: start;
}
.soort-tile {
  border: 3px solid transparent;
  background: #f7f8fb;
  border-radius: 12px;
  padding: 8px 8px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-height: 150px;
  color: var(--tekst);
  transition: transform .08s, border-color .1s;
}
.soort-tile:active { transform: scale(.97); }
.soort-tile.selected { border-color: var(--blauw); background: var(--blauw-zacht); }
.soort-tile img, .soort-tile .foto-leeg { width: 100%; height: 104px; object-fit: contain; border-radius: 8px; background: #fff; }
.soort-tile span {
  font-weight: 600; font-size: 16px; text-align: center; line-height: 1.2;
  overflow-wrap: anywhere; hyphens: auto; flex-shrink: 0; max-width: 100%;
  /* maximaal 3 regels; langere namen eindigen op "…" */
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.foto-leeg { display: grid; place-items: center; font-size: 34px; font-weight: 700; color: #9aa3bd; background: #eef0f6 !important; }

.invoer-panel { align-items: stretch; gap: 10px; }
.gekozen { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.gekozen-foto { width: 64px; height: 64px; flex-shrink: 0; }
.gekozen-foto img, .gekozen-foto .foto-leeg { width: 64px; height: 64px; object-fit: contain; border-radius: 10px; background: #f7f8fb; font-size: 24px; }
.gekozen-naam { font-size: 22px; font-weight: 700; }
.gekozen-naam.leeg { color: var(--tekst-2); font-weight: 500; }
.aantal-label { font-weight: 700; font-size: 16px; color: var(--tekst-2); margin-top: 4px; }
.aantal-display {
  font-size: 48px; font-weight: 700; text-align: right; padding: 4px 16px;
  border: 2px solid var(--lijn); border-radius: 12px; font-variant-numeric: tabular-nums; min-height: 72px;
}
.aantal-display.leeg { color: #b8bdcc; }
.invoer-panel { overflow-y: auto; }
.invoer-panel > *:not(.numpad) { flex-shrink: 0; }
.soort-tile img, .soort-tile .foto-leeg { flex-shrink: 0; }
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(4, minmax(52px, 1fr)); gap: 10px; flex: 1 1 auto; min-height: 238px; max-height: 360px; }
.numpad button {
  background: var(--blauw); color: #fff; border: none; border-radius: 12px;
  font-size: 30px; font-weight: 600;
  box-shadow: 0 2px 0 var(--blauw-hover);
}
.numpad button:active { background: var(--blauw-hover); transform: translateY(1px); box-shadow: none; }
.numpad .key-clear, .numpad .key-back { background: #e3e6f0; color: var(--navy); box-shadow: 0 2px 0 #c9cdda; }
.numpad .key-clear:active, .numpad .key-back:active { background: #cfd3e1; }
.btn-toevoegen {
  min-height: 76px; border: none; border-radius: 12px; background: var(--groen); color: #fff;
  font-size: 26px; font-weight: 700; box-shadow: 0 3px 0 #226b42;
}
.btn-toevoegen:disabled { background: #d9dce4; color: #8a90a2; box-shadow: none; cursor: default; }
.btn-toevoegen:not(:disabled):active { transform: translateY(2px); box-shadow: none; }

.vandaag-panel { gap: 8px; }
.vandaag-totaal {
  display: flex; justify-content: space-between; align-items: baseline;
  background: var(--navy); color: #fff; border-radius: 10px; padding: 10px 14px;
}
.vandaag-totaal strong { font-size: 26px; font-variant-numeric: tabular-nums; }
.vandaag-lijst { overflow-y: auto; flex: 1 1 50%; min-height: 80px; }
.vandaag-rij { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--lijn); }
.vandaag-rij img, .vandaag-rij .foto-leeg { width: 40px; height: 40px; object-fit: contain; border-radius: 6px; font-size: 16px; }
.vandaag-rij .naam { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.vandaag-rij .num { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.laatste-kop { font-size: 14px; margin: 6px 0 0; color: var(--tekst-2); text-transform: uppercase; letter-spacing: .05em; }
.laatste-hint { text-transform: none; letter-spacing: 0; font-weight: 400; }
.laatste-lijst { overflow-y: auto; flex: 1 1 40%; min-height: 60px; }
.laatste-rij { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--lijn); font-size: 15px; }
.laatste-rij .tijd { color: var(--tekst-2); font-variant-numeric: tabular-nums; width: 44px; }
.laatste-rij .naam { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.laatste-rij .num { font-weight: 700; font-variant-numeric: tabular-nums; }
.laatste-rij { cursor: pointer; border-radius: 8px; padding-left: 4px; min-height: 52px; }
.laatste-rij:active { background: var(--blauw-zacht); }
.laatste-rij.actief { background: #fff4d6; box-shadow: inset 3px 0 0 var(--goud); }
.btn-edit {
  width: 44px; height: 44px; border-radius: 10px; background: var(--blauw-zacht); color: var(--blauw);
  display: grid; place-items: center; font-size: 20px; flex-shrink: 0;
}
.wijzig-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: #fff4d6; color: #6b5310; border-radius: 10px; padding: 6px 6px 6px 12px; font-weight: 600; font-size: 15px;
}
.invoer-panel.wijzigen .aantal-label { display: none; }
.wijzig-banner .btn-light { min-height: 40px; }
.invoer-panel.wijzigen .aantal-display { border-color: var(--goud); background: #fffbef; }
.invoer-panel.wijzigen .btn-toevoegen:not(:disabled) { background: var(--goud); box-shadow: 0 3px 0 #8a6b20; }
.btn-del {
  width: 44px; height: 44px; border: none; border-radius: 10px; background: #fbeaea; color: var(--rood);
  font-size: 20px; font-weight: 700; flex-shrink: 0;
}
.leeg-tekst { color: var(--tekst-2); padding: 12px 4px; font-size: 15px; }

/* ---------- Dashboard ---------- */
.view-dashboard, .view-beheer { padding: 16px; height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.dash-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.segmented { display: inline-flex; background: #e3e6f0; border-radius: 12px; padding: 4px; }
.segmented button { border: none; background: transparent; padding: 10px 18px; border-radius: 9px; font-weight: 600; color: var(--tekst-2); min-height: 44px; }
.segmented button.active { background: #fff; color: var(--navy); box-shadow: var(--shadow); }
.periode-nav { display: flex; align-items: center; gap: 8px; }
.periode-label { font-size: 18px; font-weight: 700; min-width: 200px; text-align: center; }
.icon-btn { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--lijn); background: #fff; font-size: 26px; line-height: 1; color: var(--navy); }
.btn-light { min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--lijn); background: #fff; color: var(--navy); font-weight: 600; display: inline-flex; align-items: center; }
.btn-primary { min-height: 44px; padding: 0 18px; border-radius: 10px; border: none; background: var(--blauw); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--blauw-hover); }
.btn-danger { min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid #f0c9c4; background: #fff; color: var(--rood); font-weight: 600; }
.periode-eigen { display: flex; gap: 12px; }
.periode-eigen input { min-height: 44px; font: inherit; padding: 0 8px; border: 1px solid var(--lijn); border-radius: 10px; }
.dash-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.bijgewerkt { color: var(--tekst-2); font-size: 13px; }
.bijgewerkt::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--groen); margin-right: 6px; vertical-align: 1px; }
.bijgewerkt.fout::before { background: var(--rood); }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi { background: var(--kaart); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.kpi-main { background: var(--navy); color: #fff; }
.kpi-label { font-size: 14px; color: var(--tekst-2); }
.kpi-main .kpi-label, .kpi-main .kpi-sub { color: #cfd5ea; }
.kpi-value { font-size: 34px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 13px; margin-top: 2px; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.card { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.soort-tabel { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.soort-tabel th, .soort-tabel td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--lijn); }
.soort-tabel thead th { font-size: 13px; color: var(--tekst-2); font-weight: 600; }
.soort-tabel tfoot th { border-bottom: none; border-top: 2px solid var(--navy); font-size: 17px; }
.soort-tabel .num { text-align: right; width: 90px; font-weight: 600; }
.soort-tabel .bar-col { width: 40%; }
.soort-cel { display: flex; align-items: center; gap: 8px; }
.soort-cel img, .soort-cel .foto-leeg { width: 30px; height: 30px; object-fit: contain; border-radius: 5px; font-size: 13px; }
.bar { display: flex; align-items: center; gap: 8px; }
.bar-track { flex: 1; height: 12px; background: #eef0f6; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--blauw); border-radius: 6px; }
.bar-pct { width: 44px; text-align: right; font-size: 13px; color: var(--tekst-2); }

.trend { display: flex; align-items: flex-end; gap: 4px; height: 280px; padding-top: 24px; }
.trend-kol { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; position: relative; }
.trend-bar { width: 100%; max-width: 46px; background: var(--blauw); border-radius: 4px 4px 0 0; min-height: 0; }
.trend-kol.vandaag .trend-bar { background: var(--goud); }
.trend-waarde { font-size: 11px; color: var(--tekst-2); margin-bottom: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.trend-as { font-size: 11px; color: var(--tekst-2); margin-top: 4px; white-space: nowrap; height: 14px; }
.trend.dicht .trend-waarde { display: none; }

/* ---------- Beheer ---------- */
.hint { color: var(--tekst-2); font-size: 14px; margin: 0 0 12px; }
.beheer-lijst { display: flex; flex-direction: column; }
.beheer-rij { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--lijn); }
.beheer-rij img, .beheer-rij .foto-leeg { width: 56px; height: 56px; object-fit: contain; border-radius: 8px; background: #f7f8fb; font-size: 20px; }
.beheer-rij .naam { flex: 1; font-weight: 600; font-size: 17px; }
.beheer-rij.inactief .naam, .beheer-rij.inactief img { opacity: .45; }
.badge { font-size: 12px; padding: 3px 8px; border-radius: 20px; background: #eef0f6; color: var(--tekst-2); font-weight: 600; }
.badge.aan { background: #e2f3e9; color: var(--groen); }
.setup-status { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 15px; }
.setup-status .ok { color: var(--groen); }
.setup-status .nok { color: var(--rood); }
#btn-demo-reset { margin-left: 8px; }

dialog { border: none; border-radius: var(--radius); padding: 24px; width: min(480px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20, 25, 45, .45); }
.foto-edit { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.foto-preview { width: 120px; height: 120px; border-radius: 12px; background: #f7f8fb; overflow: hidden; display: grid; place-items: center; }
.foto-preview img { width: 100%; height: 100%; object-fit: contain; }
.foto-preview .foto-leeg { width: 100%; height: 100%; }
.file-btn { cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; margin-bottom: 14px; }
.field input { font: inherit; font-weight: 400; min-height: 48px; padding: 0 12px; border: 1px solid var(--lijn); border-radius: 10px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; }
.dialog-actions { display: flex; gap: 8px; margin-top: 20px; }
.spacer { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 56px; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 12px 12px 12px 20px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); display: flex; align-items: center; gap: 16px; font-size: 17px; z-index: 50;
  max-width: calc(100vw - 32px);
}
.toast.fout { background: var(--rood); }
.toast button { background: #fff; color: var(--navy); border: none; border-radius: 8px; min-height: 44px; padding: 0 14px; font-weight: 700; }

/* ---------- Responsief ---------- */
@media (max-width: 1180px) {
  .view-invoer { grid-template-columns: minmax(0, 1fr) 320px 260px; gap: 12px; padding: 12px; }
  .soort-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .soort-tile { min-height: 130px; }
  .btn-edit { display: none; }
  .soort-tile img, .soort-tile .foto-leeg { height: 84px; flex-shrink: 0; }
}
@media (max-height: 700px) {
  .numpad button { font-size: 26px; }
  .numpad { grid-template-rows: repeat(4, minmax(44px, 1fr)); gap: 8px; min-height: 200px; }
  .view-invoer .invoer-panel { padding: 12px; gap: 8px; }
  .aantal-label { display: none; }
  .footbar { padding: 4px; font-size: 12px; }
  .btn-toevoegen { min-height: 64px; flex-shrink: 0; }
  .aantal-display { font-size: 40px; min-height: 60px; }
  .gekozen, .gekozen-foto, .gekozen-foto img, .gekozen-foto .foto-leeg { min-height: 48px; height: 48px; width: auto; }
  .gekozen-foto img, .gekozen-foto .foto-leeg { width: 48px; }
}
@media (max-width: 999px) {
  .view-invoer { grid-template-columns: 1fr 1fr; grid-template-rows: auto minmax(0, 1fr); height: auto; min-height: 100%; }
  .soorten-panel { grid-column: 1 / 3; grid-row: 1; max-height: 42vh; }
  .invoer-panel { grid-column: 1; grid-row: 2; }
  .vandaag-panel { grid-column: 2; grid-row: 2; max-height: 70vh; }
  .app-title { display: none; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { gap: 10px; padding-left: 12px; height: 64px; }
  .brand-b { width: 40px; height: 40px; margin: 0 12px 0 4px; }
  .brand-logo { height: 46px; }
  .tabs a { padding: 10px 10px; font-size: 15px; }
  .view-invoer { grid-template-columns: 1fr; }
  .soorten-panel, .invoer-panel, .vandaag-panel { grid-column: 1; grid-row: auto; }
  .view-invoer, .view-dashboard, .view-beheer { padding: 12px; }
  .periode-label { min-width: 0; }
  .dash-actions { margin-left: 0; }
}
