:root {
  --bg: #0a1220;
  --bg-elev: #121c2e;
  --bg-card: #162338;
  --line: rgba(255,255,255,0.08);
  --text: #f4f1ea;
  --muted: #a8b3c7;
  --gold: #d4af37;
  --gold-soft: #f0d78c;
  --red: #c0392b;
  --red-deep: #8b1e2d;
  --green: #2ecc71;
  --blue: #3d7eff;
  --shadow: 0 18px 50px rgba(0,0,0,0.35);
  --radius: 18px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Ubuntu, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(212,175,55,0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(192,57,43,0.22), transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--gold-soft); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
.container { width: min(1100px, calc(100% - 2rem)); margin: 0 auto; }
.demo-banner {
  background: linear-gradient(90deg, #5c1a24, #8b1e2d 40%, #a67c00);
  color: #fff;
  text-align: center;
  padding: 0.55rem 1rem;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  position: sticky;
  top: 0;
  z-index: 50;
}
.demo-banner span { opacity: 0.9; font-weight: 500; }
header.site {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 0; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: 0.75rem; color: inherit; text-decoration: none; }
.brand:hover { text-decoration: none; }
.logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(145deg, var(--gold), var(--red));
  display: grid; place-items: center; font-weight: 800; color: #111;
  box-shadow: 0 8px 20px rgba(212,175,55,0.25);
}
.brand-text strong { display: block; font-size: 1.05rem; }
.brand-text small { color: var(--muted); font-size: 0.78rem; }
nav { display: flex; gap: 0.75rem; flex-wrap: wrap; }
nav a.navlink {
  color: var(--muted); padding: 0.45rem 0.8rem; border-radius: 999px;
  border: 1px solid transparent; text-decoration: none; font-size: 0.92rem;
}
nav a.navlink:hover, nav a.navlink.active {
  color: var(--text); border-color: var(--line); background: rgba(255,255,255,0.04);
}
.hero {
  display: grid; gap: 1.5rem; padding: 1.5rem 0 2rem;
}
@media (min-width: 860px) {
  .hero { grid-template-columns: 1.3fr 1fr; align-items: stretch; }
}
.hero-card, .card {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), transparent 40%), var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero-card { padding: 1.6rem; overflow: hidden; position: relative; }
.hero-card::after {
  content: ""; position: absolute; inset: auto -20% -40% 40%; height: 220px;
  background: radial-gradient(circle, rgba(212,175,55,0.25), transparent 65%);
  pointer-events: none;
}
.kicker {
  display: inline-flex; gap: 0.4rem; align-items: center;
  background: rgba(212,175,55,0.12); color: var(--gold-soft);
  border: 1px solid rgba(212,175,55,0.28);
  padding: 0.25rem 0.7rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600;
}
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.15; margin: 0.8rem 0 0.6rem; }
h2 { font-size: 1.35rem; margin: 0 0 0.75rem; }
h3 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.lead { color: var(--muted); font-size: 1.02rem; max-width: 42rem; }
.meta { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1rem 0 1.25rem; }
.pill {
  background: rgba(255,255,255,0.05); border: 1px solid var(--line);
  border-radius: 999px; padding: 0.35rem 0.75rem; font-size: 0.86rem; color: var(--muted);
}
.price-tag {
  font-size: 2rem; font-weight: 800; color: var(--gold-soft);
}
.price-tag small { font-size: 0.95rem; color: var(--muted); font-weight: 500; }
.btn {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.85rem 1.2rem; border-radius: 14px; font-weight: 700; font-size: 0.98rem;
  transition: transform .15s ease, opacity .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--gold), #e8c547);
  color: #1a1200;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost {
  background: transparent; color: var(--text); border: 1px solid var(--line);
}
.btn-danger { background: var(--red); color: white; }
.btn-success { background: #1f8f4e; color: white; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.1rem; }
.section { padding: 0.5rem 0 2.5rem; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1rem; }
.event-grid { display: grid; gap: 1rem; }
@media (min-width: 700px) { .event-grid { grid-template-columns: 1fr; } }
.event-card {
  display: grid; gap: 0; overflow: hidden; text-decoration: none; color: inherit;
}
.event-card:hover { text-decoration: none; transform: translateY(-2px); transition: transform .15s ease; }
.event-cover {
  min-height: 160px; padding: 1.25rem; display: flex; flex-direction: column; justify-content: end;
  position: relative;
}
.event-body { padding: 1.15rem 1.25rem 1.35rem; }
.event-body p { color: var(--muted); margin: 0.4rem 0 0.9rem; }
.cover-badge {
  position: absolute; top: 1rem; left: 1rem;
  background: rgba(0,0,0,0.35); backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 0.3rem 0.65rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
}
footer.site {
  border-top: 1px solid var(--line); padding: 2rem 0 2.5rem; color: var(--muted); font-size: 0.9rem;
}
footer .cols { display: grid; gap: 1rem; }
@media (min-width: 700px) { footer .cols { grid-template-columns: 2fr 1fr 1fr; } }
.form-card { padding: 1.35rem; }
label { display: block; font-size: 0.86rem; color: var(--muted); margin: 0.85rem 0 0.35rem; }
input, select, textarea {
  width: 100%; padding: 0.8rem 0.9rem; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(0,0,0,0.25); color: var(--text);
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(212,175,55,0.45); border-color: transparent;
}
.qty {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: rgba(0,0,0,0.25); border: 1px solid var(--line); border-radius: 12px; padding: 0.25rem;
}
.qty button {
  width: 40px; height: 40px; border: 0; border-radius: 10px; background: rgba(255,255,255,0.06);
  color: var(--text); font-size: 1.2rem; cursor: pointer;
}
.qty span { min-width: 2rem; text-align: center; font-weight: 700; }
.summary {
  margin-top: 1rem; padding: 1rem; border-radius: 14px;
  background: rgba(212,175,55,0.08); border: 1px solid rgba(212,175,55,0.2);
}
.summary .row { display: flex; justify-content: space-between; gap: 1rem; margin: 0.25rem 0; }
.pay-options { display: grid; gap: 0.7rem; margin: 1rem 0; }
.pay-option {
  display: flex; gap: 0.8rem; align-items: center;
  padding: 0.9rem 1rem; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(0,0,0,0.2); cursor: pointer;
}
.pay-option.active { border-color: rgba(212,175,55,0.55); background: rgba(212,175,55,0.08); }
.pay-option input { width: auto; }
.pay-option .soon {
  margin-left: auto; font-size: 0.75rem; color: var(--muted);
  border: 1px dashed var(--line); padding: 0.15rem 0.45rem; border-radius: 999px;
}
.alert {
  padding: 0.85rem 1rem; border-radius: 12px; margin: 1rem 0; font-size: 0.92rem;
}
.alert-warn { background: rgba(212,175,55,0.12); border: 1px solid rgba(212,175,55,0.35); color: var(--gold-soft); }
.alert-ok { background: rgba(46,204,113,0.12); border: 1px solid rgba(46,204,113,0.35); color: #9dffc2; }
.alert-err { background: rgba(192,57,43,0.15); border: 1px solid rgba(192,57,43,0.4); color: #ffb4ad; }
.tickets { display: grid; gap: 1rem; }
.ticket {
  background: #fff; color: #1a1a1a; border-radius: 16px; overflow: hidden;
  display: grid; grid-template-columns: 1fr auto;
}
.ticket-main { padding: 1.1rem 1.2rem; }
.ticket-qr { padding: 1rem; background: #f7f3ea; display: grid; place-items: center; min-width: 160px; }
.ticket-qr canvas, .ticket-qr img { width: 140px; height: 140px; }
.ticket .code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; letter-spacing: 0.04em; }
.ticket .muted { color: #666; font-size: 0.88rem; }
.stats { display: grid; gap: 0.8rem; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 800px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  padding: 1rem; border-radius: 14px; background: rgba(255,255,255,0.04); border: 1px solid var(--line);
}
.stat .n { font-size: 1.55rem; font-weight: 800; color: var(--gold-soft); }
.stat .l { color: var(--muted); font-size: 0.85rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.7rem 0.5rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.scanner-box { /* overridden below for square puerta */ }
#reader { width: 100%; }
.result-big {
  text-align: center; padding: 1.25rem; border-radius: 16px; margin-top: 1rem; font-size: 1.15rem; font-weight: 700;
}
.result-valid { background: rgba(46,204,113,0.15); color: #9dffc2; border: 1px solid rgba(46,204,113,0.35); }
.result-used { background: rgba(212,175,55,0.15); color: var(--gold-soft); border: 1px solid rgba(212,175,55,0.35); }
.result-invalid { background: rgba(192,57,43,0.18); color: #ffb4ad; border: 1px solid rgba(192,57,43,0.4); }
.hidden { display: none !important; }
@media print {
  .demo-banner, header.site, footer.site, .no-print { display: none !important; }
  body { background: white; color: black; }
  .ticket { break-inside: avoid; margin-bottom: 1rem; border: 1px solid #ccc; }
}

/* Organizer tabs & rendimiento */
.org-tabs {
  display: flex; flex-wrap: wrap; gap: 0.35rem;
  border-bottom: 1px solid var(--line); margin: 0.5rem 0 1.2rem; padding-bottom: 0.5rem;
}
.org-tabs button {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  padding: 0.55rem 0.9rem; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 600;
}
.org-tabs button.active {
  background: rgba(212,175,55,0.15); color: var(--gold-soft);
}
.chart {
  display: flex; align-items: flex-end; gap: 4px; height: 140px;
  padding: 0.5rem 0; overflow-x: auto;
}
.chart .bar-wrap {
  flex: 1; min-width: 28px; display: flex; flex-direction: column; align-items: center; height: 100%;
  justify-content: flex-end; gap: 4px;
}
.chart .bar {
  width: 100%; border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--gold), #8b1e2d);
  min-height: 2px;
}
.chart .bar.courtesy { background: linear-gradient(180deg, #3d7eff, #1a3a5c); }
.chart .lbl { font-size: 0.65rem; color: var(--muted); writing-mode: horizontal-tb; text-align: center; }
.disc-grid { display: grid; gap: 0.8rem; }
@media (min-width: 700px) { .disc-grid { grid-template-columns: 1fr 1fr; } }
.disc-card {
  padding: 1rem; border-radius: 14px; border: 1px solid var(--line); background: rgba(0,0,0,0.2);
}
.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 0.15rem 0.5rem;
  border-radius: 999px; border: 1px solid var(--line);
}
.badge-on { color: #9dffc2; border-color: rgba(46,204,113,0.4); background: rgba(46,204,113,0.12); }
.badge-off { color: #ffb4ad; border-color: rgba(192,57,43,0.4); background: rgba(192,57,43,0.12); }
.loc-row {
  display: grid; grid-template-columns: 1.4fr 0.8fr 0.7fr 0.7fr 0.6fr auto;
  gap: 0.4rem; align-items: end; margin-bottom: 0.5rem;
}
@media (max-width: 700px) {
  .loc-row { grid-template-columns: 1fr 1fr; }
}
.form-grid { display: grid; gap: 0.2rem 1rem; }
@media (min-width: 700px) { .form-grid.two { grid-template-columns: 1fr 1fr; } }
.toggle-row { display: flex; align-items: center; gap: 0.6rem; margin: 0.8rem 0; }
.toggle-row input { width: auto; }


/* —— Puerta: square scanner + result globo —— */
.puerta-wrap { max-width: 420px; margin: 0 auto; }
.scanner-stage {
  position: relative;
  width: min(100%, 360px);
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  border-radius: 20px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.scanner-stage #reader {
  width: 100% !important;
  height: 100% !important;
}
.scanner-stage #reader video,
.scanner-stage #reader canvas {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  border-radius: 0 !important;
}
.scanner-stage #reader > div { border: none !important; }
/* hide html5-qrcode default dashed box if present */
.scanner-stage img[alt="Info icon"] { display: none !important; }
.scan-frame {
  pointer-events: none;
  position: absolute; inset: 12%;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.35);
  z-index: 2;
}
.scan-frame::before, .scan-frame::after,
.scan-frame span::before, .scan-frame span::after {
  content: ""; position: absolute; width: 28px; height: 28px;
  border-color: #f0d78c; border-style: solid;
}
.scan-frame::before { top: -2px; left: -2px; border-width: 4px 0 0 4px; border-radius: 6px 0 0 0; }
.scan-frame::after { top: -2px; right: -2px; border-width: 4px 4px 0 0; border-radius: 0 6px 0 0; }
.scan-frame span::before { bottom: -2px; left: -2px; border-width: 0 0 4px 4px; border-radius: 0 0 0 6px; }
.scan-frame span::after { bottom: -2px; right: -2px; border-width: 0 4px 4px 0; border-radius: 0 0 6px 0; }
.scan-hint {
  position: absolute; left: 0; right: 0; bottom: 10px;
  text-align: center; z-index: 3; font-size: 0.78rem; color: #fff;
  text-shadow: 0 1px 4px #000; pointer-events: none;
}
.ingresos-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: rgba(212,175,55,0.12); border: 1px solid rgba(212,175,55,0.3);
  color: var(--gold-soft); padding: 0.35rem 0.75rem; border-radius: 999px;
  font-weight: 700; font-size: 0.9rem; margin-bottom: 0.9rem;
}

/* Hide html5-qrcode paused / dashed UI chrome */
.scanner-stage #qr-shaded-region,
.scanner-stage #reader__scan_region > img,
.scanner-stage div[style*="Scanner paused"],
.scanner-stage #reader__dashboard,
.scanner-stage #reader__header_message,
.scanner-stage #reader__status_span {
  display: none !important;
}
.scanner-stage.overlay-open video,
.scanner-stage.overlay-open canvas {
  visibility: hidden !important;
  opacity: 0 !important;
}

/* Full-screen globo overlay — above iOS camera video layer */
.globo {
  position: fixed !important;
  top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
  inset: 0 !important;
  width: 100vw; height: 100vh; height: 100dvh;
  z-index: 2147483000 !important;
  display: flex; align-items: center; justify-content: center;
  padding: 1.25rem; padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  background: rgba(0,0,0,0.82);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  animation: globoIn .18s ease-out;
  -webkit-transform: translate3d(0,0,0); transform: translate3d(0,0,0);
  isolation: isolate;
}
.globo.hidden { display: none !important; pointer-events: none !important; }
@keyframes globoIn { from { opacity: 0; -webkit-transform: translate3d(0,0,0) scale(.96); transform: translate3d(0,0,0) scale(.96); } to { opacity: 1; -webkit-transform: translate3d(0,0,0); transform: translate3d(0,0,0); } }
.globo-card {
  width: min(420px, 100%);
  border-radius: 24px;
  padding: 1.75rem 1.4rem 1.4rem;
  text-align: center;
  color: #fff;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
  position: relative;
  z-index: 1;
  -webkit-transform: translate3d(0,0,0); transform: translate3d(0,0,0);
}
.globo-card.valid { background: linear-gradient(160deg, #1f8f4e, #145c32); }
.globo-card.used { background: linear-gradient(160deg, #b8860b, #7a5a08); }
.globo-card.invalid { background: linear-gradient(160deg, #c0392b, #7a1e16); }
.globo-icon { font-size: 4rem; line-height: 1; margin-bottom: 0.4rem; }
.globo-title { font-size: 1.55rem; font-weight: 800; margin: 0 0 0.5rem; letter-spacing: -0.02em; }
.globo-sub { font-size: 1.05rem; opacity: 0.95; margin: 0.25rem 0; }
.globo-meta { font-size: 0.9rem; opacity: 0.85; margin-top: 0.75rem; line-height: 1.45; }
.globo-card .btn {
  margin-top: 1.25rem; width: 100%;
  background: rgba(255,255,255,0.95); color: #111; font-weight: 800;
}

/* —— Puerta v4: inline result screen (no overlay over video) —— */
body.puerta-result-mode {
  background: #111 !important;
  background-image: none !important;
}
body.puerta-result-mode .demo-banner,
body.puerta-result-mode header.site,
body.puerta-result-mode .puerta-scan-ui {
  display: none !important;
}
.result-screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1.5rem 1.25rem max(2rem, env(safe-area-inset-bottom));
  color: #fff;
  text-align: center;
}
body.puerta-result-mode .result-screen { display: block; }
body.puerta-result-ok { background: #16a34a !important; background-image: none !important; }
body.puerta-result-used { background: #f59e0b !important; background-image: none !important; }
body.puerta-result-deny { background: #dc2626 !important; background-image: none !important; }
.result-screen .result-big {
  font-size: clamp(2.4rem, 15vw, 5.5rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 12vh 0 1rem;
  text-shadow: 0 4px 20px rgba(0,0,0,0.25);
}
.result-screen .result-sub {
  font-size: clamp(1.1rem, 4.5vw, 1.6rem);
  font-weight: 700;
  margin: 0 0 1rem;
  opacity: 0.95;
}
.result-screen .result-meta {
  font-size: 1rem;
  line-height: 1.5;
  opacity: 0.92;
  max-width: 28rem;
  margin: 0 auto 2rem;
}
.result-screen .result-meta code {
  display: inline-block;
  margin-top: 0.5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  opacity: 0.85;
}
.result-screen .btn-next {
  appearance: none; border: 0; cursor: pointer;
  width: min(100%, 360px);
  padding: 1.05rem 1.2rem;
  border-radius: 16px;
  font-size: 1.15rem; font-weight: 800;
  background: #fff; color: #111;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.version-label {
  text-align: center; color: var(--muted); font-size: 0.75rem;
  padding: 0.75rem 0 1.5rem; opacity: 0.7;
}
body.puerta-result-mode .version-label { color: rgba(255,255,255,0.75); }
