/* Whistlepath · componentes compartidos
   Requiere tokens.css. Sin build, sin framework. Clases en inglés, textos en español.
   Índice: base · layout · cabecera · pie · tipografía · botones · formularios · paneles ·
   KPI · tablas · chips · estados · avisos · gráficas · mapa · varios */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 16px/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }
img, svg { max-width: 100%; }
a { color: var(--fg); text-decoration-color: var(--muted); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
p { margin: 0; }
ul, ol { margin: 0; padding-left: 1.2em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.num, .kpi-value, td.n, th.n { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.wrap-narrow { max-width: 760px; }
.wrap-form { max-width: 440px; }
main { flex: 1; padding-block: 24px 48px; }
.stack { display: grid; gap: 16px; align-content: start; min-width: 0; }
.stack > * { min-width: 0; }
.stack-lg { display: grid; gap: 28px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid-2-even { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 860px) {
  .grid-2, .grid-2-even, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 640px) { :root { --gutter: 24px; } }

/* ---------- Cabecera ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-row { display: flex; align-items: center; gap: 12px 24px; min-height: 56px; flex-wrap: wrap; padding-block: 8px; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--fg); text-decoration: none; flex: none; }
.brand svg { width: 28px; height: 28px; flex: none; }
.wordmark { font: 700 24px/1 var(--display); letter-spacing: -.015em; }
.wordmark span { font-weight: 500; opacity: .6; }
.nav { display: flex; gap: 2px; flex: 1; min-width: 0; }
.nav a {
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: 15px;
  padding: 6px 10px; border-radius: var(--radius); white-space: nowrap;
}
.nav a:hover { color: var(--fg); background: var(--sunk); }
.nav a[aria-current="page"] { color: var(--fg); background: var(--sunk); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; color: var(--fg); text-decoration: none; font-weight: 500; font-size: 15px; }
@media (max-width: 720px) {
  .topbar-row { gap: 8px 12px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; margin-inline: calc(var(--gutter) * -1); padding-inline: calc(var(--gutter) - 10px); scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .user-chip .user-name { display: none; }
}
@media (max-width: 420px) { .hide-sm { display: none !important; } }

/* ---------- Pie ---------- */
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; padding-block: 24px 32px; }
.footer-row { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; justify-content: space-between; }
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 16px; list-style: none; padding: 0; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--fg); }

/* ---------- Tipografía ---------- */
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; line-height: 1.12; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(30px, 5vw, 40px); }
h2 { font-size: 24px; }
h3 { font-size: 19px; }
h4 { font-size: 17px; }
.lead { font-size: 18px; line-height: 1.5; max-width: 60ch; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.xsmall { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.prose { max-width: 65ch; display: grid; gap: 12px; }
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 24px; margin-bottom: 20px; }
.page-head > div { display: grid; gap: 4px; min-width: 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.back-link { display: inline-block; margin-bottom: 12px; font-size: 14px; color: var(--muted); text-decoration: none; }
.back-link:hover { color: var(--fg); text-decoration: underline; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 15px/1 var(--body); padding: 11px 16px; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--accent-ink); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent); }
.btn-secondary { background: var(--surface); color: var(--fg); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--sunk); }
.btn-ghost { background: transparent; color: var(--fg); padding-inline: 10px; }
.btn-ghost:hover { background: var(--sunk); }
.btn-danger { background: var(--surface); color: var(--bad); border-color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); }
.btn-sm { padding: 8px 12px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--fg); text-decoration: underline; cursor: pointer; }

/* ---------- Formularios ---------- */
form { margin: 0; }
.form { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > label, .label { font-weight: 600; font-size: 15px; }
.optional { font-weight: 400; color: var(--muted); }
.hint { font-size: 14px; color: var(--muted); }
.input, .select, .textarea,
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="datetime-local"], input[type="url"], input[type="search"], input[type="tel"],
select, textarea {
  width: 100%; min-width: 0; font: 400 16px/1.3 var(--body); color: var(--fg);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 10px 12px;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[aria-invalid="true"] { border-color: var(--bad); }
.field-error { color: var(--bad); font-size: 14px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; margin: 0; display: grid; gap: 16px; min-width: 0; background: var(--surface); }
legend { font: 600 18px/1.2 var(--display); padding-inline: 6px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--fg); flex: none; }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.score-input { display: grid; grid-template-columns: minmax(0, 1fr) 88px; gap: 8px; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 40px; }
.input-suffix span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.divider-text { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.divider-text::before, .divider-text::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }

/* Interruptor accesible: <label class="switch"><input type="checkbox" role="switch"> Texto</label> */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.switch:last-child { border-bottom: 0; }
.switch input {
  appearance: none; -webkit-appearance: none; width: 40px; height: 24px; border-radius: 12px; margin: 0;
  background: var(--line-strong); position: relative; flex: none; cursor: pointer;
}
.switch input::after { content: ""; position: absolute; width: 18px; height: 18px; top: 3px; left: 3px; border-radius: 50%; background: var(--surface); }
.switch input:checked { background: var(--fg); }
.switch input:checked::after { background: var(--bg); }
.switch input:checked::after { left: 19px; }
.switch-text { display: grid; gap: 2px; }

/* ---------- Paneles (solo para datos, nunca para prosa) ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; min-width: 0; display: grid; gap: 12px; align-content: start; }
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.panel-head h2 { font-size: 21px; }
.panel-head .hint { font-size: 14px; }
.panel-flush { padding: 0; overflow: hidden; }
details.panel > summary { cursor: pointer; font: 600 19px/1.2 var(--display); list-style-position: inside; }
details.panel[open] > summary { margin-bottom: 4px; }

/* ---------- KPI ---------- */
.kpis {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden;
}
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--surface); padding: 12px 14px; display: grid; gap: 2px; align-content: start; min-width: 0; }
.kpi-label { font-size: 14px; color: var(--muted); }
.kpi-value { font: 600 32px/1.05 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-note { font-size: 13px; color: var(--muted); }
.kpi-note a { color: inherit; }

/* ---------- Tablas ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
table.data { width: 100%; border-collapse: collapse; font-size: 15px; }
table.data th, table.data td { text-align: left; padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
table.data th { font-weight: 600; font-size: 14px; color: var(--muted); }
table.data td.n, table.data th.n { text-align: right; }
table.data tbody tr:hover td { background: var(--sunk); }
table.data a { color: var(--fg); text-decoration: none; font-weight: 500; }
table.data a:hover { text-decoration: underline; }
table.data td.wrap-cell { white-space: normal; min-width: 180px; }
table.data tfoot td { font-weight: 600; border-bottom: 0; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: 500 14px/1 var(--body); color: var(--fg); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 7px 12px; cursor: pointer; white-space: nowrap;
}
.chip:hover { background: var(--sunk); }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
a.chip { display: inline-block; text-decoration: none; }
.tag { display: inline-block; font-size: 13px; line-height: 1; padding: 4px 8px; border-radius: 999px; background: var(--sunk); color: var(--muted); white-space: nowrap; }

/* ---------- Estados de verificación (icono + texto, nunca solo color) ---------- */
.st { display: inline-flex; align-items: center; gap: 5px; font-size: 14px; font-weight: 500; white-space: nowrap; }
.st svg { width: 15px; height: 15px; flex: none; }
.st-ok { color: var(--ok); }
.st-bad { color: var(--bad); }
.st-na { color: var(--na); }
.st-icon-only { gap: 0; }
.verified-count { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-weight: 600; }
.verified-count svg { width: 18px; height: 18px; }

/* ---------- Avisos y estados vacíos ---------- */
.notice {
  display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-lg); padding: 12px 14px; font-size: 15px;
}
.notice > svg { width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--muted); }
.notice-body { flex: 1 1 220px; display: grid; gap: 2px; }
.notice-error { border-color: var(--bad); background: var(--bad-bg); }
.notice-error > svg { color: var(--bad); }
.empty { text-align: center; padding: 32px 16px; display: grid; gap: 8px; justify-items: center; }
.empty svg { width: 40px; height: 40px; color: var(--muted); }
.empty p { color: var(--muted); max-width: 46ch; }
.provisional { display: inline-block; font-size: 14px; font-weight: 600; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 2px 8px; }

/* ---------- Publicidad ---------- */
.ad-slot {
  border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); background: var(--sunk);
  min-height: 120px; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 14px; padding: 12px;
}
.ad-slot .ad-label { font-size: 12px; display: block; margin-bottom: 4px; }

/* ---------- Partido ---------- */
.match-meta { color: var(--muted); font-size: 15px; }
.teams { display: grid; gap: 4px; }
.team-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; font: 600 26px/1.2 var(--display); }
.team-line .score { font-variant-numeric: tabular-nums; font-size: 34px; }
.team-line.lose { color: var(--muted); font-weight: 500; }
.team-name { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.team-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crest {
  width: 28px; height: 28px; border-radius: 50%; flex: none; display: inline-grid; place-items: center;
  background: var(--sunk); border: 1px solid var(--line); color: var(--muted); font: 600 13px/1 var(--body); overflow: hidden;
}
.crest img { width: 100%; height: 100%; object-fit: contain; }
.crest-sm { width: 22px; height: 22px; font-size: 11px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px 20px; margin: 0; }
.facts div { display: grid; gap: 2px; min-width: 0; }
.facts dt { font-size: 14px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }
.list-rows { list-style: none; padding: 0; margin: 0; }
.list-rows > li { display: flex; align-items: center; gap: 10px; padding-block: 7px; border-bottom: 1px solid var(--line); min-width: 0; }
.list-rows > li:last-child { border-bottom: 0; }
.list-rows .grow { flex: 1; min-width: 0; }
.list-rows .count { font: 600 18px/1 var(--display); font-variant-numeric: tabular-nums; flex: none; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Gráficas (SVG plano) ---------- */
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--body); font-size: 12px; fill: var(--muted); }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis { stroke: var(--line-strong); stroke-width: 1; }
.chart .bar { fill: var(--chart-bar); }
.chart .bar-last { fill: var(--accent); }
.chart .line { fill: none; stroke: var(--fg); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--fg); }
.chart .dot-last { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .value-label { fill: var(--fg); font-weight: 600; }
.chart .hit { fill: transparent; }
.chart .hit:hover + .hover-band, .chart .hover-band { fill: transparent; }
.chart-caption { font-size: 14px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; color: var(--muted); }
.legend-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

.progress { height: 8px; background: var(--sunk); border-radius: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--fg); border-radius: 4px; }

/* Barra de fondo para listas con recuento */
.bar-row { position: relative; }
.bar-row .bar-bg { position: absolute; inset: 3px auto 3px 0; background: var(--sunk); border-radius: var(--radius); z-index: 0; }
.bar-row > *:not(.bar-bg) { position: relative; z-index: 1; }

/* Celda dividida masculino/femenino */
.sexsplit { display: flex; gap: 2px; height: 26px; border-radius: 3px; overflow: hidden; min-width: 36px; }
.sexsplit > span { display: grid; place-items: center; font: 600 12px/1 var(--body); font-variant-numeric: tabular-nums; min-width: 14px; }
.sexsplit .m { background: var(--sex-m); color: var(--on-sex-m); }
.sexsplit .f { background: var(--sex-f); color: var(--on-sex-f); }
.sexsplit .x { background: var(--line-strong); color: var(--fg); }
.sexsplit .zero { background: var(--sunk); color: var(--muted); font-weight: 400; flex: 1; }

/* Mapa de calor categoría × competición */
table.heat { border-collapse: separate; border-spacing: 3px; font-size: 13px; }
table.heat th { font-weight: 500; color: var(--muted); white-space: nowrap; padding: 0 4px; }
table.heat thead th { font-size: 12px; text-align: center; vertical-align: bottom; max-width: 92px; white-space: normal; line-height: 1.2; padding-bottom: 4px; }
table.heat tbody th { text-align: left; color: var(--fg); padding-right: 10px; }
table.heat td { padding: 0; min-width: 44px; }
table.heat td.total, table.heat th.total { text-align: center; font-weight: 600; color: var(--fg); font-variant-numeric: tabular-nums; }
table.heat tfoot th, table.heat tfoot td { padding-top: 4px; }
.division + .division { border-top: 1px solid var(--line); padding-top: 14px; }
.division { display: grid; gap: 8px; min-width: 0; }
.division h3 { font-size: 18px; }
details.division { display: block; }
details.division > summary { cursor: pointer; margin-bottom: 8px; }
details.division + details.division { margin-top: 0; }

/* ---------- Mapa ---------- */
.map { width: 100%; height: 340px; border-radius: var(--radius); background: var(--sunk); border: 1px solid var(--line); overflow: hidden; position: relative; }
.map-fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center; color: var(--muted); font-size: 14px; }
@media (max-width: 560px) { .map { height: 260px; } }

/* ---------- Perfil ---------- */
.avatar { width: 88px; height: 88px; border-radius: 50%; background: var(--sunk); border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; flex: none; font: 600 32px/1 var(--display); color: var(--muted); }
.avatar-sm { width: 30px; height: 30px; font-size: 14px; }
.profile-head { display: flex; flex-wrap: wrap; gap: 16px 20px; align-items: center; }
.profile-head .profile-info { display: grid; gap: 4px; min-width: 0; flex: 1 1 220px; }

/* ---------- Precios ---------- */
.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 860px) { .plans { grid-template-columns: minmax(0, 1fr); } }
.plan { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; display: grid; gap: 14px; align-content: start; }
.plan-current { border-color: var(--fg); }
.plan-price { font: 600 40px/1 var(--display); font-variant-numeric: tabular-nums; }
.plan-price small { font: 400 16px/1 var(--body); color: var(--muted); }
.plan ul { list-style: none; padding: 0; display: grid; gap: 6px; }
.plan li { display: flex; gap: 8px; }
.plan li svg { width: 18px; height: 18px; flex: none; margin-top: 3px; color: var(--muted); }
.strike { text-decoration: line-through; color: var(--muted); }

/* ---------- Galería ---------- */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.photo { aspect-ratio: 4 / 3; background: var(--sunk); border: 1px solid var(--line); border-radius: var(--radius); display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; padding: 8px; }

/* ---------- Valoración ---------- */
.scale { display: flex; flex-wrap: wrap; gap: 6px; }
.scale label { position: relative; }
.scale input { position: absolute; opacity: 0; inset: 0; }
.scale span { display: grid; place-items: center; min-width: 44px; height: 44px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); font-weight: 600; cursor: pointer; padding-inline: 8px; }
.scale input:checked + span { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.scale input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.scale-ends { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); max-width: 520px; }

/* ---------- Índice de plantillas ---------- */
.index-list { list-style: none; padding: 0; margin: 0; }
.index-list li { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 2px 16px; padding-block: 10px; border-bottom: 1px solid var(--line); }
@media (max-width: 560px) { .index-list li { grid-template-columns: minmax(0, 1fr); } }
