:root {
  --bg: #f4f3f7;
  --surface: #ffffff;
  --surface-2: #eceaf2;
  --text: #16151c;
  --muted: #6b6878;
  --line: #e1dee9;
  --accent: #e8661c;
  --accent-ink: #ffffff;
  --ok: #18864b;
  --warn: #b86e00;
  --danger: #c0262d;
  --ticket: #14161f;
  --ticket-ink: #ffffff;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 18, 30, .06), 0 8px 24px rgba(20, 18, 30, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1016;
    --surface: #181a23;
    --surface-2: #222532;
    --text: #f1f0f6;
    --muted: #9c9aab;
    --line: #2b2e3b;
    --accent: #ff8a3d;
    --accent-ink: #1a0e05;
    --ok: #3ccf7f;
    --warn: #f2b33d;
    --danger: #ff5c63;
    --ticket: #1f2230;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
main { max-width: 560px; margin: 0 auto; padding: 24px 16px 64px; }
main.wide { max-width: 1180px; }
h1 { font-size: 28px; line-height: 1.15; margin: 0 0 6px; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
a { color: inherit; }
p.lead { color: var(--muted); margin: 0 0 24px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.stack > * + * { margin-top: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.num { font-variant-numeric: tabular-nums; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 6px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  font: inherit;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 14px;
}
textarea { min-height: 90px; resize: vertical; }
input[type="color"] { padding: 4px; height: 44px; }
input[type="checkbox"] { width: auto; margin: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 650; font-size: 15px;
  padding: 11px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button:disabled { opacity: .45; cursor: default; }
button.secondary, .button.secondary { background: transparent; color: var(--text); border-color: var(--line); }
button.ghost { background: transparent; color: var(--muted); border-color: transparent; padding: 6px 10px; }
button.danger { background: transparent; color: var(--danger); border-color: var(--line); }
button.small, .button.small { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.full { width: 100%; }
.error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 0 0 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 650; letter-spacing: .02em;
  padding: 3px 9px; border-radius: 99px; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
}
.chip.ok { color: var(--ok); }
.chip.warn { color: var(--warn); }
.chip.bad { color: var(--danger); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.brand { font-weight: 750; letter-spacing: .02em; display: flex; gap: 10px; align-items: center; text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }

/* ---------- Shop ---------- */
.demo-banner {
  font-size: 13px; text-align: center; padding: 8px 12px;
  background: var(--surface-2); color: var(--muted);
}
.event-card {
  display: grid; grid-template-columns: 64px 1fr; gap: 16px; align-items: center;
  text-decoration: none; color: inherit; padding: 16px;
  border-left: 4px solid var(--event, var(--accent));
}
.event-card + .event-card { margin-top: 12px; }
.datebox { text-align: center; border-radius: 12px; background: var(--surface-2); padding: 8px 0; }
.datebox .m { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--event, var(--accent)); }
.datebox .d { font-size: 26px; font-weight: 750; line-height: 1.1; }
.event-card .name { font-weight: 700; font-size: 17px; }

.hero { border-radius: var(--radius); padding: 24px; color: #fff; margin-bottom: 16px;
  background: linear-gradient(135deg, var(--event, #e8661c), #191b25 90%); }
.hero h1 { color: #fff; }
.hero .meta { opacity: .85; font-size: 15px; }
.tier { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.tier:first-child { border-top: 0; }
.tier .tname { font-weight: 700; display: flex; gap: 8px; align-items: center; }
.tier .swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--tier); }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 36px; height: 36px; padding: 0; border-radius: 50%; font-size: 20px; line-height: 1; }
.stepper .q { min-width: 20px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.total { font-size: 22px; font-weight: 750; font-variant-numeric: tabular-nums; }

/* Ticket card */
.ticket {
  background: var(--ticket); color: var(--ticket-ink);
  border-radius: 18px; overflow: hidden; position: relative;
  box-shadow: 0 12px 32px rgba(10, 10, 20, .22);
}
.ticket + .ticket { margin-top: 16px; }
.ticket .band { height: 6px; background: var(--tier, var(--accent)); }
.ticket .body { padding: 18px 20px; }
.ticket .label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--tier, #ff8a3d); }
.ticket .ev { font-size: 20px; font-weight: 750; margin: 2px 0 12px; }
.ticket .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ticket .val { font-weight: 600; }
.ticket .qr { background: #fff; border-radius: 12px; padding: 10px; width: 188px; margin: 18px auto 6px; }
.ticket .qr svg { display: block; width: 100%; height: auto; }
.ticket .code { text-align: center; font-family: ui-monospace, Menlo, monospace; font-size: 13px; letter-spacing: .12em; opacity: .7; }
.ticket .perf { border-top: 2px dashed rgba(255, 255, 255, .14); margin: 16px -20px 0; }
.ticket .actions { display: grid; gap: 8px; padding: 14px 20px 18px; }
.ticket .actions .row button { flex: 1; }
.ticket button.secondary { color: var(--ticket-ink); border-color: rgba(255, 255, 255, .18); }
.ticket.faded .body { opacity: .55; }
.ticket .state { font-size: 14px; font-weight: 650; padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, .07); text-align: center; }

.wallet-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #000; color: #fff; border-radius: 12px; padding: 12px 16px;
  text-decoration: none; font-weight: 650; border: 1px solid #3a3a3a; font-size: 15px;
}
.wallet-btn svg { width: 20px; height: 20px; flex: none; }
.wallets { display: grid; gap: 8px; }
@media (min-width: 480px) { .wallets.two { grid-template-columns: 1fr 1fr; } }

dialog {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; width: min(440px, calc(100vw - 32px));
  background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgba(8, 8, 14, .55); }
.linkbox { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; padding: 10px; border-radius: 10px; background: var(--surface-2); }

/* ---------- Admin ---------- */
.admin-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .admin-grid { grid-template-columns: 260px minmax(0, 1fr); } }
.admin-grid > * { min-width: 0; }
.side-list { list-style: none; padding: 0; margin: 0; }
.side-list li { padding: 10px 12px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.side-list li:hover, .side-list li.active { background: var(--bg); border-color: var(--line); }
.side-list .t { font-weight: 650; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 18px; overflow-x: auto; }
.tabs button { background: none; color: var(--muted); border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 12px; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.tile .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.tile .v { font-size: 26px; font-weight: 750; font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; position: relative; }
.bar > span { position: absolute; inset: 0 auto 0 0; border-radius: 99px; }
.bar .sold { background: var(--tier); opacity: .35; }
.bar .in { background: var(--tier); }
.tierstat { padding: 10px 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 650; padding: 8px; border-bottom: 1px solid var(--line); }
td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table-wrap { overflow-x: auto; }
.feed { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.feed li { display: grid; grid-template-columns: max-content 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.feed .tm { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.feed .admitted { color: var(--ok); }
.feed .alreadyUsed { color: var(--warn); }
.feed .invalid, .feed .wrongEvent, .feed .void, .feed .replaced, .feed .notFound { color: var(--danger); }
.tier-edit { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 56px; gap: 8px 10px; align-items: end; padding: 12px 0; border-top: 1px solid var(--line); }
.tier-edit input { margin: 0; min-width: 0; }
.tier-edit label { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tier-edit > .row { grid-column: 1 / -1; justify-content: flex-end; }
@media (max-width: 640px) { .tier-edit { grid-template-columns: 1fr 1fr; } }

/* ---------- Scanner ---------- */
body.scanner { background: #0b0c10; color: #f1f0f6; color-scheme: dark; }
body.scanner main { max-width: 640px; padding-top: 12px; }
.scan-top { display: flex; gap: 8px; align-items: center; }
.scan-top select { margin: 0; flex: 1; background: #181a23; color: inherit; border-color: #2b2e3b; }
.counter { display: flex; align-items: baseline; gap: 6px; margin: 12px 0; }
.counter .big { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; }
.viewport { position: relative; border-radius: 18px; overflow: hidden; background: #000; aspect-ratio: 1 / 1; }
.viewport video { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewport .frame { position: absolute; inset: 18%; border: 3px solid rgba(255, 255, 255, .8); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); }
.viewport .start { position: absolute; inset: 0; display: grid; place-items: center; }
body.scanner .panel { background: #14161f; border-color: #262938; }
body.scanner input { background: #0f1016; border-color: #2b2e3b; color: inherit; }
body.scanner button.secondary { color: inherit; border-color: #2b2e3b; }
.result {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 32px 24px; text-align: center; color: #fff;
}
.result.green { background: #0f8a43; }
.result.amber { background: #c98000; }
.result.red { background: #c0262d; }
.result .icon { font-size: 92px; line-height: 1; font-weight: 800; }
.result .title { font-size: 40px; font-weight: 850; line-height: 1.1; margin: 12px 0 10px; }
.result .detail { font-size: 20px; max-width: 520px; opacity: .95; }
.result .holder { font-size: 26px; font-weight: 750; margin-top: 18px; }
.result .hint { position: absolute; bottom: 28px; opacity: .8; font-size: 15px; }
.result button { margin-top: 26px; background: rgba(255, 255, 255, .18); color: #fff; border-color: rgba(255, 255, 255, .4); }
.offline { position: sticky; top: 0; background: #c0262d; color: #fff; font-weight: 700; text-align: center; padding: 8px; z-index: 40; }
.search-hit { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid #262938; }
