:root {
  --paper: #fbf3e7;
  --paper-2: #f5e8d4;
  --card: #fffdf9;
  --ink: #2a0e1e;
  --ink-soft: #5a3646;
  --henna: #9a3b24;
  --henna-deep: #7c2d1a;
  --gold: #c98a2b;
  --gold-bright: #e2ab41;
  --leaf: #3e5b3a;
  --line: rgba(42, 14, 30, 0.14);
  --ok: #2f7d4f;
  --warn: #a9670f;
  --shadow: 0 18px 40px -24px rgba(42, 14, 30, 0.45);
  --radius: 18px;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* backdrop with faint henna-toned wash */
body.public {
  background:
    radial-gradient(60% 40% at 50% -5%, rgba(154, 59, 36, 0.10), transparent 70%),
    radial-gradient(50% 30% at 90% 100%, rgba(201, 138, 43, 0.10), transparent 70%),
    var(--paper);
  min-height: 100vh;
}

.wrap { width: 100%; max-width: 560px; margin: 0 auto; padding: 28px 20px 48px; }
.wrap.wide { max-width: 1080px; }

/* ---------- Hero (guest) ---------- */
.hero {
  background:
    radial-gradient(80% 120% at 50% -20%, #3c1329, var(--ink) 70%);
  color: var(--paper);
  text-align: center;
  padding: 40px 20px 30px;
  border-bottom: 3px solid var(--gold);
}
.eyebrow {
  font-size: 0.72rem; letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--gold-bright); font-weight: 600;
}
.eyebrow-dark { color: var(--henna); }
.hero-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 900; font-size: clamp(2.1rem, 7vw, 3.1rem);
  line-height: 1.05; margin: 6px 0 4px; letter-spacing: -0.5px;
}
.henna-wrap { color: var(--gold); margin-top: 10px; }
.henna { width: min(260px, 70%); height: auto; display: inline-block; }

/* ---------- Cards ---------- */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 26px;
  margin-top: 24px;
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--henna), var(--gold-bright), var(--henna));
  border-radius: var(--radius) var(--radius) 0 0;
}
.card-center { text-align: center; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.card-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.5rem; font-weight: 600; color: var(--ink);
}
.card-sub { color: var(--ink-soft); font-size: 0.95rem; margin-top: 4px; }
.lead { font-size: 1.05rem; color: var(--ink-soft); margin-bottom: 22px; }
.fineprint { margin-top: 18px; font-size: 0.85rem; }
.link-quiet { color: var(--henna); text-decoration: none; font-weight: 500; }
.link-quiet:hover { text-decoration: underline; }

/* ---------- Forms ---------- */
.form { margin-top: 18px; display: grid; gap: 18px; }
.field { display: grid; gap: 6px; }
.field-label { font-size: 0.85rem; font-weight: 600; color: var(--ink); }
.field-hint { font-size: 0.78rem; color: var(--ink-soft); }
.input {
  font: inherit; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line);
  border-radius: 12px; padding: 12px 14px; width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  outline: none; border-color: var(--henna);
  box-shadow: 0 0 0 3px rgba(154, 59, 36, 0.15);
}
.input-plate {
  text-transform: uppercase; font-weight: 700;
  letter-spacing: 0.15em; font-size: 1.15rem;
}
.alert {
  background: #fdecea; border: 1px solid #f3b6ad; color: #8a1f12;
  padding: 10px 14px; border-radius: 12px; font-size: 0.9rem; margin-bottom: 4px;
}

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1.5px solid transparent; border-radius: 12px;
  padding: 12px 18px; transition: transform 0.05s, background 0.15s, border-color 0.15s;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--henna); color: #fff8ef; }
.btn-primary:hover { background: var(--henna-deep); }
.btn-ghost { background: transparent; color: var(--henna); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--henna); background: rgba(154, 59, 36, 0.06); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 0.85rem; border-radius: 10px; }
.btn-icon { padding: 6px 10px; line-height: 1; color: var(--ink-soft); }
.btn-icon:hover { color: var(--henna); }
.inline { display: inline; }

/* ---------- UK number plate ---------- */
.plate {
  display: inline-flex; align-items: center;
  background: #f4d400; color: #111;
  font-weight: 800; letter-spacing: 0.08em;
  font-size: 1.05rem; padding: 7px 12px 7px 22px;
  border-radius: 6px; border: 1px solid #b9a200;
  position: relative; box-shadow: inset 0 0 0 1.5px rgba(0,0,0,0.06);
  font-family: 'Inter', sans-serif;
}
.plate::before {
  content: 'GB'; position: absolute; left: 0; top: 0; bottom: 0;
  width: 15px; background: #063298; color: #f4d400;
  font-size: 0.5rem; font-weight: 700; letter-spacing: 0;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 3px;
  border-radius: 6px 0 0 6px;
}
.confirm .plate { font-size: 1.5rem; margin: 8px 0 4px; padding: 10px 16px 10px 28px; }

/* ---------- Confirmation ---------- */
.tick {
  width: 58px; height: 58px; border-radius: 50%; margin: 0 auto 12px;
  background: var(--leaf); color: #fff; font-size: 1.9rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.confirm-vehicle { color: var(--ink-soft); margin: 8px 0 4px; }
.summary { margin: 20px 0; display: grid; gap: 10px; text-align: left; }
.summary > div {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; padding: 12px 14px; background: var(--paper-2); border-radius: 12px;
}
.summary dt { font-size: 0.82rem; color: var(--ink-soft); }
.summary dd { font-weight: 600; text-align: right; }
.tag {
  font-size: 0.7rem; background: var(--gold); color: #3a2400;
  padding: 2px 7px; border-radius: 999px; font-weight: 700; margin-left: 4px;
}
.foot { text-align: center; color: var(--ink-soft); font-size: 0.78rem; padding: 8px 0 28px; opacity: 0.8; }

/* ---------- Admin ---------- */
body.admin { background: var(--paper); min-height: 100vh; }
.topbar { background: var(--ink); color: var(--paper); border-bottom: 2px solid var(--gold); }
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { color: var(--gold); display: flex; }
.brand-mark .henna { width: 64px; }
.brand-text { font-family: 'Fraunces', serif; font-weight: 600; font-size: 1.05rem; }
.topbar-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.who { font-size: 0.82rem; color: rgba(251, 243, 231, 0.75); }

/* Live viewer count pill */
.viewer-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.75rem; font-weight: 600;
  color: rgba(251, 243, 231, 0.9);
  background: rgba(251, 243, 231, 0.10);
  border: 1px solid rgba(251, 243, 231, 0.18);
  border-radius: 999px; padding: 4px 10px;
  cursor: default; white-space: nowrap;
}
.viewer-pill::before {
  content: ''; display: inline-block; width: 7px; height: 7px;
  border-radius: 50%; background: #6fcf7a;
  box-shadow: 0 0 0 0 rgba(111, 207, 122, 0.6);
  animation: pulse-dot 2.4s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(111, 207, 122, 0.55); }
  50%       { box-shadow: 0 0 0 5px rgba(111, 207, 122, 0); }
}
.topbar .btn-ghost { color: var(--paper); border-color: rgba(251, 243, 231, 0.3); }
.topbar .btn-ghost:hover { border-color: var(--gold); background: rgba(251, 243, 231, 0.08); }

.page-head { margin: 26px 0 8px; }
.page-title { font-family: 'Fraunces', serif; font-weight: 600; font-size: 1.9rem; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 18px 0; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; text-align: center;
}
.stat-num { display: block; font-family: 'Fraunces', serif; font-size: 2rem; font-weight: 900; }
.stat-ok { color: var(--ok); }
.stat-warn { color: var(--warn); }
.stat-label { font-size: 0.78rem; color: var(--ink-soft); }

.qr-panel {
  display: flex; gap: 20px; align-items: center; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line);
  border-left: 4px solid var(--gold); border-radius: 14px; padding: 18px; margin-bottom: 18px;
}
.qr-img { border-radius: 10px; background: #fff; padding: 6px; border: 1px solid var(--line); flex: none; }
.qr-body { flex: 1; min-width: 220px; }
.qr-title { font-family: 'Fraunces', serif; font-size: 1.15rem; color: var(--henna); }
.qr-sub { font-size: 0.85rem; color: var(--ink-soft); margin: 4px 0 10px; }
.url {
  display: inline-block; background: var(--paper-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 9px; font-size: 0.8rem; word-break: break-all; color: var(--ink);
}
.qr-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.table-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden;
}
.table-scroll { overflow-x: auto; }
.records { width: 100%; border-collapse: collapse; min-width: 640px; }
.records th {
  text-align: left; font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-soft); font-weight: 600; padding: 14px 16px;
  background: var(--paper-2); border-bottom: 1px solid var(--line);
}
.records td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.records tr:last-child td { border-bottom: none; }
.records tbody tr:hover:not(.empty) { background: rgba(201, 138, 43, 0.05); }
.cell-center { text-align: center; }
.cell-vehicle { color: var(--ink-soft); font-size: 0.9rem; }
.t-strong { display: block; font-weight: 600; }
.t-weak { display: block; font-size: 0.74rem; color: var(--ink-soft); }
.time-left {
  display: inline-block; margin-top: 3px;
  font-size: 0.72rem; font-weight: 700;
  color: var(--ok); background: #e2f2e8;
  padding: 2px 7px; border-radius: 999px;
}
.time-urgent {
  color: #8a3a00; background: #fdefd8;
  animation: blink-urgent 1.8s ease-in-out infinite;
}
@keyframes blink-urgent {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}
.row-expired td { background: rgba(154, 59, 36, 0.04); }
.empty td { text-align: center; color: var(--ink-soft); padding: 40px 20px; font-size: 0.92rem; }

/* status badges */
.badge { font-size: 0.72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge-ok { background: #e2f2e8; color: var(--ok); }
.badge-active { background: #fdefd8; color: var(--warn); }
.badge-muted { background: #eee6da; color: #7a6a58; }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 44px; height: 25px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; background: #cfc3b2; border-radius: 999px; transition: background 0.2s;
}
.slider::before {
  content: ''; position: absolute; height: 19px; width: 19px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform 0.2s; box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.switch input:checked + .slider { background: var(--leaf); }
.switch input:checked + .slider::before { transform: translateX(19px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px rgba(62, 91, 58, 0.35); }

/* focus + motion + print */
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; }
  .topbar-inner { flex-direction: column; align-items: flex-start; }
}

@media print {
  body.admin { background: #fff; }
  .topbar, .page-head, .stats, .table-card, .qr-actions { display: none !important; }
  .qr-panel { border: none; box-shadow: none; justify-content: center; text-align: center; flex-direction: column; }
  .qr-img { width: 320px; height: 320px; }
}
