/* ── Design tokens ─────────────────────────────────────────────────────────── */
:root {
  --orange:    #FF6B35;
  --orange-dk: #E55A25;
  --dark:      #0F172A;
  --dark2:     #1E293B;
  --dark3:     #334155;
  --text:      #F1F5F9;
  --muted:     #94A3B8;
  --success:   #22C55E;
  --warning:   #F59E0B;
  --error:     #EF4444;
  --blue:      #60A5FA;
  --purple:    #A78BFA;
  --radius:    16px;
  --safe-top:  env(safe-area-inset-top, 0px);
  --safe-bot:  env(safe-area-inset-bottom, 0px);
  --header-h:  60px;
  --tabbar-h:  56px;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--dark);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ── Screens ─────────────────────────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  background: var(--dark);
  overflow: hidden;
}
.screen.active { display: flex; }

/* ═══════════════════════════════════════════════════════
   INSTALL SCREEN
═══════════════════════════════════════════════════════ */
#screen-install {
  align-items: center;
  justify-content: flex-end;
  background: linear-gradient(160deg, #1a1a2e 0%, var(--dark) 60%);
}
.install-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 30%, rgba(255,107,53,.18) 0%, transparent 70%);
  pointer-events: none;
}
.install-body {
  position: relative; width: 100%;
  padding: 32px 24px calc(32px + var(--safe-bot));
  background: var(--dark2);
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -8px 40px rgba(0,0,0,.4);
  border-top: 1px solid rgba(255,255,255,.06);
}
.install-logo {
  width: 72px; height: 72px;
  background: var(--orange); border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 8px 24px rgba(255,107,53,.4);
}
.install-logo svg { width: 40px; height: 40px; fill: #fff; }
.install-title { font-size: 26px; font-weight: 700; text-align: center; margin-bottom: 8px; }
.install-sub   { font-size: 14px; color: var(--muted); text-align: center; margin-bottom: 28px; line-height: 1.5; }
.install-features { display: flex; gap: 10px; margin-bottom: 28px; }
.install-feat {
  flex: 1; background: var(--dark3); border-radius: 14px;
  padding: 16px 10px; text-align: center;
  border: 1px solid rgba(255,255,255,.06);
}
.install-feat .icon {
  width: 44px; height: 44px; border-radius: 13px;
  background: rgba(255,107,53,.15); border: 1px solid rgba(255,107,53,.2);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 9px; color: var(--orange);
}
.install-feat .icon svg { width: 20px; height: 20px; }
.install-feat .label { font-size: 11px; color: var(--muted); line-height: 1.4; font-weight: 500; }
.btn-install {
  width: 100%; padding: 16px; border: none; border-radius: var(--radius);
  background: var(--orange); color: #fff;
  font-size: 16px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 20px rgba(255,107,53,.4);
  transition: transform .1s, box-shadow .1s;
}
.btn-install:active { transform: scale(.98); box-shadow: none; }
.btn-skip {
  display: block; width: 100%; margin-top: 14px;
  background: none; border: none; color: var(--muted);
  font-size: 14px; cursor: pointer; padding: 8px;
}
.ios-guide {
  background: var(--dark3); border-radius: 12px;
  padding: 16px; margin-bottom: 20px;
  border: 1px solid rgba(255,255,255,.06);
}
.ios-step {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px; font-size: 14px;
}
.ios-step:last-child { margin-bottom: 0; }
.ios-step .num {
  width: 24px; height: 24px; background: var(--orange);
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════
   LOGIN SCREEN
═══════════════════════════════════════════════════════ */
#screen-login {
  align-items: center; justify-content: center;
  padding: calc(var(--safe-top) + 24px) 24px 24px;
  background: linear-gradient(160deg, #1a1a2e 0%, var(--dark) 60%);
}
#screen-login::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 20%, rgba(255,107,53,.15) 0%, transparent 65%);
}
.login-card {
  position: relative; width: 100%; max-width: 400px;
  background: var(--dark2); border-radius: 24px;
  padding: 40px 32px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
  border: 1px solid rgba(255,255,255,.06);
}
.login-logo {
  width: 64px; height: 64px; background: var(--orange);
  border-radius: 18px; display: flex; align-items: center;
  justify-content: center; margin: 0 auto 20px;
  box-shadow: 0 6px 20px rgba(255,107,53,.4);
}
.login-logo svg { width: 36px; height: 36px; fill: #fff; }
.login-title { font-size: 24px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.login-sub   { font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 32px; }
.field { margin-bottom: 16px; }
.field label {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--muted); margin-bottom: 7px;
  font-weight: 600; letter-spacing: .5px; text-transform: uppercase;
}
.field label svg { opacity: .7; }
.field input {
  width: 100%; padding: 14px 16px;
  background: var(--dark3); border: 1.5px solid rgba(255,255,255,.08);
  border-radius: 12px; color: var(--text); font-size: 15px;
  outline: none; transition: border-color .2s, background .2s;
}
.field input::placeholder { color: var(--muted); opacity: .6; }
.field input:focus { border-color: var(--orange); background: rgba(255,107,53,.04); }
.btn-login {
  width: 100%; padding: 15px; border: none; border-radius: 12px;
  background: var(--orange); color: #fff;
  font-size: 16px; font-weight: 700; cursor: pointer; margin-top: 8px;
  box-shadow: 0 4px 16px rgba(255,107,53,.35);
  transition: transform .1s;
}
.btn-login:active { transform: scale(.98); }
.btn-login:disabled { opacity: .6; cursor: not-allowed; }
.login-error {
  display: none;
  margin-top: 12px; padding: 10px 14px; border-radius: 10px;
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.25);
  color: var(--error); font-size: 13px; text-align: center;
  align-items: center; justify-content: center; gap: 6px;
}

/* ═══════════════════════════════════════════════════════
   EVENTS SCREEN
═══════════════════════════════════════════════════════ */
#screen-events { background: var(--dark); }
.events-header {
  padding: calc(var(--safe-top) + 20px) 20px 18px;
  background: var(--dark2);
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.events-header-top {
  display: flex; align-items: center; justify-content: space-between;
}
.ev-title { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.scanner-name-row {
  font-size: 13px; color: var(--muted); margin-top: 3px;
  display: flex; align-items: center; gap: 5px;
}
.scanner-name-row svg { width: 13px; height: 13px; opacity: .6; }
.btn-logout {
  width: 40px; height: 40px; background: var(--dark3);
  border: 1px solid rgba(255,255,255,.08); border-radius: 12px;
  color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.btn-logout:active { background: rgba(239,68,68,.15); color: var(--error); }
.events-list { flex: 1; overflow-y: auto; padding: 16px; padding-bottom: calc(16px + var(--safe-bot)); }
.events-list-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; gap: 12px; color: var(--muted); text-align: center; padding: 40px 20px;
}
.events-list-empty .empty-icon {
  width: 64px; height: 64px; background: var(--dark3); border-radius: 20px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 4px; color: var(--muted);
}
.events-list-empty .empty-icon svg { width: 28px; height: 28px; }
.events-list-empty p { font-size: 14px; max-width: 220px; line-height: 1.5; }
.event-card {
  background: var(--dark2); border-radius: var(--radius);
  padding: 16px; margin-bottom: 10px; cursor: pointer;
  border: 1.5px solid rgba(255,255,255,.06);
  transition: border-color .2s, transform .12s;
  display: flex; gap: 14px; align-items: center;
}
.event-card:active { transform: scale(.99); border-color: var(--orange); }
.event-card-cover {
  width: 54px; height: 54px; border-radius: 10px;
  object-fit: cover; flex-shrink: 0; background: var(--dark3);
}
.event-card-cover-placeholder {
  width: 54px; height: 54px; border-radius: 10px; flex-shrink: 0;
  background: var(--dark3); display: flex; align-items: center; justify-content: center;
  color: var(--muted); border: 1px solid rgba(255,255,255,.05);
}
.event-card-cover-placeholder svg { width: 22px; height: 22px; }
.event-card-info { flex: 1; min-width: 0; }
.event-card-name { font-size: 15px; font-weight: 600; margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-card-meta { display: flex; flex-direction: column; gap: 3px; }
.event-meta-item {
  font-size: 12px; color: var(--muted);
  display: flex; align-items: center; gap: 4px;
}
.event-meta-item svg { width: 11px; height: 11px; flex-shrink: 0; opacity: .7; }
.event-card-arrow {
  width: 28px; height: 28px; background: var(--dark3); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; color: var(--muted); flex-shrink: 0;
}
.event-card-arrow svg { width: 14px; height: 14px; }

/* ═══════════════════════════════════════════════════════
   SHELL SCREEN
═══════════════════════════════════════════════════════ */
#screen-shell { background: var(--dark); }

/* Shell header */
.shell-header {
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-top) + 10px) 14px 10px;
  background: var(--dark2);
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
  min-height: calc(var(--safe-top) + var(--header-h));
}
.shell-event-btn {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  background: var(--dark3); border: 1px solid rgba(255,255,255,.07);
  border-radius: 12px; padding: 8px 10px 8px 10px;
  cursor: pointer; color: var(--text);
  transition: background .15s;
  overflow: hidden;
}
.shell-event-btn:active    { background: rgba(255,107,53,.12); }
.shell-event-btn:disabled  { opacity: .45; cursor: default; }
.shell-event-icon {
  width: 32px; height: 32px; border-radius: 9px;
  background: rgba(255,107,53,.15); border: 1px solid rgba(255,107,53,.2);
  display: flex; align-items: center; justify-content: center;
  color: var(--orange); flex-shrink: 0;
}
.shell-event-icon svg { width: 15px; height: 15px; }
.shell-event-info { flex: 1; min-width: 0; text-align: left; }
.shell-event-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shell-event-date { font-size: 11px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shell-chev { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }

.shell-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.shell-live-pill {
  display: flex; align-items: center; gap: 6px;
  background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.2);
  border-radius: 20px; padding: 5px 10px;
  font-size: 13px; font-weight: 700; color: var(--success);
  white-space: nowrap;
}
.live-dot {
  width: 7px; height: 7px; background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(34,197,94,.6);
  animation: livePulse 1.8s ease-out infinite;
}
@keyframes livePulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,.5); }
  70%  { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

.shell-back-btn {
  width: 36px; height: 36px; background: var(--dark3);
  border: 1px solid rgba(255,255,255,.08); border-radius: 10px;
  color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.shell-back-btn:active { background: rgba(255,107,53,.15); color: var(--orange); }

/* Shell body — hosts both tabs */
.shell-body {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* ── Tab system ──────────────────────────────────────── */
.shell-tab {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* Scanner tab: always at z-index 1 so camera keeps running */
#tab-scan  { z-index: 1; background: #000; }

/* Stats tab: slides in on top, solid bg so camera is hidden */
#tab-stats {
  z-index: 2;
  background: var(--dark);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}
#tab-stats.active { transform: translateX(0); }

/* ── Tab bar ─────────────────────────────────────────── */
.tab-bar {
  display: flex;
  background: var(--dark2);
  border-top: 1px solid rgba(255,255,255,.07);
  padding-bottom: var(--safe-bot);
  flex-shrink: 0;
}
.tab-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
  padding: 10px 4px 10px;
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 11px; font-weight: 600;
  letter-spacing: .2px;
  transition: color .2s;
  position: relative;
}
.tab-btn.active { color: var(--orange); }
.tab-icon {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.tab-icon svg { width: 22px; height: 22px; transition: transform .2s; }
.tab-btn.active .tab-icon svg { transform: scale(1.1); }
.tab-btn::before {
  content: '';
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 0; height: 2px;
  background: var(--orange); border-radius: 0 0 2px 2px;
  transition: width .25s cubic-bezier(.34,1.56,.64,1);
}
.tab-btn.active::before { width: 32px; }

/* ═══════════════════════════════════════════════════════
   SCANNER TAB
═══════════════════════════════════════════════════════ */
#qr-reader { position: absolute; inset: 0; }
#qr-reader video { width: 100% !important; height: 100% !important; object-fit: cover !important; }
#qr-reader > div { display: none !important; }
#qr-reader__scan_region { position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important; }
#qr-reader__scan_region img { display: none !important; }

/* Viewfinder */
.scan-overlay {
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse 65% 55% at 50% 46%, transparent 0%, rgba(0,0,0,.55) 100%);
}
.scan-frame {
  position: relative;
  width: min(260px, 65vw); height: min(260px, 65vw);
}
.scan-corner {
  position: absolute; width: 28px; height: 28px;
  border-color: var(--orange); border-style: solid;
}
.scan-corner.tl { top: 0; left: 0; border-width: 3px 0 0 3px; border-radius: 8px 0 0 0; }
.scan-corner.tr { top: 0; right: 0; border-width: 3px 3px 0 0; border-radius: 0 8px 0 0; }
.scan-corner.bl { bottom: 0; left: 0; border-width: 0 0 3px 3px; border-radius: 0 0 0 8px; }
.scan-corner.br { bottom: 0; right: 0; border-width: 0 3px 3px 0; border-radius: 0 0 8px 0; }
.scan-line {
  position: absolute; left: 4px; right: 4px; height: 2px;
  background: linear-gradient(to right, transparent, var(--orange), transparent);
  filter: drop-shadow(0 0 4px var(--orange));
  animation: scanLine 2s ease-in-out infinite;
}
@keyframes scanLine {
  0%   { top: 4px; }
  50%  { top: calc(100% - 4px); }
  100% { top: 4px; }
}
.scan-hint {
  position: absolute; bottom: -38px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: rgba(255,255,255,.6); white-space: nowrap;
  background: rgba(0,0,0,.45); backdrop-filter: blur(6px);
  padding: 6px 14px; border-radius: 20px;
}

/* Scan result card */
.scan-result {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 20;
  padding: 12px 14px 14px;
  transform: translateY(110%);
  transition: transform .32s cubic-bezier(.34,1.56,.64,1);
  pointer-events: none;
}
.scan-result.visible { transform: translateY(0); pointer-events: auto; }
.scan-result-card {
  border-radius: 20px; padding: 16px 16px 0;
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  display: flex; gap: 14px; align-items: center;
  position: relative; overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.scan-result-card.success   { background: rgba(22,163,74,.95); }
/* Admitted, but the booking is not finished. Green would read as "done" and
   the agent would forget the two people still to come. */
.scan-result-card.partial   {
  background: rgba(13,148,136,.95);
  border: 2px solid rgba(94,234,212,.45);
}
.scan-result-card.warning   { background: rgba(217,119,6,.95); }
.scan-result-card.error     { background: rgba(220,38,38,.95); }
.scan-result-card.duplicate {
  background: rgba(109,40,217,.95);
  border: 2px solid rgba(196,160,255,.5);
  box-shadow: 0 0 0 0 rgba(139,92,246,.6), 0 10px 40px rgba(0,0,0,.5);
  animation: duplicatePulse .5s ease-out forwards;
}
@keyframes duplicatePulse {
  0%   { box-shadow: 0 0 0 0 rgba(139,92,246,.7), 0 10px 40px rgba(0,0,0,.5); }
  100% { box-shadow: 0 0 0 18px rgba(139,92,246,0), 0 10px 40px rgba(0,0,0,.5); }
}
@keyframes cardShake {
  0%, 100% { transform: translateX(0); }
  15%  { transform: translateX(-8px); }
  30%  { transform: translateX(8px); }
  45%  { transform: translateX(-5px); }
  60%  { transform: translateX(5px); }
  75%  { transform: translateX(-2px); }
}
.scan-result-card.shake { animation: cardShake .45s cubic-bezier(.36,.07,.19,.97); }

.result-icon {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.result-icon svg { width: 26px; height: 26px; }
@keyframes iconBounce {
  0%   { transform: scale(.55); opacity: 0; }
  65%  { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
.result-icon.animate { animation: iconBounce .32s cubic-bezier(.34,1.56,.64,1) both; }

.result-info { flex: 1; min-width: 0; padding-bottom: 16px; }
.result-name { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; margin-bottom: 3px; }
.result-type { font-size: 13px; color: rgba(255,255,255,.8); }
.result-msg  { font-size: 12px; color: rgba(255,255,255,.65); margin-top: 3px; }

/* Undo button on the result card. Sized for a thumb on a moving queue, and
   held clear of the card's own tap-to-hold surface. */
.result-undo {
  display: none;
  flex-shrink: 0; align-self: center;
  margin-bottom: 16px;
  padding: 10px 16px; border-radius: 12px;
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.14); color: #fff;
  font-size: 13px; font-weight: 700; letter-spacing: .01em;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.result-undo:active   { background: rgba(255,255,255,.28); }
.result-undo.visible  { display: block; }
.result-undo:disabled { opacity: .55; }

.result-progress {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 3px; background: rgba(255,255,255,.15);
}
.result-progress-fill {
  height: 100%; background: rgba(255,255,255,.55);
  transform-origin: left;
}

/* Floating action buttons (torch + manual entry) */
.scan-actions {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  z-index: 10;
  display: flex; flex-direction: column; gap: 10px;
}
.scan-action-btn {
  width: 48px; height: 48px;
  background: rgba(15,23,42,.7); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.15); border-radius: 14px;
  color: rgba(255,255,255,.85); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, color .2s, border-color .2s;
}
.scan-action-btn svg { width: 20px; height: 20px; }
.scan-action-btn:active { background: rgba(255,255,255,.15); }
.scan-action-btn.torch-on {
  background: rgba(255,214,0,.15);
  border-color: rgba(255,214,0,.4);
  color: #FFD600;
}

/* ═══════════════════════════════════════════════════════
   STATS TAB (full page)
═══════════════════════════════════════════════════════ */
.stats-page { padding: 20px 16px calc(20px + var(--safe-bot)); }

.stats-page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.stats-page-title { font-size: 20px; font-weight: 800; letter-spacing: -.3px; }
.stats-refresh-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--dark3); border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px; padding: 7px 12px;
  color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer;
  transition: color .2s, background .2s;
}
.stats-refresh-btn:active { background: rgba(255,107,53,.12); color: var(--orange); }
.stats-refresh-btn.spinning svg { animation: spin .6s linear infinite; }

/* Stats grid */
.stats-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin-bottom: 14px;
}
.stat-card {
  background: var(--dark2); border-radius: 18px; padding: 16px;
  border: 1px solid rgba(255,255,255,.06);
}
.stat-icon {
  width: 36px; height: 36px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.stat-icon svg { width: 17px; height: 17px; }
.stat-icon.orange { background: rgba(255,107,53,.15); color: var(--orange); }
.stat-icon.green  { background: rgba(34,197,94,.15);  color: var(--success); }
.stat-icon.blue   { background: rgba(96,165,250,.15); color: var(--blue); }
.stat-icon.purple { background: rgba(167,139,250,.15); color: var(--purple); }
.stat-label { font-size: 11px; color: var(--muted); letter-spacing: .3px; margin-bottom: 5px; font-weight: 500; }
.stat-value { font-size: 32px; font-weight: 800; line-height: 1; letter-spacing: -.8px; color: var(--text); }
.stat-value.orange { color: var(--orange); }
.stat-value.green  { color: var(--success); }
.stat-value.purple { color: var(--purple); }

/* Capacity bar */
.stats-capacity {
  background: var(--dark2); border-radius: 16px; padding: 16px;
  border: 1px solid rgba(255,255,255,.06); margin-bottom: 14px;
}
.capacity-label-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.capacity-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.capacity-counts { font-size: 13px; font-weight: 700; color: var(--text); }
.capacity-bar-bg { height: 10px; background: var(--dark3); border-radius: 5px; overflow: hidden; }
.capacity-partial { margin-top: 9px; font-size: 12px; font-weight: 600; color: rgb(94,234,212); }
.capacity-partial[hidden] { display: none; }
.capacity-bar-fill {
  height: 100%;
  background: linear-gradient(to right, var(--orange-dk), var(--orange));
  border-radius: 5px;
  transition: width .7s cubic-bezier(.4,0,.2,1);
}

/* Recent scans */
.scans-section {
  background: var(--dark2); border-radius: 18px;
  border: 1px solid rgba(255,255,255,.06); overflow: hidden;
}
.scans-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.scans-section-title {
  font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px;
}
.live-badge {
  display: flex; align-items: center; gap: 5px;
  background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.2);
  border-radius: 8px; padding: 3px 7px;
  font-size: 10px; font-weight: 800; color: var(--success); letter-spacing: .6px;
}
.live-dot-sm {
  width: 6px; height: 6px; background: var(--success); border-radius: 50%;
  animation: livePulse 1.8s ease-out infinite;
}

.scan-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.scan-row:last-child { border-bottom: none; }
.scan-row-dot {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.scan-row-dot svg { width: 17px; height: 17px; }
.scan-row-dot.single { background: rgba(34,197,94,.12); color: var(--success); }
.scan-row-dot.pass   { background: rgba(255,107,53,.12); color: var(--orange); }
.scan-row-info { flex: 1; min-width: 0; }
.scan-row-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scan-row-type { font-size: 12px; color: var(--muted); margin-top: 1px; }
.scan-row-time { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.scan-row-undo {
  flex-shrink: 0; margin-left: 10px;
  padding: 7px 12px; border-radius: 10px;
  border: 1px solid var(--dark3);
  background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 600;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.scan-row-undo:active   { background: rgba(255,255,255,.08); color: #fff; }
.scan-row-undo:disabled { opacity: .5; }
.scans-empty { text-align: center; padding: 32px 16px; color: var(--muted); font-size: 14px; }

/* ═══════════════════════════════════════════════════════
   BOTTOM SHEETS (event switcher + manual entry)
═══════════════════════════════════════════════════════ */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s;
}
.sheet-overlay.open { opacity: 1; pointer-events: auto; }

.bottom-sheet {
  width: 100%;
  background: var(--dark2); border-radius: 24px 24px 0 0;
  padding: 0 0 calc(20px + var(--safe-bot));
  border-top: 1px solid rgba(255,255,255,.07);
  max-height: 85vh; overflow-y: auto;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.sheet-overlay.open .bottom-sheet {
  transform: translateY(0);
  transition: transform .32s cubic-bezier(.34,1.56,.64,1);
}

.sheet-handle {
  width: 36px; height: 4px; background: var(--dark3);
  border-radius: 2px; margin: 14px auto 18px;
}
.sheet-title-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  margin-bottom: 4px;
}
.sheet-title { font-size: 17px; font-weight: 700; }
.sheet-close-btn {
  width: 32px; height: 32px; background: var(--dark3); border: none;
  border-radius: 50%; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255,255,255,.07);
}
.sheet-close-btn:active { background: rgba(255,255,255,.12); }
.sheet-sub {
  font-size: 13px; color: var(--muted); padding: 0 20px 16px;
  line-height: 1.5;
}

/* Event switcher rows */
.switcher-event-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px; cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,.05);
  transition: background .15s;
}
.switcher-event-row:last-child { border-bottom: none; }
.switcher-event-row:active { background: rgba(255,107,53,.07); }
.switcher-event-row.current { background: rgba(255,107,53,.08); }
.switcher-cover {
  width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
  object-fit: cover; background: var(--dark3);
}
.switcher-cover-placeholder {
  width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
  background: var(--dark3); display: flex; align-items: center;
  justify-content: center; color: var(--muted);
}
.switcher-cover-placeholder svg { width: 18px; height: 18px; }
.switcher-event-info { flex: 1; min-width: 0; }
.switcher-event-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.switcher-event-date { font-size: 12px; color: var(--muted); margin-top: 2px; }
.switcher-check {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--orange); display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}
.switcher-check svg { width: 13px; height: 13px; }

/* Sheet footer (logout row) */
.sheet-footer {
  padding: 12px 20px 0;
  border-top: 1px solid rgba(255,255,255,.06);
  margin-top: 8px;
}
.sheet-logout-row {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  background: rgba(239,68,68,.06);
  border: 1px solid rgba(239,68,68,.15); border-radius: 14px;
  color: var(--error); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.sheet-logout-row:active { background: rgba(239,68,68,.14); }
.sheet-logout-row svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Manual entry form */
#manual-entry-form { padding: 16px 20px 0; }
#manual-code-input {
  width: 100%; padding: 15px 16px;
  background: var(--dark3); border: 1.5px solid rgba(255,255,255,.08);
  border-radius: 12px; color: var(--text); font-size: 16px; font-family: 'SF Mono', 'Fira Code', monospace;
  letter-spacing: 1px; text-transform: uppercase;
  outline: none; transition: border-color .2s;
  margin-bottom: 12px;
}
#manual-code-input::placeholder { color: var(--muted); opacity: .5; font-family: -apple-system, sans-serif; letter-spacing: 0; text-transform: none; font-size: 14px; }
#manual-code-input:focus { border-color: var(--orange); }
.btn-manual-submit {
  width: 100%; padding: 15px; border: none; border-radius: 12px;
  background: var(--orange); color: #fff;
  font-size: 16px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 16px rgba(255,107,53,.35);
  transition: transform .1s;
}
.btn-manual-submit:active { transform: scale(.98); }
.btn-manual-submit:disabled { opacity: .6; cursor: not-allowed; }

/* Group admission — "combien entrent ?"
   Big targets on purpose: this is tapped one-handed, at a gate, with a queue
   waiting, and a mis-tap here admits the wrong number of people. */
.qty-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  padding-bottom: 4px;
}
.qty-btn {
  min-height: 60px; border-radius: 14px;
  background: var(--dark3); border: 1.5px solid rgba(255,255,255,.08);
  color: var(--text); font-size: 22px; font-weight: 800;
  cursor: pointer; transition: transform .1s, border-color .2s;
}
.qty-btn:active { transform: scale(.96); border-color: var(--orange); }
.qty-btn-all {
  grid-column: 1 / -1; font-size: 16px;
  background: var(--orange); border-color: transparent; color: #fff;
  box-shadow: 0 4px 16px rgba(255,107,53,.35);
}

/* Search by name */
#search-input {
  width: calc(100% - 40px); margin: 0 20px 12px; padding: 15px 16px;
  background: var(--dark3); border: 1.5px solid rgba(255,255,255,.08);
  border-radius: 12px; color: var(--text); font-size: 16px;
  outline: none; transition: border-color .2s;
  -webkit-appearance: none;
}
#search-input::placeholder { color: var(--muted); opacity: .5; font-size: 14px; }
#search-input:focus { border-color: var(--orange); }
/* Capped so the list scrolls inside the sheet rather than pushing the input
   off the top of a phone that is already half keyboard. */
#search-results { max-height: 46vh; overflow-y: auto; }
.search-hint {
  text-align: center; padding: 26px 20px; color: var(--muted); font-size: 13px;
}
.search-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px; cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,.05);
  transition: background .15s;
}
.search-row:last-child { border-bottom: none; }
.search-row:active { background: rgba(255,107,53,.07); }
.search-row.used { opacity: .55; }
.search-row-code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px; color: var(--muted); flex-shrink: 0; letter-spacing: .5px;
}

/* Camera picker rows */
.camera-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px; cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,.05);
  transition: background .15s;
}
.camera-row:last-child { border-bottom: none; }
.camera-row:active { background: rgba(255,107,53,.07); }
.camera-row.current { background: rgba(255,107,53,.08); }
.camera-row-icon {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  background: var(--dark3); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.camera-row-icon svg { width: 17px; height: 17px; }
.camera-row-label {
  flex: 1; min-width: 0; font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ═══════════════════════════════════════════════════════
   SHARED UTILITIES
═══════════════════════════════════════════════════════ */
.spinner {
  width: 20px; height: 20px; border: 2px solid rgba(255,255,255,.25);
  border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.snackbar {
  position: fixed; bottom: calc(80px + var(--safe-bot)); left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--dark3); color: var(--text); padding: 11px 20px;
  border-radius: 12px; font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,.45); z-index: 9999;
  opacity: 0;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .3s;
  max-width: calc(100vw - 48px);
  white-space: normal;
  text-align: center;
  border: 1px solid rgba(255,255,255,.08);
  pointer-events: none;
}
.snackbar.show { transform: translateX(-50%) translateY(0); opacity: 1; }
