:root {
  --ink: #0e0f14; --surface: #181a23; --raised: #20232f; --line: #2c3040;
  --text: #f4f1ea; --muted: #9a9db0; --accent: #ff6b4a; --accent-ink: #1a0b06;
  --ok: #4ade80; --bad: #f87171; --pass: #7dd3fc;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ink); color: var(--text);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh; display: flex; flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 8px; text-wrap: balance; }
h1 { font-size: clamp(1.7rem, 5vw, 2.4rem); }
h2 { font-size: 1.2rem; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.mark { width: 22px; height: 22px; border-radius: 6px; background:
  linear-gradient(var(--ink), var(--ink)) 7px 7px / 8px 8px no-repeat, var(--accent); }
nav { display: flex; align-items: center; gap: 16px; font-size: 0.95rem; }
nav a { color: var(--text); }
nav form { margin: 0; }
.linkbtn { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }

main { width: 100%; max-width: 620px; margin: 0 auto; padding: 24px 16px 40px; flex: 1; }
main.wide { max-width: 920px; }
footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }

.hero { margin-bottom: 22px; }
.hero p { color: var(--muted); max-width: 46ch; }

.events { display: grid; gap: 12px; }
.event {
  display: flex; gap: 14px; align-items: center; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text);
  transition: border-color .15s, transform .15s;
}
.event:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.event h2 { margin: 0 0 2px; font-size: 1.08rem; }
.event p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.date {
  flex: 0 0 58px; height: 62px; border-radius: 12px; background: var(--raised);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
}
.date span { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); font-weight: 700; }
.date strong { font-size: 1.5rem; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px !important; }
.tag {
  display: inline-block; font-size: 0.74rem; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  background: var(--raised); color: var(--muted); border: 1px solid var(--line); text-transform: capitalize;
}
.tag.recurring { color: var(--pass); border-color: color-mix(in srgb, var(--pass) 40%, transparent); }
.tag.single { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.tag.full, .tag.st-cancelled { color: var(--bad); }
.tag.st-active { color: var(--ok); }
.tag.st-used { color: var(--muted); }

.back { display: inline-block; margin-bottom: 16px; color: var(--muted); }
.detail { margin-bottom: 20px; }
.detail .tags { margin: 0 0 10px !important; }
.when { color: var(--accent); font-weight: 600; }
.desc { color: var(--muted); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.panel.narrow { max-width: 420px; margin: 24px auto; }
label { display: block; font-size: 0.88rem; font-weight: 600; margin-bottom: 14px; }
.opt { font-weight: 400; color: var(--muted); }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 12px; font: inherit; font-size: 16px;
  color: var(--text); background: var(--ink); border: 1px solid var(--line); border-radius: 10px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.check input { width: auto; margin: 0; }
.hp { position: absolute; left: -9999px; }
.btn {
  display: inline-block; width: 100%; padding: 14px 18px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 700; text-align: center;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.small { width: auto; padding: 8px 14px; font-size: 0.9rem; border-radius: 10px; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.inline { display: inline-block; margin-top: 12px; }
.error, .notice { padding: 10px 12px; border-radius: 10px; font-size: 0.92rem; }
.error, .notice.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.notice.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }

/* ticket */
.ticket { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; overflow: hidden; margin-bottom: 20px; }
.ticket .stub { padding: 22px 22px 18px; border-bottom: 2px dashed var(--line); position: relative; }
.ticket .stub::before, .ticket .stub::after {
  content: ""; position: absolute; bottom: -12px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); border: 1px solid var(--line);
}
.ticket .stub::before { left: -12px; } .ticket .stub::after { right: -12px; }
.ticket .tags { margin: 0 0 10px !important; }
.ticket h1 { font-size: 1.5rem; }
.holder { font-size: 1.1rem; font-weight: 700; margin: 10px 0 0; }
.qr { padding: 22px; display: flex; justify-content: center; }
.qr svg { width: min(260px, 70vw); height: auto; background: #fff; border-radius: 14px; padding: 10px; }
.ticket.used .qr svg, .ticket.cancelled .qr svg { opacity: .35; }
.fine { text-align: center; color: var(--muted); font-size: 0.88rem; padding: 0 22px 20px; margin: 0; }

.log { list-style: none; margin: 12px 0 0; padding: 0; font-size: 0.9rem; }
.log li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.log .admitted span:last-child, tr.admitted td:last-child { color: var(--ok); }
.log .denied span:last-child, tr.denied td:last-child { color: var(--bad); }

/* scanner */
.viewport { position: relative; aspect-ratio: 1; background: #000; border-radius: 22px; overflow: hidden; border: 1px solid var(--line); }
.viewport video { width: 100%; height: 100%; object-fit: cover; }
.reticle { position: absolute; inset: 16%; border: 3px solid rgba(255,255,255,.85); border-radius: 22px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
.cammsg { position: absolute; inset: auto 0 12px; text-align: center; margin: 0; font-size: 0.9rem; text-shadow: 0 1px 4px #000; padding: 0 12px; }
.result { margin-top: 14px; padding: 18px; border-radius: var(--radius); border: 2px solid; }
.result.admitted { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.result.denied { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.result .verdict { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.result.admitted .verdict { color: var(--ok); } .result.denied .verdict { color: var(--bad); }
.result .who { font-size: 1.15rem; font-weight: 700; margin: 6px 0 2px; }
.result p { margin: 0 0 4px; }
.result .btn { margin-top: 12px; }
.manual { margin-top: 18px; }

/* admin */
.headrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.headrow h1 { margin: 0; }
.search { display: flex; gap: 8px; flex: 1 1 260px; max-width: 420px; }
.search input { margin: 0; padding: 8px 12px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.stats strong { display: block; font-size: 1.7rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stats span { color: var(--muted); font-size: 0.82rem; }
.status { font-size: 0.88rem; color: var(--muted); margin-bottom: 6px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); margin-top: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 480px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.07em; background: var(--surface); }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.sub { margin: 26px 0 10px; }
.tcard { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.actions { display: flex; gap: 8px; }
.actions form { margin: 0; }
.empty { color: var(--muted); padding: 30px 0; text-align: center; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
