:root {
  --bg-deep: #130b24;
  --bg-card: #1f1338;
  --bg-elevated: #2b1b4d;
  --border-subtle: rgba(245, 158, 11, 0.22);
  --gold: #f59e0b;
  --gold-bright: #fbbf24;
  --emerald: #10b981;
  --emerald-dark: #059669;
  --amber: #f59e0b;
  --crimson: #ef4444;
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --text-dim: #94a3b8;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}

.hidden {
  display: none !important;
}

/* LOGIN OVERLAY */
.login-overlay {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top, #2e1759 0%, #130b24 70%);
}

.login-card {
  width: 100%;
  max-width: 390px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 28px 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.diya-badge {
  font-size: 44px;
  margin-bottom: 8px;
}

.login-card h1 {
  margin: 0;
  font-size: 24px;
  color: var(--gold-bright);
}

.subtitle {
  margin: 4px 0 22px;
  color: var(--text-muted);
  font-size: 14px;
}

#login-form {
  text-align: left;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 12px 0 6px;
}

input[type="text"],
input[type="password"],
input[type="search"],
.select-input {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(15, 9, 28, 0.85);
  color: var(--text-main);
  outline: none;
}

input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25);
}

.error-msg {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid var(--crimson);
  color: #fca5a5;
  font-size: 14px;
}

/* APP SHELL */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: calc(74px + var(--safe-bottom));
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(19, 11, 36, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 14px 12px;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 17px;
  color: var(--gold-bright);
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: var(--bg-elevated);
  color: var(--text-main);
  cursor: pointer;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
}

.sync-pill.pending .sync-dot {
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
}

.sync-pill.offline .sync-dot {
  background: var(--crimson);
}

.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-chip {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 6px 8px;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-val {
  font-size: 14px;
  color: var(--text-muted);
}

.stat-val strong {
  color: var(--gold-bright);
  font-size: 16px;
}

/* MAIN VIEW & TABS */
.main-view {
  flex: 1;
  padding: 14px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* SCANNER CARD */
.scanner-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  overflow: hidden;
  padding: 12px;
}

.scanner-viewport-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #090512;
}

.qr-reader-box {
  width: 100%;
  min-height: 260px;
  background: #090512;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

.qr-reader-box video {
  border-radius: 12px;
  object-fit: cover;
}

/* LIVE SCAN PROGRESS HUD & LASER */
.scan-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transition: box-shadow 0.15s ease;
}

.scan-hud.detected {
  box-shadow: inset 0 0 0 4px var(--emerald), inset 0 0 30px rgba(16, 185, 129, 0.45);
}

.scan-laser {
  position: absolute;
  left: 10%;
  right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-bright), #10b981, var(--gold-bright), transparent);
  box-shadow: 0 0 10px var(--gold-bright), 0 0 18px #10b981;
  top: 18%;
  opacity: 0;
}

.scan-hud.scanning .scan-laser {
  opacity: 0.95;
  animation: laserSweep 1.8s ease-in-out infinite alternate;
}

@keyframes laserSweep {
  0% { top: 15%; }
  100% { top: 78%; }
}

.scan-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(13, 7, 26, 0.82);
  backdrop-filter: blur(6px);
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  border-top: 1px solid rgba(245, 158, 11, 0.2);
}

.scan-pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--amber);
  flex-shrink: 0;
}

.scan-hud.scanning .scan-pulse-dot {
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
  animation: pulseDot 0.9s ease-in-out infinite alternate;
}

.scan-hud.paused .scan-pulse-dot {
  background: var(--text-dim);
}

@keyframes pulseDot {
  from { transform: scale(0.85); opacity: 0.6; }
  to { transform: scale(1.25); opacity: 1; }
}

.scan-frame-counter {
  margin-left: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--gold-bright);
}

.scanner-controls {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.scanner-controls .btn {
  flex: 1;
}

.scan-instructions {
  text-align: center;
  margin: 14px 4px;
}

.instruction-title {
  margin: 0;
  font-weight: 700;
  font-size: 16px;
  color: var(--gold-bright);
}

.instruction-sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* RECENT CHECK-INS */
.recent-box {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.section-header {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-hint {
  font-size: 13px;
  color: var(--text-dim);
  padding: 8px 0;
}

/* GUEST LIST & SEARCH */
.search-sticky {
  position: sticky;
  top: 98px;
  z-index: 20;
  background: var(--bg-deep);
  padding-bottom: 10px;
}

.search-input-wrap {
  position: relative;
}

.clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
}

.filter-pills {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  overflow-x: auto;
}

.filter-pill {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
  cursor: pointer;
}

.filter-pill.active {
  background: var(--gold);
  color: #130b24;
  border-color: var(--gold);
}

.attendee-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guest-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.guest-row:active {
  transform: scale(0.985);
}

.guest-row.checked {
  border-left: 4px solid var(--emerald);
}

.guest-info h4 {
  margin: 0 0 3px;
  font-size: 16px;
  color: var(--text-main);
}

.guest-meta {
  font-size: 12px;
  color: var(--text-dim);
}

.guest-badges {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.party-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--gold-bright);
}

.status-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
}

.status-tag.done {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.status-tag.wait {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
}

.status-tag.unsynced {
  background: rgba(245, 158, 11, 0.2);
  color: var(--gold-bright);
}

/* ADMIN CARDS */
.admin-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
}

.admin-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
  color: var(--gold-bright);
}

.muted-text {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.kv-list {
  margin-bottom: 12px;
  font-size: 13px;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.file-input {
  width: 100%;
  margin-bottom: 10px;
  font-size: 13px;
}

.radio-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  margin-bottom: 12px;
}

.status-note {
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  font-size: 13px;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 16px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
}

.btn:active {
  opacity: 0.85;
}

.btn-sm {
  padding: 9px 12px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
  margin-top: 10px;
}

.btn-row {
  display: flex;
  gap: 8px;
}

.btn-row .btn {
  flex: 1;
}

.btn-primary {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #130b24;
}

.btn-confirm {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  font-size: 18px;
  padding: 16px;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.35);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-outline {
  background: transparent;
  color: var(--gold-bright);
  border: 1px solid var(--gold);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid var(--crimson);
}

.btn-danger-outline {
  background: transparent;
  color: #fca5a5;
  border: 1px solid var(--crimson);
}

/* BOTTOM NAVIGATION */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: rgba(19, 11, 36, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-around;
  padding: 6px 8px calc(6px + var(--safe-bottom));
  max-width: 560px;
  margin: 0 auto;
}

.nav-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.nav-btn.active {
  color: var(--gold-bright);
}

.nav-icon {
  font-size: 20px;
}

/* CONFIRMATION BOTTOM SHEET MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 2, 12, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-sheet {
  width: 100%;
  max-width: 520px;
  background: var(--bg-card);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  border-top: 1px solid var(--border-subtle);
  overflow: hidden;
  padding-bottom: calc(16px + var(--safe-bottom));
  animation: slideUp 0.18s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-banner {
  padding: 12px 18px;
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.banner-ready {
  background: linear-gradient(90deg, #059669, #10b981);
  color: #ffffff;
}

.banner-warning {
  background: linear-gradient(90deg, #d97706, #f59e0b);
  color: #130b24;
}

.banner-error {
  background: linear-gradient(90deg, #dc2626, #ef4444);
  color: #ffffff;
}

.modal-body {
  padding: 18px;
}

.entrant-header {
  text-align: center;
  margin-bottom: 14px;
}

.badge-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.reg-id-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--gold-bright);
  font-size: 12px;
  font-weight: 700;
}

.slot-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  font-size: 12px;
  font-weight: 700;
}

.slot-badge.mismatch {
  background: rgba(239, 68, 68, 0.22);
  color: #fca5a5;
  border: 1px solid var(--crimson);
}

.slot-mismatch-box {
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid var(--crimson);
  color: #fecaca;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  text-align: center;
  margin-bottom: 14px;
  line-height: 1.4;
}

.entrant-header h2 {
  margin: 0 0 4px;
  font-size: 24px;
  color: var(--text-main);
}

.entrant-contact {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.already-checked-box {
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid var(--amber);
  color: var(--gold-bright);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  text-align: center;
  margin-bottom: 14px;
}

.headcount-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.counter-box {
  background: rgba(15, 9, 28, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
}

.counter-title {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.counter-registered {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin: 2px 0 10px;
}

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.step-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: var(--bg-elevated);
  color: var(--text-main);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}

.step-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--gold-bright);
  min-width: 28px;
}

.modal-sub-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.modal-sub-actions .btn {
  flex: 1;
}

.notfound-code {
  background: rgba(0, 0, 0, 0.35);
  padding: 10px;
  border-radius: 8px;
  word-break: break-all;
  font-size: 13px;
}
