/* ONTICKETS: base y componentes compartidos (panel, escáner, barra y sitio público).
   El panel usa estos valores; el sitio público (body.pub) redefine los tokens de componentes en site.css. */
/* Fuentes propias (public/fonts, licencia OFL): sin pedidos a Google ni a nadie más. El navegador baja sólo
   las que la página usa: el panel, Manrope e Instrument Serif; el sitio público, Geist y Geist Mono. */
@font-face { font-family: "Geist"; src: url("../fonts/Geist-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("../fonts/GeistMono-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("../fonts/Manrope-Variable-latin.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("../fonts/InstrumentSerif-latin.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("../fonts/InstrumentSerif-Italic-latin.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
:root {
  --olive: #2E450E;
  --olive-2: #3F5D17;
  --olive-deep: #17240A;
  --sand: #F2ECE1;
  --sand-2: #E8DDC8;
  --sea: #E2F2F7;
  --ocean: #1E6FA8;
  --ocean-deep: #0E3B5C;
  --sun: #F2A93B;
  --sun-2: #FFC86B;
  --ink: #1A1F14;
  --muted: #5D6352;
  --white: #FFFDF8;
  --ok: #1F7A3A;
  --ok-bg: #DDF3E3;
  --bad: #B3261E;
  --bad-bg: #FBE3E0;
  --warn: #8A5A00;
  --warn-bg: #FFF0CF;
  --line: #DCD1BC;
  --f-sans: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-serif: "Instrument Serif", Georgia, serif;
  --r-sm: 12px;
  --r: 22px;
  --r-lg: 36px;
  --shadow: 0 30px 60px -30px rgba(23, 36, 10, .35);
  --shadow-sm: 0 6px 20px -10px rgba(23, 36, 10, .25);
  --gutter: clamp(16px, 4vw, 48px);

  /* Tokens de componentes: botones, campos, tarjetas, etiquetas, entrada */
  --accent: var(--sun);
  --accent-2: var(--sun-2);
  --accent-ink: var(--olive-deep);
  --surface: var(--white);
  --field: var(--white);
  --field-focus: var(--olive-2);
  --field-ring: rgba(63, 93, 23, .2);
  --focus: var(--ocean);
  --r-btn: 999px;
  --r-pill: 999px;
  --btn-weight: 800;
  --card-shadow: var(--shadow-sm);
  --ticket-bg: var(--olive-deep);
  --ticket-ink: var(--white);
  --ticket-qr: var(--white);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--f-sans); background: var(--sand); color: var(--ink); line-height: 1.5; font-size: 16px; }
img, svg { max-width: 100%; }
a { color: var(--olive-2); }
h1, h2, h3 { line-height: 1.12; margin: 0 0 .5em; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .04em; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 var(--gutter); }
.narrow { max-width: 760px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.event-tools { margin-bottom: 14px; }
.image-preview { max-width: 320px; width: 100%; border-radius: 8px; display: block; margin: 6px 0; }
.spread { justify-content: space-between; }
.grid2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 22px; border-radius: var(--r-btn); border: 0; font: inherit; font-weight: var(--btn-weight); cursor: pointer; text-decoration: none; background: var(--accent); color: var(--accent-ink); transition: transform .15s, background .15s; }
.btn:hover { background: var(--accent-2); }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: inherit; box-shadow: inset 0 0 0 2px currentColor; }
.btn.dark { background: var(--olive); color: var(--white); }
.btn.dark:hover { background: var(--olive-2); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.sm { min-height: 44px; padding: 0 14px; font-size: .875rem; }
.btn.block { width: 100%; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--olive-2); text-decoration: underline; cursor: pointer; }

/* Formularios */
label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.hint { font-weight: 500; font-size: .8rem; color: var(--muted); }
input, select, textarea { width: 100%; min-height: 46px; padding: 10px 14px; border: 1.5px solid var(--line); border-radius: var(--r-sm); background: var(--field); font: inherit; color: var(--ink); }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--field-focus); outline: none; box-shadow: 0 0 0 3px var(--field-ring); }
input[type=checkbox], input[type=radio] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--field-focus); margin: 0; flex: none; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; }
.err { color: var(--bad); font-size: .85rem; font-weight: 700; margin-top: 4px; }
.field.has-err input { border-color: var(--bad); }
.fields2 { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* Avisos */
.alert { padding: 14px 18px; border-radius: var(--r-sm); font-weight: 600; margin: 16px 0; }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.info { background: var(--sea); color: var(--ocean-deep); }

.card { background: var(--surface); border-radius: var(--r); padding: clamp(18px, 3vw, 28px); box-shadow: var(--card-shadow); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: var(--r-pill); font-size: .78rem; font-weight: 800; background: var(--sand-2); color: var(--olive-deep); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.info { background: var(--sea); color: var(--ocean-deep); }

/* ---------- Marca (panel, escáner y barra; el sitio público la redibuja en site.css) ---------- */
.brand { color: var(--white); text-decoration: none; display: flex; flex-direction: column; line-height: 1; }
.brand b { font-size: 1.35rem; letter-spacing: .1em; font-weight: 800; text-transform: uppercase; }
.brand span { font-family: var(--f-serif); font-style: italic; color: var(--sun-2); font-size: 1rem; }
.summary-line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.summary-line.total { border-top: 2px solid var(--ink); margin-top: 8px; padding-top: 12px; font-weight: 800; font-size: 1.15rem; }
.summary-line.discount { color: var(--ok); }

/* Entrada (ticket) */
.ticket { display: grid; grid-template-columns: 1fr; background: var(--surface); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); break-inside: avoid; page-break-inside: avoid; }
@media (min-width: 640px) { .ticket { grid-template-columns: 1fr 260px; } }
.ticket .t-info { padding: 22px; background: var(--ticket-bg); color: var(--ticket-ink); position: relative; }
.ticket .t-event { font-family: var(--f-serif); font-style: italic; color: var(--accent-2); font-size: 1.2rem; }
.ticket .t-info h3 { font-size: 1.5rem; margin: 6px 0 14px; }
.ticket .t-flyer { margin: -22px -22px 16px; height: 150px; position: relative; overflow: hidden; }
.ticket .t-flyer img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ticket .t-flyer::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 30%, var(--ticket-bg)); }
.ticket .t-when { font-size: .85rem; margin-top: 4px; opacity: .85; }
.ticket .t-head { margin-bottom: 14px; }
.ticket .t-info h3 { margin: 10px 0 0; }
.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; letter-spacing: .02em; background: var(--accent); color: var(--accent-ink, #fff); vertical-align: middle; }
.ticket dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: .9rem; }
.ticket dt { opacity: .7; }
.ticket dd { margin: 0; font-weight: 700; }
.ticket .t-qr { padding: 18px; background: var(--ticket-qr); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border-left: 2px dashed var(--line); }
.ticket .t-qr svg { width: 220px; height: 220px; }
.ticket.void .t-qr svg, .ticket.used .t-qr svg { opacity: .15; }
.ticket-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 0 0; }

/* ---------- Admin ---------- */
body.admin { background: #F6F2EA; }
/* minmax(0, 1fr): con 1fr la columna no baja del ancho de su contenido y el menú (links sin cortar)
   ensanchaba todo el panel en el celular en vez de desplazarse. */
.adm { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100vh; }
@media (min-width: 980px) { .adm { grid-template-columns: 240px minmax(0, 1fr); } }
.adm-side { background: var(--olive-deep); color: var(--white); padding: 18px 14px; }
@media (min-width: 980px) { .adm-side { position: sticky; top: 0; height: 100vh; overflow: auto; } }
.adm-side .brand { margin: 4px 8px 18px; }
.adm-side nav { display: flex; flex-direction: column; gap: 2px; }
@media (max-width: 979px) { .adm-side nav { flex-direction: row; overflow-x: auto; padding-bottom: 6px; } .adm-side nav .grp { display: none; } }
.adm-side nav a { color: rgba(255, 253, 248, .85); text-decoration: none; padding: 10px 12px; border-radius: 10px; font-weight: 700; font-size: .92rem; white-space: nowrap; }
.adm-side nav a:hover { background: rgba(255, 255, 255, .08); }
.adm-side nav a.on { background: var(--sun); color: var(--olive-deep); }
.adm-side nav .grp { font-size: .7rem; letter-spacing: .16em; text-transform: uppercase; opacity: .55; margin: 14px 12px 4px; }
.adm-side .me { margin-top: 18px; padding: 12px; border-top: 1px solid rgba(255, 255, 255, .12); font-size: .85rem; }
@media (max-width: 979px) {
  .adm-side { padding: 10px 12px; }
  .adm-side .brand { margin: 0 4px 8px; }
  .adm-side .me { margin-top: 6px; padding: 6px 4px 0; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
  .adm-side .me br, .adm-side .me > span { display: none; }
  .adm-side .me form { margin: 0 !important; }
}
.adm-main { padding: 22px var(--gutter) 60px; min-width: 0; }
.adm-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.adm-head h1 { font-size: 1.6rem; margin: 0; }
.evsel { display: flex; gap: 8px; align-items: center; }
.evsel select { min-height: 40px; width: auto; max-width: 260px; }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 18px; }
.kpi { background: var(--white); border-radius: 18px; padding: 16px 18px; box-shadow: var(--shadow-sm); }
.kpi small { display: block; font-weight: 700; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.kpi b { display: block; font-size: 1.7rem; font-variant-numeric: tabular-nums; margin-top: 4px; }
.kpi span { font-size: .82rem; color: var(--muted); }
.bar { height: 10px; background: var(--sand-2); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--olive-2); border-radius: 999px; }
.tbl-wrap { overflow-x: auto; background: var(--white); border-radius: 18px; box-shadow: var(--shadow-sm); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 14px; border-bottom: 1.5px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid #EEE6D6; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl a { font-weight: 700; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-height: 40px; flex: 1 1 160px; }
/* Gráficos SVG del panel (views/charts.js): línea principal en oliva, comparación punteada en gris. */
.ch { margin: 8px 0 0; }
.ch svg { display: block; width: 100%; height: auto; overflow: visible; }
.ch-grid { stroke: var(--line); stroke-width: 1; }
.ch-tick { fill: var(--muted); font-size: 11px; font-family: var(--f-sans); }
.ch-line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.ch-line.a { stroke: var(--olive-2); }
.ch-line.b { stroke: var(--muted); stroke-dasharray: 5 4; stroke-width: 2; }
.ch-dot { fill: transparent; stroke: none; }
.ch-dot:hover { fill: var(--sun); }
.ch-bar { fill: var(--olive-2); }
.ch-bar:hover { fill: var(--sun); }
.ch-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: 6px; }
.ch-legend i { display: inline-block; width: 18px; height: 3px; vertical-align: middle; margin-right: 6px; background: var(--olive-2); }
.ch-legend .b i { background: repeating-linear-gradient(90deg, var(--muted) 0 5px, transparent 5px 9px); }
.funnel { display: grid; gap: 10px; margin-top: 8px; }
.funnel-row { display: grid; grid-template-columns: minmax(0, 9rem) minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.funnel-row small { grid-column: 2 / -1; color: var(--muted); font-size: .75rem; margin-top: -4px; }
.funnel-row small:empty { display: none; }
.funnel-bar { height: 12px; background: var(--sand-2); border-radius: 999px; overflow: hidden; }
.funnel-bar i { display: block; height: 100%; background: var(--olive-2); border-radius: 999px; }
.section { margin-top: 26px; }
.section > h2 { font-size: 1.1rem; }
.actions-inline { display: flex; gap: 6px; flex-wrap: wrap; }
.actions-inline form { margin: 0; }
iframe.mail { width: 100%; height: 520px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--olive-deep); }
.login .card { width: 100%; max-width: 400px; }

/* ---------- Scanner ---------- */
body.scan { background: #0f1708; color: var(--white); min-height: 100vh; }
.scan-top { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; gap: 8px; background: var(--olive-deep); flex-wrap: wrap; }
.scan-top select, .scan-top input { min-height: 38px; width: auto; padding: 6px 10px; }
.scan-stats { display: flex; gap: 14px; font-weight: 800; font-size: .95rem; }
.scan-stats b { color: var(--sun-2); font-variant-numeric: tabular-nums; }
.scan-main { max-width: 560px; margin: 0 auto; padding: 14px 16px 40px; }
.video-box { position: relative; aspect-ratio: 1; background: #000; border-radius: 22px; overflow: hidden; }
.video-box video { width: 100%; height: 100%; object-fit: cover; }
.video-box .frame { position: absolute; inset: 18%; border: 4px solid rgba(255, 200, 107, .9); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); }
.video-box .msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; color: var(--white); }
.mode { display: flex; background: rgba(255, 255, 255, .08); border-radius: 999px; padding: 4px; margin: 12px 0; }
.mode button { flex: 1; min-height: 40px; border: 0; border-radius: 999px; background: transparent; color: var(--white); font: inherit; font-weight: 800; cursor: pointer; }
.mode button.on { background: var(--sun); color: var(--olive-deep); }
.manual { display: flex; gap: 8px; margin-top: 12px; }
.manual input { text-transform: uppercase; font-family: ui-monospace, Consolas, monospace; letter-spacing: .1em; }
.result { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 10px; }
.result.ok { background: #1F7A3A; }
.result.valid { background: #1E6FA8; }
.result.warn { background: #C77700; }
.result.bad { background: #B3261E; }
.result h2 { font-size: clamp(2.4rem, 12vw, 4.5rem); margin: 0; font-weight: 800; }
.result .who { font-size: 1.6rem; font-weight: 800; }
.result .dni { font-size: 1.3rem; font-family: ui-monospace, Consolas, monospace; background: rgba(0, 0, 0, .2); padding: 6px 14px; border-radius: 10px; }
.result .btn { margin-top: 18px; min-width: 220px; background: var(--white); }
.recent { margin-top: 18px; font-size: .85rem; }
.recent li { padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, .08); list-style: none; display: flex; justify-content: space-between; gap: 8px; }
.recent ul { padding: 0; margin: 0; }

@media print {
  .topbar, footer.site, .no-print, .ticket-actions, .timer { display: none !important; }
  body { background: #fff; }
  .ticket { box-shadow: none; border: 1px solid #ccc; margin-bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Mis entradas: QR en vivo ---------- */
/* El borde gira siempre: en la puerta, un QR con el borde quieto es una captura de pantalla. */
.qr-live { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.qr-live .qr { width: 236px; height: 236px; padding: 6px; border-radius: 14px; background: conic-gradient(from var(--qr-turn, 0deg), var(--sun), var(--olive-2), var(--sun)); animation: qr-turn 3s linear infinite; position: relative; overflow: hidden; }
/* Banda de brillo que cruza el QR en vivo (como SafeTix): una captura queda quieta, la entrada real se mueve. */
.qr-live .qr::after { content: ''; position: absolute; inset: 6px; border-radius: 10px; pointer-events: none; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .55) 50%, transparent 65%); transform: translateX(-100%); animation: qr-shine 2.4s ease-in-out infinite; }
@keyframes qr-shine { 60%, 100% { transform: translateX(100%); } }
.qr-renew { font-size: .82rem; font-variant-numeric: tabular-nums; }
.qr-live .qr svg { width: 100%; height: 100%; display: block; border-radius: 10px; }
@property --qr-turn { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@keyframes qr-turn { to { --qr-turn: 360deg; } }
@media (prefers-reduced-motion: reduce) { .qr-live .qr, .qr-live .qr::after { animation-duration: 12s; } }
.qr-live-note { display: flex; flex-direction: column; gap: 6px; text-align: center; max-width: 220px; padding: 18px; border: 2px dashed var(--line); border-radius: 14px; }
.code-input { font-size: 1.8rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }

/* Barra (cashless) */
.bar-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.bar-product { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; padding: 14px; min-height: 76px; border-radius: 16px; border: 0; background: var(--olive-deep); color: var(--white); font: inherit; text-align: left; cursor: pointer; }
.bar-product:active { transform: scale(.98); }
.bar-product span { color: var(--sun-2); font-weight: 800; }
.bar-cart { background: rgba(255, 255, 255, .06); border-radius: 16px; padding: 14px; }
.bar-cart ul { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.wallet-card .balance { font-size: 2rem; font-weight: 800; }

/* Artistas y line up del panel */
.artist-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; display: block; }
.lineup-edit td { padding: 6px 8px; }
.lineup-edit input:not([type=checkbox]), .lineup-edit select { min-height: 44px; padding: 6px 10px; }
.lineup-edit .check { min-width: 44px; min-height: 44px; align-items: center; justify-content: center; }
.lineup-edit input[type=datetime-local] { min-width: 190px; }
.lineup-edit select { min-width: 13em; }
.lineup-edit input[name^=la_sort] { width: 5em; }
.lineup-edit input[name^=la_stage] { min-width: 9em; }
/* Vista previa de los colores de la fecha */
.palette-preview { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 4px; padding: 22px; border-radius: 6px; background: var(--pv-bg); color: var(--pv-text); }
.palette-preview b { font-size: 1.4rem; letter-spacing: -.02em; text-transform: uppercase; }
.palette-preview span { background: var(--pv-accent); color: var(--pv-ink); padding: 10px 18px; border-radius: 4px; font-weight: 700; }
/* Mi seguridad: QR para la app de códigos */
.narrow-card { max-width: 560px; }
.totp-qr { width: 200px; padding: 10px; margin: 8px 0 4px; background: #fff; border-radius: 8px; }
.totp-qr svg { display: block; width: 100%; height: auto; }

/* Utilidades de espaciado para las vistas (en lugar de estilos en línea). Llevan !important porque ajustan un
   caso puntual y tienen que ganarle al margen propio del componente (.alert, .card, .section-title…). */
.mt-s { margin-top: 10px !important; }
.mt { margin-top: 16px !important; }
.mt-l { margin-top: 24px !important; }
.mt0 { margin-top: 0 !important; }
.m0 { margin: 0 !important; }
.mb { margin-bottom: 16px !important; }
.my-s { margin-top: 12px !important; margin-bottom: 8px !important; }
.pb-page { padding-bottom: 80px; }
.t-center { text-align: center; }
.grow-input { flex: 1 1 190px; width: auto; }
