:root {
  --bg: #0b0b10;
  --surface: #15151d;
  --surface-2: #1d1d28;
  --border: #2a2a38;
  --text: #f3f3f7;
  --muted: #9a9aab;
  --accent: #8b5cf6;
  --accent-2: #a78bfa;
  --ok: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -200px, #22163f 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}
a { color: var(--accent-2); }
h1 { font-size: 1.75rem; line-height: 1.2; margin: .2em 0 .4em; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 1.4em 0 .7em; }
.card h2:first-child, .section-head h2 { margin-top: 0; }
p { margin: .5em 0; }
main { padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); margin: 0 auto; }
main.narrow { max-width: 480px; }
main.wide { max-width: 1200px; }
main.has-bar { padding-bottom: 120px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .04em; padding: 6px 0 18px; }
.brand a { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 10px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.admin-bar { justify-content: space-between; }
.eyebrow { color: var(--accent-2); font-size: .8rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.right { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; }
.lead { font-size: 1.1rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin: 0 0 16px; }
.card.ready { text-align: center; border-color: var(--accent); }

/* forms */
.stack { display: grid; gap: 14px; margin-top: 16px; }
label { display: grid; gap: 6px; font-size: .9rem; color: var(--muted); }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=date], input:not([type]) {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; min-height: 48px;
}
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
label.check { display: flex; gap: 10px; align-items: flex-start; color: var(--muted); font-size: .85rem; }
label.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.row-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.row-form .grow { flex: 1 1 220px; }
.inline { display: inline-flex; align-items: center; gap: 6px; }
.num { width: 90px !important; min-height: 36px !important; padding: 6px 10px !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
  color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 16px; min-height: 44px; cursor: pointer; text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--accent-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #7c4dee; }
.btn.big { width: 100%; min-height: 54px; font-size: 1.05rem; }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: .85rem; }
.btn.ok { background: rgba(34, 197, 94, .15); border-color: rgba(34, 197, 94, .5); color: #86efac; }
.btn.danger { color: #fca5a5; border-color: rgba(239, 68, 68, .5); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
button.link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; text-decoration: underline; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.error { color: #fecaca; background: rgba(239, 68, 68, .12); border: 1px solid rgba(239, 68, 68, .4); border-radius: 10px; padding: 10px 12px; }
.warn { color: #fde68a; background: rgba(245, 158, 11, .1); border: 1px solid rgba(245, 158, 11, .35); border-radius: 10px; padding: 10px 12px; margin: 0 0 10px; font-size: .9rem; }
.flash { color: #ddd6fe; background: rgba(139, 92, 246, .14); border: 1px solid rgba(139, 92, 246, .45); border-radius: 10px; padding: 10px 12px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.pill.ok { color: #86efac; border-color: rgba(34, 197, 94, .5); background: rgba(34, 197, 94, .1); }
.count { color: var(--muted); font-weight: 500; font-size: .9em; margin-left: 4px; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 1.4em 0 .7em; }
.card .section-head:first-child { margin-top: 0; }
.section-head h1, .section-head h2 { margin: 0; }

/* ticket */
.ticket-card {
  background: #fff; color: #111; border-radius: 22px; padding: 22px 22px 18px; text-align: center; margin: 14px 0 18px;
  box-shadow: 0 0 0 4px var(--accent), 0 20px 60px rgba(139, 92, 246, .35);
}
.ticket-label { margin: 0; font-weight: 600; color: #555; text-transform: uppercase; letter-spacing: .1em; font-size: .85rem; }
.ticket-number { margin: 0; font-size: clamp(4.5rem, 26vw, 7rem); font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.ticket-name { margin: 10px 0 0; font-weight: 600; font-size: 1.1rem; }

/* galleries */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.ph { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.ph-img { display: block; padding: 0; border: 0; background: #000; cursor: zoom-in; aspect-ratio: 4 / 5; width: 100%; }
.ph-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph > .btn, .pick { margin: 8px; }
.pick { display: flex; align-items: center; justify-content: center; min-height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-weight: 600; font-size: .85rem; cursor: pointer; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick .on { display: none; }
.pick:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #fff; }
.pick:has(input:checked) .on { display: inline; }
.pick:has(input:checked) .off { display: none; }
.ph:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

.buybar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: rgba(21, 21, 29, .94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.buybar-info { display: grid; min-width: 0; }
.buybar .btn { flex: none; min-width: 140px; }

.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .94); display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100vw; max-height: calc(100vh - 120px); object-fit: contain; }
.lb-close, .lb-prev, .lb-next { position: absolute; background: rgba(255, 255, 255, .1); color: #fff; border: 0; border-radius: 50%; width: 48px; height: 48px; font-size: 1.6rem; cursor: pointer; }
.lb-close { top: calc(12px + env(safe-area-inset-top)); right: 12px; font-size: 1.2rem; }
.lb-prev { left: 8px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 8px; top: 50%; transform: translateY(-50%); }
.lb-actions { position: absolute; bottom: calc(18px + env(safe-area-inset-bottom)); left: 0; right: 0; display: flex; justify-content: center; }
.lb-actions .btn { min-width: 180px; }

.spinner { width: 40px; height: 40px; margin: 30px auto; border: 4px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* admin */
.list { display: grid; gap: 10px; }
.list-item { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; color: inherit; text-decoration: none; }
.list-item:hover { border-color: var(--accent-2); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
.qr-block { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.qr-block > div { flex: 1 1 260px; min-width: 0; }
.qr-mini { display: block; width: 160px; flex: none; background: #fff; border-radius: 12px; padding: 8px; }
.qr-mini svg { display: block; width: 100%; height: auto; }
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 22px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.dropzone.over { border-color: var(--accent); background: rgba(139, 92, 246, .08); }
.dropzone input[type=file] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.progress { flex-basis: 100%; }
.progress .bar { height: 8px; border-radius: 99px; background: var(--accent); width: 0; transition: width .2s; }
.toolbar { position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; margin: 0 -10px 8px; background: rgba(21, 21, 29, .95); backdrop-filter: blur(8px); border-radius: 12px; }
.admin-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tile { position: relative; display: block; border-radius: 10px; overflow: hidden; border: 2px solid transparent; background: #000; cursor: pointer; color: var(--text); }
.tile img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.tile input { position: absolute; top: 8px; left: 8px; width: 20px; height: 20px; accent-color: var(--accent); z-index: 2; }
.tile:has(input:checked) { border-color: var(--accent); }
.tile.is-hidden img { opacity: .35; }
.badges { position: absolute; top: 6px; right: 6px; left: 34px; display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.badge { font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: rgba(0, 0, 0, .7); border: 1px solid var(--border); }
.badge.tag { background: var(--accent); border-color: var(--accent); }
.fname { position: absolute; bottom: 0; left: 0; right: 0; font-size: .7rem; padding: 2px 6px; background: rgba(0, 0, 0, .6); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.danger-zone { border-color: rgba(239, 68, 68, .35); }

/* full-screen QR (show on phone / print) */
.qr-body { background: #fff; color: #111; }
.qr-full { max-width: 640px; text-align: center; padding-top: 32px; }
.qr-full .eyebrow { color: #7c3aed; }
.qr-full .muted { color: #555; }
.qr-big { width: min(86vw, 520px); margin: 18px auto; }
.qr-big svg { width: 100%; height: auto; display: block; }
@media print { .noprint { display: none; } }

.legal { max-width: 1200px; margin: 0 auto; padding: 8px 16px 24px; color: var(--muted); font-size: .75rem; text-align: center; }
.has-bar + .legal, main.has-bar ~ .legal { padding-bottom: 110px; }
.qr-body .legal { display: none; }
