/* MELO TICKETS · estilos compartidos. Mobile-first: la base es el celular, los @media (min-width) amplían. */
:root {
  /* Paleta Oficial */
  --coffee: #1E1014;          /* Color dark */
  --ivory: #FBFFF1;           /* Color light */
  --orchid: #802392;          /* Color principal de marca */
  --cta: #0DE756;             /* Color CTA / Énfasis */
  --wisteria: #B4A0E5;        /* Color contraste secundario */

  /* Mapeo semántico de tokens */
  --morado: var(--orchid);
  --morado-2: #6A1A7B;
  --oro: var(--cta);
  --jade: var(--cta);
  --champana: var(--wisteria);
  --marfil: var(--ivory);
  --negro: var(--coffee);
  --linea: #E4DFEC;
  --ok: #087A2D;
  --ok-bg: #E7FAEE;
  --warn: #9E5D00;
  --warn-bg: #FCF4E4;
  --bad: #B52336;
  --bad-bg: #FCE8EB;
  --info: var(--orchid);
  --info-bg: #F4EBF7;
  --muted: #6C5E78;
  --serif: 'Bebas Neue', 'Montserrat', sans-serif;
  --title: var(--serif);
  --sans: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --nav-h: 64px;
  --shadow: 0 1px 3px rgba(30, 16, 20, .06), 0 6px 18px rgba(128, 35, 146, .08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-family: var(--sans); font-size: 16px; line-height: 1.5; color: var(--negro); background: var(--marfil); overflow-wrap: break-word; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; letter-spacing: .04em; margin: 0 0 .4em; line-height: 1.05; color: var(--morado); }
h1 { font-size: 34px; } h2 { font-size: 28px; } h3 { font-size: 22px; }
a { color: var(--morado-2); }
button, input, select, textarea { font: inherit; color: inherit; }
button, .btn, a.btn, select, summary, [role=button] { touch-action: manipulation; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px 12px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; }
.stack > * + * { margin-top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--morado); background: var(--morado); color: var(--marfil); font-weight: 600; cursor: pointer; text-decoration: none; transition: transform .08s ease, background .15s ease, box-shadow .15s ease; }
.btn:hover { background: #6b1b7b; border-color: #6b1b7b; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.gold, .btn.jade, .btn.cta { background: var(--cta); border-color: var(--cta); color: var(--coffee); font-weight: 700; }
.btn.gold:hover, .btn.jade:hover, .btn.cta:hover { background: #0bd14e; border-color: #0bd14e; }
.btn.ghost { background: transparent; color: var(--morado); border-color: transparent; }
.btn.ghost:hover { background: var(--info-bg); }
.btn.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.sm { min-height: 44px; padding: 6px 14px; font-size: 14px; }
.btn.block { width: 100%; min-height: 52px; font-size: 17px; }
/* grupos de botones: en celular ocupan todo el ancho para pulgares */
.btn-stack { display: flex; flex-direction: column; gap: 10px; }
.btn-stack .btn { width: 100%; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-grid .btn { width: 100%; padding-inline: 10px; text-align: center; }

/* formularios (16px evita el zoom automático de iOS al enfocar) */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--morado); }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid #D5CEE0; border-radius: 12px; background: #fff; font-size: 16px; color: var(--negro);
}
input[type=file] { width: 100%; font-size: 14px; padding: 10px; border: 1px dashed #D5CEE0; border-radius: 12px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--morado); box-shadow: 0 0 0 3px rgba(128, 35, 146, .22); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid rgba(128, 35, 146, .45); outline-offset: 2px; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; padding: 10px 0; min-height: 44px; }
.check input { width: 24px; height: 24px; margin-top: 0; flex: 0 0 auto; accent-color: var(--morado); }
.error-msg { color: var(--bad); font-size: 14px; min-height: 20px; }
.error-msg:not(:empty) { background: var(--bad-bg); padding: 10px 12px; border-radius: 10px; font-weight: 600; }

/* tarjetas */
.card { background: #fff; border: 1px solid var(--linea); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); }
.card.dark { background: linear-gradient(135deg, var(--coffee) 0%, #341628 100%); color: var(--marfil); border-color: rgba(180, 160, 229, .25); }
.card.dark h2, .card.dark h3 { color: var(--wisteria); }
.card + .card, .card + .table-wrap, .table-wrap + .card { margin-top: 14px; }
.kpis > .card { margin-top: 0; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { padding: 14px; }
.kpi .v { font-family: var(--serif); font-size: 34px; font-weight: 400; letter-spacing: .02em; line-height: 1; color: var(--morado); overflow-wrap: anywhere; }
.kpi .l { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 8px; line-height: 1.3; }
.kpi[role=button]:active { background: var(--info-bg); }
.bar { height: 12px; background: #E8E3EE; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--morado); border-radius: 99px; }
.bar.full > i { background: var(--bad); }
.bar.high > i { background: var(--jade); }
.cap { margin-bottom: 16px; }
.cap:last-child { margin-bottom: 0; }
.cap .row { justify-content: space-between; margin-bottom: 6px; font-size: 14px; }
.grid-auto { display: grid; gap: 18px; grid-template-columns: 1fr; }

/* etiquetas */
.pill { display: inline-block; padding: 3px 11px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.sin_vender { background: #ECE6F3; color: #4B3F57; }
.pill.registrada { background: var(--warn-bg); color: var(--warn); }
.pill.activa { background: var(--info-bg); color: var(--info); }
.pill.ingresada { background: var(--ok-bg); color: var(--ok); }
.pill.anulada { background: var(--bad-bg); color: var(--bad); }
.cat { display: inline-block; padding: 3px 10px; border-radius: 6px; font-size: 12px; font-weight: 700; letter-spacing: .06em; color: #fff; }
.cat.GENERAL { background: #922B40; } .cat.VIP { background: var(--jade); color: var(--coffee); } .cat.ICONIK { background: var(--morado); color: #fff; }

/* tablas: en celular cada fila se convierte en una tarjeta (los <td> llevan data-label) */
.table-wrap { overflow-x: auto; border: 1px solid var(--linea); border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); background: #F4EFF9; padding: 10px 12px; white-space: nowrap; }
td { padding: 10px 12px; border-top: 1px solid var(--linea); vertical-align: middle; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #FAF7FD; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 719px) {
  .table-wrap.rt { border: 0; background: transparent; box-shadow: none; overflow: visible; border-radius: 0; }
  .rt table, .rt tbody { display: block; }
  .rt thead { display: none; }
  .rt tr { display: block; background: #fff; border: 1px solid var(--linea); border-radius: 14px; padding: 6px 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
  .card .rt tr { box-shadow: none; background: var(--marfil); }
  .rt tr.click:active { background: var(--info-bg); }
  .rt td { display: flex; justify-content: space-between; align-items: center; gap: 14px; border: 0; padding: 7px 0; text-align: right; min-height: 36px; }
  .rt td + td { border-top: 1px dashed var(--linea); }
  .rt td::before { content: attr(data-label); flex: 0 0 auto; max-width: 45%; text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .rt td[data-label=""]::before { display: none; }
  .rt td[data-label=""] { justify-content: flex-start; font-size: 16px; }
  .rt td.hide-sm { display: flex; }
  .rt td:empty { display: none; }
  .rt td input, .rt td select { max-width: 55%; text-align: right; }
  /* lista de puntos: nombre arriba y 3 cifras clave en fila */
  .rt.pts tr { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 8px; padding: 14px; }
  .rt.pts td { display: flex; flex-direction: column-reverse; align-items: flex-start; justify-content: flex-end; gap: 2px; border: 0; padding: 0; text-align: left; min-height: 0; font-size: 17px; font-variant-numeric: tabular-nums; }
  .rt.pts td + td { border: 0; }
  .rt.pts td::before { max-width: none; }
  .rt.pts td:nth-child(1)::before { display: none; }
  .rt.pts td:nth-child(1) { grid-column: 1 / -1; font-size: 18px; margin-bottom: 4px; }
  .rt.pts td:nth-child(2), .rt.pts td:nth-child(5), .rt.pts td:nth-child(6), .rt.pts td:nth-child(7) { display: none; }
  .rt.pts td:nth-child(8) { align-items: flex-end; text-align: right; }
  /* lista de boletas: tarjeta compacta (serie + estado / comprador + valor / categoría + punto) */
  .rt.compact tr { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "a b" "d e" "c f"; gap: 2px 12px; align-items: center; padding: 12px 14px; }
  .rt.compact td { display: block; border: 0; padding: 0; min-height: 0; text-align: left; }
  .rt.compact td::before { display: none; }
  .rt.compact td + td { border: 0; }
  .rt.compact td:nth-child(1) { grid-area: a; font-size: 17px; }
  .rt.compact td:nth-child(2) { grid-area: c; padding-top: 6px; }
  .rt.compact td:nth-child(3) { grid-area: b; text-align: right; }
  .rt.compact td:nth-child(4) { grid-area: d; padding-top: 4px; font-weight: 500; }
  .rt.compact td:nth-child(5) { grid-area: f; padding-top: 6px; text-align: right; font-size: 13px; color: var(--muted); }
  .rt.compact td:nth-child(6) { grid-area: e; text-align: right; padding-top: 4px; font-weight: 600; }
}

/* cabecera */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--coffee); color: var(--marfil); padding: calc(8px + var(--safe-t)) 14px 8px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(180, 160, 229, .15); }
.topbar .brand { display: inline-flex; align-items: center; gap: 8px; font-family: var(--serif); font-size: 24px; font-weight: 700; letter-spacing: .14em; color: var(--jade); line-height: 1; }
.topbar .brand img.nav-logo { height: 32px; width: auto; max-width: 120px; object-fit: contain; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); display: block; }
.topbar .brand small { font-family: var(--sans); font-size: 10px; letter-spacing: .4em; color: var(--wisteria); margin-left: 8px; }
.topbar .who { margin-left: auto; font-size: 13px; color: var(--wisteria); display: flex; gap: 4px; align-items: center; min-width: 0; }
.topbar .who #who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw; }
.topbar .who a, .topbar button.link { background: none; border: 0; color: var(--wisteria); text-decoration: none; cursor: pointer; padding: 8px 10px; min-height: 44px; display: inline-flex; align-items: center; font-weight: 600; border-radius: 10px; }
.topbar .who a:active, .topbar button.link:active { background: rgba(180, 160, 229, .16); }

/* navegación: barra inferior fija en celular (alcance del pulgar), pestañas arriba en pantallas grandes */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; background: #fff; border-top: 1px solid var(--linea); box-shadow: 0 -4px 18px rgba(30, 16, 20, .08); padding-bottom: var(--safe-b); }
.tabs button { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: var(--nav-h); padding: 8px 2px; background: transparent; border: 0; color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; position: relative; }
.tabs button svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-current=page] { color: var(--morado); }
.tabs button[aria-current=page]::before { content: ''; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 4px 4px; background: var(--jade); }
.tabs button:active { background: var(--info-bg); }
.badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 20px; padding: 1px 6px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 12px; line-height: 1.4; text-align: center; font-weight: 700; }
main.wrap { max-width: 1100px; margin: 0 auto; padding: 16px 14px calc(var(--nav-h) + var(--safe-b) + 28px); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: end; }
.toolbar .field { margin: 0; flex: 1 1 calc(50% - 10px); min-width: 0; }
.toolbar .field.grow, .toolbar.one-col .field { flex-basis: 100%; }
.toolbar .btn { flex: 1 1 100%; }
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.page-head h2 { margin: 0; flex: 1 1 auto; min-width: 0; }

/* modal: hoja inferior (bottom sheet) en celular */
.overlay { position: fixed; inset: 0; background: rgba(30, 16, 20, .65); display: flex; align-items: flex-end; justify-content: center; z-index: 50; animation: fade .15s ease; backdrop-filter: blur(2px); }
.modal { background: var(--marfil); border-radius: 22px 22px 0 0; width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain; padding: 22px 18px 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .35); animation: sheet .22s ease; }
.modal::before { content: ''; display: block; width: 44px; height: 5px; border-radius: 9px; background: #D5CEE0; margin: -10px auto 14px; }
.modal h2 { font-size: 24px; }
.modal .actions { position: sticky; bottom: 0; display: flex; flex-direction: column-reverse; gap: 10px; margin: 16px -18px 0; padding: 12px 18px calc(12px + var(--safe-b)); background: var(--marfil); border-top: 1px solid var(--linea); }
.modal .actions .btn { width: 100%; }
.toast { position: fixed; left: 50%; top: calc(var(--safe-t) + 70px); transform: translateX(-50%); background: var(--negro); color: var(--marfil); border: 1px solid rgba(180, 160, 229, .25); padding: 13px 20px; border-radius: 12px; z-index: 80; max-width: 92vw; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); animation: fade .15s ease; }
.toast.bad { background: var(--bad); color: #fff; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; font-size: 14px; margin: 0; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.timeline li { padding: 8px 0; border-top: 1px solid var(--linea); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Corrección de datos tras el registro */
details.edit { margin-top: 4px; }
details.edit summary { cursor: pointer; padding: 12px 0; font-weight: 600; color: var(--morado); min-height: 48px; display: flex; align-items: center; }
details.edit[open] summary { margin-bottom: 8px; }

/* ---------- tablet / escritorio ---------- */
@media (min-width: 720px) {
  body { font-size: 15px; }
  h1 { font-size: 34px; }
  .btn { min-height: 44px; }
  .btn.sm { min-height: 36px; }
  .btn.block { min-height: 48px; font-size: 16px; }
  .btn-stack { flex-direction: row; flex-wrap: wrap; }
  .btn-stack .btn { width: auto; }
  .btn-grid { display: flex; flex-wrap: wrap; }
  .btn-grid .btn { width: auto; }
  input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea { min-height: 44px; font-size: 15px; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
  .kpi .v { font-size: 34px; }
  .grid-auto { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
  .topbar { padding: 10px 20px; }
  .topbar .who #who { max-width: none; }
  .tabs { position: static; bottom: auto; box-shadow: none; border: 0; background: var(--coffee); padding: 8px 16px 0; gap: 4px; overflow-x: auto; }
  .tabs button { flex: 0 0 auto; flex-direction: row; gap: 8px; min-height: 44px; padding: 10px 18px; color: var(--wisteria); font-size: 15px; border-radius: 10px 10px 0 0; }
  .tabs button svg { display: none; }
  .tabs button[aria-current=page] { background: var(--marfil); color: var(--morado); font-weight: 700; }
  .tabs button[aria-current=page]::before { display: none; }
  .badge { position: static; background: var(--jade); color: var(--coffee); font-weight: 700; }
  main.wrap { padding: 22px 20px 60px; }
  .toolbar .field { flex: 0 1 auto; min-width: 150px; }
  .toolbar .field.grow { flex: 1 1 220px; }
  .toolbar.one-col .field { flex: 0 1 auto; }
  .toolbar .btn { flex: 0 0 auto; }
  .overlay { align-items: flex-start; padding: 24px 12px; overflow-y: auto; }
  .modal { border-radius: 16px; padding: 22px; max-height: none; box-shadow: 0 20px 60px rgba(0, 0, 0, .4); }
  .modal::before { display: none; }
  .modal .actions { position: static; flex-direction: row; flex-wrap: wrap; justify-content: flex-end; margin: 16px 0 0; padding: 0; border: 0; background: none; }
  .modal .actions .btn { width: auto; }
  .toast { top: auto; bottom: 24px; }
}

/* enlaces de teléfono / WhatsApp: área táctil cómoda */
a.tel { display: inline-flex; align-items: center; min-height: 44px; }
/* pantallas táctiles (también tablets grandes): botones pequeños siguen siendo tocables */
@media (pointer: coarse) { .btn.sm { min-height: 44px; } }
/* etiquetas de la barra inferior: sin desbordes en celulares muy angostos */
.tabs button span:not([aria-hidden]) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* resumen por categoría: en celular, nombre arriba y cifras en cuadrícula de 2 columnas */
@media (max-width: 719px) {
  .rt.stats tr { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; padding: 14px; }
  .rt.stats td { display: flex; flex-direction: column-reverse; align-items: flex-start; justify-content: flex-end; gap: 2px; border: 0; padding: 6px 0; text-align: left; min-height: 0; font-size: 22px; font-variant-numeric: tabular-nums; }
  .rt.stats td + td { border: 0; }
  .rt.stats td::before { max-width: none; }
  .rt.stats td:nth-child(1) { grid-column: 1 / -1; flex-direction: row; justify-content: flex-start; padding-bottom: 4px; font-size: 16px; }
  .rt.stats td:nth-child(1)::before { display: none; }
}

/* celulares en horizontal (poca altura): barra inferior más baja, con icono y texto lado a lado */
@media (max-height: 480px) and (orientation: landscape) and (max-width: 719px) {
  :root { --nav-h: 52px; }
  .tabs button { flex-direction: row; gap: 8px; padding-block: 4px; }
  .modal { max-height: 96dvh; }
}

/* filas y tarjetas accionables: foco visible para teclado */
tr.click:focus-visible { outline: 3px solid var(--morado); outline-offset: -3px; }
tr.click:focus-visible td { background: var(--info-bg); }
.kpi[role=button]:focus-visible { outline: 3px solid var(--morado); outline-offset: 2px; }
