:root {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f59e0b;
  --border: #334155;
  --radius: 16px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: linear-gradient(160deg, #0f172a 0%, #1e3a5f 100%);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--accent); }
.wrap { max-width: 960px; margin: 0 auto; padding: 20px; }
header {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  justify-content: space-between; margin-bottom: 20px;
}
header h1 { margin: 0; font-size: 1.4rem; }
header .sub { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
.nav a {
  display: inline-block; padding: 8px 14px; border-radius: 999px;
  background: rgba(56,189,248,0.15); text-decoration: none; margin-left: 6px;
}
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.card h2 { margin: 0 0 12px; font-size: 1.1rem; }
label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea, button {
  font: inherit; border-radius: 10px; border: 1px solid var(--border);
  padding: 10px 12px; width: 100%; background: #0b1220; color: var(--text);
}
button {
  background: var(--accent); color: #0f172a; font-weight: 700;
  border: none; cursor: pointer; width: auto;
}
button.secondary { background: #334155; color: var(--text); }
button.danger { background: var(--red); color: white; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .row { grid-template-columns: 1fr; } }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.stats { display: flex; gap: 12px; flex-wrap: wrap; }
.stat {
  flex: 1; min-width: 100px; background: #0b1220; border-radius: 12px;
  padding: 12px; text-align: center; border: 1px solid var(--border);
}
.stat b { display: block; font-size: 1.6rem; }
.stat span { color: var(--muted); font-size: 0.8rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; }
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 700;
}
.badge.ok { background: rgba(34,197,94,0.2); color: #86efac; }
.badge.wait { background: rgba(56,189,248,0.2); color: #7dd3fc; }
.qr-thumb { width: 56px; height: 56px; border-radius: 8px; background: white; }
.pin-gate {
  max-width: 360px; margin: 12vh auto; text-align: center;
}
.hint { color: var(--muted); font-size: 0.85rem; margin-top: 8px; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #022c22; color: #a7f3d0; padding: 12px 18px; border-radius: 999px;
  display: none; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.toast.show { display: block; }
.toast.err { background: #450a0a; color: #fecaca; }

/* Scanner */
.scanner-body { overflow: hidden; }
#reader {
  width: 100%; max-width: 480px; margin: 0 auto;
  border-radius: 16px; overflow: hidden; background: #000;
}
.result-overlay {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  flex-direction: column; z-index: 100; padding: 24px; text-align: center;
  transition: background 0.15s ease;
}
.result-overlay.show { display: flex; }
.result-overlay.green { background: rgba(22,163,74,0.95); }
.result-overlay.red { background: rgba(220,38,38,0.95); }
.result-overlay.orange { background: rgba(217,119,6,0.95); }
.result-overlay h1 { font-size: clamp(2rem, 8vw, 3.5rem); margin: 0 0 12px; }
.result-overlay p { font-size: 1.2rem; margin: 0; opacity: 0.95; }
.result-overlay .meta { margin-top: 18px; font-size: 1rem; opacity: 0.9; }
.scan-status {
  text-align: center; margin: 12px 0; color: var(--muted);
}

.btn-link {
  display: inline-block; padding: 12px 18px; border-radius: 999px;
  background: #22c55e; color: #052e16 !important; font-weight: 800;
  text-decoration: none;
}
.btn-link:hover { filter: brightness(1.05); }
.badge.pending { background: rgba(245,158,11,0.2); color: #fcd34d; }
.badge.rejected { background: rgba(239,68,68,0.2); color: #fca5a5; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button.active { background: var(--accent); color: #0f172a; }
