*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f0f4ff;
  --bg2: #ffffff;
  --bg3: #e8edf8;
  --border: #d0d8ee;
  --accent: #4361ee;
  --rood: #ef4444;
  --groen: #10b981;
  --geel: #f59e0b;
  --paars: #8b5cf6;
  --tekst: #1e2a4a;
  --subtekst: #5a6a8a;
  --font-ui: 'Syne', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 14px;
  --nav-h: 66px;
  --shadow: 0 2px 12px rgba(67, 97, 238, 0.10);
}

body.dark-mode {
  --bg: #111827;
  --bg2: #1e293b;
  --bg3: #263045;
  --border: #334155;
  --accent: #6382ff;
  --rood: #f87171;
  --groen: #34d399;
  --geel: #fbbf24;
  --paars: #a78bfa;
  --tekst: #f0f4ff;
  --subtekst: #94a3b8;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.30);
}

html {
  height: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100%;
  width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--tekst);
  font-family: var(--font-ui);
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
  background: var(--bg);
  position: relative;
  overflow-x: hidden;
}

header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 10px 14px 8px;
  flex-shrink: 0;
  gap: 8px;
  box-shadow: var(--shadow);
  width: 100%;
}

.header-rij1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.logo {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent);
  white-space: nowrap;
}

.logo span {
  color: var(--geel);
}

.sync-status {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 700;
  white-space: nowrap;
}

.sync-status.online {
  color: var(--groen);
  background: rgba(16, 185, 129, .12);
}

.sync-status.offline {
  color: var(--rood);
  background: rgba(239, 68, 68, .12);
}

.header-acties {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.theme-toggle,
#notif-btn,
#refresh-btn {
  flex: 1;
  background: var(--bg3);
  color: var(--tekst);
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 36px;
  padding: 0 8px;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
}

.theme-toggle:active,
#notif-btn:active,
#refresh-btn:active {
  background: var(--border);
}

main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
  padding: 16px;
  padding-bottom: calc(var(--nav-h) + 12px);
}

.scherm {
  display: none;
  width: 100%;
}

.scherm.actief {
  display: block;
}

nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: var(--nav-h);
  background: var(--bg2);
  border-top: 2px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(67, 97, 238, 0.08);
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--subtekst);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-family: var(--font-ui);
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  padding: 6px 0;
  transition: color 0.15s;
}

.nav-btn .icon {
  font-size: 1.3rem;
  line-height: 1;
}

.nav-btn.actief {
  color: var(--accent);
}

.scherm-titel {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 18px;
  color: var(--tekst);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-kaart {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.stat-kaart.accent {
  border-left: 4px solid var(--accent);
}

.stat-getal {
  font-size: 2rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--accent);
  line-height: 1;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--subtekst);
  text-transform: uppercase;
  margin-top: 6px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.sync-sectie {
  margin-top: 16px;
}

.sync-sectie h2 {
  font-size: 0.8rem;
  color: var(--subtekst);
  text-transform: uppercase;
  margin-bottom: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.scanner-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

#camera-view {
  width: 100%;
  height: 52vmax;
  max-height: 60vh;
  border-radius: var(--radius);
  border: 2px solid var(--accent);
  overflow: hidden;
  position: relative;
  background: #000;
  box-shadow: var(--shadow);
}

#camera-view.verborgen {
  display: none;
}

#camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scan-kader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scan-kader-box {
  width: 72%;
  height: 42%;
  border: 2px dashed rgba(255, 255, 255, 0.75);
  border-radius: 12px;
  position: relative;
  box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.35);
}

.scan-lijn {
  width: 100%;
  height: 2px;
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
  position: absolute;
  top: 50%;
  animation: scanbeweging 2s ease-in-out infinite;
}

@keyframes scanbeweging {

  0%,
  100% {
    top: 10%;
  }

  50% {
    top: 85%;
  }
}

.scanner-hint {
  color: var(--subtekst);
  font-size: 0.85rem;
  text-align: center;
  line-height: 1.5;
}

#scan-resultaat.verborgen {
  display: none;
}

.resultaat-kaart {
  background: var(--bg2);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px;
  width: 100%;
  box-shadow: var(--shadow);
}

.resultaat-kaart h3 {
  font-size: 1.2rem;
  margin-bottom: 4px;
}

.barcode-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--subtekst);
  margin-bottom: 12px;
}

.voorraad-getal {
  font-size: 1.5rem;
  font-family: var(--font-mono);
  color: var(--accent);
  font-weight: 800;
}

.voorraad-acties {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.scan-aantal-group {
  margin-top: 12px;
}

.scan-aantal-group label {
  font-size: 0.8rem;
  color: var(--subtekst);
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

.scan-aantal-group input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--tekst);
  font-size: 1rem;
  font-family: var(--font-mono);
}

.btn {
  flex: 1;
  padding: 12px 14px;
  border: none;
  border-radius: 10px;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: filter 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.96);
  filter: brightness(0.9);
}

.btn-primair {
  background: var(--accent);
  color: #fff;
}

.btn-rood {
  background: var(--rood);
  color: #fff;
}

.btn-groen {
  background: var(--groen);
  color: #fff;
}

.btn-geel {
  background: var(--geel);
  color: #fff;
}

.btn-paars {
  background: var(--paars);
  color: #fff;
}

.btn-outline {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--tekst);
}

.btn-lg {
  padding: 15px;
  width: 100%;
  font-size: 1rem;
}

.zoek-wrapper {
  margin-bottom: 14px;
}

.zoek-input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--tekst);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  box-shadow: var(--shadow);
}

.zoek-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

#items-lijst {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-rij {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow);
}

.item-rij.laag-voorraad {
  border-left: 4px solid var(--rood);
}

.item-info {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.item-naam {
  font-weight: 700;
  font-size: 1rem;
}

.item-meta {
  font-size: 0.78rem;
  color: var(--subtekst);
  font-family: var(--font-mono);
  margin-top: 3px;
}

.item-voorraad {
  text-align: right;
  flex-shrink: 0;
}

.aantal {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent);
}

.aantal.kritiek {
  color: var(--rood);
}

.eenheid {
  font-size: 0.78rem;
  color: var(--subtekst);
}

.item-sync-indicator {
  font-size: 0.7rem;
}

.item-sync-indicator.gesync {
  color: var(--groen);
}

.item-sync-indicator.niet-gesync {
  color: var(--subtekst);
}

.item-acties {
  display: flex;
  gap: 8px;
}

.item-acties .btn {
  padding: 8px 10px;
  font-size: 0.82rem;
}

.leeg-bericht {
  text-align: center;
  color: var(--subtekst);
  padding: 40px 0;
  font-size: 0.95rem;
}

.actie-bewerk-verwijder {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.form-groep {
  margin-bottom: 14px;
}

.form-groep label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--subtekst);
  margin-bottom: 5px;
  letter-spacing: 0.06em;
}

.form-groep input,
.form-groep select {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--tekst);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  box-shadow: var(--shadow);
}

.form-groep input:focus,
.form-groep select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.form-2col {
  display: flex;
  gap: 12px;
}

.form-2col .form-groep {
  flex: 1;
}

#toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + 14px);
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 28px);
  max-width: 440px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.25s;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.toast.zichtbaar {
  opacity: 1;
  transform: translateY(0);
}

.toast-succes {
  background: var(--groen);
  color: #fff;
}

.toast-fout {
  background: var(--rood);
  color: #fff;
}

.toast-info {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--tekst);
}

@media (min-width: 600px) {
  #items-lijst {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .scherm-titel {
    font-size: 1.7rem;
  }
}

@media (min-width: 768px) {
  :root {
    --nav-h: 70px;
  }

  #app {
    max-width: 100%;
  }

  header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    height: 64px;
    gap: 24px;
  }

  .header-rij1 {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    margin: 0;
  }

  #sync-status {
    margin-left: auto;
    margin-right: auto;
  }

  .header-acties {
    flex: 0 0 auto;
    width: auto;
    margin: 0;
  }

  .theme-toggle,
  #notif-btn,
  #refresh-btn {
    flex: 0 0 auto;
    padding: 0 14px;
  }

  .logo {
    font-size: 1.3rem;
  }

  main {
    padding: 40px;
    padding-bottom: calc(var(--nav-h) + 24px);
  }

  .scherm {
    max-width: 1100px;
    margin: 0 auto;
  }

  .scherm-titel {
    font-size: 2rem;
    margin-bottom: 28px;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 28px;
  }

  .stats-grid .stat-kaart[style*="grid-column"] {
    grid-column: auto !important;
  }

  .stat-kaart {
    padding: 24px;
  }

  .stat-getal {
    font-size: 2.8rem;
  }

  #items-lijst {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }

  nav {
    height: var(--nav-h);
    padding: 0 40px;
  }

  .nav-btn {
    font-size: 0.75rem;
    gap: 6px;
  }

  .nav-btn .icon {
    font-size: 1.5rem;
  }

  #item-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 24px;
  }

  #item-form .form-2col,
  #item-form button[type="submit"] {
    grid-column: 1 / -1;
  }

  .scanner-wrapper {
    max-width: 600px;
    margin: 0 auto;
  }

  .sync-sectie {
    display: flex;
    align-items: center;
    gap: 20px;
  }

  .sync-sectie h2 {
    margin-bottom: 0;
    white-space: nowrap;
  }

  #sync-btn {
    flex: 1;
    max-width: 400px;
  }

  #toast-container {
    bottom: auto;
    top: 80px;
    right: 24px;
    left: auto;
    transform: none;
    width: 340px;
  }
}

@media (min-width: 1200px) {
  main {
    padding: 48px 60px;
    padding-bottom: calc(var(--nav-h) + 24px);
  }

  .scherm {
    max-width: 1300px;
  }

  #items-lijst {
    grid-template-columns: repeat(4, 1fr);
  }
}