/* simulador_broker.css — SIMULADOR DE BROKER.

   La barra de umbrales (.broker-need*) es la MISMA que la tarjeta de broker de
   la ficha del jugador; sus reglas viven en pages/estadisticas.css y se repiten
   aquí porque esta página no carga ese archivo (son 4 KB para cuatro reglas).
   Si tocas una, toca la otra. */

/* ---------- Cabecera ---------- */
.sb-head { align-items: center; }
.sb-lede {
  margin: 0 0 var(--sp-5); max-width: 74ch;
  font-size: 15.5px; line-height: 1.6; color: var(--muted);
}
.sb-lede strong { color: var(--ink); font-weight: 600; }

/* ---------- Chips de jugadores elegidos ---------- */
.sb-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: var(--sp-3); }
.sb-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 6px 5px 8px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--ink);
  border-left: 3px solid var(--ink);
}
.sb-chip__x {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px; border-radius: 50%;
  color: var(--muted); font-size: 15px; line-height: 1; text-decoration: none;
}
.sb-chip__x:hover { background: var(--down-tint); color: var(--down); text-decoration: none; }

/* ---------- Selector ---------- */
.sb-picker { padding: var(--sp-4); }
.sb-picker__lbl {
  display: block; margin-bottom: 6px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted);
}
.sb-picker__row { display: flex; gap: 8px; flex-wrap: wrap; }
.sb-picker__row input[type="text"] {
  flex: 1 1 260px; min-width: 0;
  font: inherit; font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-input); padding: 8px 12px;
}
.sb-picker__row input[type="text"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sb-picker__row input[type="text"]:disabled { background: var(--ground); color: var(--muted); }
.sb-picker__row .btn { padding: 8px 18px; font-size: 14px; }
.sb-picker__equipos { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.sb-picker__equipos a { font-weight: 600; margin-left: 6px; }
.sb-picker__tope { margin: 10px 0 0; font-size: 13px; }

/* ---------- Controles ---------- */
.sb-controls {
  display: flex; flex-wrap: wrap; align-items: flex-end;
  gap: var(--sp-4); padding: var(--sp-4);
}
.sb-controls .fgroup { display: flex; flex-direction: column; gap: 6px; }
.sb-controls .flabel {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted);
}
.sb-controls .seg {
  display: inline-flex; background: var(--ground);
  border: 1px solid var(--line); border-radius: var(--r-pill); padding: 2px;
}
.sb-controls .seg a, .sb-controls .seg button {
  font: inherit; font-size: 12px; font-weight: 600; padding: 5px 12px;
  border: 0; background: none; border-radius: var(--r-pill);
  color: var(--muted); white-space: nowrap; cursor: pointer;
}
.sb-controls .seg a:hover, .sb-controls .seg button:hover { color: var(--ink); text-decoration: none; }
.sb-controls .seg a.is-active, .sb-controls .seg button.is-active { background: var(--ink); color: #fff; }
.sb-controls .seg a:focus-visible, .sb-controls .seg button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.sb-aviso { margin: 10px 0 0; font-size: 13px; line-height: 1.6; max-width: 82ch; }

/* ---------- Rejilla de tarjetas ---------- */
.sb-cards {
  display: grid; gap: var(--sp-4);
  /* 540px: las ocho columnas (jornada · estimado · tres umbrales · precio ·
     variación en € y en %) necesitan unos 500px de tabla para no comprimirse.
     En pantalla ancha salen dos tarjetas por fila y se leen mejor. */
  grid-template-columns: repeat(auto-fill, minmax(540px, 1fr));
}
.sb-cards[data-count="1"] { grid-template-columns: minmax(0, 560px); }
.sb-card { padding: var(--sp-4); border-top: 3px solid var(--ink); }

/* Color de acento por jugador: mismo orden que $PALETA en el PHP. */
.sb-card--0 { border-top-color: #131C2E; } .sb-chip--0 { border-left-color: #131C2E; }
.sb-card--1 { border-top-color: #2563EB; } .sb-chip--1 { border-left-color: #2563EB; }
.sb-card--2 { border-top-color: #C07C1D; } .sb-chip--2 { border-left-color: #C07C1D; }
.sb-card--3 { border-top-color: #7C3AED; } .sb-chip--3 { border-left-color: #7C3AED; }
.sb-card--4 { border-top-color: #0E7490; } .sb-chip--4 { border-left-color: #0E7490; }
.sb-card--5 { border-top-color: #B91C1C; } .sb-chip--5 { border-left-color: #B91C1C; }
.sb-card--6 { border-top-color: #15803D; } .sb-chip--6 { border-left-color: #15803D; }
.sb-card--7 { border-top-color: #A16207; } .sb-chip--7 { border-left-color: #A16207; }
.sb-card--8 { border-top-color: #9D174D; } .sb-chip--8 { border-left-color: #9D174D; }
.sb-card--9 { border-top-color: #4338CA; } .sb-chip--9 { border-left-color: #4338CA; }

.sb-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.sb-swatch--0 { background: #131C2E; } .sb-swatch--1 { background: #2563EB; }
.sb-swatch--2 { background: #C07C1D; } .sb-swatch--3 { background: #7C3AED; }
.sb-swatch--4 { background: #0E7490; } .sb-swatch--5 { background: #B91C1C; }
.sb-swatch--6 { background: #15803D; } .sb-swatch--7 { background: #A16207; }
.sb-swatch--8 { background: #9D174D; } .sb-swatch--9 { background: #4338CA; }

/* ---------- Cabecera de tarjeta ---------- */
.sb-card__head { display: flex; align-items: center; gap: 10px; margin-bottom: var(--sp-3); }
.sb-card__foto {
  width: 46px; height: 46px; flex: 0 0 46px;
  border-radius: 50%; object-fit: cover; object-position: top center;
  background: var(--ground); border: 1px solid var(--line);
}
.sb-card__foto--fb {
  display: grid; place-items: center;
  font-size: 15px; font-weight: 700; color: var(--muted);
}
.sb-card__id { min-width: 0; }
.sb-card__nombre {
  display: block; font-size: 16px; font-weight: 700; color: var(--ink);
  line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sb-card__nombre:hover { color: var(--accent-deep); text-decoration: none; }
.sb-card__meta { display: flex; align-items: center; gap: 5px; margin-top: 4px; flex-wrap: wrap; }
.sb-baja {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--down); background: var(--down-tint); padding: 2px 6px; border-radius: 4px;
}

/* ---------- Precio ---------- */
.sb-card__precio { padding-bottom: var(--sp-3); border-bottom: 1px solid var(--line); }
.sb-card__precio .label {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted);
}
.sb-precio-num {
  margin: 2px 0 2px; font-size: 26px; font-weight: 700; line-height: 1.1;
  color: var(--accent-deep); letter-spacing: -.01em;
}
.sb-card__sub { margin: 0; font-size: 12.5px; color: var(--muted); }
.sb-card__sub strong { color: var(--ink); font-weight: 600; }

/* ---------- Barra de umbrales (espejo de pages/estadisticas.css) ---------- */
.broker-need { margin-top: var(--sp-3); }
.broker-need__cap {
  margin: 0 0 4px; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
}
.broker-need__nums {
  display: flex; justify-content: space-between; gap: 8px;
  font-size: 13px; font-variant-numeric: tabular-nums;
}
.broker-need__num { font-weight: 700; white-space: nowrap; }
.broker-need__num.down { color: var(--down); }
.broker-need__num.flat { color: var(--muted); font-weight: 600; }
.broker-need__num.up { color: var(--up); }
.broker-need__bar {
  position: relative; height: 8px; margin: 6px 0 0; border-radius: 4px;
  background: linear-gradient(90deg, var(--down) 0%, var(--line) 46%, var(--line) 54%, var(--up) 100%);
}
.broker-need__mid {
  position: absolute; left: 50%; top: -2px; width: 1px; height: 12px;
  background: var(--muted); opacity: .6;
}
.broker-need__marker {
  position: absolute; top: -4px; width: 4px; height: 16px; border-radius: 2px;
  background: var(--ink); box-shadow: 0 0 0 2px var(--surface);
  transform: translateX(-2px); transition: left .15s ease;
}
.broker-need__verdict {
  margin: 8px 0 0; font-size: 13px; line-height: 1.5; color: var(--muted);
}
.broker-need__verdict strong { font-variant-numeric: tabular-nums; color: var(--ink); }

/* ---------- Tabla por jornadas ---------- */
.sb-tabla-wrap { margin-top: var(--sp-3); overflow-x: auto; }
.sb-tabla { font-size: 13px; min-width: 500px; }
.sb-tabla th, .sb-tabla td { padding: 6px 6px; }
.sb-tabla thead th { font-size: 9.5px; letter-spacing: .05em; }
.sb-tabla tbody th, .sb-tabla tfoot th {
  position: static; background: none; color: var(--muted);
  font-size: 11.5px; font-weight: 700; text-transform: none; letter-spacing: 0;
  text-align: left; white-space: nowrap;
}
.sb-tabla tbody tr:nth-child(even) td, .sb-tabla tbody tr:nth-child(even) th { background: var(--zebra); }
.sb-tabla tbody tr:hover td, .sb-tabla tbody tr:hover th { background: var(--hover); }
/* Los tres umbrales de cada jornada van en gris y agrupados con una línea a la
   izquierda, para que el ojo separe «lo que necesita» de «lo que le pasa». */
.sb-tabla .sb-nec { color: var(--muted); }
.sb-tabla .sb-nec--flat { color: var(--ink); font-weight: 600; }
.sb-tabla th.sb-grp, .sb-tabla td.sb-grp { border-left: 1px solid var(--line); }
.sb-tabla thead th.sb-grp { border-left-color: rgba(255, 255, 255, .18); }
.sb-tabla tfoot th, .sb-tabla tfoot td {
  border-top: 2px solid var(--ink); font-weight: 700; color: var(--ink);
}
.sb-tabla tfoot th { color: var(--ink); }

.sb-input {
  width: 60px; font: inherit; font-size: 13px; font-weight: 700;
  text-align: right; font-variant-numeric: tabular-nums;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-input);
  padding: 4px 6px;
}
.sb-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sb-input::-webkit-outer-spin-button, .sb-input::-webkit-inner-spin-button { opacity: 1; }

/* ---------- Gráfica ---------- */
.sb-chart-card { padding: var(--sp-4); }
.sb-chart svg { width: 100%; height: auto; display: block; }
.sb-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; }
.sb-legend .key {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; color: var(--muted);
}

/* ---------- Explicación / fórmulas ---------- */
.sb-explica { padding: var(--sp-5); }
.sb-explica h2 { margin: 0 0 var(--sp-3); font-size: 19px; }
.sb-explica p { margin: 0 0 12px; font-size: 14.5px; line-height: 1.65; color: var(--muted); max-width: 76ch; }
.sb-explica p:last-child { margin-bottom: 0; }
.sb-explica strong { color: var(--ink); font-weight: 600; }
.sb-formula {
  font-size: 13.5px; font-weight: 600; color: var(--ink);
  background: var(--ground); border: 1px solid var(--line);
  border-radius: var(--r-input); padding: 10px 12px;
  overflow-x: auto; white-space: nowrap;
}
.sb-formula span { color: var(--accent-deep); }

.sb-defs { margin-top: var(--sp-5); }
.sb-defs > summary {
  font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer;
  padding: 10px 0; list-style: none; display: flex; align-items: center; gap: 8px;
}
.sb-defs > summary::-webkit-details-marker { display: none; }
.sb-defs > summary::before {
  content: ''; width: 8px; height: 8px; flex: 0 0 8px;
  border-right: 2px solid var(--accent-deep); border-bottom: 2px solid var(--accent-deep);
  transform: rotate(-45deg); transition: transform .15s ease;
}
.sb-defs[open] > summary::before { transform: rotate(45deg); }
.sb-defs > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sb-defs__body { padding: 4px 0 var(--sp-4); }
.sb-defs__body p { margin: 0 0 12px; font-size: 14px; line-height: 1.65; color: var(--muted); max-width: 78ch; }
.sb-defs__body ul { margin: 0 0 12px; padding-left: 20px; }
.sb-defs__body li { font-size: 14px; line-height: 1.65; color: var(--muted); margin-bottom: 8px; max-width: 78ch; }
.sb-defs__body strong { color: var(--ink); font-weight: 600; }

@media (max-width: 640px) {
  /* minmax(0,1fr) y no 1fr: con `auto` de mínimo, el ancho mínimo de la tabla
     (500px) empujaba la tarjeta más allá del viewport y la página entera
     scrolleaba en horizontal. Así la tarjeta se ajusta y es la tabla la que
     scrollea dentro de su .sb-tabla-wrap. */
  .sb-cards { grid-template-columns: minmax(0, 1fr); }
  .sb-cards[data-count="1"] { grid-template-columns: minmax(0, 1fr); }
  .sb-precio-num { font-size: 22px; }
  .sb-controls { gap: var(--sp-3); }
  .sb-input { width: 60px; }
}

/* Umbral por debajo de lo que se ha visto nunca (SB_SUELO): se enseña el número
   igual, atenuado, en vez de esconderlo. Ver el comentario de sb_umbral(): el
   11% de las actuaciones tienen SM negativo, así que negativo ≠ imposible. */
.sb-inalc { opacity: .45; }
