/* ============================================================
 * Estilos propios del reporte de estrategia. La base (encabezado, tarjetas,
 * botones, tablas, paginación, carga) es styles.css, igual a explicabilidad.
 * ============================================================ */
/* Los botones ocultos por configuración (atributo hidden) no deben reaparecer por un display de clase. */
[hidden] { display: none !important; }

:root {
  --sube: #16a34a;
  --baja: #dc2626;
  --alerta: #f59e0b;
  --oportunidad: #0288d1;
}

.txt-sube { color: var(--sube); font-weight: 600; }
.txt-baja { color: var(--baja); font-weight: 600; }
.muted { color: var(--text-muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.header-inline-filter label { font-size: 12px; font-weight: 700; color: #475569; }

.fuente-datos {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 35px;
  font-size: 11.5px;
  color: var(--text-muted);
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.fuente-datos .material-symbols-outlined { font-size: 15px; color: var(--text-muted); }
.fuente-datos--mock { background: #fff4e5; color: #663c00; }
.fuente-datos--mock .material-symbols-outlined { color: #ed6c02; }
.fuente-datos--mock .link-btn { color: #663c00; padding-left: 16px; }
.link-btn {
  border: none;
  background: none;
  color: #1d4ed8;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.icon-btn {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #334155;
}
.icon-btn:hover { border-color: #94a3b8; color: var(--accent-red); }
.icon-btn .material-symbols-outlined { font-size: 18px; }

.chk-inline { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: #475569; cursor: pointer; }

/* ---------- Franja de alertas ---------- */
.franja-alertas {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
@media (max-width: 1000px) { .franja-alertas { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.alerta-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-left: 4px solid var(--alerta);
  border-radius: var(--border-radius);
  padding: 12px 14px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
  transition: box-shadow 0.2s, border-color 0.2s;
  font-family: inherit;
}
.alerta-card:hover { box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08); }
.alerta-card--critico { border-left-color: var(--baja); }
.alerta-card--alerta { border-left-color: var(--alerta); }
.alerta-card.activa { border-color: #94a3b8; background: #f8fafc; box-shadow: inset 0 0 0 1px #94a3b8; }
.alerta-icono { font-size: 22px; color: var(--text-muted); }
.alerta-card--critico .alerta-icono { color: var(--baja); }
.alerta-card--alerta .alerta-icono { color: var(--alerta); }
.alerta-cuerpo { display: flex; flex-direction: column; gap: 2px; }
.alerta-numero { font-size: 22px; font-weight: 700; color: var(--text-main); line-height: 1.1; }
.alerta-etiqueta { font-size: 12px; font-weight: 600; color: #334155; }
.alerta-monto { font-size: 11px; color: var(--text-muted); }

/* ---------- Evolución y definiciones ---------- */
.fila-evolucion {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: stretch;
  margin-bottom: 20px;
}
.fila-evolucion > .section-card { margin-bottom: 0; }
@media (max-width: 1150px) {
  .fila-evolucion { grid-template-columns: 1fr; }
  .card-definiciones { height: auto; min-height: 0; }
}

/* La card de definiciones toma el alto de la evolución (no lo agranda) y desplaza su lista por dentro. */
.card-definiciones { display: flex; flex-direction: column; height: 0; min-height: 100%; }
.card-definiciones .section-header-row { margin-bottom: 10px; padding-bottom: 10px; }
.definiciones {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-right: -10px;
  padding-right: 6px;
}
.def-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  padding: 5px 8px;
  cursor: pointer;
  font-family: inherit;
}
.def-item:hover { background: #f8fafc; border-color: #e2e8f0; }
.def-item.seleccionado { background: #f1f5f9; border-color: #94a3b8; }
.def-titulo { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--text-main); }
.def-titulo .esc-swatch { margin-right: 0; }
.def-texto { font-size: 11px; color: #475569; line-height: 1.35; padding-left: 16px; }

.tag-grupo {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 100px;
  margin-left: 6px;
  white-space: nowrap;
}
.tag-grupo--activo { background: #dbeafe; color: #1e3a8a; }
.tag-grupo--inactivo { background: #fef3c7; color: #92400e; }
.tag-grupo--sin_compra { background: #e2e8f0; color: #334155; }

/* ---------- Escalera (ranking animado) ---------- */
.esc-nomenclatura {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 11px;
  color: var(--text-muted);
  margin: -6px 0 14px;
}
.nom-item { display: inline-flex; align-items: center; gap: 4px; }
.nom-item .tag-grupo { margin-left: 0; }

.esc-controles {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.esc-controles input[type="range"] { flex: 1; max-width: 520px; accent-color: var(--accent-red); cursor: pointer; }
.esc-periodo { font-size: 13px; font-weight: 700; color: var(--text-main); white-space: nowrap; }

.escalera { position: relative; }
.esc-fila {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 32px;
  display: grid;
  grid-template-columns: 24px 230px minmax(0, 1fr) 64px 64px;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1), background 0.2s;
}
.esc-fila:hover { background: #f8fafc; border-color: #e2e8f0; }
.esc-fila.seleccionada { background: #f1f5f9; border-color: #94a3b8; }
.esc-puesto { font-size: 11px; font-weight: 700; color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }
.esc-nombre { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--text-main); white-space: nowrap; }
.esc-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; margin-right: 4px; }
.esc-nombre .esc-swatch { margin-right: 0; }
.esc-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.esc-barra {
  height: 16px;
  border-radius: 0 4px 4px 0;
  min-width: 2px;
  transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.esc-valor { font-size: 12px; font-weight: 700; color: var(--text-main); white-space: nowrap; font-variant-numeric: tabular-nums; }
.esc-mov { font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.esc-mov--sube { color: var(--sube); }
.esc-mov--baja { color: var(--baja); }
.escalera.sin-transicion .esc-fila,
.escalera.sin-transicion .esc-barra { transition: none; }
@media (prefers-reduced-motion: reduce) { .esc-fila, .esc-barra { transition: none; } }

.esc-resumen { margin: 12px 0 0; font-size: 12.5px; color: #334155; }
#escaleraTabla { margin-top: 14px; }

.esc-tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: #1e293b;
  color: #ffffff;
  font-size: 11.5px;
  line-height: 1.5;
  padding: 8px 10px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  max-width: 300px;
}
.esc-tooltip .txt-sube { color: #86efac; }
.esc-tooltip .txt-baja { color: #fca5a5; }
.tooltip-hint { color: #cbd5e1; font-size: 10.5px; }

.tabla-simple { min-width: 0; table-layout: auto; }
.tabla-simple td:first-child { white-space: nowrap; }

/* ---------- Guía del segmento ---------- */
.seg-vacio { color: var(--text-muted); font-size: 13px; margin: 0; }
.seg-chip {
  display: inline-block;
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
  white-space: nowrap;
}
.seg-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.seg-kpi { border: 1px solid #e2e8f0; border-radius: 6px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.seg-kpi-valor { font-size: 18px; font-weight: 700; color: var(--text-main); }
.seg-kpi-label { font-size: 11px; color: var(--text-muted); }

.seg-guia { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.seg-guia th, .seg-guia td { border: 1px solid #e2e8f0; padding: 10px 12px; vertical-align: top; text-align: left; }
.seg-guia thead th { background: #f8fafc; font-size: 11px; color: #334155; }
.seg-guia tbody th { width: 170px; font-size: 12.5px; color: var(--text-main); background: #f8fafc; }
.seg-guia tbody th span { display: block; font-size: 10.5px; font-weight: 400; color: var(--text-muted); margin-top: 2px; }
.seg-guia td { color: #334155; line-height: 1.45; }
.seg-nota { font-size: 11px; color: var(--text-muted); margin: 10px 0 0; }

/* ---------- Lista de clientes ---------- */
.chips-filtros { display: inline-flex; gap: 6px; }
.chip-filtro {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  padding: 2px 4px 2px 10px;
}
.chip-filtro--alerta { background: #fff7ed; border-color: #fdba74; }
.chip-filtro button { border: none; background: none; cursor: pointer; font-size: 14px; line-height: 1; color: var(--text-muted); padding: 0 4px; }

.tabla-clientes { min-width: 980px; font-size: 12px; }
.tabla-clientes td { vertical-align: middle; }
.fila-cliente { cursor: pointer; }
.fila-cliente:hover td { background: #f8fafc; }
.fila-cliente:focus { outline: 2px solid #94a3b8; outline-offset: -2px; }
.rank { color: var(--text-muted); font-weight: 700; }
.cli-nombre { display: block; font-weight: 600; color: var(--text-main); }
.cli-sub { display: block; font-size: 10.5px; color: var(--text-muted); margin-top: 1px; }
.cli-sub .esc-swatch { width: 8px; height: 8px; }

.mov { display: inline-block; width: 18px; text-align: center; font-weight: 700; }
.mov--sube { color: var(--sube); }
.mov--baja { color: var(--baja); }
.mov--igual, .mov--nuevo { color: #94a3b8; }

.senal {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 100px;
  white-space: nowrap;
  color: #ffffff;
}
.senal--critico { background: var(--baja); }
.senal--alerta { background: var(--alerta); }
.senal--oportunidad { background: var(--sube); }
.senal--info { background: #0284c7; }

.lista-vacia { padding: 30px; text-align: center; color: var(--text-muted); }

/* ---------- Ficha del cliente ---------- */
.ficha-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.25); z-index: 40; }
.ficha-overlay[hidden] { display: none; }
.ficha-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(640px, 100vw);
  background: var(--bg-card);
  box-shadow: -4px 0 18px rgba(0, 0, 0, 0.15);
  z-index: 45;
  overflow-y: auto;
  padding: 22px 24px 30px;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.ficha-panel.abierta { transform: translateX(0); }
.ficha-cerrar { position: absolute; top: 14px; right: 14px; }

.ficha-titulo { border-left: 4px solid var(--accent-red); padding-left: 10px; margin-bottom: 14px; padding-right: 40px; }
.ficha-titulo h2 { margin: 0 0 4px; font-size: 17px; color: var(--text-main); }
.ficha-titulo p { margin: 0; font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.ficha-industria { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px 2px 6px; border-radius: 999px; background: #f1f5f9; border: 1px solid #e2e8f0; color: #334155; font-size: 11.5px; font-weight: 600; }
.ficha-industria .material-symbols-outlined { font-size: 15px; color: #64748b; }
.ficha-industria--vacia { color: var(--text-muted); font-weight: 500; }
.ficha-datos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin-bottom: 8px; }
.ficha-dato { display: flex; flex-direction: column; }
.ficha-dato-label { font-size: 10.5px; color: var(--text-muted); font-weight: 600; }
.ficha-dato-valor { font-size: 12.5px; color: var(--text-main); font-weight: 600; }

.ficha-seccion { border-top: 1px solid #e2e8f0; padding-top: 12px; margin-top: 14px; }
.ficha-seccion h3 { margin: 0 0 10px; font-size: 13px; color: var(--text-main); }
.ficha-aviso { font-size: 11.5px; color: #92400e; background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 8px 10px; }
.ficha-cargando { display: flex; justify-content: center; padding: 40px 0; }

.lt-fila { display: flex; gap: 2px; }
.lt-celda { flex: 1; height: 22px; border-radius: 3px; min-width: 10px; }
.lt-ejes { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--text-muted); margin-top: 4px; }
.lt-leyendas { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.lt-leyenda { font-size: 11px; color: #334155; display: inline-flex; align-items: center; }

.cambios { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cambios li { font-size: 12px; color: #334155; line-height: 1.45; display: flex; gap: 8px; }
.cambios li span { font-weight: 700; }
.cambio-sube span { color: var(--sube); }
.cambio-baja span { color: var(--baja); }
.cambio-igual { color: var(--text-muted); }

.estado { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 100px; color: #ffffff; white-space: nowrap; }
.estado--ganada { background: #16a34a; }
.estado--perdida { background: #dc2626; }
.estado--abierta { background: #f59e0b; }

.hacer { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.hacer li { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: #334155; line-height: 1.45; background: #f8fafc; border-radius: 6px; padding: 8px 10px; }
.hacer li .material-symbols-outlined { font-size: 17px; }
.hacer-critico .material-symbols-outlined { color: var(--baja); }
.hacer-alerta .material-symbols-outlined { color: var(--alerta); }
.hacer-oportunidad .material-symbols-outlined { color: var(--sube); }
.hacer-info .material-symbols-outlined { color: #0284c7; }
.hacer-guia { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hacer-guia strong { font-size: 11.5px; color: var(--text-main); }
.hacer-guia p { font-size: 11.5px; color: #334155; margin: 4px 0 0; line-height: 1.45; }

/* ---------- Acciones sugeridas (título + texto) ---------- */
.accion-titulo { display: block; font-size: 12.5px; color: var(--text-main); margin-bottom: 2px; }
.accion-texto { display: block; font-size: 12px; color: #475569; line-height: 1.45; }
.seg-guia thead th:first-child { color: var(--text-main); font-size: 11.5px; }
.hacer li > span:last-child { display: flex; flex-direction: column; }
.hacer-mirada { display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-muted); }
.hacer-guia p { margin: 8px 0 0; }

/* ---------- Filtro rápido por alerta ----------
 * Cada alerta lleva el color de su tono: fondo suave con texto oscuro del mismo color,
 * y color lleno con texto blanco cuando está elegida. El punto repite el color para que
 * se distinga también en impresión o con baja saturación. */
.filtro-senales { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -6px 0 16px; }
.filtro-senales-label { font-size: 11.5px; font-weight: 700; color: var(--text-muted); margin-right: 2px; }
.pastilla-senal {
  --tono: #475569;
  --tono-suave: #f1f5f9;
  --tono-borde: #cbd5e1;
  --tono-texto: #1e293b;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--tono-texto);
  background: var(--tono-suave);
  border: 1px solid var(--tono-borde);
  border-radius: 20px;
  padding: 4px 6px 4px 11px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.pastilla-senal::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tono);
  flex-shrink: 0;
}
.pastilla-senal:hover { box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }
.pastilla-num {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 11px;
  background: #ffffff;
  color: var(--tono-texto);
  border-radius: 10px;
  padding: 1px 7px;
}
.pastilla-senal--critico { --tono: #dc2626; --tono-suave: #fee2e2; --tono-borde: #fca5a5; --tono-texto: #991b1b; }
.pastilla-senal--alerta { --tono: #d97706; --tono-suave: #fef3c7; --tono-borde: #fcd34d; --tono-texto: #92400e; }
.pastilla-senal--oportunidad { --tono: #16a34a; --tono-suave: #dcfce7; --tono-borde: #86efac; --tono-texto: #166534; }
.pastilla-senal--info { --tono: #0284c7; --tono-suave: #e0f2fe; --tono-borde: #7dd3fc; --tono-texto: #075985; }
.pastilla-senal.activa { background: var(--tono); border-color: var(--tono); color: #ffffff; }
.pastilla-senal.activa::before { background: #ffffff; }
.pastilla-senal.activa .pastilla-num { color: var(--tono); }
/* «Todas»: neutro; elegida en el gris oscuro de la app. */
.pastilla-senal[data-alerta=""] { padding-right: 11px; }
.pastilla-senal[data-alerta=""]::before { display: none; }
.pastilla-senal[data-alerta=""].activa { background: #1e293b; border-color: #1e293b; }

/* Reproducción continua: cada cuadro fija posición y ancho, sin transiciones CSS. */
.escalera.continuo .esc-fila,
.escalera.continuo .esc-barra { transition: none; }
