/* Tokens del Manual de Front End Einteligent 2026 (Diseño tableros imputs.pdf) */
:root {
  /* 3.1 imagotipo */
  --logo-negro: #000000;
  --logo-gris: #525252;
  --logo-azul: #0174FD;
  /* 3.2 colores principales (gráficas) */
  --g-azul-claro: #6FD6FF;
  --g-azul: #0174FD;
  --g-azul-oscuro: #003A82;
  --g-verde: #82C842;
  --g-verde-seco: #64B178;
  /* alertas */
  --a-rojo: #B10404;
  --a-salmon: #F26E5F;
  --a-naranja: #FF7B22;
  /* textos y componentes */
  --t-menu: #6D7D80;
  --t-general: #545454;
  --t-deshabilitado: #C5C5C5;
  --c-mapas: #6D5BBA;
  --c-dynamic: #69B445;
  --c-lease: #00B3FF;
  --c-citronella: #FF931E;
  /* columnas y fondos */
  --f-header: #000000;
  --f-tabla-1: #FFFFFF;
  --f-tabla-2: #F0F4F9;
  --f-tabla-titulo: #C2E7FF;
  --f-general: #E9EEF6;
  --f-secundario: #F0F1F1;
  --f-hover: #FFEB99;
  /* 12. botones */
  --btn-primario: #2201B2;
  --btn-rechazo: #EE4C01;
  /* derivados */
  --card-radius: 22px;
  --card-shadow: 0 10px 26px rgba(0, 58, 130, 0.10), 0 2px 6px rgba(0, 58, 130, 0.06);
  --font: Calibri, "Segoe UI", -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  font-size: 14px;                 /* cuerpo: Calibri regular 14 */
  color: var(--t-general);
  background: var(--f-general);
  min-height: 100vh;
}

/* ---------- header negro (manual: fondo de header #000000) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--f-header);
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 64px;
  border-bottom: 1px solid rgba(255,255,255,.10);
}
.topbar img.ei { height: 26px; display: block; }
.topbar .sep { width: 1px; height: 26px; background: rgba(255,255,255,.25); }
.topbar .sistema { color: #fff; font-size: 15px; letter-spacing: .4px; opacity: .92; }
.topbar nav { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar nav a {
  display: inline-flex; align-items: center; justify-content: center; min-height: 38px;
  color: #eef3f8; text-decoration: none; font-size: 13.5px; font-weight: 700;
  padding: 8px 15px; border: 1px solid rgba(255,255,255,.22); border-radius: 11px;
  background: rgba(255,255,255,.06); box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
  transition: color .16s ease, background .16s ease, border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.topbar nav a:hover {
  color: #fff; background: rgba(1,116,253,.24); border-color: rgba(111,214,255,.70);
  box-shadow: 0 7px 18px rgba(0,0,0,.22); transform: translateY(-1px);
}
.topbar nav a.activo {
  background: #fff; border-color: #fff; color: #102c47;
  box-shadow: 0 7px 20px rgba(0,0,0,.25);
} /* manual 3.2: menú activo claro */
.topbar nav a[data-tab="ai-live"] { border-color: rgba(111,214,255,.48); }
.topbar nav a[data-tab="ai-live"].panel-open { color: #fff; background: var(--g-azul); border-color: var(--g-azul); }

/* ---------- head de la vista (card Head 10%) ---------- */
.head-card {
  background: #fff; border-radius: var(--card-radius); box-shadow: var(--card-shadow);
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  padding: 14px 26px; margin: 22px 26px 0;
}
.head-card img.banorte { height: 30px; }
.head-card h1 {
  font-size: 21px;                 /* título: Calibri regular 21 y altas */
  font-weight: 400; text-transform: uppercase; letter-spacing: 1px;
  color: var(--t-general); flex: 1; text-align: center; min-width: 220px;
}
.head-card .corte { font-size: 12.5px; color: var(--t-menu); text-align: right; line-height: 1.35; }
.head-card .corte b { color: var(--t-general); font-weight: 700; }

/* tabs de vistas dentro del tablero */
.tabs {
  display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 26px 0;
}
.tabs a {
  text-decoration: none; color: var(--t-menu); background: #fff;
  border: 1px solid transparent; border-radius: 999px; padding: 8px 18px;
  font-size: 14px; box-shadow: var(--card-shadow); transition: all .15s;
}
.tabs a:hover { background: var(--f-hover); color: var(--t-general); }
.tabs a.activo { background: var(--btn-primario); color: #fff; }

/* ---------- grid de cards (manual: distribución 30/30, 30/15/15, 40, 20) ---------- */
main { padding: 18px 26px 40px; display: grid; gap: 18px; grid-template-columns: repeat(20, 1fr); }

/* ---------- portada: directorio operativo ---------- */
.home-main { grid-template-columns: minmax(0,1fr); gap: 20px; padding-top: 20px; }
.home-main .home-kpis {
  grid-column: 1 / -1;
  padding: 18px 22px 20px; border: 1px solid rgba(0,58,130,.08); box-shadow: 0 9px 24px rgba(0,58,130,.07);
  animation: homeEnter .32s ease both;
}
.home-main .home-kpis .kpi-row { gap: 0; margin-top: 8px; border-top: 1px solid #e7edf4; }
.home-main .home-kpis .kpi {
  border-radius: 0; background: transparent; padding: 14px 12px 5px;
  border-right: 1px solid #e7edf4;
}
.home-main .home-kpis .kpi:last-child { border-right: 0; }
.home-directory { grid-column: 1 / -1; min-width: 0; animation: homeEnter .38s .05s ease both; }
.home-directory-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 2px 2px 14px;
}
.home-directory-head h2 { color: #17324d; font-size: 22px; line-height: 1.1; }
.home-directory-head p { max-width: 520px; color: var(--t-menu); font-size: 12.5px; line-height: 1.45; text-align: right; }
.home-eyebrow {
  display: block; margin-bottom: 5px; color: #075bbd; font-size: 10.5px; font-weight: 800;
  letter-spacing: .11em; text-transform: uppercase;
}
.home-board-grid {
  display: grid; grid-template-columns: minmax(0,1.25fr) minmax(0,1.1fr) minmax(220px,.72fr); gap: 14px;
}
.home-board {
  min-width: 0; padding: 18px; border: 1px solid rgba(0,58,130,.12); border-radius: 18px;
  background: rgba(255,255,255,.82); box-shadow: 0 7px 20px rgba(0,58,130,.055);
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.home-board:hover { border-color: rgba(1,116,253,.28); box-shadow: 0 12px 28px rgba(0,58,130,.09); transform: translateY(-2px); }
.home-board > header { display: flex; align-items: center; gap: 12px; }
.home-board-icon {
  display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 13px;
  color: #075bbd; background: #e8f3ff; border: 1px solid #cfe5fb;
}
.home-board-icon svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.home-board-title { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.home-board-title strong { color: #17324d; font-size: 17px; line-height: 1.15; }
.home-board-title small { color: var(--t-menu); font-size: 11px; }
.home-board > p { min-height: 34px; margin: 12px 0 13px; color: #60788d; font-size: 12px; line-height: 1.45; }
.home-board-actions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; }
.home-board-actions a {
  display: flex; min-width: 0; min-height: 38px; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 10px; border: 1px solid #d5e1eb; border-radius: 10px; color: #294862;
  background: #fff; text-decoration: none; font-size: 11.5px; font-weight: 700; line-height: 1.2;
  transition: color .15s ease, background .15s ease, border-color .15s ease, transform .15s ease;
}
.home-board-actions a b { flex: none; color: #7e96aa; font-size: 15px; transition: transform .15s ease; }
.home-board-actions a:hover, .home-board-actions a:focus-visible {
  color: #075bbd; background: #f1f8ff; border-color: #8fc2fb; transform: translateY(-1px);
}
.home-board-actions a:hover b, .home-board-actions a:focus-visible b { color: var(--g-azul); transform: translateX(2px); }
.home-board-actions a.recommended { color: #075bbd; background: #eef7ff; border-color: #b8d9fa; }
.home-board-calidad { align-self: start; }
.home-board-calidad .home-board-actions { grid-template-columns: 1fr; }
.home-board-calidad .home-board-actions a { min-height: 46px; }
.home-source {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; min-width: 0;
  padding: 12px 15px; border: 1px solid rgba(0,58,130,.11); border-radius: 15px; color: #294862;
  background: rgba(255,255,255,.60); animation: homeEnter .38s .10s ease both;
}
.home-source-mark { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 50%; background: #eaf7ee; }
.home-source-mark i { width: 9px; height: 9px; border-radius: 50%; background: var(--g-verde-seco); box-shadow: 0 0 0 4px rgba(100,177,120,.14); }
.home-source > div { min-width: 0; flex: 1; }
.home-source strong { display: block; margin-bottom: 2px; color: #17324d; font-size: 12.5px; }
.home-source p { color: var(--t-menu); font-size: 11.5px; line-height: 1.35; }
.home-source .badge { position: static; flex: none; }
@keyframes homeEnter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.loading-workspace {
  grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px;
  min-height: 310px; align-content: start;
}
.loading-workspace-copy { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 4px; padding: 6px 2px 0; }
.loading-workspace-copy b { color: #17324d; font-size: 16px; }
.loading-workspace-copy span { color: var(--t-menu); font-size: 12px; }
.loading-skeleton {
  height: 168px; border-radius: var(--card-radius); background: linear-gradient(100deg, #fff 22%, #f5f8fb 36%, #fff 50%);
  background-size: 240% 100%; box-shadow: var(--card-shadow); animation: liveSkeleton 1.4s ease-in-out infinite;
}
.loading-skeleton.wide { grid-column: 1 / -1; height: 86px; }
@keyframes liveSkeleton { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.card {
  background: #fff; border-radius: var(--card-radius); box-shadow: var(--card-shadow);
  padding: 18px 22px 20px; min-width: 0; position: relative;
  display: flex; flex-direction: column;
}
.card.w30 { grid-column: span 10; }
.card.w15 { grid-column: span 5; }
.card.w35 { grid-column: span 15; }
.card.w40, .card.w20 { grid-column: span 20; }
.card.w25 { grid-column: span 7; }
@media (max-width: 980px) { .card.w30, .card.w15, .card.w25, .card.w35 { grid-column: span 20; } }
@media (max-width: 900px) {
  .home-board-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .home-board-calidad { grid-column: 1 / -1; }
  .home-board-calidad .home-board-actions { max-width: 340px; }
}
@media (max-width: 640px) {
  main { padding: 12px 12px 32px; gap: 12px; }
  .head-card { margin: 12px 12px 0; padding: 12px 16px; }
  .tabs { margin: 12px 12px 0; }
  .card { padding: 14px 16px 16px; }
  .card h2 { padding-right: 0; }
  .card > .card-tags { position: static; order: -1; align-self: flex-start; margin-bottom: 8px; flex-wrap: wrap; }
  .topbar { padding: 8px 12px 10px; gap: 10px; height: auto; min-height: 48px; flex-wrap: wrap; }
  .topbar .sistema, .topbar .sep { display: none; }
  .topbar nav { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); width: 100%; margin-left: 0; }
  .topbar nav a { width: 100%; min-height: 34px; padding: 6px 9px; font-size: 11.5px; }
  .home-directory-head { align-items: flex-start; flex-direction: column; gap: 6px; }
  .home-directory-head p { text-align: left; }
  .home-board-grid { grid-template-columns: 1fr; }
  .home-board-calidad { grid-column: auto; }
  .home-board-actions { grid-template-columns: 1fr; }
  .home-board > p { min-height: 0; }
  .home-source { align-items: flex-start; flex-wrap: wrap; }
  .home-source > div { flex-basis: calc(100% - 50px); }
  .home-main .home-kpis .kpi { min-width: 50%; border-bottom: 1px solid #e7edf4; }
  .loading-workspace { grid-template-columns: 1fr; }
  .loading-skeleton, .loading-skeleton.wide { grid-column: 1; }
}

/* en cards angostas los tags fluyen arriba del título para no encimarse */
.card.w15 > .card-tags, .card.w25 > .card-tags { position: static; order: -1; align-self: flex-start; margin-bottom: 8px; }
.card.w15 h2, .card.w25 h2 { padding-right: 0; }

.card h2 {
  font-size: 18px;                 /* manual p.5: subtítulo Calibri REGULAR 18, altas y bajas */
  font-weight: 400; color: var(--t-general); margin-bottom: 4px; padding-right: 130px;
}
.card .sub { font-size: 13px; color: var(--t-menu); margin-bottom: 12px; }

/* barra de datos embebida en celdas de tabla */
.databar { position: relative; display: block; min-width: 92px; text-align: right; }
.databar.mini { min-width: 54px; }
.databar i { position: absolute; left: 0; top: 1px; bottom: 1px; border-radius: 4px; }
.databar b { position: relative; font-weight: 400; }

/* delta comparativa bajo un dato duro */
.delta {
  text-align: center; font-weight: 700; font-size: 14px; cursor: default;
  padding: 4px 0 2px; letter-spacing: .2px;
}
.delta.up { color: #3d6b12; }
.delta.down { color: var(--a-rojo); }

/* bullet: valor actual vs marca de referencia (Stephen Few) */
.bullet { margin: 6px 18px 2px; }
.bullet .b-track {
  position: relative; height: 14px; border-radius: 7px;
  background: var(--f-tabla-2); overflow: visible; cursor: default;
}
.bullet .b-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  border-radius: 7px; background: var(--g-azul);
  transition: width .9s cubic-bezier(.2,.8,.2,1);
}
.bullet .b-ref {
  position: absolute; top: -4px; bottom: -4px; width: 3px; border-radius: 2px;
  background: var(--t-general); box-shadow: 0 0 0 1.5px #fff;
}
.bullet .b-leyenda { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--t-menu); margin-top: 8px; justify-content: center; }
.bullet .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.bullet .b-refsw { background: var(--t-general); width: 3px; border-radius: 2px; margin: 0 8px 0 5px; }

/* celda con tinte semafórico continuo (verde→amarillo→naranja→rojo) */
.heat { display: block; text-align: right; padding: 2px 8px; border-radius: 6px; min-width: 72px; }

/* banda de honestidad: la lógica del bloque no está confirmada */
.card.alerta-logica { border: 1.5px dashed var(--a-naranja); }
.aviso-logica {
  font-size: 12px; font-weight: 700; color: #9a4a00;
  background: rgba(255, 123, 34, .10); border-radius: 8px;
  padding: 5px 10px; margin-bottom: 10px; align-self: flex-start;
}

/* mini-barra apilada de contexto (real vs estimado) */
.mini-stack { margin: 2px 0 12px; }
.mini-stack .ms-bar, .mezcla-fila .ms-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; }
.mini-stack .ms-bar i, .mezcla-fila .ms-bar i { display: block; cursor: default; transition: width .8s cubic-bezier(.2,.8,.2,1); }
.mini-stack .ms-leyenda { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--t-menu); margin-top: 6px; }
.mini-stack .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
/* mezcla 100% por fila (label + barra apilada) — vista 3 C1 y reutilizable */
.mezcla-fila { display: flex; align-items: center; gap: 10px; margin: 7px 0; }
.mezcla-fila .lbl { font-size: 12.5px; color: var(--t-menu); min-width: 96px; text-align: right; }

/* dato duro (manual: Calibri Bold 100) */
.dato-duro { text-align: center; padding: 12px 0 6px; }
.dato-duro .num {
  font-weight: 700; color: var(--t-general);
  font-size: clamp(48px, 7vw, 100px); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.dato-duro .etiqueta { font-size: 18px; color: var(--t-general); margin-top: 10px; font-weight: 700; }

/* KPI triple (vista 2): el dato duro por estado con lectura semántica */
.kpi-triple { display: flex; flex-direction: column; gap: 12px; padding: 8px 0 4px; }
.kpi-triple .fila { padding: 8px 12px; border-radius: 14px; background: var(--f-tabla-2); cursor: default; }
.kpi-triple .num {
  font-weight: 700; color: var(--t-general); line-height: 1.05;
  font-size: clamp(30px, 3.4vw, 48px); font-variant-numeric: tabular-nums;
}
.kpi-triple .etiqueta { font-size: 14.5px; color: var(--t-general); font-weight: 700; margin-top: 3px; }
.kpi-triple .share { font-size: 12px; color: var(--t-menu); margin-top: 1px; }
.kpi-triple .hip {
  font-size: 10.5px; font-weight: 700; letter-spacing: .3px; vertical-align: 2px;
  padding: 2px 8px; border-radius: 999px; background: var(--f-hover); color: #7a5e00;
}
.hip { /* chip ámbar reutilizable fuera del kpi-triple (hipótesis / alerta suave) */
  font-size: 10.5px; font-weight: 700; letter-spacing: .3px;
  padding: 2px 8px; border-radius: 999px; background: var(--f-hover); color: #7a5e00;
  white-space: nowrap;
}

/* fila resaltada en tablas (p.ej. nodo único de resguardo) */
.tabla-wrap tr.fila-alerta td { background: rgba(255, 123, 34, .13); }
/* fila seleccionada por clic (V7-C3: estado fijado para los mini-KPIs) —
   color opaco para que la columna sticky no se transparente */
.tabla-wrap tr.fila-sel td { background: #E6F0FE; }
.tabla-wrap.matriz tbody tr.fila-sel td:first-child { background: #E6F0FE; }
.tabla-wrap.matriz tbody tr.fila-sel:hover td:first-child { background: var(--f-hover); }
/* dentro de una celda, el chip ámbar baja a su propia línea (no ensancha la columna) */
.tabla-wrap td .hip { display: block; width: fit-content; margin-top: 2px; }
/* fila fantasma: hueco del tablero original hecho visible (V4-C2, "2023 sin registro") */
.tabla-wrap tr.fantasma td {
  color: var(--t-menu); font-style: italic;
  background: repeating-linear-gradient(45deg, transparent 0 7px, rgba(109, 125, 128, .07) 7px 14px);
}
/* sparkline embebido en celda de tabla (Charts.spark) */
.tabla-wrap td .spark { display: inline-block; vertical-align: middle; }
/* matriz ancha (V7-C3, patrón T5): encabezado y primera columna fijos dentro de
   su propio scroll — el thead ya es sticky-top global; el contenedor recibe
   scroll vertical y la columna Estado fondo opaco por estado de fila
   (zebra/hover/total) para que el contenido pase por debajo sin transparentarse */
.tabla-wrap.matriz { max-height: 620px; overflow: auto; }
.tabla-wrap.matriz thead th { z-index: 3; }
.tabla-wrap.matriz th:first-child, .tabla-wrap.matriz td:first-child {
  position: sticky; left: 0; z-index: 2; background: #fff;
  box-shadow: 4px 0 6px -4px rgba(44, 74, 90, .22);
}
.tabla-wrap.matriz thead th:first-child { z-index: 4; background: var(--f-tabla-titulo); }
.tabla-wrap.matriz tbody tr:nth-child(even) td:first-child { background: var(--f-tabla-2); }
.tabla-wrap.matriz tbody tr:hover td:first-child { background: var(--f-hover); }
.tabla-wrap.matriz tbody tr.total td:first-child { background: #fff; }
/* franja de mini-KPIs sobre una gráfica (V6-C4): cifra + etiqueta con dot */
.mini-kpis { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 4px 0 10px; }
.mini-kpis .mk { cursor: default; }
.mini-kpis .v { font-weight: 700; font-size: 24px; color: var(--t-general); margin-right: 8px; }
.mini-kpis .l { font-size: 12px; color: var(--t-menu); }

/* micro-leyenda del mapa: top estados por intensidad relativa (V5-C4) */
.top-intensidad .fila { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin: 4px 0; cursor: default; }
.top-intensidad .rk { color: var(--t-menu); min-width: 14px; text-align: right; }
.top-intensidad .edo { min-width: 96px; }
.top-intensidad .bar { flex: 1; height: 8px; background: #F0F4F9; border-radius: 4px; overflow: hidden; }
.top-intensidad .bar i { display: block; height: 100%; background: linear-gradient(90deg, #C2E7FF, #003A82); border-radius: 4px; }
.top-intensidad .t { color: var(--t-menu); min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }

/* lista con pills de color (manual p.22, "Ejemplo de distribución": label + pill con la cifra) */
.pill-list { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; }
.pill-list .fila {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 5px 10px; border-radius: 10px;
}
.pill-list .fila { transition: opacity .18s; }
.pill-list .fila:hover { box-shadow: inset 0 0 0 999px rgba(255, 235, 153, .45); } /* compone sobre la barra de share */
.pill-list:hover .fila:not(:hover) { opacity: .45; } /* focus + context */
.pill-list .etiqueta { font-size: 14px; color: var(--t-general); }
.pill-list .pill {
  min-width: 64px; text-align: center; padding: 3px 14px; border-radius: 999px;
  color: #fff; font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums;
}

/* KPIs por marca */
.kpi-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.kpi { flex: 1; min-width: 110px; text-align: center; padding: 10px 6px; border-radius: 14px; background: var(--f-tabla-2); }
.kpi .k-label { font-size: 13px; color: var(--t-menu); letter-spacing: .5px; }
.kpi .k-value { font-size: clamp(22px, 2.6vw, 34px); font-weight: 700; color: var(--g-azul); font-variant-numeric: tabular-nums; }
.kpi .k-detalle { font-size: 11.5px; color: var(--t-menu); margin-top: 4px; line-height: 1.35; }

/* ---------- procedencia + insights de card ---------- */
.card-tags {
  position: absolute; top: 16px; right: 18px;
  display: flex; gap: 8px; align-items: center;
}
.badge {
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
  padding: 4px 11px; border-radius: 999px; cursor: default; white-space: nowrap;
}
.insight-chip {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(34, 1, 178, .08); color: var(--btn-primario);
  font-size: 13px; cursor: default; transition: all .15s;
}
.insight-chip:hover { background: var(--btn-primario); color: #fff; }
/* foco visible por teclado en todo lo interactivo (Tab) */
.chip:focus-visible, .leyenda .item:focus-visible, .insight-chip:focus-visible,
.badge:focus-visible, .tabla-wrap tr:focus-visible, .tabs a:focus-visible,
.topbar nav a:focus-visible, th.ordenable:focus-visible {
  outline: 2px solid var(--btn-primario); outline-offset: 2px; border-radius: 6px;
}
/* ✦ vivo: el chip muestra lecturas recalculadas de la vista filtrada */
.insight-chip.vivo::after {
  content: ""; position: absolute; top: -2px; right: -2px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #0174FD; border: 2px solid #fff;
}
.badge.auditado { background: rgba(130, 200, 66, .18); color: #3d6b12; }
.badge.en_vivo { background: rgba(1, 116, 253, .14); color: #004d9f; box-shadow: inset 0 0 0 1px rgba(1,116,253,.18); }
.badge.vivo_contexto { background: linear-gradient(90deg, rgba(1,116,253,.14), rgba(130,200,66,.17)); color: #244d73; }
.badge.contexto_fijo { background: rgba(130,200,66,.18); color: #3d6b12; }
.badge.mixto_vivo { background: linear-gradient(90deg, rgba(1,116,253,.13), rgba(130,200,66,.17)); color: #244d73; }
.badge.referencia_pptx { background: var(--f-hover); color: #7a5e00; }
.badge.medido_pptx { background: rgba(1, 116, 253, .12); color: #0b4f9e; }
.badge.pendiente { background: var(--f-secundario); color: var(--t-menu); }

.nota { font-size: 12px; color: var(--t-menu); margin-top: 10px; line-height: 1.45; border-top: 1px solid var(--f-tabla-2); padding-top: 8px; }

.live-summary {
  grid-column: span 20; display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 16px; background: rgba(1,116,253,.07);
  border: 1px solid rgba(1,116,253,.12); color: var(--t-general);
}
.live-summary .badge { position: static; flex: none; }
.live-summary p { margin: 0; font-size: 13.5px; line-height: 1.45; }
.fixed-context-list { margin: 0; padding-left: 20px; color: var(--t-menu); line-height: 1.55; }
.offline-message { padding: 18px; border-radius: 14px; background: rgba(177,4,4,.06); color: var(--t-general); line-height: 1.5; }
.live-assistant-card { min-height: 230px; justify-content: center; }
.live-assistant-copy { max-width: 680px; color: var(--t-menu); line-height: 1.55; }
.live-assistant-link {
  align-self: flex-start; display: inline-flex; padding: 11px 18px; border-radius: 12px;
  background: var(--g-azul); color: #fff; text-decoration: none; font-weight: 700;
}
.live-assistant-link:hover { background: #003A82; }

/* placeholder pendiente */
.pend {
  flex: 1; min-height: 150px; border: 2px dashed var(--t-deshabilitado); border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; color: var(--t-menu); font-size: 14px; text-align: center; padding: 18px;
}
.pend .icono { font-size: 26px; opacity: .55; }

/* ---------- tablas (manual: títulos #C2E7FF, fondos blanco/#F0F4F9, hover #FFEB99) ---------- */
.tabla-wrap { overflow-x: auto; flex: 1; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
thead th {
  background: var(--f-tabla-titulo); color: var(--t-general); font-weight: 700;
  padding: 8px 12px; text-align: left; white-space: nowrap; position: sticky; top: 0;
}
thead th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody td { padding: 7px 12px; white-space: nowrap; }
tbody tr:nth-child(even) { background: var(--f-tabla-2); }
tbody tr:hover { background: var(--f-hover); }
tbody tr.total td { font-weight: 700; border-top: 2px solid var(--f-tabla-titulo); background: #fff; }
td .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: baseline; }

/* ---------- gráficas ---------- */
.chart { width: 100%; flex: 1; min-height: 0; }
.chart svg { display: block; width: 100%; height: auto; }
.leyenda { display: flex; gap: 16px; flex-wrap: wrap; margin: 4px 0 10px; font-size: 13px; font-weight: 700; color: var(--t-general); } /* manual p.9: leyendas en Calibri Bold */
.leyenda .item { display: flex; align-items: center; gap: 6px; }
.leyenda .sw { width: 11px; height: 11px; border-radius: 3px; }

.leyenda .item.clicable { cursor: pointer; user-select: none; }
.leyenda .item.clicable:hover { opacity: .75; }
.leyenda .item.apagado { opacity: .35; text-decoration: line-through; }

/* selector de granularidad (manual p.8: Q/M/W → aquí M/T/A) */
.gran { display: inline-flex; gap: 0; margin-left: auto; }
.gran .chip { border-radius: 0; min-width: 40px; padding: 0 12px; margin-left: -1.5px; }
.gran .chip:first-child { border-radius: 999px 0 0 999px; margin-left: 0; }
.gran .chip:last-child { border-radius: 0 999px 999px 0; }

/* facetas (paneles gemelos con la misma escala) */
.facetas { display: flex; gap: 14px; flex-wrap: wrap; }
.faceta { flex: 1; min-width: 280px; }
.faceta-titulo { text-align: center; font-size: 13.5px; color: var(--t-menu); margin-bottom: 4px; }

/* herramientas de tabla (manual 14: búsqueda pill con contorno) */
.tabla-tools { display: flex; gap: 10px; align-items: center; margin: 2px 0 10px; flex-wrap: wrap; }
.buscador {
  height: 34px; border-radius: 999px; border: 1.5px solid var(--t-deshabilitado);
  padding: 0 16px 0 36px; font-family: var(--font); font-size: 13.5px; color: var(--t-general);
  /* manual 3.2: campos de texto sobre #E9EEF6 */
  background: var(--f-general) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="%236D7D80" stroke-width="2.4"><circle cx="11" cy="11" r="7"/><line x1="16.5" y1="16.5" x2="21" y2="21"/></svg>') 13px center no-repeat;
  min-width: 180px; outline: none;
}
.buscador:focus { border-color: var(--g-azul); }
th.ordenable { cursor: pointer; user-select: none; }
th.ordenable:hover { background: var(--f-hover); }

/* tooltip (manual 3.2: #FFEB99 = fondo de etiquetas de cursor del mouse) */
#tooltip {
  position: fixed; z-index: 100; pointer-events: none; display: none;
  background: var(--f-hover); border-radius: 10px; box-shadow: 0 6px 22px rgba(0,58,130,.22);
  padding: 8px 12px; font-size: 13px; color: var(--t-general); max-width: 300px;
}
#tooltip b { color: var(--logo-negro); }

/* ---------- filtros / botones (manual 12: pill 160x43 / 80x43) ---------- */
.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.chip {
  border: 1.5px solid var(--t-deshabilitado); background: #fff; color: var(--t-general);
  border-radius: 999px; height: 34px; padding: 0 16px; font-family: var(--font); font-size: 13.5px;
  cursor: pointer; transition: all .15s;
}
.chip:hover { background: var(--f-hover); }
.chip.activo { background: var(--btn-primario); border-color: var(--btn-primario); color: #fff; }
select.chip { background: var(--f-general); } /* manual 3.2: campos de texto = #E9EEF6 */
.chip:disabled { color: var(--t-deshabilitado); cursor: not-allowed; background: var(--f-secundario); }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 160px; height: 43px; border-radius: 999px; border: none;
  background: var(--btn-primario); color: #fff; font-family: var(--font); font-size: 15px; cursor: pointer;
}
.btn.secundario { background: #fff; color: var(--btn-primario); border: 1.5px solid var(--btn-primario); }

/* ---------- modal de zoom estatal ---------- */
.modal-fondo {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0, 20, 45, .45); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 26px;
}
.modal-card {
  background: #fff; border-radius: var(--card-radius); box-shadow: var(--card-shadow);
  padding: 18px 22px; width: min(880px, 100%); max-height: 92vh;
  display: flex; flex-direction: column; gap: 10px;
}
.modal-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.modal-head h2 { font-size: 21px; font-weight: 400; text-transform: uppercase; letter-spacing: 1px; color: var(--t-general); } /* manual p.5: título 21 regular y altas */
.modal-sub { font-size: 12.5px; color: var(--t-menu); flex: 1; }
.modal-cerrar { margin-left: auto; }
.modal-lienzo { overflow: auto; flex: 1; min-height: 0; display: flex; justify-content: center; }
.zoom-chart { width: 100%; }
.zoom-chart svg { display: block; width: 100%; height: auto; max-height: 62vh; margin: 0 auto; }
.modal-pie { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.leyenda-relieve { width: 220px; min-width: 180px; }
.leyenda-relieve svg { display: block; width: 100%; height: auto; }
.modal-pie .nota { flex: 1; min-width: 240px; }

/* ---------- lectura inteligente (capa #3) ---------- */
.card.intel { border-top: 4px solid var(--btn-primario); }
.intel .narrativa {
  font-size: 14.5px; line-height: 1.55; color: var(--t-general);
  max-width: 1080px; margin-bottom: 14px;
}
.hallazgos { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 10px; }
.hallazgo {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--f-tabla-2); border-radius: 14px; padding: 11px 14px;
  font-size: 13px; line-height: 1.5;
}
.hallazgo .h-ic { font-size: 13px; line-height: 1.5; flex: none; }
.hallazgo.sev-info .h-ic { color: var(--g-azul); }
.hallazgo.sev-alerta .h-ic { color: var(--a-naranja); }
.hallazgo.sev-critico .h-ic { color: var(--a-rojo); }
.hallazgo.sev-critico { background: rgba(177, 4, 4, 0.06); }
.fuente-chip {
  display: inline-block; margin-top: 7px; font-size: 11px; font-family: var(--font);
  color: var(--t-menu); background: #fff; border: 1px solid var(--t-deshabilitado);
  border-radius: 999px; padding: 2.5px 10px; cursor: pointer; transition: all .15s;
}
.fuente-chip:hover { background: var(--f-hover); color: var(--t-general); }
.card.flash { animation: flashCard 1.8s ease; }
@keyframes flashCard {
  0%, 55% { box-shadow: 0 0 0 3px var(--btn-primario), var(--card-shadow); }
  100% { box-shadow: var(--card-shadow); }
}

/* botón de export PNG (aparece al pasar el cursor por la card) */
.png-btn {
  position: absolute; bottom: 12px; right: 14px; z-index: 5;
  font-family: var(--font); font-size: 11.5px; color: var(--t-menu);
  background: #fff; border: 1px solid var(--t-deshabilitado); border-radius: 999px;
  padding: 3px 12px; cursor: pointer; opacity: 0; transition: opacity .15s, background .15s;
}
.card:hover .png-btn { opacity: 1; }
.png-btn:hover { background: var(--f-hover); color: var(--t-general); }

/* accesibilidad: sin animaciones cuando el usuario lo pide */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* footer discreto */
footer { text-align: center; padding: 8px 0 26px; font-size: 12px; color: var(--t-menu); }
footer a { color: var(--g-azul); text-decoration: none; }

/* ---------- Vista 9 · Calidad de Datos ---------- */
/* V9-C1: KPI con anillo de progreso (severidad semántica) */
.kpi.con-anillo { cursor: default; }
.kpi .k-aro { position: relative; width: 92px; height: 92px; margin: 6px auto 2px; }
.kpi .k-aro .anillo { position: absolute; inset: 0; width: 100%; height: 100%; }
.kpi .k-aro .anillo circle:last-child { transition: stroke-dashoffset .9s cubic-bezier(.2,.8,.2,1); }
.kpi .k-aro .k-value {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
@media (prefers-reduced-motion: reduce) {
  .kpi .k-aro .anillo circle:last-child { transition: none; }
}

/* V9-C3: par de la corrección C2 (mismo cruce, join corregido) */
.par-c2 {
  margin: 10px 0 14px; padding: 12px 14px; border-radius: 14px;
  background: var(--f-tabla-2); cursor: default; font-size: 13px;
}
.par-c2 .pc-titulo { font-weight: 700; margin-bottom: 8px; }
.par-c2 .pc-fila { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.par-c2 .pc-bar {
  position: relative; flex: 1; height: 14px; background: #F0F4F9;
  border-radius: 7px; overflow: hidden; min-width: 120px;
}
.par-c2 .pc-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 7px; }
.par-c2 .pc-val {
  font-size: 11.5px; color: #545454; min-width: 46px; text-align: right;
  font-variant-numeric: tabular-nums;
}
.par-c2 .pc-conector { color: var(--t-menu); font-size: 12px; margin: 2px 0 2px 18px; }
.par-c2 .pc-adoptado {
  margin-top: 8px; font-size: 12px; color: #3d7a1e;
  background: rgba(130, 200, 66, .14); border-radius: 8px; padding: 6px 10px;
}

/* V9-C5: llaves colapsadas a resumen */
.llaves-resumen {
  display: flex; align-items: center; gap: 12px; margin: 10px 0;
  padding: 12px 14px; border-radius: 14px; background: var(--f-tabla-2);
}
.llaves-resumen .ok {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: rgba(130, 200, 66, .18); color: #3d7a1e; font-size: 18px; font-weight: 700;
}
.llaves-resumen .det { font-size: 12.5px; color: var(--t-menu); }
.llaves-resumen .chip { margin-left: auto; }

/* ---------- brush de rango temporal (navigator bajo las líneas) ---------- */
.brush { margin: 2px 0 0; }
.brush svg { display: block; width: 100%; }

/* ---------- Asistente (capa #3, vista 11) ----------
   El hero oscuro es la ÚNICA excepción declarada al manual: el visual de onda
   de voz (referencia del usuario) pide fondo oscuro; los azules son del manual. */
.asis-hero {
  background: radial-gradient(120% 140% at 50% 0%, #0A1A30 0%, #050D1A 70%);
  color: #E9EEF6;
}
.asis-hero h2 { color: #fff; padding-right: 0; }
.asis-hero .asis-sub { font-size: 13.5px; color: #9FB4CC; line-height: 1.45; max-width: 880px; }
.asis-onda { display: block; width: 100%; height: 170px; margin: 6px 0 2px; }
.asis-nota-visual { font-size: 11.5px; color: #5C7492; }

.asis-chat { display: flex; flex-direction: column; gap: 10px; }
.asis-historial {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 460px; overflow-y: auto; padding: 4px 2px;
}
.asis-msg { max-width: 78%; border-radius: 16px; padding: 10px 14px; font-size: 14px; line-height: 1.5; }
.asis-msg.user { align-self: flex-end; background: var(--btn-primario); color: #fff; border-bottom-right-radius: 6px; }
.asis-msg.bot { align-self: flex-start; background: var(--f-general); border-bottom-left-radius: 6px; }
.asis-resp { white-space: pre-wrap; }
.asis-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.asis-pill {
  display: inline-flex; align-items: center; gap: 7px; background: #fff;
  border-radius: 999px; padding: 4px 11px; font-size: 12.5px; box-shadow: 0 1px 3px rgba(0,58,130,.10);
}
.asis-pill b { color: var(--g-azul); }
.asis-ins { margin-top: 8px; font-size: 12.5px; color: var(--t-general); display: flex; flex-direction: column; gap: 3px; }
.asis-adv {
  margin-top: 8px; font-size: 12.5px; color: #7a5e00; background: var(--f-hover);
  border-radius: 10px; padding: 7px 10px; display: flex; flex-direction: column; gap: 4px;
}
.asis-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 9px; }
.asis-meta .badge { position: static; }
.asis-ver { text-decoration: none; display: inline-flex; align-items: center; }
.asis-ops { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.asis-ops .chip { white-space: normal; text-align: left; height: auto; min-height: 34px; padding: 6px 12px; }
.asis-chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.asis-chips .chip { white-space: normal; height: auto; min-height: 34px; padding: 6px 12px; text-align: left; }
.asis-chips-lbl { font-size: 12.5px; color: var(--t-menu); }
.asis-form { display: flex; gap: 8px; }
.asis-input { flex: 1; max-width: none; }
.asis-envia { background: var(--btn-primario); border-color: var(--btn-primario); color: #fff; }
@media (max-width: 640px) {
  .asis-msg { max-width: 94%; }
  .asis-onda { height: 120px; }
}

/* datos dentro de la respuesta: las partículas los "acomodan" al llegar */
.asis-dato { color: var(--g-azul); font-weight: 700; }
.asis-anima .asis-dato, .asis-anima .asis-pill b {
  opacity: 0; transform: translateY(5px);
  transition: opacity .28s ease, transform .34s ease;
}
.asis-anima .asis-dato.on, .asis-anima .asis-pill b.on { opacity: 1; transform: none; }
.asis-ia-estado b { color: #6FD6FF; font-weight: 700; }
.asis-chip-ia {
  display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 10px;
  font-size: 11.5px; font-weight: 700; color: #0b4f9e;
  background: linear-gradient(90deg, rgba(111,214,255,.25), rgba(1,116,253,.14));
}
.asis-espera { display: inline-flex; gap: 5px; padding: 4px 2px; }
.asis-espera span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--g-azul);
  animation: asisPunto 1.1s ease-in-out infinite;
}
.asis-espera span:nth-child(2) { animation-delay: .18s; }
.asis-espera span:nth-child(3) { animation-delay: .36s; }
@keyframes asisPunto { 0%, 100% { opacity: .25; transform: translateY(0); } 45% { opacity: 1; transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .asis-espera span { animation: none; opacity: .6; } }

/* ---------- integración: fuente SQL viva + acceso persistente a GPT Realtime ---------- */
.live-source {
  display: flex; align-items: center; gap: 9px; min-width: 230px;
  border-radius: 14px; padding: 8px 10px; background: var(--f-general);
  color: var(--t-general); box-shadow: inset 0 0 0 1px rgba(0,58,130,.07);
}
.live-source > span:nth-child(2) { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.live-source b { font-size: 12.5px; }
.live-source small { color: var(--t-menu); font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-source button {
  border: 0; background: #fff; color: var(--g-azul); border-radius: 10px;
  padding: 6px 8px; font: inherit; font-size: 11px; font-weight: 700; cursor: pointer;
}
.live-dot { width: 9px; height: 9px; flex: none; border-radius: 50%; background: #C5C5C5; }
.live-source.live .live-dot { background: #64B178; box-shadow: 0 0 0 4px rgba(100,177,120,.14); }
.live-source.loading .live-dot { background: #0174FD; animation: livePulse 1s ease-in-out infinite; }
.live-source.snapshot .live-dot { background: #FF931E; }
.live-source.offline .live-dot { background: #B10404; box-shadow: 0 0 0 4px rgba(177,4,4,.10); }
@keyframes livePulse { 50% { opacity: .35; transform: scale(.75); } }

.ai-targetable { cursor: pointer; transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease; }
.ai-targetable:hover { border-color: rgba(1,116,253,.25); }
.ai-targetable.ai-selected {
  border-color: rgba(1,116,253,.55);
  box-shadow: 0 0 0 3px rgba(1,116,253,.12), 0 12px 28px rgba(0,58,130,.13);
}
.ai-targetable.flash { animation: aiCardFlash 1.1s ease; }
@keyframes aiCardFlash { 35% { box-shadow: 0 0 0 7px rgba(1,116,253,.17), 0 12px 28px rgba(0,58,130,.13); } }
.ai-modified {
  display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px;
  color: #075bbd; background: #edf6ff; border: 1px solid #cfe6ff;
  font-size: 10px; font-weight: 700; white-space: nowrap;
}

/* ---------- lienzo libre: resultados nuevos creados por TAB IA ---------- */
.free-canvas {
  grid-column: 1 / -1; width: calc(100% - 32px); margin: 8px 16px 24px; padding: 0;
  border-top: 1px solid rgba(0,58,130,.15); background: transparent;
}
.free-canvas-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  padding: 24px 4px 16px;
}
.free-canvas-head h2 { margin: 0 0 4px; color: #17324d; font-size: 21px; font-weight: 700; }
.free-canvas-head p { margin: 0; max-width: 720px; color: var(--t-menu); font-size: 12.5px; line-height: 1.45; }
.free-canvas-create {
  flex: none; border: 0; border-radius: 12px; padding: 10px 14px;
  color: #fff; background: var(--g-azul); font: 700 12px/1 inherit; cursor: pointer;
  box-shadow: 0 8px 20px rgba(1,116,253,.18); transition: transform .16s ease, box-shadow .16s ease;
}
.free-canvas-create:hover { transform: translateY(-1px); box-shadow: 0 11px 24px rgba(1,116,253,.24); }
.free-canvas-results { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.free-canvas-empty {
  grid-column: 1 / -1; display: flex; min-height: 150px; flex-direction: column; justify-content: center; align-items: center;
  gap: 6px; border: 1px dashed #b8cbdd; border-radius: 18px; color: #6c8195; background: rgba(255,255,255,.54); text-align: center;
}
.free-canvas-empty strong { color: #294862; font-size: 14px; }
.free-canvas-empty span { max-width: 620px; font-size: 12px; }
.free-visual {
  min-width: 0; overflow: hidden; border: 1px solid rgba(0,58,130,.11); border-radius: 18px;
  background: #fff; box-shadow: 0 9px 25px rgba(0,58,130,.08); transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.free-visual:hover { transform: translateY(-1px); box-shadow: 0 13px 30px rgba(0,58,130,.12); }
.free-visual.selected { border-color: rgba(1,116,253,.55); box-shadow: 0 0 0 3px rgba(1,116,253,.11), 0 13px 30px rgba(0,58,130,.12); }
.free-visual > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 17px 18px 8px; }
.free-visual h3 { margin: 0 0 3px; color: #17324d; font-size: 16px; }
.free-visual header p { margin: 0; color: var(--t-menu); font-size: 11.5px; line-height: 1.4; }
.free-visual-actions { display: flex; gap: 6px; flex: none; }
.free-visual-actions button {
  border: 1px solid #d6e2ed; border-radius: 9px; padding: 6px 8px; color: #31516f; background: #fff; font: 700 10px/1 inherit; cursor: pointer;
}
.free-visual-actions button:hover { border-color: #8fc2fb; color: #075bbd; background: #f5faff; }
.free-visual-actions button.danger { color: #8b3a3a; }
.free-chart {
  position: relative; width: 100%; min-width: 0; height: 360px; min-height: 320px;
  overflow: hidden; background: #fff;
}
.free-chart svg { display: block; }
.free-table-wrap { max-height: 390px; margin: 8px 16px 12px; overflow: auto; border: 1px solid #e1e9f1; border-radius: 12px; }
.free-table { width: 100%; border-collapse: collapse; color: #2b4359; font-size: 11.5px; }
.free-table th { position: sticky; z-index: 1; top: 0; padding: 9px 10px; color: #17324d; background: #dff1ff; text-align: left; }
.free-table td { padding: 8px 10px; border-top: 1px solid #edf2f6; }
.free-table tr:nth-child(even) td { background: #f7f9fb; }
.free-visual-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 9px 16px 13px; color: #6c8195; font-size: 10px; border-top: 1px solid #edf2f6; }
.free-status { border-radius: 999px; padding: 3px 7px; color: #42637e; background: #eef4f8; }
.free-status.certified_join { color: #27733b; background: #e9f7ed; }
.free-status.exploratory { color: #8a5a0a; background: #fff3df; }
.free-error { margin: 16px; padding: 14px; border-radius: 12px; color: #8b3a3a; background: #fff0f0; font-size: 12px; }

.tab-ai-fab {
  position: fixed; z-index: 1000; right: 22px; bottom: 22px;
  display: flex; align-items: center; gap: 10px; min-width: 206px;
  padding: 9px 14px 9px 9px; border-radius: 18px; font: inherit; text-align: left;
  background: #fff; color: var(--t-general); box-shadow: 0 14px 38px rgba(0,58,130,.22);
  border: 1px solid rgba(1,116,253,.16); cursor: pointer; transition: transform .18s, box-shadow .18s, opacity .18s;
}
.tab-ai-fab:hover { transform: translateY(-2px); box-shadow: 0 18px 44px rgba(0,58,130,.28); }
.tab-ai-fab > span, .tab-ai-avatar {
  display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 13px;
  color: #fff; background: var(--g-azul); font-size: 14px; font-weight: 800;
}
.tab-ai-fab b { display: flex; flex-direction: column; font-size: 13px; }
.tab-ai-fab small { color: var(--t-menu); font-size: 10.5px; font-weight: 400; margin-top: 2px; }
.tab-ai-fab.busy > span { animation: tabAiPulse 1.2s ease-in-out infinite; }
.tab-ai-fab.has-unread::after {
  content: ""; position: absolute; top: 7px; right: 8px; width: 9px; height: 9px;
  border-radius: 50%; background: #64B178; box-shadow: 0 0 0 3px #fff;
}
.tab-ai-fab.panel-open { opacity: 0; pointer-events: none; transform: translateY(8px); }

.tab-ai-panel {
  position: fixed; z-index: 1100; right: 22px; bottom: 22px;
  width: min(410px, calc(100vw - 28px)); height: min(630px, calc(100vh - 44px));
  display: grid; grid-template-rows: auto auto minmax(150px, 1fr) auto auto;
  overflow: hidden; border-radius: 22px; border: 1px solid rgba(0,58,130,.12);
  background: #fff; box-shadow: 0 26px 70px rgba(0,36,83,.24);
  opacity: 0; pointer-events: none; transform: translateY(16px) scale(.97); transform-origin: bottom right;
  transition: opacity .2s ease, transform .2s ease;
}
.tab-ai-panel.open { opacity: 1; pointer-events: auto; transform: none; }
.tab-ai-head { display: flex; align-items: center; gap: 11px; padding: 14px 14px 10px; border-bottom: 1px solid #edf1f5; }
.tab-ai-avatar { width: 38px; height: 38px; border-radius: 12px; }
.tab-ai-heading { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.tab-ai-heading strong { color: #10233d; font-size: 14px; }
.tab-ai-heading small { color: var(--t-menu); font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab-ai-close {
  width: 34px; height: 34px; border: 0; border-radius: 11px; background: #f3f6f9; color: #567;
  font: 22px/1 inherit; cursor: pointer;
}
.tab-ai-prompts { display: flex; gap: 7px; overflow-x: auto; padding: 10px 12px 8px; scrollbar-width: none; }
.tab-ai-prompts::-webkit-scrollbar { display: none; }
.tab-ai-prompt {
  flex: none; border: 1px solid #dce7f1; border-radius: 999px; padding: 7px 10px;
  background: #fff; color: #31516f; font: 11px inherit; cursor: pointer; white-space: nowrap;
}
.tab-ai-prompt:hover { color: #075bbd; border-color: #9bc9ff; background: #f4f9ff; }
.tab-ai-log { overflow-y: auto; padding: 8px 12px 14px; background: linear-gradient(180deg, #fbfdff, #fff 28%); }
.tab-ai-message {
  width: fit-content; max-width: 88%; margin: 7px 0; padding: 10px 12px; border-radius: 15px;
  color: #1c3651; background: #edf2f8; font-size: 12.5px; line-height: 1.45; white-space: pre-wrap;
}
.tab-ai-message.user { margin-left: auto; color: #fff; background: var(--g-azul); border-bottom-right-radius: 5px; }
.tab-ai-message.assistant { border-bottom-left-radius: 5px; }
.tab-ai-message.system { color: #82570b; background: #fff6e6; border: 1px solid #f4d49b; }
.tab-ai-typing { display: inline-flex; gap: 4px; align-items: center; min-width: 42px; }
.tab-ai-typing i { width: 6px; height: 6px; border-radius: 50%; background: #4b769f; animation: tabAiDots 1s infinite ease-in-out; }
.tab-ai-typing i:nth-child(2) { animation-delay: .15s; }
.tab-ai-typing i:nth-child(3) { animation-delay: .3s; }
.tab-ai-message.notice {
  max-width: 100%; margin: 8px 0; padding: 8px 10px; border-radius: 10px;
  color: #31516f; background: #f4f8fb; border: 1px dashed #bfd2e2; font-size: 11px;
}
.tab-ai-status {
  display: grid; grid-template-columns: 8px minmax(0,1fr) auto; align-items: center; gap: 8px;
  min-height: 44px; padding: 6px 14px 4px; color: #60778d; border-top: 1px solid #edf2f6;
}
.tab-ai-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #64B178; }
.tab-ai-status.busy .tab-ai-status-dot { background: var(--g-azul); animation: tabAiPulse 1.2s infinite ease-in-out; }
.tab-ai-status.error .tab-ai-status-dot { background: #B10404; }
.tab-ai-status-copy { display: flex; min-width: 0; flex-direction: column; gap: 1px; }
.tab-ai-status-copy b { overflow: hidden; color: #405c76; font-size: 10.5px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.tab-ai-status-copy small { overflow: hidden; color: #7a8ea1; font-size: 9.5px; text-overflow: ellipsis; white-space: nowrap; }
.tab-ai-status em {
  border-radius: 999px; padding: 4px 7px; color: #075bbd; background: #e8f3ff;
  font-size: 9.5px; font-style: normal; font-weight: 700; white-space: nowrap;
}
.tab-ai-composer { display: grid; grid-template-columns: 42px minmax(0,1fr) 42px; gap: 8px; padding: 8px 10px 11px; }
.tab-ai-mic, .tab-ai-send {
  height: 42px; border: 0; border-radius: 13px; font: inherit; cursor: pointer;
}
.tab-ai-mic { color: #4b6984; background: #eef4f7; }
.tab-ai-mic.active { color: #fff; background: #64B178; box-shadow: 0 0 0 4px rgba(100,177,120,.14); }
.tab-ai-send { color: #fff; background: var(--g-azul); font-size: 22px; font-weight: 600; }
.tab-ai-composer textarea {
  width: 100%; max-height: 96px; resize: none; border: 1px solid #cbd9e6; border-radius: 14px;
  padding: 11px 12px; color: #1b3550; background: #fff; font: 12.5px/1.4 inherit; outline: none;
}
.tab-ai-composer textarea:focus { border-color: #67abf6; box-shadow: 0 0 0 3px rgba(1,116,253,.09); }
@keyframes tabAiPulse { 50% { opacity: .55; transform: scale(.9); } }
@keyframes tabAiDots { 0%, 70%, 100% { opacity: .28; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }

@media (max-width: 1050px) {
  .free-canvas-results { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .head-card .corte { display: none; }
  .live-source { min-width: 100%; order: 3; }
  .tab-ai-fab { min-width: auto; right: 14px; bottom: 14px; padding: 8px; border-radius: 16px; }
  .tab-ai-fab > b { display: none; }
  .tab-ai-panel { right: 8px; bottom: 8px; width: calc(100vw - 16px); height: min(640px, calc(100vh - 16px)); border-radius: 19px; }
  .free-canvas { width: calc(100% - 20px); margin-inline: 10px; }
  .free-canvas-head { align-items: flex-start; flex-direction: column; gap: 12px; }
  .free-canvas-results { grid-template-columns: 1fr; }
  .free-visual > header { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  .live-source.loading .live-dot, .tab-ai-fab.busy > span, .tab-ai-status.busy span, .tab-ai-typing i { animation: none; }
  .tab-ai-panel, .tab-ai-fab, .ai-targetable { transition: none; }
}
