/* ============================================
   FaceCheck — Event Face Scan Registration
   Design System: Bright, Event/Conference vibe
   ============================================ */

:root {
  /* Brand */
  --ink: #15131A;
  --ink-2: #2A2530;
  --ink-3: #4A4350;
  --ink-4: #7A7280;
  --ink-5: #B8B2BD;
  --line: #E8E2D9;
  --line-2: #D6CFC2;

  /* Backgrounds */
  --bg: #F5F0E6;
  --bg-warm: #F7F2E8;
  --surface: #FFFFFF;
  --surface-2: #FBF8F1;

  /* Vibrant palette */
  --primary: #4F46E5;          /* electric indigo */
  --primary-soft: #E0DEFF;
  --primary-ink: #1E1B7A;
  --coral: #FB6F50;            /* warm coral */
  --coral-soft: #FFE2D8;
  --mint: #10B981;             /* success */
  --mint-soft: #D1FAE5;
  --green: #10B981;            /* alias used by the check-in "บันทึก"/success styles — was undefined → invisible button */
  --yellow: #F5C518;           /* attention */
  --yellow-soft: #FFF3C4;
  --magenta: #EC4899;
  --magenta-soft: #FCE7F3;
  --cyan: #06B6D4;
  --cyan-soft: #CFFAFE;
  --danger: #DC2626;
  --danger-soft: #FEE2E2;

  /* Dark surface (for radar / realtime) */
  --dark: #0F0E14;
  --dark-2: #1A1822;
  --dark-3: #252231;
  --dark-line: #312D40;

  /* Radii */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(21,19,26,.04), 0 1px 3px rgba(21,19,26,.06);
  --shadow-md: 0 4px 14px rgba(21,19,26,.06), 0 2px 4px rgba(21,19,26,.04);
  --shadow-lg: 0 18px 40px -12px rgba(21,19,26,.18), 0 6px 12px rgba(21,19,26,.06);

  /* Type */
  --font-display: "IBM Plex Sans Thai Looped", "IBM Plex Sans Thai", system-ui, sans-serif;
  --font-body: "IBM Plex Sans Thai", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; padding: 0; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ====== Layout shell ====== */
.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--ink);
  color: #fff;
  padding: 22px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sb-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 6px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sb-brand-mark {
  width: 38px; height: 38px;
  background: var(--coral);
  border-radius: 12px;
  display: grid; place-items: center;
  position: relative;
  overflow: hidden;
}
.sb-brand-mark::before {
  content: ""; position: absolute; inset: 6px;
  border: 2px solid #fff; border-radius: 50%;
  border-top-color: transparent; border-right-color: transparent;
  transform: rotate(-25deg);
}
.sb-brand-mark::after {
  content: ""; width: 6px; height: 6px; background: var(--yellow); border-radius: 50%; z-index: 1;
}
.sb-brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.sb-brand-tag {
  font-size: 10.5px; color: rgba(255,255,255,0.5);
  text-transform: uppercase; letter-spacing: 0.12em; margin-top: 1px;
}

.sb-section { display: flex; flex-direction: column; gap: 2px; }
.sb-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(255,255,255,0.4);
  padding: 0 10px 6px;
  font-weight: 600;
}

.sb-item {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  color: rgba(255,255,255,0.7);
  font-weight: 500;
  font-size: 14px;
  transition: background 120ms, color 120ms;
  cursor: pointer;
  text-align: left;
  width: 100%;
  min-height: 44px;            /* comfortable touch target */
  position: relative;
}
/* Menu label: always one line — never wrap Thai text onto two rows */
.sb-label {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sb-item.is-active {
  background: var(--coral);
  color: #fff;
  font-weight: 600;
}
.sb-item.is-primary:not(.is-active) {
  background: rgba(251,111,80,0.12);
  color: #FFC9B8;
  border: 1px solid rgba(251,111,80,0.25);
}
.sb-item.is-primary:not(.is-active):hover {
  background: rgba(251,111,80,0.2);
  color: #fff;
}
.sb-item .sb-icon { display: grid; place-items: center; width: 20px; height: 20px; flex: none; }
.sb-item .sb-badge {
  margin-left: auto;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 11px; font-weight: 600;
  padding: 1px 7px; border-radius: var(--r-pill);
  min-width: 22px; text-align: center;
}
.sb-item.is-active .sb-badge { background: rgba(255,255,255,0.22); }

.sb-foot {
  margin-top: auto;
  padding: 14px 10px 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 10px;
}

.sb-device-lock {
  background: linear-gradient(135deg, rgba(251,111,80,0.22), rgba(236,72,153,0.18));
  border: 1px solid rgba(251,111,80,0.35);
  border-radius: var(--r-md);
  padding: 12px 14px;
  color: #FFD7CB;
  position: relative;
  overflow: hidden;
}
.sb-device-lock::before {
  content: ""; position: absolute; top: -30px; right: -30px;
  width: 80px; height: 80px; border-radius: 50%;
  background: rgba(251,111,80,0.18);
  filter: blur(20px);
}
.sb-device-lock > * { position: relative; z-index: 1; }
.sb-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--magenta));
  color: #fff; font-weight: 700; display: grid; place-items: center;
  font-size: 13px;
  font-family: var(--font-display);
}
.sb-user { line-height: 1.2; flex: 1; min-width: 0; }
.sb-user-name { font-weight: 600; font-size: 13px; color: #fff; }
.sb-user-role { font-size: 11px; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 0.08em; }

/* ====== Main area ====== */
.main {
  display: flex; flex-direction: column;
  min-width: 0;
}
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 32px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(6px);
}
.topbar-title {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.topbar-sub { font-size: 12.5px; color: var(--ink-4); margin-top: 1px; }

.topbar-search {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 8px 14px;
  width: 280px;
}
.topbar-search input { background: none; border: none; outline: none; flex: 1; width: 100%; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.tb-icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  position: relative;
}
.tb-icon-btn .dot {
  position: absolute; top: 8px; right: 9px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--coral);
  border: 2px solid var(--bg);
}

.content {
  padding: 24px 32px 48px;
  flex: 1;
}

/* ====== Generic ====== */
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  padding: 20px;
}
.card.flat { box-shadow: none; }
.card.bare { padding: 0; overflow: hidden; }

.h1 { font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.1; }
.h2 { font-family: var(--font-display); font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.h3 { font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--ink-4); }
.label-sm { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-4); font-weight: 600; }

/* Pill / Chip */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600;
  background: var(--surface-2);
  color: var(--ink-3);
  border: 1px solid var(--line);
}
.chip.coral { background: var(--coral-soft); color: #99311E; border-color: transparent; }
.chip.mint { background: var(--mint-soft); color: #065F46; border-color: transparent; }
.chip.indigo { background: var(--primary-soft); color: var(--primary-ink); border-color: transparent; }
.chip.yellow { background: var(--yellow-soft); color: #78580B; border-color: transparent; }
.chip.magenta { background: var(--magenta-soft); color: #831843; border-color: transparent; }
.chip.cyan { background: var(--cyan-soft); color: #155E75; border-color: transparent; }
.chip.dark { background: var(--ink); color: #fff; border-color: transparent; }
.chip .dot-sm { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.7; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  border-radius: var(--r-pill);
  font-weight: 600;
  font-size: 14px;
  transition: transform 80ms, background 120ms, border-color 120ms;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-2); }
.btn-coral { background: var(--coral); color: #fff; }
.btn-coral:hover { background: #E55E40; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--surface); }
.btn-soft { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-soft:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-lg { padding: 14px 24px; font-size: 15px; }
.btn-block { width: 100%; }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.input {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 11px 14px;
  outline: none;
  font-size: 14px;
  transition: border-color 100ms, box-shadow 100ms;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input.lg { padding: 14px 16px; font-size: 15px; }

/* Tables */
.tbl {
  width: 100%;
  border-collapse: separate; border-spacing: 0;
}
.tbl th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  padding: 12px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.tbl th:first-child { border-top-left-radius: var(--r-md); }
.tbl th:last-child { border-top-right-radius: var(--r-md); }
.tbl td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--surface-2); }

/* Stat blocks */
.stat-grid { display: grid; gap: 14px; grid-template-columns: repeat(4, 1fr); }
.stat {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  display: flex; flex-direction: column; gap: 10px;
}
.stat-icon {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: grid; place-items: center;
}
.stat-label { font-size: 12.5px; color: var(--ink-4); font-weight: 500; }
.stat-value {
  font-family: var(--font-display);
  font-size: 34px; font-weight: 700;
  line-height: 1; letter-spacing: -0.02em;
}
.stat-value .unit { font-size: 16px; color: var(--ink-4); font-weight: 500; margin-left: 4px; }
.stat-delta {
  font-size: 12px;
  display: inline-flex; align-items: center; gap: 4px;
  font-weight: 600;
}
.stat-delta.up { color: #047857; }
.stat-delta.down { color: var(--danger); }
.stat .stat-spark {
  position: absolute; right: 0; bottom: 0; left: 0; height: 36px; opacity: 0.6;
}

/* Avatar */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-soft), var(--magenta-soft));
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
  color: var(--primary-ink);
  flex: none;
  font-family: var(--font-display);
}
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.avatar.xl { width: 96px; height: 96px; font-size: 30px; }
.avatar.coral { background: linear-gradient(135deg, #FFD7CB, #FFB0A0); color: #99311E; }
.avatar.mint { background: linear-gradient(135deg, #C4F2E3, #99E3C8); color: #065F46; }
.avatar.yellow { background: linear-gradient(135deg, #FFEEA8, #FFD96B); color: #78580B; }
.avatar.cyan { background: linear-gradient(135deg, #C7F2FA, #92E0EE); color: #155E75; }
.avatar.magenta { background: linear-gradient(135deg, #FBC9DD, #F593BD); color: #831843; }
.avatar.indigo { background: linear-gradient(135deg, #D9D5FA, #B6AFFB); color: var(--primary-ink); }

/* ====== Login ====== */
.login-page {
  min-height: 100vh;
  background: var(--bg);
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}
.login-hero {
  background: var(--ink);
  color: #fff;
  padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-hero-bg {
  position: absolute; inset: 0; opacity: 0.6;
  background:
    radial-gradient(circle at 30% 20%, rgba(251,111,80,0.35), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(79,70,229,0.45), transparent 45%),
    radial-gradient(circle at 50% 95%, rgba(236,72,153,0.3), transparent 40%);
}
.login-hero > * { position: relative; z-index: 1; }
.login-form-side {
  display: grid; place-items: center;
  padding: 48px;
}
.login-form {
  width: 100%; max-width: 400px;
  display: flex; flex-direction: column; gap: 20px;
}
.login-tabs {
  display: flex; gap: 4px;
  background: var(--surface);
  padding: 4px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
}
.login-tab {
  flex: 1; padding: 8px 14px;
  border-radius: var(--r-pill);
  font-size: 13px; font-weight: 600;
  color: var(--ink-4);
}
.login-tab.is-active { background: var(--ink); color: #fff; }

/* ====== Radar / Realtime ====== */
/* Light theme to match the rest of the app — the sci-fi face mesh visual
   keeps its dark backdrop only INSIDE the scan-visual card (a "dark island"
   on a light page). */
.realtime-page {
  background: var(--bg);
  color: var(--ink);
  min-height: calc(100vh - 80px);
  margin: -24px -32px -48px;
  padding: 32px;
  position: relative;
  overflow: hidden;
}
.realtime-page::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 25% 30%, rgba(79,70,229,0.04), transparent 50%),
    radial-gradient(circle at 75% 70%, rgba(251,111,80,0.04), transparent 50%);
  pointer-events: none;
}
.realtime-page > * { position: relative; z-index: 1; }

/* The face-mesh visual needs a dark backdrop to read properly. Wrap it in
   this class so the WIREFRAME stays cyan-glowing on near-black without
   dragging the whole page to dark theme. */
.rt-scan-card {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 24px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}
.rt-scan-card::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(circle at 28% 16%, rgba(251,111,80,0.06), transparent 55%),
    radial-gradient(circle at 80% 88%, rgba(79,70,229,0.05), transparent 55%);
}
.rt-scan-card > * { position: relative; z-index: 1; }

/* Clean, on-brand "live scan" stage — light, to match the bright page */
.live-scan {
  position: relative;
  width: 100%; max-width: 480px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  display: grid; place-items: center;
}
.live-scan-ring {
  position: absolute; border-radius: 50%;
  border: 1px solid rgba(21,19,26,0.08);
}
.live-scan-ring.r1 { inset: 0; }
.live-scan-ring.r2 { inset: 12%; border-style: dashed; border-color: rgba(21,19,26,0.10); }
.live-scan-ring.r3 { inset: 26%; }
.live-scan-sweep {
  position: absolute; inset: 4%; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0deg 280deg, rgba(251,111,80,0.16) 330deg, rgba(251,111,80,0.55) 358deg, transparent 360deg);
  -webkit-mask: radial-gradient(circle, transparent 55%, #000 57%);
          mask: radial-gradient(circle, transparent 55%, #000 57%);
  animation: radar-spin 4s linear infinite;
}
.live-scan-line {
  position: absolute; left: 14%; right: 14%; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(79,70,229,0.5), rgba(251,111,80,0.6), transparent);
  filter: drop-shadow(0 0 5px rgba(251,111,80,0.3));
  border-radius: 2px;
  animation: scanline 2.8s ease-in-out infinite;
}
.live-scan-core {
  position: relative; z-index: 2;
  width: 46%; aspect-ratio: 1; border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  display: grid; place-items: center;
}
/* Center scan face — a touch larger than a standard xl avatar */
.live-scan-core .avatar.xl { width: 118px; height: 118px; font-size: 36px; }
.live-scan-glyph {
  width: 60px; height: 60px; border-radius: 18px;
  background: linear-gradient(135deg, var(--coral), #EC4899 55%, var(--primary));
  color: #fff; display: grid; place-items: center;
  box-shadow: 0 8px 18px rgba(251,111,80,0.28);
}

/* Live "watching" filler — keeps the live-log column from looking empty
   when only a few scans have come in. */
.rt-watching {
  flex: 1; min-height: 100px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; text-align: center;
}
.rt-watching-pulse {
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--mint-soft); color: #065F46;
  display: grid; place-items: center;
  animation: rt-watch-pulse 1.8s ease-out infinite;
}
@keyframes rt-watch-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,0.45); }
  70%  { box-shadow: 0 0 0 14px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

.radar-stage {
  position: relative;
  aspect-ratio: 1 / 1;
  max-width: 460px;
  margin: 0 auto;
  display: grid; place-items: center;
}
.radar-bg {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at center, rgba(79,70,229,0.18), rgba(15,14,20,0) 70%);
}
.radar-ring {
  position: absolute;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 50%;
}
.radar-ring.r1 { inset: 0; }
.radar-ring.r2 { inset: 12%; }
.radar-ring.r3 { inset: 24%; }
.radar-ring.r4 { inset: 36%; }
.radar-ring.dashed { border-style: dashed; opacity: 0.5; }

.radar-cross {
  position: absolute; inset: 0;
  pointer-events: none;
}
.radar-cross::before, .radar-cross::after {
  content: ""; position: absolute; background: rgba(255,255,255,0.06);
}
.radar-cross::before { left: 50%; top: 0; bottom: 0; width: 1px; }
.radar-cross::after  { top: 50%; left: 0; right: 0; height: 1px; }

.radar-sweep {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(251,111,80,0) 0deg, rgba(251,111,80,0) 270deg, rgba(251,111,80,0.55) 350deg, rgba(251,111,80,0.9) 360deg);
  -webkit-mask: radial-gradient(circle at center, transparent 0%, transparent 0%, #000 0%, #000 100%);
  animation: radar-spin 3.2s linear infinite;
  mix-blend-mode: screen;
}
@keyframes radar-spin {
  to { transform: rotate(360deg); }
}

.radar-scanline {
  position: absolute; left: 8%; right: 8%; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(245,197,24,0.9), transparent);
  filter: drop-shadow(0 0 6px rgba(245,197,24,0.6));
  animation: scanline 2.4s ease-in-out infinite;
  border-radius: 2px;
}
@keyframes scanline {
  0% { top: 18%; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { top: 82%; opacity: 0; }
}

.radar-dot {
  position: absolute;
  width: 8px; height: 8px;
  background: var(--coral);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--coral);
  animation: blip 2s ease-out infinite;
}
@keyframes blip {
  0% { transform: scale(0.6); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: scale(2.6); opacity: 0; }
}

.radar-center {
  position: relative;
  z-index: 2;
  width: 58%;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0)),
    rgba(15,14,20,0.65);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.12);
  display: grid; place-items: center;
  text-align: center;
  padding: 16px;
  box-shadow: 0 0 40px rgba(251,111,80,0.25), inset 0 0 30px rgba(79,70,229,0.18);
}
.radar-center .scan-glyph {
  width: 64px; height: 64px;
  margin: 0 auto 10px;
  border: 2px dashed rgba(255,255,255,0.4);
  border-radius: 18px;
  display: grid; place-items: center;
  animation: pulseRotate 3s linear infinite;
}
@keyframes pulseRotate {
  to { transform: rotate(360deg); }
}

/* Realtime — success card */
.scan-result {
  position: relative;
  z-index: 2;
  background: var(--surface);
  border-radius: var(--r-xl);
  border: 1px solid rgba(16,185,129,0.45);
  padding: 18px;
  text-align: center;
  box-shadow: 0 0 0 4px rgba(16,185,129,0.12), var(--shadow-lg);
  animation: result-in 360ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes result-in {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Device strip */
.device-list {
  display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto;
  max-height: 100%;
}
/* Live-log rows — light surface (was dark white-alpha) */
.device-log-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: background 150ms;
  margin-bottom: 6px;
}
.device-log-row:hover { background: var(--bg); }
.device-log-row.fresh {
  animation: fresh-in 700ms ease;
  border-color: rgba(16,185,129,0.55);
}
@keyframes fresh-in {
  from { transform: translateX(8px); background: var(--mint-soft); }
  to { transform: translateX(0); background: var(--surface-2); }
}

/* Device grid */
.device-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
/* Each tile is a small dark "screen" — the face-mesh visual needs dark
   to read. The header/label area uses lighter text on the dark tile. */
.device-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  aspect-ratio: 3 / 4;
  position: relative;
  overflow: hidden;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.device-tile.scanning {
  border-color: rgba(251,111,80,0.5);
  box-shadow: 0 0 0 2px rgba(251,111,80,0.15), 0 0 32px rgba(251,111,80,0.18);
}
.device-tile-screen {
  flex: 1;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  position: relative;
  overflow: hidden;
  background-image: radial-gradient(circle at 50% 38%, rgba(251,111,80,0.06), transparent 62%);
}

/* ====== Person list ====== */
.person-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
}

/* Scrollbar */
.scroll-thin::-webkit-scrollbar { width: 6px; height: 6px; }
.scroll-thin::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); border-radius: 6px; }
.scroll-thin::-webkit-scrollbar-track { background: transparent; }

/* Session card */
.session-card {
  position: relative;
  padding: 22px;
  border-radius: var(--r-xl);
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
}
.session-card .session-stripe {
  position: absolute; top: 0; left: 0; right: 0; height: 6px;
}

/* Progress bar */
.bar { height: 8px; background: var(--surface-2); border-radius: var(--r-pill); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--ink); transition: width 400ms ease; }

/* Tag input */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  font-size: 11.5px; font-weight: 600;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-3);
}

/* Page header */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 22px; gap: 16px;
}
.page-head h1 { font-family: var(--font-display); font-size: 26px; font-weight: 700; margin: 0; letter-spacing: -0.015em; }
.page-head .sub { font-size: 13px; color: var(--ink-4); margin-top: 4px; }

/* Toggle */
.toggle {
  position: relative;
  width: 38px; height: 22px; border-radius: var(--r-pill);
  background: var(--line);
  transition: background 120ms;
  cursor: pointer;
  flex: none;
}
.toggle::after {
  content: ""; position: absolute; left: 2px; top: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 120ms;
}
.toggle.on { background: var(--mint); }
.toggle.on::after { transform: translateX(16px); }

/* Status indicator dot */
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.status-dot.online { background: var(--mint); box-shadow: 0 0 0 3px rgba(16,185,129,0.18); }
.status-dot.offline { background: var(--ink-5); }
.status-dot.busy { background: var(--coral); box-shadow: 0 0 0 3px rgba(251,111,80,0.18); }
/* Live preview "LIVE" indicator — green, blinking while the camera is online */
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); animation: live-blink 1.1s ease-in-out infinite; }
@keyframes live-blink {
  0%, 100% { opacity: 1;   box-shadow: 0 0 7px 1px rgba(16,185,129,0.85); }
  50%      { opacity: 0.3; box-shadow: 0 0 2px 0 rgba(16,185,129,0.35); }
}

/* Misc */
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.divider.dark { background: rgba(255,255,255,0.08); }

/* Bigger viewport */
@media (max-width: 1200px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .device-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 64px 1fr; }
  .sb-brand-name, .sb-brand-tag, .sb-section-label, .sb-item span:not(.sb-icon):not(.sb-badge), .sb-user { display: none; }
  .sb-item { justify-content: center; }
  .login-page { grid-template-columns: 1fr; }
  .login-hero { display: none; }
}

/* ====== Station view (single table) ====== */
.station-page {
  margin: -24px -32px -48px;
  min-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
}
.station-hero {
  background: linear-gradient(120deg, #FFF6EE 0%, #F3EEFF 60%, #EEF7FF 100%);
  border-bottom: 1px solid var(--line);
  padding: 24px 32px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  position: relative;
  overflow: hidden;
}
.station-hero::before {
  content: ""; position: absolute; top: -90px; right: -60px;
  width: 240px; height: 240px; border-radius: 50%;
  background: radial-gradient(circle, rgba(251,111,80,0.12), transparent 70%);
}
.station-hero > * { position: relative; z-index: 1; }

.station-device-mark {
  width: 72px; height: 96px;
  border-radius: 18px;
  position: relative;
  display: grid; place-items: center;
  box-shadow: var(--shadow-md);
}
.station-device-mark-inner {
  position: absolute; top: 8px; left: 8px; right: 8px; height: 48px;
  border-radius: 12px;
  background: rgba(0,0,0,0.55);
  display: grid; place-items: center;
  color: rgba(255,255,255,0.9);
  backdrop-filter: blur(8px);
}
.station-device-mark::after {
  content: "HIKVISION";
  position: absolute; bottom: 10px;
  font-size: 8px; font-weight: 700; letter-spacing: 0.15em;
  color: rgba(255,255,255,0.8);
}

.station-progress {
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 24px;
}

.station-main {
  display: grid;
  grid-template-columns: 0.75fr 1.25fr;
  gap: 0;
  flex: 1;
  min-height: 0;
}

.station-scan-area {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0;
  position: relative;
  overflow: hidden;
}
.station-scan-area::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 28% 18%, rgba(251,111,80,0.06), transparent 55%),
    radial-gradient(circle at 78% 88%, rgba(79,70,229,0.05), transparent 55%);
  pointer-events: none;
}
.station-scan-area > * { position: relative; z-index: 1; }

.station-scan-frame {
  flex: 1;
  display: grid;
  place-items: center;
  position: relative;
  padding: 32px;
  min-height: 0;
}

.station-result {
  position: absolute;
  left: 24px; right: 24px; bottom: 24px;
  display: flex; align-items: center; gap: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid rgba(16,185,129,0.45);
  border-radius: var(--r-xl);
  box-shadow: 0 0 0 4px rgba(16,185,129,0.12), var(--shadow-lg);
  animation: result-in 360ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.station-roster {
  background: var(--surface);
  display: flex; flex-direction: column;
  border-left: 1px solid var(--line);
  min-height: 0;
}

.station-roster-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 18px;
  display: flex; flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.station-roster-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  transition: background 120ms, border-color 120ms;
}
.station-roster-row:hover { background: var(--surface-2); }
.station-roster-row.is-checked {
  background: var(--mint-soft);
  border-color: rgba(16,185,129,0.25);
}
.station-roster-row.is-checked:hover { background: #C9F2E1; }
.station-roster-row.is-scanning {
  background: var(--coral-soft);
  border-color: rgba(251,111,80,0.4);
  animation: pulse-row 1.2s ease-in-out infinite;
}
@keyframes pulse-row {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251,111,80,0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(251,111,80,0); }
}

/* ====== All-stations monitor ====== */
.all-stations-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.all-stations-grid .station-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
  padding: 0;
  position: relative;
  min-height: 380px;
  transition: transform 140ms, box-shadow 140ms;
}
.all-stations-grid .station-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.all-stations-grid .station-card.is-offline {
  opacity: 0.7;
}
.station-card-top {
  height: 5px;
}
.station-card-preview {
  margin: 8px 14px;
  background: var(--dark);
  border-radius: var(--r-md);
  padding: 14px;
  height: 140px;
  display: grid; place-items: center;
  position: relative;
  overflow: hidden;
  background-image: radial-gradient(circle at 40% 40%, rgba(79,70,229,0.25), transparent 60%);
}

@media (max-width: 1400px) {
  .all-stations-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1100px) {
  .all-stations-grid { grid-template-columns: repeat(2, 1fr); }
  .station-main { grid-template-columns: 1fr; }
}

/* ====== Check-in page (per-operator) ====== */
.checkin-page {
  margin: -24px -32px -48px;
  min-height: calc(100vh - 80px);
  display: flex; flex-direction: column;
}

.checkin-hero {
  background: linear-gradient(120deg, #FFF6EE 0%, #FFEEE5 60%, #FFE8E0 100%);
  border-bottom: 1px solid var(--line);
  padding: 20px 32px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  position: relative; overflow: hidden;
}
.checkin-hero::before {
  content: ""; position: absolute; top: -110px; right: -40px;
  width: 240px; height: 240px; border-radius: 50%;
  background: radial-gradient(circle, rgba(251,111,80,0.13), transparent 70%);
}
.checkin-hero > * { position: relative; z-index: 1; }

.checkin-op-mark {
  width: 64px; height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--coral), #E55E40);
  display: grid; place-items: center;
  box-shadow: 0 8px 20px rgba(251,111,80,0.35);
  position: relative;
  flex: none;
}
.checkin-op-mark::after {
  content: ""; position: absolute; bottom: -2px; right: -2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--mint);
  border: 3px solid #FFF6EE;
}

.checkin-progress {
  flex: 1; min-width: 320px;
  max-width: 520px;
  padding: 14px 18px;
  background: rgba(255,255,255,0.6);
  border: 1px solid rgba(255,255,255,0.8);
  border-radius: var(--r-lg);
  backdrop-filter: blur(8px);
}

.checkin-search-wrap {
  padding: 18px 32px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 80px; z-index: 5;
}
.checkin-search {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px;
  background: var(--surface-2);
  border: 2px solid var(--line);
  border-radius: 16px;
  transition: border-color 120ms, box-shadow 120ms;
}
.checkin-search:focus-within {
  border-color: var(--coral);
  box-shadow: 0 0 0 4px var(--coral-soft);
  background: var(--surface);
}
.checkin-search input {
  flex: 1;
  background: transparent;
  border: none; outline: none;
  font-size: 17px;
  font-weight: 500;
  font-family: var(--font-mono), var(--font-body);
  letter-spacing: 0.01em;
}
.checkin-search input::placeholder {
  color: var(--ink-5);
  font-family: var(--font-body);
  font-weight: 400;
  letter-spacing: normal;
}

.checkin-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 24px 24px;
  display: flex; flex-direction: column; gap: 6px;
}

.checkin-row {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
  transition: background 100ms, border-color 100ms, transform 80ms;
}
.checkin-row:hover {
  background: var(--surface-2);
  border-color: var(--line-2);
}
.checkin-row:active {
  transform: scale(0.998);
}
.checkin-row.is-done {
  background: var(--mint-soft);
  border-color: rgba(16,185,129,0.25);
}
.checkin-row.is-done:hover { background: #C9F2E1; }
.checkin-row .checkin-row-chevron { color: var(--ink-5); transition: transform 120ms; }
.checkin-row:hover .checkin-row-chevron { transform: translateX(2px); color: var(--ink-3); }

.checkin-row-id {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--ink);
  background: var(--surface-2);
  padding: 8px 14px;
  border-radius: 10px;
  min-width: 110px;
  text-align: center;
  flex: none;
  border: 1px solid var(--line);
}
.checkin-row.is-done .checkin-row-id {
  background: rgba(16,185,129,0.15);
  color: #065F46;
  border-color: rgba(16,185,129,0.3);
}
.checkin-row-name {
  font-weight: 600; font-size: 15px;
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.checkin-row-status {
  display: flex; align-items: center; gap: 10px;
  flex: none;
}

.checkin-recent {
  padding: 14px 24px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

/* ====== Check-in popup ====== */
.checkin-popup-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(15,14,20,0.55);
  backdrop-filter: blur(8px);
  display: grid; place-items: center;
  padding: 16px;
  animation: result-in 200ms ease;
}
.checkin-popup {
  width: 100%; max-width: 540px;
  background: var(--surface);
  border-radius: 24px;
  box-shadow: 0 24px 60px -12px rgba(0,0,0,0.3);
  /* Fit within the screen: scroll inside instead of overflowing off-screen
     (important on small client displays). */
  max-height: calc(100vh - 28px);
  overflow-x: hidden; overflow-y: auto;
  display: flex; flex-direction: column;
  animation: popup-pop 320ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes popup-pop {
  from { transform: scale(0.92) translateY(10px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.checkin-popup-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.checkin-popup-person {
  display: flex; align-items: center; gap: 18px;
  padding: 20px;
  background: var(--surface-2);
}

.checkin-device-strip {
  margin: 0 20px;
  padding: 12px 16px;
  background: linear-gradient(90deg, #FFEEE7 0%, #FFE4DA 100%);
  border: 1px solid rgba(251,111,80,0.3);
  border-radius: 14px;
  margin-top: 16px;
}
.checkin-device-strip-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--coral);
  color: #fff;
  display: grid; place-items: center;
  position: relative;
  flex: none;
}

.checkin-recheck {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px 20px;
  margin: 20px;
  margin-bottom: 0;
  background: var(--surface);
  border: 2px dashed var(--line-2);
  border-radius: 16px;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
  width: calc(100% - 40px);
  font-family: inherit; color: inherit;
}
.checkin-recheck:hover { border-color: var(--coral); }
.checkin-recheck.is-on {
  background: var(--mint-soft);
  border-color: var(--mint);
  border-style: solid;
}
.checkin-recheck-box {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--surface);
  border: 2px solid var(--line-2);
  display: grid; place-items: center;
  color: #fff;
  flex: none;
  transition: background 120ms, border-color 120ms, transform 120ms;
}
.checkin-recheck-box.is-on {
  background: var(--mint);
  border-color: var(--mint);
  animation: tick-pop 360ms cubic-bezier(.2,1.4,.5,1);
}
@keyframes tick-pop {
  0%   { transform: scale(0.8); }
  60%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.checkin-scan-btn {
  margin: 20px;
  padding: 18px 22px !important;
  border-radius: 18px !important;
  display: flex; align-items: center; gap: 16px;
  width: calc(100% - 40px);
  transition: transform 80ms, background 120ms, opacity 120ms;
  text-align: left;
  font-size: 15px;
}
.checkin-scan-btn:not(:disabled):hover { transform: translateY(-1px); }
.checkin-scan-btn-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: rgba(255,255,255,0.2);
  display: grid; place-items: center;
  color: #fff;
  flex: none;
}
.checkin-scan-btn:disabled .checkin-scan-btn-icon {
  background: var(--surface);
  color: var(--ink-5);
}

/* Quiet secondary action under the big scan button (confirm w/ existing photo) */
.checkin-secondary-btn {
  margin: 0 20px 8px;
  width: calc(100% - 40px);
  justify-content: center;
  gap: 8px;
  color: var(--ink-3);
}

.checkin-scanning {
  display: flex; gap: 22px; align-items: center;
  padding: 24px;
  background: var(--dark);
  color: #fff;
  margin: 0 20px 20px;
  border-radius: 18px;
  position: relative;
  overflow: hidden;
}
.checkin-scanning::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 50%, rgba(251,111,80,0.2), transparent 60%);
  pointer-events: none;
}
.checkin-scanning > * { position: relative; z-index: 1; }
.checkin-scanning .h3 { color: #fff; }
.checkin-scanning .muted { color: rgba(255,255,255,0.6); }
.checkin-scanning-visual {
  flex: none;
  width: 160px;
  display: grid; place-items: center;
}

.checkin-step-list {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.checkin-success {
  padding: 32px 24px;
  text-align: center;
}
.checkin-success-icon {
  width: 88px; height: 88px;
  border-radius: 50%;
  background: var(--mint);
  color: #fff;
  display: grid; place-items: center;
  margin: 0 auto;
  animation: success-pop 480ms cubic-bezier(.2,1.4,.5,1);
  box-shadow: 0 0 0 8px var(--mint-soft);
}
@keyframes success-pop {
  0%   { transform: scale(0.4); opacity: 0; }
  60%  { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
