:root {
  --blue: #1D4BB8;
  --blue-dark: #163A92;
  --navy: #0F1F4F;
  --yellow: #FFFF55;
  --yellow-soft: #FFFFCC;
  --bg: #EEF2FA;
  --card: #FFFFFF;
  --line: #E1E6F0;
  --muted: #4A5068;
  --danger: #B42318;
  --ok: #1F7A45;
  --radius: 14px;
  --head: 'Archivo', system-ui, sans-serif;
  --body: 'Inter', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--body); color: var(--navy); background: var(--bg); font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); }
a:hover { color: var(--navy); }
h1, h2, h3 { font-family: var(--head); font-weight: 800; margin: 0; line-height: 1.15; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.brand { font-family: var(--head); font-style: italic; font-weight: 900; letter-spacing: 0.2px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; box-shadow: 0 0 0 5px var(--blue); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1.5px solid var(--blue); background: #fff; color: var(--blue); font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #F2F5FC; color: var(--blue); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: var(--yellow); border-color: var(--blue); font-weight: 700; }
.btn-primary:hover { background: var(--blue-dark); color: var(--yellow); }
.btn-yellow { background: var(--yellow); color: var(--navy); border-color: var(--yellow); font-weight: 700; }
.btn-yellow:hover { background: #F5F53C; color: var(--navy); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #FDECEA; color: var(--danger); }
.btn-big { min-height: 54px; font-family: var(--head); font-style: italic; font-weight: 800; font-size: 18px; letter-spacing: 0.3px; text-transform: uppercase; width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-link { background: none; border: 0; color: var(--blue); font: inherit; font-weight: 600; cursor: pointer; padding: 0; text-decoration: underline; min-height: 0; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 0; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; background: var(--yellow); color: var(--navy); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 14px; font-weight: 600; }
.input, select.input, textarea.input { width: 100%; min-height: 46px; border: 1.5px solid #8A90A6; border-radius: 10px; padding: 0 12px; font: inherit; font-size: 16px; background: #fff; color: var(--navy); }
textarea.input { padding: 10px 12px; min-height: 90px; resize: vertical; }
.input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(29, 75, 184, 0.2); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.4; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--blue); flex-shrink: 0; }
.form { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.hint { font-size: 12px; color: var(--muted); }
.error-box { background: #FDECEA; color: var(--danger); border-radius: 10px; padding: 10px 12px; font-size: 14px; font-weight: 600; }
.info-box { display: flex; gap: 10px; align-items: flex-start; background: var(--yellow-soft); border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.45; }
.notice { background: #fff; border: 2px dashed var(--blue); border-radius: var(--radius); padding: 14px 16px; font-size: 14px; }

/* ---------- Cards & badges ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.card-yellow { background: var(--yellow); border: 2.5px solid var(--blue); }
.card-blue { background: var(--blue); color: #fff; }
.card-blue h2, .card-blue h3 { color: var(--yellow); }
.card-blue .muted { color: #D5DEF5; }
.card-outline { border: 2px solid var(--blue); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; font-size: 11px; font-weight: 700; letter-spacing: 0.4px; border-radius: 6px; padding: 4px 7px; border: 1.5px solid var(--blue); color: var(--blue); background: #fff; text-transform: uppercase; white-space: nowrap; }
.badge-blue { background: var(--blue); color: var(--yellow); }
.badge-yellow { background: var(--yellow); color: var(--navy); }
.badge-grey { border-color: #8A90A6; color: var(--muted); }
.badge-green { border-color: var(--ok); color: var(--ok); }
.pill { border-radius: 999px; padding: 4px 10px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.list-row:first-of-type { border-top: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.pts { font-family: var(--head); font-weight: 800; font-size: 16px; white-space: nowrap; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }
.big-num { font-family: var(--head); font-weight: 800; font-size: 30px; line-height: 1.1; }

/* ---------- Player layout ---------- */
.player { max-width: 520px; margin: 0 auto; min-height: 100vh; background: var(--bg); position: relative; }
.p-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; background: var(--blue); color: #fff; position: sticky; top: 0; z-index: 10; }
.p-header .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.p-header img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.p-header .hello { font-size: 13px; color: #D5DEF5; }
.p-header .name { font-family: var(--head); font-weight: 800; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-main { display: flex; flex-direction: column; gap: 16px; padding: 18px 16px 100px; }
.p-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: var(--blue); }
.p-nav-inner { max-width: 520px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); height: 70px; padding-bottom: env(safe-area-inset-bottom); }
.p-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: #fff; text-decoration: none; font-size: 12px; }
.p-nav a[aria-current="page"] { color: var(--yellow); font-weight: 700; }
.p-nav svg { width: 22px; height: 22px; }

.ring-wrap { position: relative; width: 180px; height: 180px; margin: 0 auto; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-center .n { font-family: var(--head); font-weight: 900; font-size: 52px; line-height: 1; }

.auth-hero { background: var(--yellow); padding: 28px 24px 30px; display: flex; flex-direction: column; align-items: center; gap: 12px; border-bottom: 3px solid var(--blue); text-align: center; }
.auth-hero img { width: 108px; height: 108px; border-radius: 50%; object-fit: cover; }
.auth-hero h1 { font-family: var(--head); font-style: italic; font-weight: 900; font-size: 30px; color: var(--navy); }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { border: 2px solid var(--blue); border-radius: 12px; padding: 10px 6px; text-align: center; background: #fff; }
.tile .n { font-family: var(--head); font-weight: 800; font-size: 22px; }
.tile .l { font-size: 12px; color: var(--muted); line-height: 1.3; }
.tile.on { background: var(--blue); color: var(--yellow); }
.tile.on .l { color: #fff; }

.qr-box { background: #fff; border-radius: 12px; padding: 10px; display: inline-flex; }
.qr-box svg { display: block; width: 200px; height: 200px; }
.code-text { font-family: var(--head); font-weight: 800; font-size: 22px; letter-spacing: 3px; }
.voucher { border: 2.5px solid var(--blue); border-radius: 18px; overflow: hidden; background: #fff; }
.voucher-top { background: var(--yellow); padding: 16px 18px; border-bottom: 2.5px dashed var(--blue); }
.voucher-body { padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }

/* ---------- Admin layout ---------- */
.admin { display: flex; min-height: 100vh; }
.a-side { width: 240px; flex-shrink: 0; background: var(--blue); color: #fff; padding: 22px 14px; display: flex; flex-direction: column; gap: 4px; }
.a-side .logo { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.a-side .logo img { width: 40px; height: 40px; border-radius: 50%; }
.a-side a { padding: 11px 12px; border-radius: 10px; color: #fff; text-decoration: none; font-size: 14px; }
.a-side a:hover { background: var(--blue-dark); color: #fff; }
.a-side a[aria-current="page"] { background: var(--yellow); color: var(--navy); font-weight: 700; }
.a-side .spacer { flex: 1; }
.a-main { flex: 1; min-width: 0; padding: 26px 30px 60px; display: flex; flex-direction: column; gap: 20px; max-width: 1200px; }
.a-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi { background: #fff; border-radius: var(--radius); padding: 16px 18px; }
.kpi .l { font-size: 13px; color: var(--muted); }
.kpi.hl { background: var(--yellow); border: 2px solid var(--blue); }
.cols { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.cols > * { flex: 1 1 360px; min-width: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 8px; white-space: nowrap; }
td { padding: 11px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #F5F7FC; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--blue); color: #fff; border-radius: 999px; padding: 5px 5px 5px 12px; font-size: 13px; font-weight: 600; }
.chip button { width: 28px; height: 28px; border-radius: 50%; border: 0; background: var(--blue-dark); color: #fff; cursor: pointer; font-size: 16px; line-height: 1; }
.search-wrap { position: relative; }
.results { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; background: #fff; border: 1.5px solid var(--blue); border-radius: 10px; margin-top: 4px; max-height: 260px; overflow-y: auto; box-shadow: 0 8px 24px rgba(15, 31, 79, 0.15); }
.results button { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; background: #fff; font: inherit; cursor: pointer; border-top: 1px solid var(--line); }
.results button:first-child { border-top: 0; }
.results button:hover, .results button:focus { background: #F2F5FC; }
.period-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--yellow); border-radius: 10px; padding: 12px 14px; }
.bar { height: 12px; background: var(--line); border-radius: 6px; overflow: hidden; }
.bar > div { height: 100%; background: var(--blue); border-radius: 6px; }
.tabs-mobile { display: none; }

@media (max-width: 860px) {
  .admin { flex-direction: column; }
  .a-side { width: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px; gap: 6px; position: sticky; top: 0; z-index: 10; }
  .a-side .logo { padding: 0 6px 0 0; }
  .a-side .logo .brand-text, .a-side .spacer { display: none; }
  .a-side a { white-space: nowrap; padding: 9px 11px; }
  .a-main { padding: 18px 14px 50px; }
}

/* ---------- Modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 31, 79, 0.55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; padding: 0; }
.modal { background: #fff; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
@media (min-width: 700px) { .modal-bg { align-items: center; padding: 20px; } .modal { border-radius: 18px; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.close-btn { width: 44px; height: 44px; border-radius: 10px; border: 0; background: var(--bg); cursor: pointer; font-size: 22px; color: var(--navy); }
.scanner video { width: 100%; border-radius: 12px; background: #000; aspect-ratio: 1 / 1; object-fit: cover; }
.toast-wrap { position: fixed; left: 0; right: 0; bottom: 84px; z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast { background: var(--navy); color: #fff; border-radius: 12px; padding: 12px 16px; font-size: 14px; font-weight: 600; max-width: 480px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); pointer-events: auto; }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.table-wrap table { min-width: 600px; }
