:root {
  --navy: #0b3b75;
  --navy-deep: #07284f;
  --saffron: #ea580c;
  --ink: #10233d;
  --muted: #5b6b80;
  --line: #d7deea;
  --paper: #f4f6fb;
  --white: #ffffff;
  --shadow: 0 12px 28px rgba(7, 40, 79, 0.1);
  --tabbar-h: 76px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Outfit, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--navy-deep);
  color: white;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-logos {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.brand-logo {
  display: block;
  height: 56px;
  width: auto;
  max-width: 150px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 4px;
}
.brand-kicker { margin: 0; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: #f8d7b0; }
.brand h1 { margin: 2px 0 0; font-size: 18px; font-weight: 700; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.toggle input { accent-color: #f4b942; }

.layout { padding: 12px; display: grid; gap: 12px; }
.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
}
h2 { margin: 0; font-size: 16px; }

.preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.camera-box {
  min-height: 220px;
  border-radius: 12px;
  background: #0b1220;
  overflow: hidden;
  margin-bottom: 12px;
}
.camera-box:empty { display: none; }
.camera-box.active { display: block; min-height: 220px; }

#lookup-form { display: flex; gap: 8px; }
#lookup-form input, #table-filter {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font: inherit;
  font-size: 16px;
}
.status { margin: 10px 0 0; font-size: 13px; font-weight: 600; color: var(--navy); }
.status.error { color: #b42318; }

.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.45; }
.btn-primary { background: var(--saffron); color: white; }
.btn-ghost {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--line);
}
.linkish, .reprint-btn {
  background: none;
  border: 0;
  color: var(--navy);
  font-weight: 700;
  cursor: pointer;
}

.stage {
  min-height: 280px;
  border-radius: 16px;
  background:
    linear-gradient(#eef2f7 1px, transparent 1px) 0 0 / 14px 14px,
    linear-gradient(90deg, #eef2f7 1px, transparent 1px) 0 0 / 14px 14px,
    #f4f7fb;
  display: grid;
  place-items: center;
  padding: 18px 12px;
}
.empty, .empty-row { color: var(--muted); text-align: center; }
.empty { padding: 12px; max-width: 16em; line-height: 1.4; }

.sticker {
  width: min(280px, 100%);
  aspect-ratio: 72 / 68;
  height: auto;
  background: #fff;
  color: #000;
  border: 1px solid #d0d7e2;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(16, 35, 61, 0.12);
  overflow: hidden;
  padding: 0;
}
.sticker img,
#sticker-preview {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}
#print-root {
  display: none;
}

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stats article {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}
.stats span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.stats strong { display: block; margin-top: 4px; font-size: 24px; }

.checkin-list { display: grid; gap: 8px; }
.checkin-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.checkin-card strong { display: block; }
.checkin-card p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.pill {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.pill.visitor { background: #e8f1ff; color: var(--navy); }
.pill.exhibitor { background: #fff1e6; color: #9a3412; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid var(--line);
  z-index: 30;
}
.tab-btn {
  border: 0;
  border-radius: 12px;
  padding: 12px;
  font: inherit;
  font-weight: 800;
  background: #eef3fb;
  color: var(--muted);
}
.tab-btn.active { background: var(--navy); color: white; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(7, 40, 79, 0.55);
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(360px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.modal-card h2 { margin-bottom: 8px; }
.modal-card p { margin: 0; color: var(--ink); font-size: 14px; line-height: 1.4; }
.reprint-who { margin-top: 8px !important; font-weight: 700; color: var(--navy); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

@media (max-width: 900px) {
  .tab-panel { display: none; }
  body[data-tab="scanner"] #tab-scanner,
  body[data-tab="dashboard"] #tab-dashboard { display: grid; gap: 12px; }
}

@media (max-width: 420px) {
  .brand-logo { height: 44px; max-width: 110px; }
  .brand h1 { font-size: 16px; }
}

@media (min-width: 901px) {
  body { padding-bottom: 24px; }
  .tabbar { display: none; }
  .layout {
    padding: 20px 28px;
    grid-template-columns: 1.1fr 0.9fr;
    align-items: start;
  }
  .tab-panel { display: grid; gap: 12px; }
  #tab-dashboard { grid-column: 2; grid-row: 1; }
  .stats { grid-template-columns: 1fr 1fr; }
}

@media print {
  @page { size: 80mm 210mm; margin: 0; }
  html, body {
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
  }
}
