/* Pronosticador — hoja de estilos.
 *
 * Los colores de datos salen de la paleta de referencia sin retocar: los tres
 * primeros slots categoricos (azul, naranja, aqua), que son los unicos validados
 * para todos los pares en modo claro y oscuro a la vez. No sustituir por gusto:
 * el orden de los slots es el mecanismo que garantiza que se distingan con
 * daltonismo, no una decision estetica.
 */

:root {
  color-scheme: light;

  --surface-1: #fcfcfb;
  --plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);

  /* Slots categoricos 1-3 */
  --series-1: #2a78d6;  /* gana local */
  --series-2: #eb6834;  /* empate */
  --series-3: #1baf7a;  /* gana visitante */

  /* Rampa azul, para el medidor de confianza (relleno sobre pista del mismo tono) */
  --meter-fill: #2a78d6;
  --meter-track: #cde2fb;

  --ok: #0ca30c;
  --warn: #fab219;

  --radius: 12px;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* El modo oscuro son los mismos ocho tonos escalonados para la superficie
   oscura, no un volteo automatico de los claros. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --meter-fill: #3987e5;
    --meter-track: #184f95;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --plane: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --meter-fill: #3987e5;
  --meter-track: #184f95;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--plane);
  color: var(--text-primary);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- Cabecera ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 0.7rem; }
.brand-mark { font-size: 1.6rem; line-height: 1; }
.brand h1 { margin: 0; font-size: 1.15rem; font-weight: 650; letter-spacing: -0.01em; }
.brand-sub { margin: 0; font-size: 0.82rem; color: var(--text-secondary); }

.topbar-actions { display: flex; gap: 0.5rem; }

.btn {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  cursor: pointer;
}
.btn:hover { background: var(--plane); }
.btn:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }
.btn[aria-pressed="true"] { background: var(--gridline); }
.btn-icon { padding: 0.4rem 0.6rem; }
.btn:disabled { opacity: 0.55; cursor: default; }

/* ---------- Estructura ---------- */

.wrap { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

.aviso {
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  background: var(--surface-1);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.meta {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.meta dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.9rem 1.5rem;
}
.meta dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.meta dd { margin: 0.15rem 0 0; font-size: 0.95rem; font-weight: 600; }

/* ---------- Leyenda ---------- */

.leyenda {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin-bottom: 1rem;
  font-size: 0.83rem;
  color: var(--text-secondary);
}
.leyenda-item { display: inline-flex; align-items: center; gap: 0.4rem; }
/* La identidad la lleva la muestra de color junto al texto; el texto nunca
   se pinta del color de la serie. */
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw-1 { background: var(--series-1); }
.sw-2 { background: var(--series-2); }
.sw-3 { background: var(--series-3); }

/* ---------- Tarjetas ---------- */

.tarjetas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 1rem;
}
@media (max-width: 520px) {
  .tarjetas { grid-template-columns: 1fr; }
}

.tarjeta {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.t-cabecera {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 0.76rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.t-equipos {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
}
.equipo { display: flex; align-items: center; gap: 0.55rem; min-width: 0; }
.equipo.visit { flex-direction: row-reverse; text-align: right; }
.equipo-escudo {
  width: 30px; height: 30px; flex: none;
  object-fit: contain;
}
.equipo-inicial {
  width: 30px; height: 30px; flex: none;
  border-radius: 50%;
  background: var(--gridline);
  color: var(--text-secondary);
  display: grid; place-items: center;
  font-size: 0.72rem; font-weight: 700;
}
.equipo-nombre {
  font-weight: 620;
  font-size: 0.98rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.equipo-pos { font-size: 0.74rem; color: var(--text-muted); font-weight: 500; }

/* Marcador pronosticado: cifra grande en la misma sans, con figuras
   proporcionales (tabular-nums solo en columnas de tabla). */
.marcador {
  font-size: 1.7rem;
  font-weight: 680;
  letter-spacing: -0.02em;
  text-align: center;
  line-height: 1.1;
}
.marcador small {
  display: block;
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ---------- Barra apilada 1X2 ---------- */

.barra {
  display: flex;
  height: 22px;               /* <= 24px: nunca rellena todo el hueco */
  border-radius: 4px;
  overflow: visible;
  gap: 2px;                   /* separador de 2px en color de superficie */
  background: transparent;
}
.seg {
  min-width: 3px;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 650;
  overflow: hidden;
}
/* Extremos redondeados de 4px solo en los bordes exteriores del apilado. */
.seg:first-child { border-radius: 4px 0 0 4px; }
.seg:last-child { border-radius: 0 4px 4px 0; }
.seg-1 { background: var(--series-1); }
.seg-2 { background: var(--series-2); }
.seg-3 { background: var(--series-3); }
/* Etiqueta dentro del relleno: blanco o tinta segun la luminancia, la unica
   excepcion a "el texto nunca lleva el color del dato". */
.seg-oscuro { color: #ffffff; }
.seg-claro { color: #0b0b0b; }

.barra-pies {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--text-secondary);
}

/* ---------- Medidor de confianza ---------- */

.confianza { display: flex; align-items: center; gap: 0.7rem; font-size: 0.8rem; }
.confianza-label { color: var(--text-secondary); white-space: nowrap; }
.medidor {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--meter-track);   /* pista = paso claro de la misma rampa */
  overflow: hidden;
}
.medidor > i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--meter-fill);
}
.confianza-valor { font-weight: 650; white-space: nowrap; }

/* ---------- Factores y detalle ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip {
  font-size: 0.76rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--plane);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

details.detalle { border-top: 1px solid var(--gridline); padding-top: 0.7rem; }
details.detalle > summary {
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 600;
  list-style: none;
}
details.detalle > summary::-webkit-details-marker { display: none; }
details.detalle > summary::before { content: "▸ "; }
details.detalle[open] > summary::before { content: "▾ "; }
.detalle-cuerpo { font-size: 0.87rem; color: var(--text-secondary); }
.detalle-cuerpo h4 {
  margin: 0.9rem 0 0.3rem;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.detalle-cuerpo p { margin: 0 0 0.6rem; }
.detalle-cuerpo ul { margin: 0.2rem 0; padding-left: 1.1rem; }

.t-error {
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-left: 3px solid var(--warn);
  padding-left: 0.75rem;
}

.resultado-real {
  font-size: 0.8rem;
  font-weight: 620;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.resultado-real .icono { font-size: 0.9rem; }

/* ---------- Tabla ---------- */

.tabla-wrap { overflow-x: auto; }
.tabla {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.88rem;
}
.tabla caption {
  text-align: left;
  padding: 0.85rem 1rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.tabla th, .tabla td {
  padding: 0.6rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--gridline);
}
.tabla thead th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}
.tabla tbody tr:last-child td { border-bottom: none; }
/* Columnas de numeros: aqui si se alinean verticalmente. */
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Pie ---------- */

.pie {
  border-top: 1px solid var(--border);
  background: var(--surface-1);
}
.pie p {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.1rem 1.25rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.cargando {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

/* ---------- Pagina de calibracion ---------- */

.intro {
  max-width: 62ch;
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin: 0 0 1.5rem;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.tile-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
/* Cifra grande con figuras proporcionales: tabular-nums solo en columnas. */
.tile-valor {
  font-size: 1.55rem;
  font-weight: 660;
  letter-spacing: -0.02em;
  margin-top: 0.15rem;
  line-height: 1.15;
}
.tile-nota { font-size: 0.76rem; color: var(--text-secondary); }

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.panel h2 { margin: 0 0 0.35rem; font-size: 1rem; font-weight: 650; }
.panel-sub {
  margin: 0 0 1rem;
  font-size: 0.86rem;
  color: var(--text-secondary);
  max-width: 62ch;
}
.panel .tabla { border: none; }
.panel .tabla caption { padding-left: 0; }

.chart { position: relative; margin-bottom: 1.25rem; max-width: 620px; }

.tooltip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: var(--text-primary);
  color: var(--surface-1);
  font-size: 0.76rem;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  white-space: nowrap;
}

.nav-sec {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
}
.nav-sec:hover { color: var(--text-primary); }

/* ---------- Pagina de valor de mercado ---------- */

/* Par divergente de la paleta de referencia: azul <-> rojo, polos frio/calido
   que se leen como opuestos, con el cero en gris neutro. No es un par
   categorico: aqui el color codifica signo, no identidad. */
:root { --div-pos: #2a78d6; --div-neg: #e34948; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --div-pos: #3987e5; --div-neg: #e66767; }
}
:root[data-theme="dark"] { --div-pos: #3987e5; --div-neg: #e66767; }

.sw-pos { background: var(--div-pos); }
.sw-neg { background: var(--div-neg); }

.medidor-peso { display: flex; align-items: center; gap: 0.85rem; }
.medidor-peso .medidor { flex: 1; }

.opcion {
  display: grid;
  grid-template-columns: 8.5rem 12rem 1fr 5rem 7rem 4.5rem;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--gridline);
  font-size: 0.85rem;
}
.opcion-cabecera {
  border-top: none;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.opcion-nombre { font-weight: 600; }
.opcion-probs { color: var(--text-secondary); }
.opcion-probs .sep { margin: 0 0.35rem; color: var(--text-muted); }
.opcion-num { text-align: right; font-variant-numeric: tabular-nums; }
.opcion-num .muted { color: var(--text-muted); }
.opcion-cuota { text-align: right; }
.cuota-num { font-weight: 650; font-variant-numeric: tabular-nums; }
.cuota-casa {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.div-barra { position: relative; height: 14px; }
.div-cero {
  position: absolute; left: 50%; top: 0; bottom: 0;
  width: 1px; background: var(--baseline);
}
.div-fill {
  position: absolute; top: 3px; height: 8px;
  border-radius: 4px;
  min-width: 2px;
}
.div-fill.pos { background: var(--div-pos); }
.div-fill.neg { background: var(--div-neg); }

@media (max-width: 760px) {
  .opcion { grid-template-columns: 1fr 1fr; gap: 0.3rem 0.75rem; }
  .opcion-cabecera { display: none; }
  .div-barra { grid-column: 1 / -1; }
}
