:root {
  --brand: #0b3d6b;
  --brand-light: #e8f0f8;
  --ok: #1a7f3c;
  --warn: #b45309;
  --danger: #b91c1c;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1a222c;
  --muted: #64748b;
  --border: #d8dee6;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 17px;
  -webkit-font-smoothing: antialiased;
}
.app { max-width: 640px; margin: 0 auto; padding: 12px; padding-bottom: 90px; }
.wide { max-width: 1280px; }
h1 { font-size: 1.25rem; color: var(--brand); }
h2 { font-size: 1.05rem; margin-bottom: 8px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 4px; position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; margin-bottom: 12px;
}
label { display: block; font-size: .9rem; color: var(--muted); margin: 10px 0 4px; }
input, select, button, textarea {
  font: inherit; width: 100%; padding: 13px 14px; border: 1px solid var(--border);
  border-radius: 12px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
button { cursor: pointer; border: none; font-weight: 600; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:active { opacity: .85; }
.btn-secondary { background: var(--brand-light); color: var(--brand); }
.btn-ghost { background: transparent; color: var(--brand); width: auto; padding: 8px 10px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-big { padding: 18px; font-size: 1.15rem; border-radius: 14px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.muted { color: var(--muted); font-size: .9rem; }
.small { font-size: .82rem; }
.center { text-align: center; }
.mt { margin-top: 12px; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; background: var(--brand-light); color: var(--brand);
}
.badge.ok { background: #dcfce7; color: var(--ok); }
.badge.warn { background: #fef3c7; color: var(--warn); }
.badge.danger { background: #fee2e2; color: var(--danger); }

.list-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 6px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.list-item:last-child { border-bottom: none; }
.list-item .code { font-weight: 700; font-size: .95rem; }
.list-item .desc { color: var(--muted); font-size: .85rem; }

/* Alfabetbalk boven de tellijst */
.alpha-bar {
  display: flex; flex-wrap: wrap; gap: 4px;
  position: sticky; top: 0; z-index: 4;
  background: var(--card); padding: 8px 0; margin-top: 8px;
  border-bottom: 1px solid var(--border);
}
.alpha-btn {
  width: auto; flex: 1 0 30px; min-width: 30px; padding: 7px 0;
  font-size: .85rem; font-weight: 700; text-align: center;
  background: var(--brand-light); color: var(--brand); border-radius: 8px;
}
.alpha-btn:active { background: var(--brand); color: #fff; }

/* Tellijst-rijen op het hoofdscherm */
.tl-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 2px; border-bottom: 1px solid var(--border);
}
.tl-row:last-child { border-bottom: none; }
.tl-row.done { background: #f0fdf4; }
.tl-check { width: 24px; height: 24px; flex: none; accent-color: var(--ok); }
.tl-info { flex: 1; min-width: 0; cursor: pointer; }
.tl-info .code { font-weight: 700; font-size: .92rem; }
.tl-info .desc { color: var(--muted); font-size: .8rem; overflow-wrap: break-word; }
.tl-theor { flex: none; text-align: right; min-width: 46px; font-variant-numeric: tabular-nums; }
.tl-input {
  flex: none; width: 84px; padding: 10px 8px; text-align: center;
  font-weight: 700; border-radius: 10px;
}

/* Scanner overlay */
.overlay {
  position: fixed; inset: 0; background: #000; z-index: 50;
  display: flex; flex-direction: column;
}
.overlay video { flex: 1; object-fit: cover; width: 100%; }
.overlay .overlay-bar { padding: 14px; background: #111; }
.scanbox {
  position: absolute; left: 10%; right: 10%; top: 35%; height: 22%;
  border: 3px solid #4ade80; border-radius: 12px; pointer-events: none;
}

/* Sync status voetbalk */
.syncbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  background: var(--card); border-top: 1px solid var(--border);
  padding: 10px 16px; display: flex; justify-content: space-between; align-items: center;
  max-width: 640px; margin: 0 auto; font-size: .85rem;
}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.online { background: var(--ok); }
.dot.offline { background: var(--danger); }

/* Admin-tabel */
table { width: 100%; border-collapse: collapse; font-size: .85rem; background: var(--card); }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { background: var(--brand-light); color: var(--brand); position: sticky; top: 0; cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.flagged td { background: #fff7ed; }
tr.needs td { background: #fee2e2; }
.table-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--border); border-radius: 12px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
/* Upload-kaarten naast elkaar: gelijke hoogte, knoppen onderaan uitgelijnd */
.upload-row { align-items: stretch; }
.upload-row .card { display: flex; flex-direction: column; }
.upload-row .card > button:last-child { margin-top: auto; padding-top: 13px; }
.filters button { width: auto; padding: 8px 14px; font-size: .85rem; }
.filters button.active { background: var(--brand); color: #fff; }
.toast {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 10px;
  z-index: 100; font-size: .9rem; opacity: 0; transition: opacity .3s; pointer-events: none;
}
.toast.show { opacity: 1; }
.qty-input { font-size: 2rem; text-align: center; font-weight: 700; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { background: var(--brand-light); border-radius: 12px; padding: 12px; text-align: center; }
.stat .v { font-size: 1.4rem; font-weight: 700; color: var(--brand); }
.stat .l { font-size: .75rem; color: var(--muted); }
