:root {
  --bg: #f6f7fb;
  --bg-accent: #eef1f7;
  --bg-image-opacity: 0.36;
  --bg-overlay-opacity: 0.52;
  --text: #101319;
  --muted: #5c6472;
  --line: #e1e4ea;
  --card: #ffffff;
  --primary: #101319;
  --primary-light: #2c3340;
  --accent: #0f766e;
  --success: #16a34a;
  --shadow: 0 18px 40px rgba(16, 19, 25, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  position: relative;
  isolation: isolate;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image: url("./bg.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: var(--bg-image-opacity);
  pointer-events: none;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(circle at top, rgba(255, 255, 255, 0.96) 12%, rgba(246, 247, 251, 0.95) 72%);
  opacity: var(--bg-overlay-opacity);
  pointer-events: none;
}

a {
  color: inherit;
  text-decoration: none;
}

.navbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 40px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--primary);
  border-radius: 999px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  display: inline-block;
}

.nav-links {
  display: flex;
  gap: 20px;
  font-size: 14px;
  color: var(--muted);
}

.nav-links a {
  padding: 6px 10px;
  border-radius: 999px;
  transition: all 0.2s ease;
}

.nav-links a:hover {
  background: var(--bg-accent);
  color: var(--text);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--muted);
}

.page {
  max-width: 1200px;
  margin: 32px auto 80px;
  padding: 0 40px;
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 32px;
  align-items: center;
  margin-bottom: 32px;
}

.hero-card {
  background: var(--card);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: center;
  align-items: center;
}

.kicker {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

h1 {
  font-size: 36px;
  margin-bottom: 12px;
}

h2 {
  font-size: 24px;
}

.subtitle {
  font-size: 16px;
  color: var(--muted);
}

.card {
  background: var(--card);
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.card-header {
  margin-bottom: 16px;
}

.chart-wrapper {
  padding: 8px 0 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-light);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-ghost {
  background: #fff;
  color: var(--primary);
  border-color: var(--line);
}

.btn-ghost:hover {
  border-color: var(--primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  margin-left: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  background: rgba(16, 19, 25, 0.92);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.scan-layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 30px;
}

.scan-theme-a {
  --accent: #0f766e;
  --success: #16a34a;
  --scan-active: #eaf6f5;
  --scan-complete: #ecfdf3;
}

.scan-theme-b {
  --accent: #1e3a8a;
  --success: #2563eb;
  --scan-active: #e0e7ff;
  --scan-complete: #eff6ff;
}

.scan-theme-c {
  --accent: #c2410c;
  --success: #f97316;
  --scan-active: #fff1e6;
  --scan-complete: #fff7ed;
}

.scan-left {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.status-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 10px;
}

.status-step {
  display: flex;
  gap: 14px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--bg-accent);
  transition: all 0.2s ease;
}

.status-step.is-active {
  border-color: var(--accent);
  background: var(--scan-active, #eaf6f5);
}

.status-step.is-complete {
  border-color: var(--success);
  background: var(--scan-complete, #ecfdf3);
}

.status-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  position: relative;
}

.status-step.is-active .status-icon::after,
.status-step.is-complete .status-icon::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.status-step.is-complete .status-icon::after {
  background: var(--success);
}

.manual-entry {
  background: #fff;
  border-radius: 16px;
  padding: 14px;
  border: 1px solid var(--line);
}

.manual-entry label {
  font-size: 12px;
  color: var(--muted);
}

.input-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 14px;
}

.scan-message {
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--bg-accent);
  color: var(--muted);
}

.camera-frame {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  background: #0f172a;
  min-height: 380px;
  box-shadow: var(--shadow);
}

.camera-frame video,
.camera-frame canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}

.camera-frame.detected {
  outline: 4px solid var(--success);
  outline-offset: -4px;
}

.scan-hint {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: rgba(16, 19, 25, 0.75);
  color: #fff;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
}

.camera-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(255, 255, 255, 0.85);
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  font-size: 12px;
}

.camera-actions .btn {
  padding: 6px 10px;
  font-size: 12px;
}

.record-list {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  min-height: 120px;
}

.record-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.record-item:last-child {
  border-bottom: none;
}

.summary-panel {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.summary-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
}

.summary-stamp {
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 1.5px dashed #c8ced9;
  background: #eceff5;
  color: #8e97a7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: all 0.2s ease;
}

.summary-stamp span {
  display: block;
  width: 66%;
  height: 66%;
  background-image: url("./ai.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  font-size: 0;
  line-height: 0;
  color: transparent;
  opacity: 0.42;
  filter: grayscale(1);
}

.summary-stamp.is-active {
  border-color: #fb923c;
  background: #ffedd5;
  color: #c2410c;
  box-shadow: inset 0 0 0 2px rgba(194, 65, 12, 0.18);
}

.summary-stamp.is-active span {
  opacity: 1;
  filter: none;
}

.summary-stamp.is-redeemed {
  position: relative;
}

.summary-stamp.is-redeemed::after {
  content: "";
  position: absolute;
  width: 130%;
  height: 2px;
  background: rgba(124, 45, 18, 0.75);
  transform: rotate(-32deg);
  top: 50%;
  left: -15%;
}

.summary-total {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  font-size: 15px;
}

.redeem-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.redeem-actions .btn {
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
}

.redeem-status {
  font-size: 14px;
  border-radius: 10px;
  background: var(--bg-accent);
  color: var(--muted);
  padding: 8px 10px;
}

.redeem-status.is-ready {
  background: #dcfce7;
  color: #166534;
}

.redeem-status.is-warn {
  background: #fff7ed;
  color: #9a3412;
}

.redeem-status.is-success {
  background: #e0f2fe;
  color: #075985;
}

.booth-group {
  margin-top: 24px;
}

.booth-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.booth-card {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.booth-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.booth-code {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.booth-select {
  min-width: 220px;
  min-height: 120px;
  width: 100%;
}

.booth-table input,
.booth-table select {
  min-width: 140px;
}

.booth-permission-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.booth-permission-grid {
  display: grid;
  gap: 16px;
}

.booth-permission-group {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: #fff;
}

.booth-permission-group h3 {
  margin-bottom: 10px;
  font-size: 16px;
}

.booth-permission-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.booth-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--bg-accent);
  font-size: 13px;
}

.booth-checkbox input[type="checkbox"] {
  width: 12px;
  height: 12px;
  margin-top: 2px;
  flex: 0 0 12px;
}

.booth-checkbox span {
  flex: 1;
  line-height: 1.4;
  word-break: break-word;
}

.visitor-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--line);
}

.on-site-card {
  max-width: 640px;
  margin: 32px auto 0;
}

.on-site-form {
  gap: 16px;
}

.on-site-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

.on-site-message {
  margin-bottom: 16px;
}

.on-site-success {
  margin-bottom: 16px;
  background: #dcfce7;
  color: #166534;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 19, 25, 0.32);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.loading-overlay[hidden] {
  display: none !important;
}

.loading-panel {
  min-width: 240px;
  background: #fff;
  border-radius: 20px;
  padding: 24px 28px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.loading-spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid #d7dce5;
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.qr-card {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.qr-image {
  width: 120px;
  height: 120px;
}

.qr-meta {
  text-align: center;
  font-size: 13px;
}

.visitor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.backfill-form {
  max-width: 560px;
}

.backfill-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.visitor-status-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 16px;
  margin: 16px 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stats-section + .stats-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.stat-card {
  background: var(--bg-accent);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.stat-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: end;
  margin-bottom: 20px;
}

.export-actions {
  display: flex;
  gap: 10px;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

thead {
  background: var(--bg-accent);
  text-align: left;
  font-size: 13px;
  color: var(--muted);
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.muted {
  color: var(--muted);
}

.account-form {
  margin-top: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.login-card {
  background: #fff;
  padding: 36px;
  border-radius: 24px;
  box-shadow: var(--shadow);
  width: 500px;
}

.login-brand h1 {
  font-size: 26px;
  margin: 10px 0 6px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 20px;
}

.alert {
  background: #fee2e2;
  color: #b91c1c;
  padding: 10px 12px;
  border-radius: 12px;
  margin-top: 12px;
  font-size: 13px;
}

@media (max-width: 960px) {
  .navbar {
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .nav-links {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    max-height: 0;
    opacity: 0;
    transform: scaleY(0.95);
    transform-origin: top;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
  }

  .nav-open .nav-links {
    max-height: 520px;
    opacity: 1;
    transform: scaleY(1);
  }

  .nav-user {
    grid-column: 1 / -1;
    justify-content: flex-start;
    font-size: 16px;
    font-weight: 400;
  }

  .page {
    padding: 0 20px;
  }

  .hero,
  .scan-layout {
    grid-template-columns: 1fr;
  }

  .camera-frame {
    min-height: 260px;
  }

  .grid-3 {
    grid-template-columns: 1fr;
  }

  .visitor-grid {
    grid-template-columns: 1fr;
  }

  .visitor-status-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .backfill-summary-grid {
    grid-template-columns: 1fr;
  }

  .on-site-card {
    margin-top: 24px;
  }

  .summary-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
  }

  .summary-stamp {
    font-size: 10px;
    border-width: 1px;
  }

  .redeem-actions {
    grid-template-columns: 1fr;
  }

  body::before {
    background-position: center top;
  }
}
