/**
 * ============================================================================
 * PRO DESIGN SYSTEM — KIT DASHBOARD (tableros)
 * ============================================================================
 * Extiende el kit web con: paneles, tarjetas de KPI, chips, tablas de datos y
 * gráficos (barras simples, agrupadas, apiladas, horizontales y dona).
 *
 * Depende de: tokens/design-tokens.css + components/pro-components.css
 *
 * REGLAS DE VISUALIZACIÓN aplicadas (no alterar sin re-validar):
 *  · COLOR POR FUNCIÓN: tonal (misma familia) por defecto · énfasis (foco vs
 *    contexto) · categórica SOLO para entidades distintas, máx. 4 y por posición.
 *    Los colores de estado están reservados y nunca se usan como serie.
 *  · Barras ≤ 24px de grosor, extremo de dato redondeado 4px y recto en la base.
 *  · Separación entre marcas contiguas = 2px del color de la superficie (nunca borde).
 *  · Grillas y ejes en gris hairline 1px sólido, recesivos.
 *  · El texto NUNCA lleva el color de la serie: usa tokens de texto. La identidad
 *    la da el punto/muestra de color al lado.
 *  · Leyenda presente siempre que haya 2+ series; etiquetas directas selectivas.
 * ============================================================================
 */

/* ==========================================================================
   1 · LAYOUT DEL TABLERO
   ========================================================================== */
.pro-dash {
  background: var(--pro-bg-canvas, var(--pro-bg-subtle));
  min-height: 100vh;
  padding: var(--pro-space-8) 0;
}
.pro-dash__head {
  display: flex; flex-wrap: wrap; gap: var(--pro-space-4);
  align-items: flex-end; justify-content: space-between;
  margin-bottom: var(--pro-space-6);
}
.pro-dash__title { font-size: var(--pro-font-size-h3); font-weight: var(--pro-font-weight-bold); text-transform: uppercase; margin: 0; }
.pro-dash__subtitle { color: var(--pro-text-secondary); margin: var(--pro-space-1) 0 0; font-size: var(--pro-font-size-sm); }

/* Fila de filtros: SIEMPRE en una sola fila arriba de los gráficos */
.pro-dash__filters { display: flex; flex-wrap: wrap; gap: var(--pro-space-2); align-items: center; }

/* Grilla de tarjetas */
.pro-dash__grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--pro-space-5); }
.pro-span-3  { grid-column: span 3; }
.pro-span-4  { grid-column: span 4; }
.pro-span-6  { grid-column: span 6; }
.pro-span-8  { grid-column: span 8; }
.pro-span-12 { grid-column: span 12; }

@media (max-width: 1024px) {
  .pro-span-3 { grid-column: span 6; }
  .pro-span-4, .pro-span-6, .pro-span-8 { grid-column: span 12; }
}
@media (max-width: 640px) {
  .pro-span-3 { grid-column: span 12; }
}

/* ==========================================================================
   1b · PANEL DE FILTROS
   --------------------------------------------------------------------------
   CRITERIO: el control se elige por la CANTIDAD de opciones, no por costumbre.
   Una fila de desplegables iguales esconde el estado y aplana la jerarquía.

     2–4 opciones fijas   → control segmentado (todas visibles, un clic)
     5–8 opciones         → chips de selección múltiple (visibles, con estado)
     muchas (autor, bloque)→ desplegable CON buscador interno
     texto libre          → campo de búsqueda con lupa

   Y una regla que lo ordena todo: lo aplicado SIEMPRE se ve como chips
   removibles con el conteo de resultados. El usuario nunca abre un control
   para averiguar qué filtró.
   ========================================================================== */
.pro-filterbar {
  background: var(--pro-bg-surface);
  border: 1px solid var(--pro-border-subtle);
  border-radius: var(--pro-radius-lg, 12px);
  padding: var(--pro-space-4);
  margin-bottom: var(--pro-space-5);
  display: flex; flex-direction: column; gap: var(--pro-space-3);
}
.pro-filterbar__row { display: flex; flex-wrap: wrap; gap: var(--pro-space-3); align-items: center; }
.pro-filterbar__label {
  font-size: var(--pro-font-size-xs, 0.75rem); text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--pro-text-muted); white-space: nowrap;
}
/* GRUPO: mantiene unidos rótulo y control. Sin esto, al angostar la pantalla
   el rótulo se separa de su filtro y termina pareciendo el rótulo del de al
   lado — la fuente de desprolijidad más común en una barra de filtros. */
.pro-filterbar__group {
  display: inline-flex; align-items: center; gap: var(--pro-space-2);
  flex: 0 0 auto;            /* nunca se estira ni se parte */
  min-width: 0;
}
.pro-filterbar__spacer { flex: 1; }
.pro-filterbar__divider { height: 1px; background: var(--pro-border-subtle); margin: var(--pro-space-1) 0; }

/* --- Búsqueda ----------------------------------------------------------- */
.pro-search { position: relative; flex: 1 1 260px; min-width: 200px; display: flex; align-items: center; }
.pro-search__icon {
  position: absolute; left: 12px; width: 16px; height: 16px; pointer-events: none;
  fill: none; stroke: var(--pro-text-muted); stroke-width: 2; stroke-linecap: round;
}
.pro-search__input {
  width: 100%; height: 36px;
  padding: 0 32px 0 34px;
  font-family: inherit; font-size: var(--pro-font-size-sm);
  color: var(--pro-text-primary); background: var(--pro-bg-subtle);
  border: 1px solid var(--pro-border-default); border-radius: var(--pro-radius-full, 999px);
}
.pro-search__input::placeholder { color: var(--pro-text-muted); }
.pro-search__input:focus { outline: none; box-shadow: var(--pro-focus-ring); background: var(--pro-bg-surface); }
.pro-search__input::-webkit-search-cancel-button { display: none; }
.pro-search__clear {
  position: absolute; right: 8px; width: 20px; height: 20px; border: 0; padding: 0;
  border-radius: 50%; cursor: pointer; line-height: 1;
  background: var(--pro-bg-muted); color: var(--pro-text-secondary);
  display: none; place-items: center; font-size: 13px;
}
.pro-search.is-filled .pro-search__clear { display: grid; }

/* --- Control segmentado (2–4 opciones fijas) ---------------------------- */
.pro-segmented {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--pro-bg-subtle); border: 1px solid var(--pro-border-default);
  border-radius: var(--pro-radius-full, 999px); padding: 2px;
}
.pro-segmented__opt {
  font-family: inherit; font-size: var(--pro-font-size-sm); line-height: 1;
  padding: 0.5em 0.9em; border: 0; border-radius: var(--pro-radius-full, 999px);
  background: transparent; color: var(--pro-text-secondary); cursor: pointer;
  white-space: nowrap;
}
.pro-segmented__opt:hover { color: var(--pro-text-primary); }
.pro-segmented__opt[aria-pressed="true"] {
  background: var(--pro-bg-surface); color: var(--pro-text-primary);
  font-weight: var(--pro-font-weight-bold); box-shadow: var(--pro-shadow-xs);
}
.pro-segmented__opt:focus-visible { outline: none; box-shadow: var(--pro-focus-ring); }

/* --- Desplegable con buscador (muchas opciones) ------------------------- */
.pro-filter { position: relative; }
.pro-filter__btn {
  display: inline-flex; align-items: center; gap: 0.5em; height: 36px;
  padding: 0 0.9em; font-family: inherit; font-size: var(--pro-font-size-sm);
  background: var(--pro-bg-surface); color: var(--pro-text-secondary);
  border: 1px solid var(--pro-border-default); border-radius: var(--pro-radius-full, 999px);
  cursor: pointer; white-space: nowrap;
}
.pro-filter__btn:hover { background: var(--pro-bg-subtle); color: var(--pro-text-primary); }
.pro-filter__btn:focus-visible { outline: none; box-shadow: var(--pro-focus-ring); }
.pro-filter__btn[aria-expanded="true"] { border-color: var(--pro-brand-400); color: var(--pro-text-primary); }
.pro-filter__btn svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.5; }
/* Contador de selección: el botón dice cuántos hay sin abrirlo */
.pro-filter__count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--pro-brand-200); color: var(--pro-brand-900);
  font-size: 11px; font-weight: var(--pro-font-weight-bold);
  display: none; place-items: center;
}
.pro-filter.has-selection .pro-filter__count { display: grid; }
.pro-filter.has-selection .pro-filter__btn { border-color: var(--pro-brand-400); color: var(--pro-text-primary); }

.pro-filter__pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: var(--pro-z-dropdown);
  width: 260px; background: var(--pro-bg-surface);
  border: 1px solid var(--pro-border-default); border-radius: var(--pro-radius-md, 8px);
  box-shadow: var(--pro-shadow-lg); padding: var(--pro-space-3);
  display: flex; flex-direction: column; gap: var(--pro-space-2);
}
.pro-filter__pop[hidden] { display: none; }
/* Si el control está cerca del borde derecho, el panel se ancla a la derecha
   para no salirse de la pantalla. */
.pro-filter__pop.is-right, .pro-period__pop.is-right { left: auto; right: 0; }
.pro-filter__popsearch {
  width: 100%; height: 32px; padding: 0 10px;
  font-family: inherit; font-size: var(--pro-font-size-sm);
  border: 1px solid var(--pro-border-default); border-radius: var(--pro-radius-sm);
  background: var(--pro-bg-subtle); color: var(--pro-text-primary);
}
.pro-filter__popsearch:focus { outline: none; box-shadow: var(--pro-focus-ring); }
.pro-filter__list { list-style: none; margin: 0; padding: 0; max-height: 190px; overflow-y: auto; }
.pro-filter__list li[hidden] { display: none; }
.pro-filter__list label {
  display: flex; align-items: center; gap: 0.55em;
  padding: 0.4em 0.3em; border-radius: var(--pro-radius-sm);
  font-size: var(--pro-font-size-sm); color: var(--pro-text-secondary); cursor: pointer;
}
.pro-filter__list label:hover { background: var(--pro-bg-subtle); color: var(--pro-text-primary); }
.pro-filter__list input { accent-color: var(--pro-brand-500); width: 15px; height: 15px; }
.pro-filter__empty { font-size: var(--pro-font-size-sm); color: var(--pro-text-muted); padding: 0.4em 0.3em; }
.pro-filter__actions { display: flex; justify-content: space-between; gap: var(--pro-space-2); border-top: 1px solid var(--pro-border-subtle); padding-top: var(--pro-space-2); }
.pro-filter__actions button {
  font-family: inherit; font-size: var(--pro-font-size-sm); background: none; border: 0;
  color: var(--pro-text-link); cursor: pointer; padding: 0.2em 0.4em; border-radius: var(--pro-radius-sm);
}
.pro-filter__actions button:hover { background: var(--pro-bg-subtle); }

/* --- Chips de selección múltiple (5–8 opciones, ej. estados) ------------ */
.pro-chipset { display: flex; flex-wrap: wrap; gap: var(--pro-space-2); }

/* --- Fila de filtros aplicados: el estado SIEMPRE visible ---------------- */
/* min-height reserva el alto de la fila: sin esto, al aplicar el primer
   filtro aparece la fila y todo el tablero salta bajo el cursor. */
.pro-filterbar__active { display: flex; flex-wrap: wrap; gap: var(--pro-space-2); align-items: center; min-height: 26px; }
.pro-filterbar__result {
  font-size: var(--pro-font-size-sm); color: var(--pro-text-secondary);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.pro-filterbar__result strong { color: var(--pro-text-primary); font-weight: var(--pro-font-weight-bold); }
.pro-filterbar__clear {
  font-family: inherit; font-size: var(--pro-font-size-sm); background: none; border: 0;
  color: var(--pro-text-link); cursor: pointer; padding: 0.25em 0.5em; border-radius: var(--pro-radius-sm);
}
.pro-filterbar__clear:hover { background: var(--pro-bg-subtle); }

/* ==========================================================================
   1c · SELECTOR DE PERÍODO (rango desde/hasta, por año o por mes)
   --------------------------------------------------------------------------
   Modelo de selección (el de los selectores de rango, predecible):
     1er clic → fija un extremo · 2º clic → cierra el rango · 3º → empieza otro.
   Las flechas ‹ › corren la ventana de años/meses: nunca una lista larga.
   ========================================================================== */
.pro-period { position: relative; }
.pro-period__pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: var(--pro-z-dropdown);
  width: 300px; background: var(--pro-bg-surface);
  border: 1px solid var(--pro-border-default); border-radius: var(--pro-radius-md, 8px);
  box-shadow: var(--pro-shadow-lg); padding: var(--pro-space-3);
  display: flex; flex-direction: column; gap: var(--pro-space-3);
}
.pro-period__pop[hidden] { display: none; }
.pro-period__presets { display: flex; flex-wrap: wrap; gap: var(--pro-space-2); }

.pro-period__nav { display: flex; align-items: center; justify-content: space-between; gap: var(--pro-space-2); }
.pro-period__nav button {
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--pro-border-default); background: var(--pro-bg-surface);
  color: var(--pro-text-secondary); display: grid; place-items: center; font-size: 14px; line-height: 1;
}
.pro-period__nav button:hover { background: var(--pro-bg-subtle); color: var(--pro-text-primary); }
.pro-period__nav button:disabled { opacity: 0.35; cursor: not-allowed; }
.pro-period__navlabel {
  font-size: var(--pro-font-size-sm); font-weight: var(--pro-font-weight-bold);
  color: var(--pro-text-primary); font-variant-numeric: tabular-nums;
}

/* Tira de celdas. Sin separación horizontal para que el rango se lea continuo. */
.pro-period__strip { display: grid; gap: 4px 0; }
.pro-period__strip--year  { grid-template-columns: repeat(3, 1fr); }
.pro-period__strip--month { grid-template-columns: repeat(4, 1fr); }
.pro-period__cell {
  font-family: inherit; font-size: var(--pro-font-size-sm); line-height: 1;
  padding: 0.55em 0; border: 0; background: transparent; cursor: pointer;
  color: var(--pro-text-secondary); border-radius: var(--pro-radius-full, 999px);
  font-variant-numeric: tabular-nums;
}
.pro-period__cell:hover { background: var(--pro-bg-subtle); color: var(--pro-text-primary); }
.pro-period__cell.is-in {
  background: var(--pro-brand-100); color: var(--pro-brand-900); border-radius: 0;
}
.pro-period__cell.is-start, .pro-period__cell.is-end, .pro-period__cell.is-single {
  background: var(--pro-brand-400); color: #1c1714; font-weight: var(--pro-font-weight-bold);
}
.pro-period__cell.is-start { border-radius: 999px 0 0 999px; }
.pro-period__cell.is-end   { border-radius: 0 999px 999px 0; }
.pro-period__cell.is-single{ border-radius: 999px; }
.pro-period__cell:disabled { opacity: 0.3; cursor: not-allowed; }
.pro-period__cell:focus-visible { outline: none; box-shadow: var(--pro-focus-ring); }

.pro-period__hint { font-size: var(--pro-font-size-xs, 0.75rem); color: var(--pro-text-muted); }

/* CAMPOS DESDE / HASTA · hacen visible el modelo antes de tocar nada.
   El campo resaltado es el que se está eligiendo, y se puede clickear para
   corregir sólo ese extremo (sin rehacer el rango entero). */
.pro-period__ends { display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--pro-space-2); align-items: center; }
.pro-period__end {
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
  width: 100%; padding: 6px 10px; cursor: pointer; font-family: inherit; text-align: left;
  background: var(--pro-bg-surface); border: 1px solid var(--pro-border-default);
  border-radius: var(--pro-radius-md, 8px);
}
.pro-period__end small {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--pro-text-muted); line-height: 1;
}
.pro-period__end span {
  font-size: var(--pro-font-size-sm); font-weight: var(--pro-font-weight-bold);
  color: var(--pro-text-primary); font-variant-numeric: tabular-nums; line-height: 1.2;
}
.pro-period__end.is-active { border-color: var(--pro-brand-400); background: var(--pro-brand-100); }
.pro-period__end.is-active small { color: var(--pro-brand-900); }
.pro-period__arrow { color: var(--pro-text-muted); font-size: 14px; }

/* Vista previa del rango mientras se elige el segundo extremo */
.pro-period__cell.is-preview { background: var(--pro-brand-100); color: var(--pro-brand-900); border-radius: 0; }

@media (max-width: 720px) {
  /* En pantallas angostas cada grupo ocupa una fila completa y el rótulo va
     arriba: así nunca queda un rótulo huérfano al lado de otro control. */
  .pro-search { flex-basis: 100%; }
  .pro-filterbar__group { flex: 1 1 100%; flex-direction: column; align-items: flex-start; gap: var(--pro-space-1); }
  .pro-filterbar__group .pro-segmented { width: 100%; justify-content: space-between; }
  .pro-filterbar__group .pro-segmented__opt { flex: 1; text-align: center; }
  .pro-filter, .pro-period { flex: 1 1 100%; }
  .pro-filter__btn, .pro-period > .pro-filter__btn { width: 100%; justify-content: space-between; }
  .pro-filter__pop, .pro-period__pop { width: 100%; }
}

/* ==========================================================================
   2 · PANEL (contenedor de gráfico o tabla)
   ========================================================================== */
.pro-panel {
  background: var(--pro-bg-surface);
  border: 1px solid var(--pro-border-subtle);
  border-radius: var(--pro-radius-lg, 12px);
  padding: var(--pro-space-5);
  display: flex; flex-direction: column;
  min-width: 0;                      /* permite que el contenido se encoja */
}
.pro-panel--flush { padding: 0; overflow: hidden; }
.pro-panel__head {
  display: flex; flex-wrap: wrap; gap: var(--pro-space-3);
  align-items: baseline; justify-content: space-between;
  margin-bottom: var(--pro-space-4);
}
.pro-panel--flush .pro-panel__head { padding: var(--pro-space-5) var(--pro-space-5) 0; margin-bottom: var(--pro-space-3); }
.pro-panel__title { font-size: var(--pro-font-size-base); font-weight: var(--pro-font-weight-bold); margin: 0; }
.pro-panel__sub { font-size: var(--pro-font-size-sm); color: var(--pro-text-muted); margin: var(--pro-space-1) 0 0; }
.pro-panel__foot { margin-top: auto; padding-top: var(--pro-space-4); font-size: var(--pro-font-size-sm); color: var(--pro-text-muted); }

/* ==========================================================================
   3 · KPI / TARJETA DE VALOR
   ========================================================================== */
.pro-kpi { display: flex; flex-direction: column; gap: var(--pro-space-2); }
.pro-kpi__label {
  font-size: var(--pro-font-size-sm); color: var(--pro-text-secondary);
  text-transform: uppercase; letter-spacing: 0.04em; margin: 0;
}
.pro-kpi__value {
  font-size: clamp(1.75rem, 3vw, 2.5rem); font-weight: var(--pro-font-weight-bold);
  line-height: 1; margin: 0; font-variant-numeric: tabular-nums;
  color: var(--pro-text-primary);
}
.pro-kpi__meta { display: flex; align-items: center; gap: var(--pro-space-2); flex-wrap: wrap; }
.pro-kpi__note { font-size: var(--pro-font-size-sm); color: var(--pro-text-muted); }

/* Delta (variación). El signo + icono acompañan al color: nunca color solo. */
.pro-delta {
  display: inline-flex; align-items: center; gap: 0.25em;
  font-size: var(--pro-font-size-sm); font-weight: var(--pro-font-weight-bold);
  font-variant-numeric: tabular-nums;
}
.pro-delta--up   { color: var(--pro-success-fg); }
.pro-delta--down { color: var(--pro-error-fg); }
.pro-delta--flat { color: var(--pro-text-muted); }

/* --- KPI con ícono de estado -------------------------------------------
   El ícono + la etiqueta llevan el significado; el color refuerza, nunca
   comunica solo. Los colores de ESTADO están reservados: no usarlos como
   serie en un gráfico. */
.pro-kpi__top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--pro-space-3); }
.pro-kpi__icon {
  flex: none; width: 40px; height: 40px; border-radius: var(--pro-radius-md, 8px);
  display: grid; place-items: center;
  background: var(--pro-bg-muted); color: var(--pro-text-secondary);
}
.pro-kpi__icon svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* Variantes de estado: tiñen ícono y (opcionalmente) el número */
.pro-kpi--success .pro-kpi__icon { background: var(--pro-success-bg); color: var(--pro-success-fg); }
.pro-kpi--warning .pro-kpi__icon { background: var(--pro-warning-bg); color: var(--pro-warning-fg); }
.pro-kpi--error   .pro-kpi__icon { background: var(--pro-error-bg);   color: var(--pro-error-fg); }
.pro-kpi--info    .pro-kpi__icon { background: var(--pro-info-bg);    color: var(--pro-info-fg); }
.pro-kpi--brand   .pro-kpi__icon { background: var(--pro-brand-200);  color: var(--pro-brand-900); }
.pro-kpi--inactive .pro-kpi__icon { background: var(--pro-state-inactive-bg); color: var(--pro-state-inactive-fg); }

/* Número en color de estado: usar SOLO cuando el estado ES el mensaje
   (ej. "próximos a caducar"), no como decoración. */
.pro-kpi__value--success { color: var(--pro-success-fg); }
.pro-kpi__value--warning { color: var(--pro-warning-fg); }
.pro-kpi__value--error   { color: var(--pro-error-fg); }
.pro-kpi__value--info    { color: var(--pro-info-fg); }
.pro-kpi__value--inactive { color: var(--pro-state-inactive-fg); }

/* Barra de acento superior: refuerza el estado sin gritar */
.pro-panel--accent { border-top: 3px solid var(--pro-border-default); }
.pro-panel--accent-success { border-top-color: var(--pro-success-500); }
.pro-panel--accent-warning { border-top-color: var(--pro-warning-500); }
.pro-panel--accent-error   { border-top-color: var(--pro-error-500); }
.pro-panel--accent-info    { border-top-color: var(--pro-info-500); }
.pro-panel--accent-brand   { border-top-color: var(--pro-brand-400); }
.pro-panel--accent-inactive { border-top-color: var(--pro-state-inactive-border); }

/* Sparkline opcional dentro del KPI */
.pro-sparkline { display: block; width: 100%; height: 32px; overflow: visible; }
.pro-sparkline path { fill: none; stroke: var(--pro-chart-tonal-mid); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ==========================================================================
   4 · CHIPS
   --------------------------------------------------------------------------
   Chip = etiqueta compacta de estado/categoría. Los de estado llevan punto
   (no dependen solo del color). Variantes de tono reutilizan tokens semánticos.
   ========================================================================== */
.pro-chip {
  display: inline-flex; align-items: center; gap: 0.4em;
  padding: 0.25em 0.7em;
  border-radius: var(--pro-radius-full, 999px);
  border: 1px solid transparent;
  font-size: var(--pro-font-size-sm);
  font-weight: var(--pro-font-weight-medium);
  line-height: 1.4;
  white-space: nowrap;
  background: var(--pro-bg-muted); color: var(--pro-text-secondary);
}
.pro-chip--sm { font-size: var(--pro-font-size-xs, 0.75rem); padding: 0.15em 0.55em; }

/* Punto indicador (secundario al color de fondo) */
.pro-chip__dot { width: 0.5em; height: 0.5em; border-radius: 50%; background: currentColor; flex: none; }

/* Estados semánticos */
.pro-chip--success { background: var(--pro-success-bg); color: var(--pro-success-fg); border-color: var(--pro-success-border); }
.pro-chip--warning { background: var(--pro-warning-bg); color: var(--pro-warning-fg); border-color: var(--pro-warning-border); }
.pro-chip--error   { background: var(--pro-error-bg);   color: var(--pro-error-fg);   border-color: var(--pro-error-border); }
.pro-chip--info    { background: var(--pro-info-bg);    color: var(--pro-info-fg);    border-color: var(--pro-info-border); }
.pro-chip--brand   { background: var(--pro-brand-200);  color: var(--pro-brand-900); }
.pro-chip--outline { background: transparent; border-color: var(--pro-border-default); color: var(--pro-text-secondary); }

/* INACTIVO · lo que YA ocurrió (caducado, cerrado, archivado). No es una
   alerta: nadie puede accionar sobre el pasado, así que va en gris. El rojo
   queda reservado para lo que exige una acción ahora. */
.pro-chip--inactive { background: var(--pro-state-inactive-bg); color: var(--pro-state-inactive-fg); border-color: var(--pro-state-inactive-border); }

/* AUTORÍA · dos valores de una MISMA dimensión → dos pasos relacionados,
   ambos con color (nunca uno con color y otro sin). */
.pro-chip--own     { background: var(--pro-brand-200); color: var(--pro-brand-900); border-color: var(--pro-brand-300); }
.pro-chip--support { background: var(--pro-chart-tonal-faint); color: var(--pro-chart-tonal-strong); border-color: var(--pro-chart-tonal-soft); }

/* Chip interactivo (filtro). Seleccionado = fondo de marca, no solo borde. */
.pro-chip--filter { cursor: pointer; background: transparent; border-color: var(--pro-border-default); color: var(--pro-text-secondary); font-family: inherit; }
.pro-chip--filter:hover { background: var(--pro-bg-subtle); }
.pro-chip--filter[aria-pressed="true"] { background: var(--pro-brand-200); border-color: var(--pro-brand-400); color: var(--pro-brand-900); }
.pro-chip--filter:focus-visible { outline: none; box-shadow: var(--pro-focus-ring); }

/* Chip removible */
.pro-chip__close { background: none; border: 0; cursor: pointer; color: inherit; font-size: 1.1em; line-height: 1; padding: 0; opacity: 0.7; }
.pro-chip__close:hover { opacity: 1; }

/* ==========================================================================
   5 · TABLA DE DATOS
   ========================================================================== */
.pro-data-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: var(--pro-font-size-sm); height: auto !important; }
.pro-data-table th {
  text-align: left !important; font-weight: 500 !important;
  text-transform: uppercase; font-size: var(--pro-font-size-xs, 0.75rem); letter-spacing: 0.04em;
  color: var(--pro-text-muted);
  padding: 0.5rem 0.75rem !important;
  border-bottom: 1px solid var(--pro-border-default);
  background: var(--pro-bg-surface);
  position: sticky; top: 0; z-index: 1;
  vertical-align: middle !important;
  height: 40px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
.pro-data-table th:first-child, .pro-data-table td:first-child {
  padding-left: 1.25rem !important;
}
.pro-data-table th:last-child, .pro-data-table td:last-child {
  padding-right: 2rem !important;
}
.pro-data-table td {
  padding: 0.5rem 0.75rem !important;
  border-bottom: 1px solid var(--pro-border-subtle);
  color: var(--pro-text-secondary);
  vertical-align: middle !important;
  text-align: left !important;
  white-space: nowrap !important;
  font-weight: normal !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
.pro-data-table tbody { height: auto !important; }
.pro-data-table tbody tr:not(.pro-detail-row) { height: 44px !important; max-height: 44px !important; }
.pro-data-table tbody tr:not(.pro-detail-row) td { height: 44px !important; padding-top: 0.4rem !important; padding-bottom: 0.4rem !important; }
.pro-data-table tbody tr.pro-detail-row { height: auto !important; }
.pro-data-table tbody tr.pro-detail-row td { height: auto !important; padding: 1.25rem 2rem !important; vertical-align: top !important; white-space: normal !important; overflow: visible !important; }
.pro-data-table tbody tr:hover { background: var(--pro-bg-subtle); }
.pro-data-table tbody tr:last-child td { border-bottom: 0; }
.pro-data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.pro-data-table .strong { color: var(--pro-text-secondary); font-weight: normal !important; }
.pro-table-scroll { overflow-x: auto; flex: none !important; }

/* ==========================================================================
   6 · PAGINACIÓN PRO (PILL ELEGANTE EN 1 LÍNEA)
   ========================================================================== */
.pro-pagination-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 1.25rem 0 0.5rem 0;
}

.pro-pagination-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--pro-bg-surface, #ffffff);
  border: 1px solid var(--pro-border-subtle, #e2e8f0);
  border-radius: 9999px;
  padding: 0.35rem 1.1rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.pro-pagination__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 4px;
  border-radius: 50%;
  border: none;
  background: transparent !important;
  color: var(--pro-text-secondary, #475569);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  text-decoration: none;
}

.pro-pagination__btn:hover:not(:disabled):not(.pro-pagination__btn--active) {
  color: var(--pro-text-primary, #0f172a);
  background: rgba(0, 0, 0, 0.05) !important;
}

.pro-pagination__btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.pro-pagination__btn--active {
  background: #3b82f6 !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.pro-pagination__ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 28px;
  color: var(--pro-text-muted, #94a3b8);
  font-size: 13px;
}

.pro-pagination__divider {
  width: 1px;
  height: 18px;
  background-color: var(--pro-border-subtle, #e2e8f0);
  margin: 0 0.35rem;
}

.pro-pagination__goto {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 13px;
  color: var(--pro-text-muted, #64748b);
  white-space: nowrap;
  margin: 0;
  padding: 0;
  border: none;
}

.pro-pagination__input {
  width: 44px;
  height: 26px;
  padding: 0 0.3rem;
  border: 1px solid var(--pro-border-default, #cbd5e1);
  border-radius: 6px;
  background: var(--pro-bg-surface, #ffffff);
  color: var(--pro-text-primary, #0f172a);
  font-size: 12px;
  text-align: center;
  outline: none;
  transition: all 0.15s ease;
}

.pro-pagination__input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.pro-pagination__input::-webkit-inner-spin-button,
.pro-pagination__input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.pro-pagination__input[type=number] {
  -moz-appearance: textfield;
}

/* Barra de progreso en celda (magnitud dentro de la tabla) */
.pro-cell-bar { display: flex; align-items: center; gap: var(--pro-space-2); }
.pro-cell-bar__track { flex: 1; height: 6px; min-width: 48px; background: var(--pro-bg-muted); border-radius: 3px; overflow: hidden; }
.pro-cell-bar__fill { height: 100%; background: var(--pro-chart-tonal-mid); border-radius: 3px; }

/* ==========================================================================
   6 · GRÁFICOS — ARMAZÓN COMÚN
   ========================================================================== */
.pro-chart { position: relative; }

/* Leyenda (obligatoria con 2+ series) */
.pro-legend { display: flex; flex-wrap: wrap; gap: var(--pro-space-4); margin-bottom: var(--pro-space-4); }
.pro-legend__item { display: inline-flex; align-items: center; gap: 0.5em; font-size: var(--pro-font-size-sm); color: var(--pro-text-secondary); }
.pro-legend__swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* Ejes y grilla: recesivos */
.pro-plot { position: relative; display: flex; gap: var(--pro-space-3); }
.pro-axis-y {
  display: flex; flex-direction: column-reverse; justify-content: space-between;
  font-size: var(--pro-font-size-xs, 0.75rem); color: var(--pro-text-muted);
  font-variant-numeric: tabular-nums; text-align: right; flex: none;
  padding-bottom: 1.5rem;      /* deja lugar a las etiquetas del eje X */
}
.pro-plot__area { position: relative; flex: 1; min-width: 0; }
.pro-gridlines { position: absolute; inset: 0 0 1.5rem 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.pro-gridlines span { display: block; border-top: 1px solid var(--pro-border-subtle); }

/* ==========================================================================
   7 · BARRAS VERTICALES (columnas) — simples, agrupadas y apiladas
   ========================================================================== */
.pro-bars { position: relative; display: flex; align-items: flex-end; gap: var(--pro-space-2); height: var(--pro-chart-h, 220px); padding-bottom: 1.5rem; }
.pro-bars__group { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; position: relative; }

/* Fila de barras dentro del grupo (2px de aire entre barras contiguas) */
.pro-bars__set { display: flex; align-items: flex-end; justify-content: center; gap: 2px; width: 100%; height: 100%; }

/* La barra: alto por --v (0–100), grosor tope 24px, extremo redondeado */
.pro-bar {
  width: 100%; max-width: 24px;
  height: calc(var(--v, 0) * 1%);
  background: var(--pro-chart-tonal-mid);
  border-radius: 4px 4px 0 0;       /* extremo de dato redondeado, base recta */
  align-self: flex-end;
  transition: filter var(--pro-duration-fast, 150ms) ease;
}
.pro-bars__group:hover .pro-bar { filter: brightness(1.06); }

/* Etiqueta de categoría bajo cada grupo */
.pro-bars__label {
  position: absolute; bottom: -1.5rem; left: 0; right: 0;
  text-align: center; font-size: var(--pro-font-size-xs, 0.75rem);
  color: var(--pro-text-muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
/* Valor sobre la barra (etiqueta directa, usar de forma selectiva).
   Se ancla a la altura de la barra: el grupo debe declarar el mismo --v. */
.pro-bars__value {
  position: absolute; left: 0; right: 0;
  bottom: calc(var(--v, 0) * 1%);
  margin-bottom: 6px;
  font-size: var(--pro-font-size-xs, 0.75rem); color: var(--pro-text-secondary);
  font-variant-numeric: tabular-nums; text-align: center; white-space: nowrap;
}

/* Apiladas: segmentos con 2px de superficie entre sí */
/* align-self: center — el grupo es flex en COLUMNA, así que "flex-end"
   desplazaría la pila hacia la derecha en vez de hacia abajo. */
.pro-bars__stack { width: 100%; max-width: 24px; height: calc(var(--v, 0) * 1%); display: flex; flex-direction: column-reverse; gap: 2px; align-self: center; }
.pro-bars__seg { width: 100%; height: calc(var(--s, 0) * 1%); background: var(--pro-chart-tonal-mid); }
.pro-bars__stack > .pro-bars__seg:last-child { border-radius: 4px 4px 0 0; }

/* ==========================================================================
   8 · BARRAS HORIZONTALES (ranking / categorías de nombre largo)
   ========================================================================== */
.pro-hbars { display: flex; flex-direction: column; gap: var(--pro-space-3); }
.pro-hbar { display: grid; grid-template-columns: minmax(80px, 26%) 1fr auto; gap: var(--pro-space-3); align-items: center; }
.pro-hbar__label { font-size: var(--pro-font-size-sm); color: var(--pro-text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pro-hbar__track { background: var(--pro-bg-subtle); border-radius: 4px; height: 16px; overflow: hidden; }
.pro-hbar__fill { height: 100%; width: calc(var(--v, 0) * 1%); background: var(--pro-chart-tonal-mid); border-radius: 0 4px 4px 0; }
.pro-hbar__value { font-size: var(--pro-font-size-sm); color: var(--pro-text-primary); font-variant-numeric: tabular-nums; font-weight: var(--pro-font-weight-medium); }

/* ==========================================================================
   9 · DONA / TORTA (parte-a-todo, pocas categorías)
   --------------------------------------------------------------------------
   Nota de método: para parte-a-todo con más de ~5 categorías, una barra
   apilada se lee mejor que una torta. Usar dona solo con pocas porciones.
   ========================================================================== */
.pro-donut-wrap { display: flex; align-items: center; gap: var(--pro-space-6); flex-wrap: wrap; }
.pro-donut { position: relative; flex: none; width: 180px; height: 180px; }
.pro-donut svg { transform: rotate(-90deg); display: block; width: 100%; height: 100%; }
.pro-donut circle { fill: none; stroke-width: 18; }
/* separación entre porciones: anillo del color de la superficie */
.pro-donut .pro-donut__gap { stroke: var(--pro-bg-surface); stroke-width: 22; }
.pro-donut__center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; pointer-events: none;
}
.pro-donut__value { font-size: 1.5rem; font-weight: var(--pro-font-weight-bold); line-height: 1; font-variant-numeric: tabular-nums; }
.pro-donut__label { font-size: var(--pro-font-size-xs, 0.75rem); color: var(--pro-text-muted); margin-top: 2px; }

/* Leyenda con valores (hace de etiqueta directa para la dona) */
.pro-donut-legend { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: var(--pro-space-2); }
.pro-donut-legend__row { display: grid; grid-template-columns: 12px 1fr auto; gap: var(--pro-space-2); align-items: center; font-size: var(--pro-font-size-sm); }
.pro-donut-legend__swatch { width: 10px; height: 10px; border-radius: 3px; }
.pro-donut-legend__name { color: var(--pro-text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pro-donut-legend__val { color: var(--pro-text-primary); font-variant-numeric: tabular-nums; font-weight: var(--pro-font-weight-medium); }

/* ==========================================================================
   10 · TOOLTIP (capa de hover)
   ========================================================================== */
.pro-tooltip {
  position: fixed; z-index: 999; pointer-events: none;
  background: var(--pro-bg-inverse); color: var(--pro-text-inverse);
  padding: var(--pro-space-2) var(--pro-space-3);
  border-radius: var(--pro-radius-md, 8px);
  font-size: var(--pro-font-size-sm); line-height: 1.4;
  box-shadow: var(--pro-shadow-lg);
  opacity: 0; transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
  max-width: 240px;
}
.pro-tooltip.is-visible { opacity: 1; transform: translateY(0); }
.pro-tooltip__title { font-weight: var(--pro-font-weight-bold); display: block; margin-bottom: 2px; }
.pro-tooltip__row { display: flex; align-items: center; gap: 0.5em; white-space: nowrap; }
.pro-tooltip__swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.pro-tooltip__val { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: var(--pro-font-weight-bold); }

/* ==========================================================================
   11 · COLOR POR FUNCIÓN — elegir la familia según lo que el dato SIGNIFICA
   --------------------------------------------------------------------------
   TONAL (por defecto): comparar dentro de una misma familia.
   ÉNFASIS: una serie es el foco, el resto es contexto.
   CATEGÓRICA (.pro-s1..4): solo entidades distintas. Máximo 4.
   ========================================================================== */

/* Tonal — misma familia, distinta intensidad */
.pro-tonal-strong { background: var(--pro-chart-tonal-strong); }
.pro-tonal-mid    { background: var(--pro-chart-tonal-mid); }
.pro-tonal-soft   { background: var(--pro-chart-tonal-soft); }
.pro-tonal-faint  { background: var(--pro-chart-tonal-faint); }

/* Énfasis — foco vs contexto (ej. 2025 vs 2024) */
.pro-focus   { background: var(--pro-chart-focus); }
.pro-brand-fill { background: var(--pro-chart-brand); }
.pro-context { background: var(--pro-chart-context); }

/* Categórica — orden fijo por posición, nunca reciclar */
.pro-s1 { background: var(--pro-chart-1); }
.pro-s2 { background: var(--pro-chart-2); }
.pro-s3 { background: var(--pro-chart-3); }
.pro-s4 { background: var(--pro-chart-4); }

/* Trazos SVG (dona, líneas) */
.pro-stroke-1 { stroke: var(--pro-chart-1); }
.pro-stroke-2 { stroke: var(--pro-chart-2); }
.pro-stroke-3 { stroke: var(--pro-chart-3); }
.pro-stroke-4 { stroke: var(--pro-chart-4); }
.pro-stroke-tonal-strong { stroke: var(--pro-chart-tonal-strong); }
.pro-stroke-tonal-mid    { stroke: var(--pro-chart-tonal-mid); }
.pro-stroke-tonal-soft   { stroke: var(--pro-chart-tonal-soft); }
.pro-stroke-tonal-faint  { stroke: var(--pro-chart-tonal-faint); }

/* ==========================================================================
   12 · BARRAS SUPERPUESTAS (subconjunto dentro de un total)
   --------------------------------------------------------------------------
   Para "de N proyectos, M son propios": una sola barra con el total en tono
   suave y el subconjunto en tono fuerte, ambos desde la misma base. Al ser la
   MISMA familia de color, se lee como "parte de", no como dos cosas opuestas.
   Uso: <div class="pro-bars__group" style="--total:70;--own:45"> …
   ========================================================================== */
.pro-bars__overlay {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 24px;
  height: calc(var(--total, 0) * 1%);
  background: var(--pro-chart-tonal-soft);
  border-radius: 4px 4px 0 0;
}
.pro-bars__overlay-own {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 60%; max-width: 14px;
  height: calc(var(--own, 0) * 1%);
  background: var(--pro-chart-brand);
  border-radius: 3px 3px 0 0;
}

/* Impresión: los tableros se imprimen con fondos */
@media print {
  .pro-dash { background: #fff; }
  .pro-panel { break-inside: avoid; box-shadow: none; }
}
