:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1d2430;
  --muted: #677385;
  --line: #e2e6ec;
  --primary: #1f3a5f;
  --primary-2: #2d5689;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --warn: #b9770e;
  --warn-bg: #fef5e7;
  --ok: #1e8449;
  --ok-bg: #e9f7ef;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--primary-2); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  padding: 8px 16px;
  background: var(--primary);
  color: #fff;
}
.topbar .brand { color: #fff; font-weight: 700; text-decoration: none; }
.topbar nav { display: flex; gap: 4px; overflow-x: auto; }
.topbar nav a {
  color: #dbe6f5;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
}
.topbar nav a.active { background: rgba(255, 255, 255, .16); color: #fff; }

main { max-width: 920px; margin: 0 auto; padding: 16px 16px 96px; }

h1 { font-size: 1.4rem; margin: 4px 0 12px; }
h2 { font-size: 1.1rem; margin: 20px 0 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.spacer { height: 12px; }

label { display: block; font-weight: 600; margin: 12px 0 4px; }
label.inline { display: inline-flex; gap: 8px; align-items: center; font-weight: 500; margin: 0; }

input[type=text], input[type=search], input[type=number], input[type=password],
input[type=date], input[type=time], input[type=email], textarea, select {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid #c9d1dc;
  border-radius: 8px;
  background: #fff;
  color: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary-2); outline-offset: 0; border-color: transparent; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--primary-2); }

button, .btn {
  font: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #c9d1dc;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  min-height: 42px;
}
button:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary-2); border-color: var(--primary-2); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary-2); }
.btn-sm { padding: 6px 10px; min-height: 34px; font-size: .9rem; }
.btn-block { width: 100%; }

.choice {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  font-weight: 500;
  cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--primary-2); background: #eef4fb; }

/* Lijsten met loten */
.lot {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 4px 12px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.lot:last-child { border-bottom: 0; }
.lot .name { font-weight: 600; text-decoration: none; color: inherit; }
.lot .meta { font-size: .85rem; color: var(--muted); }
.lot .actions { display: flex; gap: 6px; grid-column: 2 / 4; }
@media (min-width: 640px) {
  .lot { grid-template-columns: auto 1fr auto auto; }
  .lot .actions { grid-column: auto; }
}
.list { padding: 0; overflow: hidden; }
.list-empty { padding: 14px; color: var(--muted); }

.section-title { display: flex; align-items: center; gap: 8px; }
.count { font-size: .8rem; padding: 2px 8px; border-radius: 99px; background: var(--line); color: var(--text); }

.badge { font-size: .8rem; font-weight: 600; padding: 3px 8px; border-radius: 99px; white-space: nowrap; }
.badge.expired { background: var(--danger-bg); color: var(--danger); }
.badge.soon { background: var(--warn-bg); color: var(--warn); }
.badge.later { background: var(--ok-bg); color: var(--ok); }
.badge.gone { background: var(--line); color: var(--muted); }

.bulkbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--primary);
  color: #fff;
}

/* Scanner */
#reader { width: 100%; max-width: 520px; margin: 0 auto; border-radius: 8px; overflow: hidden; background: #000; }
#reader video { width: 100% !important; }
.scan-hint { text-align: center; margin: 8px 0; }

.search-results { border: 1px solid var(--line); border-radius: 8px; margin-top: 6px; max-height: 260px; overflow-y: auto; }
.search-results button {
  display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line);
  border-radius: 0; background: #fff; font-weight: 500;
}
.search-results button:last-child { border-bottom: 0; }
.search-results button.selected { background: #eef4fb; font-weight: 700; }

.selected-product { padding: 10px 12px; border-radius: 8px; background: #eef4fb; font-weight: 600; margin-top: 8px; }
.date-preview { margin-top: 6px; font-weight: 600; }
.date-preview.error { color: var(--danger); }

.big-name { font-size: 1.3rem; font-weight: 700; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%);
  z-index: 30;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 8px;
  background: #1d2430;
  color: #fff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}
.toast.error { background: var(--danger); }

table.simple { width: 100%; border-collapse: collapse; }
table.simple th, table.simple td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }

.login { max-width: 360px; margin: 12vh auto 0; }

/* Afdruklijst */
.print-sheet h1 { margin-bottom: 2px; }
.print-table { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; }
.print-table th, .print-table td { border: 1px solid #999; padding: 6px 8px; text-align: left; }
.print-table th { background: #eee; }
.print-table .box { width: 44px; text-align: center; }
.print-table .box span { display: inline-block; width: 16px; height: 16px; border: 1.5px solid #333; }
.print-table tr.cat td { background: #f3f3f3; font-weight: 700; }
.print-table tr.expired td.days { color: var(--danger); font-weight: 700; }

@media print {
  .no-print, .topbar, .bulkbar, .toast { display: none !important; }
  body { background: #fff; }
  main { max-width: none; padding: 0; }
  .print-table { font-size: 12px; }
  .print-table tr { page-break-inside: avoid; }
}

/* Vervaldatum-invoer */
.seg { display: flex; border: 1px solid #c9d1dc; border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.seg button { flex: 1; border: 0; border-radius: 0; min-height: 40px; font-size: .9rem; background: #fff; color: var(--muted); }
.seg button + button { border-left: 1px solid #c9d1dc; }
.seg button.active { background: var(--primary-2); color: #fff; }
input.date-input {
  font-size: 1.7rem;
  text-align: center;
  letter-spacing: .08em;
  font-variant-numeric: tabular-nums;
  padding: 10px;
}
input.date-input::placeholder { color: #b6bfcc; letter-spacing: .08em; }
.date-hint { margin-top: 6px; }
.date-preview.ok { color: var(--ok); }
.date-preview.muted { color: var(--muted); font-weight: 500; }
