:root {
  --ink: #1a1a1a;
  --muted: #666;
  --accent: #0066cc;
  --ok: #16a34a;
  --err: #dc2626;
  --border: #e5e5e5;
  --bg: #f7f7f8;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

#app { max-width: 640px; margin: 0 auto; padding: 16px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 2px solid var(--accent);
  margin-bottom: 16px;
}
.brand { font-weight: 700; font-size: 18px; }
.app-version { color: var(--muted); font-size: 11px; align-self: flex-end; }
.whoami { margin-left: auto; color: var(--muted); font-size: 14px; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 14px; }

h1 { font-size: 22px; margin: 8px 0 4px; }
h2 { font-size: 16px; margin: 16px 0 8px; }
.muted { color: var(--muted); font-size: 14px; }

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin: 12px 0;
}

label { display: block; font-size: 14px; margin: 10px 0 4px; }

input[type=text], input[type=email], input[type=number], select {
  width: 100%;
  padding: 12px;
  font-size: 16px; /* voorkomt zoom op iOS */
  border: 1px solid var(--border);
  border-radius: 8px;
}

button {
  min-height: 44px; /* touch target */
  padding: 0 18px;
  font-size: 15px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-top: 12px;
}
button.primary { background: var(--accent); color: #fff; }
button.secondary { background: #fff; color: var(--accent); border-color: var(--accent); }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tab {
  background: #fff; border: 1px solid var(--border); color: var(--ink);
  min-height: 40px; margin-top: 0; border-radius: 20px; padding: 0 14px;
}
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.msg { min-height: 20px; font-size: 14px; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--err); }

/* ─── QR-scanner ─────────────────────────────────────────────────────────── */
.scan-open { width: 100%; }

#scan-panel {
  position: relative;
  width: 100%;
  max-width: 360px;
  margin: 12px auto 0;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
}
/* html5-qrcode injecteert hier een <video>; laat 't het paneel vullen. */
#scan-reader { position: absolute; inset: 0; }
#scan-reader video { width: 100% !important; height: 100% !important; object-fit: cover; display: block; }
/* Verberg de standaard-UI die de library soms bijzet (we tekenen zelf).
   Incl. de qrbox-shade (canvas/#qr-shaded-region) zodat onze eigen overlay
   niet dubbel getekend wordt. De video blijft zichtbaar. */
#scan-reader img, #scan-reader button, #scan-reader select, #scan-reader span,
#scan-reader canvas { display: none !important; }
/* De qrbox-shade is een losse <div id="qr-shaded-region"> (met solid border) die
   de library over het beeld legt. Globaal verbergen — ongeacht nesting — zodat
   alleen onze eigen overlay (vignet + hoeken) zichtbaar is. */
#qr-shaded-region { display: none !important; }

#scan-overlay { position: absolute; inset: 0; pointer-events: none; }
/* Donker vignet met een uitgesneden helder venster in het midden. */
.scan-frame {
  position: absolute;
  top: 50%; left: 50%;
  width: 62%; aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45);
  border-radius: 12px;
}
.corner {
  position: absolute; width: 22px; height: 22px;
  border: 3px solid var(--accent); border-radius: 3px;
}
.corner.tl { top: -2px; left: -2px; border-right: none; border-bottom: none; }
.corner.tr { top: -2px; right: -2px; border-left: none; border-bottom: none; }
.corner.bl { bottom: -2px; left: -2px; border-right: none; border-top: none; }
.corner.br { bottom: -2px; right: -2px; border-left: none; border-top: none; }
.scan-line {
  position: absolute; left: 6%; right: 6%; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 2px;
  animation: scan-sweep 2s ease-in-out infinite;
}
@keyframes scan-sweep {
  0%   { top: 6%;  opacity: 0.2; }
  50%  { top: 92%; opacity: 1; }
  100% { top: 6%;  opacity: 0.2; }
}
@media (prefers-reduced-motion: reduce) { .scan-line { animation: none; top: 50%; } }

#scan-panel.hit .scan-frame { box-shadow: 0 0 0 100vmax rgba(22, 163, 74, 0.35); }
#scan-panel.hit .corner { border-color: var(--ok); }

.scan-status {
  position: absolute; left: 0; right: 0; bottom: 8px;
  text-align: center; color: #fff; font-size: 13px; margin: 0;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
#scan-panel .secondary {
  position: absolute; right: 8px; top: 8px; z-index: 2;
  min-height: 36px; margin: 0; padding: 0 12px; font-size: 13px;
  background: rgba(255,255,255,0.92);
}

.result-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px; border: 1px solid var(--border); border-radius: 8px; margin: 8px 0; background: #fff;
}
.result-row .meta { font-size: 13px; color: var(--muted); }

.badge { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #eee; }
.badge.ACTIVE, .badge.PARTIAL { background: #dcfce7; color: #166534; }
.badge.REDEEMED { background: #e5e5e5; color: #444; }
.badge.EXPIRED, .badge.CANCELLED { background: #fee2e2; color: #991b1b; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat {
  border: 1px solid var(--border); border-radius: 10px; padding: 14px;
  display: flex; flex-direction: column; gap: 4px; background: #fafafa;
}
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 22px; font-weight: 700; }
.stat.breakage .stat-value { color: #b45309; }

.hidden, [hidden] { display: none !important; }
