:root {
  --navy: #0f172a;
  --navy-2: #1e293b;
  --ink: #0f172a;
  /* Derived from the surrounding text colour so they work on any branded background. */
  --muted: color-mix(in srgb, currentColor 62%, transparent);
  --line: color-mix(in srgb, currentColor 14%, transparent);
  --slate: #64748b;
  --bg: #f1f5f9;
  --card: #ffffff;
  --accent: #0284c7;
  --accent-ink: #ffffff;
  --header-bg: #0f172a;
  --header-ink: #ffffff;
  --bg-ink: #0f172a;
  --nav-bg: #ffffff;
  --nav-ink: #0f172a;
  --hot: #dc2626;
  --warm: #d97706;
  --cold: #2563eb;
  --ok: #16a34a;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--bg-ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.05rem; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; font-weight: 400; }

input, textarea, select, button { font: inherit; color: inherit; }
input[type='text'], input[type='search'], input[type='email'], input[type='tel'], input[type='password'], input:not([type]), textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  font-size: 16px; /* prevents iOS zoom on focus */
}
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input[readonly], textarea[readonly] { background: #f8fafc; color: var(--slate); }
textarea { resize: vertical; min-height: 68px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 16px;
  border: 1px solid #cbd5e1; border-radius: 10px;
  background: #fff; color: #0f172a;
  font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--hot); border-color: var(--hot); color: #fff; }
.btn.danger-text { border-color: transparent; background: none; color: var(--hot); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 0.9rem; }
.btn.light { background: transparent; border-color: currentColor; color: inherit; }
.btn.grow { flex: 1; }
.btn:disabled, .btn.disabled { opacity: 0.45; pointer-events: none; }
.icon-btn { border: 0; background: none; font-size: 1.2rem; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

.card { background: var(--card); color: var(--ink); border-radius: var(--radius); padding: 16px; display: grid; gap: 10px; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06); }
.field { display: grid; gap: 5px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.notice { background: #fef3c7; color: #78350f; padding: 10px 12px; border-radius: 10px; font-size: 0.9rem; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  min-height: 38px; padding: 0 16px; border-radius: 999px;
  border: 1px solid #cbd5e1; background: #fff; color: #0f172a; font-weight: 600; cursor: pointer;
}
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.rating .chip { flex: 1; min-height: 46px; }
.rating .chip.hot.on { background: var(--hot); border-color: var(--hot); }
.rating .chip.warm.on { background: var(--warm); border-color: var(--warm); }
.rating .chip.cold.on { background: var(--cold); border-color: var(--cold); }

.tag { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 8px; border-radius: 999px; color: #fff; background: var(--slate); }
.tag.hot { background: var(--hot); }
.tag.warm { background: var(--warm); }
.tag.cold { background: var(--cold); }
.tag.open { background: var(--ok); }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-bottom)); transform: translateX(-50%);
  max-width: min(92vw, 420px); padding: 10px 16px; border-radius: 999px;
  background: rgba(15, 23, 42, 0.94); color: #fff; font-size: 0.92rem; text-align: center; z-index: 50;
}

/* ------------------------------------------------------------ vendor app */

.vendor-app { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
.appbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: var(--header-bg); color: var(--header-ink);
}
.appbar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.appbar-logo { height: 34px; width: auto; max-width: 120px; object-fit: contain; flex: none; }
.appbar-title { display: grid; min-width: 0; }
.appbar-title strong, .appbar-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar-title span { font-size: 0.8rem; opacity: 0.7; }
.pill { border: 0; border-radius: 999px; padding: 6px 12px; font-size: 0.8rem; font-weight: 600; background: #334155; color: #e2e8f0; cursor: pointer; white-space: nowrap; }
.pill.ok { background: #14532d; color: #bbf7d0; }
.pill.warn { background: #78350f; color: #fde68a; }
.pill.off { background: #475569; color: #f1f5f9; }

.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 16px; background: var(--accent); color: var(--accent-ink); }
.banner > div:first-child { display: grid; font-size: 0.9rem; }
.banner-actions { display: flex; gap: 8px; }

.vendor-app main { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.view { max-width: 760px; margin: 0 auto; padding: 12px; display: grid; gap: 12px; }

.viewfinder { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; height: min(52dvh, 560px); min-height: 240px; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewfinder.flash::after { content: ''; position: absolute; inset: 0; background: rgba(255, 255, 255, 0.55); }
.reticle {
  position: absolute; left: 50%; top: 50%; width: min(64%, 300px); aspect-ratio: 1; transform: translate(-50%, -50%);
  border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.28); border: 3px solid rgba(255, 255, 255, 0.9);
  pointer-events: none;
}
.cam-message { position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 24px; text-align: center; background: var(--navy-2); color: #e2e8f0; }
.cam-hint { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; color: #fff; font-size: 0.85rem; text-shadow: 0 1px 3px #000; pointer-events: none; }
.cam-btn { position: absolute; top: 12px; right: 12px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 0; background: rgba(15, 23, 42, 0.7); color: #fff; font-weight: 600; cursor: pointer; }
.cam-btn[aria-pressed='true'] { background: #facc15; color: #111; }
.closed .reticle, .closed .cam-hint { display: none; }

.scan-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.recent h2 { margin: 4px 4px 8px; display: flex; justify-content: space-between; align-items: baseline; }
.list-tools { display: grid; gap: 10px; }

.lead-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lead { width: 100%; display: flex; justify-content: space-between; gap: 12px; text-align: left; padding: 12px 14px; border: 0; border-radius: var(--radius); background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06); cursor: pointer; }
.lead-main { display: grid; min-width: 0; }
.lead-main span { color: var(--muted); font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-main .lead-notes { color: inherit; opacity: 0.85; font-style: italic; }
.lead-meta { display: grid; justify-items: end; align-content: start; gap: 4px; font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--nav-bg); color: var(--nav-ink); border-top: 1px solid var(--line); padding-bottom: var(--safe-bottom); }
.tabs button { border: 0; background: none; padding: 8px 4px 10px; min-height: 56px; font-size: 0.78rem; font-weight: 600; color: inherit; opacity: 0.55; cursor: pointer; }
.tabs button.on { opacity: 1; }
.tab-icon { display: block; font-size: 1.25rem; line-height: 1.2; }
.badge { background: var(--nav-ink); color: var(--nav-bg); border-radius: 999px; padding: 1px 7px; font-size: 0.7rem; }

.sheet {
  border: 0; padding: 0; width: 100%; max-width: 560px; margin: auto auto 0;
  border-radius: 18px 18px 0 0; max-height: 92dvh; overflow-y: auto; background: var(--card); color: var(--ink);
}
.sheet::backdrop { background: rgba(15, 23, 42, 0.55); }
.sheet form { display: grid; gap: 14px; padding: 18px 16px calc(16px + var(--safe-bottom)); }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.sheet-head h2 { font-size: 1.3rem; overflow-wrap: anywhere; }
.sheet-actions { display: flex; gap: 10px; }
.sheet details { border-top: 1px solid var(--line); padding-top: 12px; }
.sheet details[open] { display: grid; gap: 10px; }
.sheet summary { font-weight: 600; cursor: pointer; padding: 4px 0; }
.sheet details[open] .when-closed, .sheet details:not([open]) .when-open { display: none; }
@media (min-width: 700px) {
  .sheet { margin: auto; border-radius: 18px; }
}

.fullscreen-message { position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; gap: 10px; padding: 32px; text-align: center; background: var(--navy); color: #fff; }

/* ------------------------------------------------------------ organizer */

.admin { max-width: 980px; margin: 0 auto; padding: 20px 16px 60px; display: grid; gap: 16px; }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.admin-head .crumbs { display: grid; gap: 2px; }
.admin a.link, .linklike { color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; font-weight: 600; }
.login { max-width: 380px; margin: 12vh auto 0; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form input { flex: 1 1 180px; width: auto; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat { background: var(--card); color: var(--ink); border-radius: var(--radius); padding: 14px 16px; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06); }
.stat b { display: block; font-size: 1.6rem; }
.stat span { color: var(--muted); font-size: 0.85rem; }
.event-list, .vendor-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.event-list button { width: 100%; text-align: left; display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; cursor: pointer; }
.vendor { display: grid; gap: 10px; }
.vendor-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.vendor-top > div:first-child { display: grid; min-width: 0; }
.vendor-count { text-align: right; }
.vendor-count b { font-size: 1.3rem; }
.vendor-link { display: flex; gap: 8px; }
.vendor-link input { font-size: 0.85rem; color: var(--slate); }
.vendor-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.vendor-actions .spacer { flex: 1; }
.qr-dialog { border: 0; border-radius: 16px; padding: 24px; text-align: center; max-width: min(92vw, 380px); }
.qr-dialog::backdrop { background: rgba(15, 23, 42, 0.55); }
.qr-dialog img { width: 100%; height: auto; display: block; margin: 12px 0; }
.samples { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.samples figure { margin: 0; text-align: center; font-size: 0.85rem; color: var(--muted); }
.samples img { width: 100%; max-width: 220px; height: auto; }
.brand-preview { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; max-width: 380px; }
.brand-preview .appbar { padding: 10px 14px; }
.brand-preview-body { display: grid; gap: 10px; padding: 12px; background: var(--bg); color: var(--bg-ink); font-size: 0.9rem; }
.brand-preview-body .card { padding: 12px; gap: 8px; }
.brand-preview .tabs { padding-bottom: 0; }
.brand-preview .tabs span { text-align: center; padding: 10px 4px; font-size: 0.78rem; font-weight: 600; opacity: 0.55; }
.brand-preview .tabs span.on { opacity: 1; }
.brand-controls { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.brand-controls .field { color: var(--slate); }
.brand-controls input[type='color'] { width: 64px; height: 46px; padding: 2px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; cursor: pointer; }

.print-sheet { display: none; }
@media print {
  /* Either the open QR dialog or the all-vendors sheet, never the dashboard. */
  #app, .toast { display: none !important; }
  body { background: #fff; }
  .qr-dialog .btn { display: none; }
  body:has(.qr-dialog[open]) .print-sheet { display: none; }
  .print-sheet { display: block; }
  .print-sheet section { height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; padding: 10vh 10vw; break-after: page; }
  .print-sheet h1 { font-size: 2.2rem; }
  .print-sheet img { width: 70mm; height: 70mm; }
  /* Grid layout: three across, dashed cut lines, cells never split across pages. */
  .print-sheet.grid { display: grid; grid-template-columns: repeat(3, 1fr); }
  .print-sheet.grid section { height: auto; padding: 5mm 4mm; gap: 2mm; border: 1px dashed #94a3b8; break-after: auto; break-inside: avoid; font-size: 9pt; }
  .print-sheet.grid h1 { font-size: 12pt; overflow-wrap: anywhere; }
  .print-sheet.grid img { width: 42mm; height: 42mm; }
}
