/* ==========================================================
   ESTILOS DE USUARIOS
   ========================================================== */

[class^='estilo-usuario-'] {
  font-weight: 600 !important;
  text-align: center !important;
  font-size: 11px !important;
  color: #3a3939a8 !important;
  background-color: #424242;
  letter-spacing: 0.3px !important;
  user-select: none !important;
  overflow: hidden !important;
}

/* --- Colores definidos --- */
.estilo-usuario-001 {
  background-color: #2e7d32 !important;
  color: #ffffff !important;
}
.estilo-usuario-002 {
  background-color: #1976d2 !important;
  color: #ffffff !important;
}
.estilo-usuario-003 {
  background-color: #ffc107 !important;
  color: #4d4d4d !important;
}
.estilo-usuario-004 {
  background-color: #7b1fa2 !important;
  color: #ffffff !important;
}
.estilo-usuario-005 {
  background-color: #546e7a !important;
  color: #ffffff !important;
}
.estilo-usuario-006 {
  background-color: #9e9e9e !important;
  color: #333333 !important;
}
.estilo-usuario-007 {
  background-color: #009688 !important;
  color: #ffffff !important;
}
.estilo-usuario-008 {
  background-color: #0288d1 !important;
  color: #ffffff !important;
}
.estilo-usuario-009 {
  background-color: #26a69a !important;
  color: #ffffff !important;
}
.estilo-usuario-010 {
  background-color: #8e24aa !important;
  color: #ffffff !important;
}
.estilo-usuario-011 {
  background-color: #c2185b !important;
  color: #ffffff !important;
}
.estilo-usuario-012 {
  background-color: #ef6c00 !important;
  color: #ffffff !important;
}
.estilo-usuario-013 {
  background-color: #455a64 !important;
  color: #ffffff !important;
}
.estilo-usuario-014 {
  background-color: #43a047 !important;
  color: #ffffff !important;
}
.estilo-usuario-015 {
  background-color: #3949ab !important;
  color: #ffffff !important;
}

/* ==========================================================
   FIN DE ESTILOS DE USUARIOS
   ========================================================== */

/* ==========================================================
   ESTRUCTURA GENERAL
   ========================================================== */

/* --- GRID PRINCIPAL --- */
.grid {
  display: grid;
  grid-template-columns: 800px 1fr;
  grid-template-rows: auto 1fr;
  /* 60px navbar + 50px hueco inferior; sin padding/margin en Q3/Q4 para no romper sync de scroll */
  height: calc(100vh - 80px);
  width: 100%;
  overflow: hidden;
  --cell-height: 22px; /* Alto base (Q1/Q2 y controles) */
  --plan-body-row-height: 26px; /* Q3/Q4 + cabecera tareas: +4px respecto al base */
  --cell-width: 20px; /* Variable para el ancho de celdas */
}

/* --- Cuadrantes base --- */
.q1,
.q2,
.q3,
.q4 {
  border: 1px solid #aaa;
  box-sizing: border-box;
}

.q1 {
  background: #ffffff;
  grid-row: 1;
  grid-column: 1;
}
.q2 {
  background: #ffffff;
  grid-row: 1;
  grid-column: 2;
  overflow-x: auto;
  white-space: nowrap;
  margin-left: 4px;
}
.q3 {
  background: #fff3cd;
  grid-row: 2;
  grid-column: 1;
  overflow-y: auto;
}
.q4 {
  background: #d4edda;
  grid-row: 2;
  grid-column: 2;
  overflow: auto;
  white-space: nowrap;
  margin-left: 4px;
}

/* --- Divisor entre Q1 y Q2 --- */
.resizer {
  grid-row: 1 / span 2;
  grid-column: 2;
  width: 5px;
  cursor: col-resize;
  background: #ffffff;
  z-index: 10;
}

/* ==========================================================
   TABLAS GENERALES
   ========================================================== */

.q1 table,
.q3 table,
.q4 table {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
}

.q2 th,
.q1 th,
.q3 th,
.q3 td,
.q4 th,
.q4 td {
  border: 1px solid #aaaaaa3b;
  padding: 0 2px;
  height: var(--cell-height); /* Usar variable */
  line-height: var(--cell-height); /* Usar variable */
  font-size: 13px; /* Ajustado de 13px a 12px para consistencia */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  box-sizing: border-box;
}

.q2 td {
  border: 1px solid #55555571;
  padding: 0 2px;
  height: var(--cell-height); /* Usar variable */
  line-height: var(--cell-height); /* Usar variable */
  font-size: 13px; /* Ajustado de 13px a 12px para consistencia */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  box-sizing: border-box;
}

.q1 td {
  border: 1px solid #aaa;
  padding: 0 2px;
  height: var(--cell-height); /* Usar variable */
  line-height: var(--cell-height); /* Usar variable */
  font-size: 13px; /* Ajustado de 13px a 12px para consistencia */
  white-space: nowrap;

  text-overflow: ellipsis;
  text-align: left;
  box-sizing: border-box;
}
/* --- Forzar alturas en Q3 y Q4 (filas de tareas / calendario, + cabecera) --- */
.q3 table.tabla-tareas tr,
.q4 table.tabla-q4 tr {
  height: var(--plan-body-row-height);
  min-height: var(--plan-body-row-height);
}

.q3 th,
.q3 td,
.q4 th,
.q4 td {
  height: var(--plan-body-row-height);
  line-height: var(--plan-body-row-height);
}

/* Cabecera de columnas de tareas (vive en Q1; debe coincidir con alto de fila Q3/Q4) */
.q1 .tareas-th th {
  height: var(--plan-body-row-height);
  line-height: var(--plan-body-row-height);
}

.q4 table.tabla-q4 td:empty::after {
  content: '\200B'; /* previene colapso */
}

/* --- Inputs dentro de Q4 --- */
.q4 input {
  height: var(--plan-body-row-height);
  line-height: var(--plan-body-row-height);
  font-size: 13px;
  padding: 0 2px;
  box-sizing: border-box;
}

/* --- Estilo para input flotante --- */
.floating-input {
  position: fixed;
  width: 80px;
  height: var(--plan-body-row-height);
  line-height: var(--plan-body-row-height);
  font-size: 13px; /* Coincide con celdas */
  padding: 0 2px; /* Coincide con celdas */
  box-sizing: border-box;
  z-index: 999;
}

/* ==========================================================
   ANCHOS DE COLUMNAS
   ========================================================== */

.col-proy {
  width: 60px;
}
.col-seguimiento {
  width: 30px;
}
.col-id {
  width: 50px;
}
.col-resp {
  width: 50px;
}
.col-hp,
.col-hr {
  width: 30px;
}
.col-est {
  width: 70px;
}
.col-pri {
  width: 70px;
}
.col-av {
  width: 30px;
}
.col-fecha_inicio,
.col-fecha_fin {
  width: 75px;
}
.col-tarea {
  width: auto;
  min-width: 150px;
}

/* Resp(3), Estatus(6), Prioridad(7), F.INI(9), F.FIN(10) — contenido centrado */
.q1 th.hd_resp,
.q1 th.hd_estatus,
.q1 th.hd_prioridad,
.q1 th.hd_fini,
.q1 th.hd_ffin,
.q3 td[data-q3-col='3'],
.q3 td[data-q3-col='6'],
.q3 td[data-q3-col='7'],
.q3 td[data-q3-col='9'],
.q3 td[data-q3-col='10'],
.vista-tabla-q34 th.vt-th-center,
.vista-tabla-q34 td[data-vt-col='3'],
.vista-tabla-q34 td[data-vt-col='6'],
.vista-tabla-q34 td[data-vt-col='7'],
.vista-tabla-q34 td[data-vt-col='9'],
.vista-tabla-q34 td[data-vt-col='10'] {
  text-align: center;
}

/* ==========================================================
   ESTILOS DE ESTATUS (TAREAS)
   ========================================================== */

[class^='estilo-estatus-'] {
  font-weight: 600 !important;
  text-align: center !important;
  font-size: 10px !important;
  color: #3f3f3f !important;
  letter-spacing: 0.3px !important;
  user-select: none !important;
}

/* --- Etapas --- */
.estilo-estatus-PENDIENTE {
  background-color: #9e9e9e !important;
  color: #fff !important;
}
.estilo-estatus-PROGRAMADA {
  background-color: #607d8b !important;
  color: #fff !important;
}
.estilo-estatus-ASIGNADA {
  background-color: #546e7a !important;
  color: #fff !important;
}
.estilo-estatus-TERMINADA {
  background-color: #0549a1 !important;
  color: #a6d7ff !important;
}
.estilo-estatus-ACTIVA {
  background-color: #2e7d32 !important;
  color: #fff !important;
}
.estilo-estatus-PAUSA {
  background-color: #ffc107 !important;
  color: #000 !important;
}
.estilo-estatus-URGE {
  background-color: #e53935 !important;
  color: #fff !important;
}
.estilo-estatus-BLOQUEADA {
  background-color: #8e24aa !important;
  color: #fff !important;
}
.estilo-estatus-ATRASO {
  background-color: #d32f2f !important;
  color: #fff !important;
}
.estilo-estatus-REVISION {
  background-color: #0b62d2 !important;
  color: #fff !important;
}
.estilo-estatus-APROBADA {
  background-color: #009688 !important;
  color: #fff !important;
}
.estilo-estatus-ENCURSO {
  background-color: #2e7d32 !important;
  color: #fff !important;
}
.estilo-estatus-CANCELADA {
  background-color: #455a64 !important;
  color: #fff !important;
}
.estilo-estatus-RECHAZADA {
  background-color: #b71c1c !important;
  color: #fff !important;
}
.estilo-estatus-SIGUE {
  background-color: #c38c0a !important;
  color: #fff !important;
}

/* ==========================================================
   ESTILOS DE PRIORIDAD (TAREAS)
   ========================================================== */

[class^='estilo-prioridad-'] {
  font-weight: 600 !important;
  text-align: center !important;
  font-size: 10px !important;
  letter-spacing: 0.3px !important;
  user-select: none !important;
}

.estilo-prioridad-CRITICA {
  background-color: #b71c1c !important;
  color: #fff !important;
}
.estilo-prioridad-ALTA {
  background-color: #e65100 !important;
  color: #fff !important;
}
.estilo-prioridad-MEDIA {
  background-color: #f9a825 !important;
  color: #000 !important;
}
.estilo-prioridad-BAJA {
  background-color: #388e3c !important;
  color: #fff !important;
}
.estilo-prioridad-MINIMA {
  background-color: #757575 !important;
  color: #fff !important;
}

/* ==========================================================
   ESTILOS COMUNES / GENERALES
   ========================================================== */

.no-select {
  user-select: none !important;
}

.row-activa {
  background-color: #cce5ff;
}

/* --- Scroll oculto en Q2 y Q3 --- */
.q2::-webkit-scrollbar,
.q3::-webkit-scrollbar {
  display: none;
}

.q2,
.q3 {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* --- Días laborales y fines de semana --- */
.col-finsemana {
  background-color: #f0f0f0;
}

.col-laboral {
  background-color: #daf3e1;
}
.col-laboral-1 {
  background-color: #e2f1e7;
}

/* --- Filas zebra en Q3 --- */
.tabla-tareas tr:nth-child(even) td {
  background-color: #eaf3fc;
}
.tabla-tareas tr:nth-child(odd) td {
  background-color: #d9ecfa;
}

.celda-activa {
  outline: 2px solid #007bff !important;
  outline-offset: -2px;
  background-color: rgb(40, 121, 196);
}

/* --- Row activa sobrescribiendo zebra --- */
.row-activa td {
  background-color: transparent;
  background-color: #80cfff1f !important;
  color: #000 !important;
}

.q4 .row-activa td {
  color: #000000 !important;
}

/* ==========================================================
   ESTADOS DE CELDAS
   ========================================================== */

.q1 .tareas-th {
  background-color: #06396f;
  color: #fff;
}
.hd_seguimiento .bi {
  color: white !important;
  background: transparent !important;
}

.celda-ocupada {
  background-color: #86bff8 !important;
  color: #165896;
}

table.tabla-q4 .row-activa td.celda-x {
  background-color: #f7b7b7 !important;
  box-shadow: inset 0 -4px 0 0 #9b021c !important;
  color: #fff;
}

table.tabla-q4 tr td.celda-x {
  background-color: #f7b7b7 !important;
  color: #660000 !important;
  box-shadow: inset 0 -4px 0 0 #9b021c !important;
  font-weight: bold;
}

.row-activa td.celda-ocupada {
  background-color: #86bff8 !important;
  color: #165896;
}

.celda-pasada {
  background-color: #39ff1470;
  color: #000;
  opacity: 0.8;
  transition: background-color 0.3s ease;
}

.celda-activa.celda-pasada {
  background-color: #39ff14;
  border: 2px solid #000000;
}

/* ==========================================================
   Q1 – CABECERA
   ========================================================== */

.tareas-th th {
  font-weight: inherit !important;
  font-size: 12px !important;
}

.q1 table {
  table-layout: fixed;
}

.q1 th.hd_proy {
  width: 50px;
}
.q1 th.hd_seguimiento {
  width: 40px;
}
.q1 th.hd_id {
  width: 50px;
}
.q1 th.hd_tarea {
  width: auto;
  text-align: left;
}
.q1 th.hd_resp {
  width: 50px;
}
.q1 th.hd_hp,
.q1 th.hd_hr {
  width: 40px;
}
.q1 th.hd_estatus {
  width: 80px;
}
.q1 th.hd_prioridad {
  width: 70px;
}
.q1 th.hd_avance {
  width: 50px;
}
.q1 th.hd_fecha_inicio,
.q1 th.hd_fecha_fin {
  width: 80px;
}

.q1 td.menu_ops button {
  font-size: 12px;
  padding: 6px 10px 6px 10px;
  line-height: 1;
}

.q1 td.menu_ops .btn-vista-plan {
  width: 28px;
  height: 28px;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
}

.q1 td.menu_ops .btn-vista-plan .bi {
  font-size: 0.85rem;
  line-height: 1;
}

/* ==========================================================
   Q2 – CABECERA DE DÍAS
   ========================================================== */

.q2 table.tabla-dias {
  border-collapse: collapse;
  table-layout: fixed;
  width: max-content;
}

.q2 th,
.q2 td {
}

/* ==========================================================
   Q3 – TABLA DE TAREAS
   ========================================================== */

.q3 table.tabla-tareas {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
}

/* Menú de tarea (antes ícono documento / seguimiento) */
.celda-seguimiento {
  text-align: center;
  width: 25px;
  cursor: pointer;
  color: #777;
  user-select: none;
  transition:
    color 0.2s,
    background-color 0.2s;
}

.celda-seguimiento:hover {
  color: #000;
  background-color: #f3f3f3;
}

.q3-menu-tarea {
  min-width: 140px;
  padding: 0.25rem 0;
}

.celda-tarea-inner {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  width: 100%;
  height: 100%;
  line-height: inherit;
}

.celda-tarea-texto {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dep-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: 0 0 6px;
  vertical-align: middle;
}

.dep-dot-in {
  background-color: #f0c000;
}

.dep-dot-out {
  background-color: #0d6efd;
}

/* ==========================================================
   Q4 – TABLA DE DÍAS / BLOQUES DE SEGUIMIENTO
   ========================================================== */

.q4 {
  position: relative;
  width: 100%;
  min-height: 250px;
}

.q4 table.tabla-q4,
q2 table.tabla-semanas {
  border-collapse: collapse;
  table-layout: fixed;
}

.q4 th,
.q4 td {
  width: var(--cell-width); /* Usar variable */
  max-width: var(--cell-width); /* Usar variable */
  min-width: var(--cell-width); /* Usar variable */
  height: var(--plan-body-row-height);
  line-height: var(--plan-body-row-height);
  border: 1px solid #aaaaaa3b;
  font-size: 13px;
  text-align: center;
  overflow: hidden;
}

/* --- Panel de Seguimiento superpuesto --- */
.q4-seguimiento {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 1rem;
  background: #f8f9fa;
  border: 1px solid #ccc;
  border-radius: 10px;
  padding: 1rem;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  animation: fadeIn 0.25s ease-in-out;
  z-index: 10;
}

.seguimiento-header {
  position: relative;
}

.q4-seguimiento h4 {
  margin: 0;
  font-size: 16px;
  color: #333;
  font-weight: 600;
  padding-right: 2rem;
}

.q4-seguimiento .btn-cerrar {
  position: absolute;
  top: 0.3rem;
  right: 0.5rem;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #888;
  transition: color 0.2s;
}
.q4-seguimiento .btn-cerrar:hover {
  color: #000;
}

.seguimiento-contenido {
  flex: 1;
  padding-top: 0.5rem;
  font-size: 13px;
  color: #555;
}

.q4-seguimiento-full {
  grid-row: 1 / span 2;
  grid-column: 2;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: #f8f9fa;
  border-left: 2px solid #ccc;
  overflow-y: auto;
  padding: 1rem;
}

/* --- Panel de Seguimiento (solo en la parte derecha) --- */
.q4-seguimiento-lateral {
  grid-row: 1 / span 2; /* ocupa Q2 + Q4 verticalmente */
  grid-column: 2; /* se queda SOLO en la columna derecha */
  display: flex;
  flex-direction: column;
  background: #f8f9fa;
  border-left: 2px solid #ccc;
  overflow-y: auto;
  padding: 1rem;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
  position: relative;
  z-index: 5; /* por debajo del resizer */
}

/* ==========================================================
   ANIMACIONES
   ========================================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================
   MODOS DE INTERACCIÓN / DRAG / LECTURA
   ========================================================== */

/* --- Drag & Drop Q3 --- */
.dragging {
  opacity: 0.4;
}
.drag-cell {
  cursor: grab;
}
.drag-cell:active {
  cursor: grabbing;
}

.row-dragging {
  outline: 2px solid #007bff;
  outline-offset: -2px;
  background-color: #e7f1ff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition:
    background-color 0.2s ease,
    outline 0.2s ease,
    box-shadow 0.2s ease;
}

.drop-above {
  border-top: 3px solid #007bff !important;
}
.drop-below {
  border-bottom: 3px solid #007bff !important;
}
.drop-above,
.drop-below {
  transition: border-color 0.15s ease;
}
.drop-above.ready,
.drop-below.ready {
  border-color: #28a745 !important;
}

.row-fade-out {
  opacity: 0;
  transform: translateY(5px);
  transition:
    opacity 0.15s ease-out,
    transform 0.15s ease-out,
    border-color 0.15s ease-out;
  border-color: #007bff !important;
}
.row-fade-in {
  opacity: 0;
  transform: translateY(-5px);
  border-color: #007bff !important;
  animation: fadeInSlide 0.2s ease-out forwards;
}
@keyframes fadeInSlide {
  from {
    opacity: 0;
    transform: translateY(-5px);
    border-color: #007bff;
  }
  to {
    opacity: 1;
    transform: translateY(0);
    border-color: inherit;
  }
}

/* --- Modo Lectura --- */
.modo-lectura {
  opacity: 0.9;
  filter: grayscale(15%);
  transition:
    opacity 0.2s ease,
    filter 0.2s ease;
}

/* Desactivar clicks en Q4, pero mantener Q3 activo */
.modo-lectura .q4 > :not(.q4-seguimiento) {
  pointer-events: none;
}

/* Q3 debe seguir recibiendo clics */
.modo-lectura .q3 {
  pointer-events: auto !important;
}

/* --- Indicador de modo --- */
.grid.main_gridXXX::after {
  content: 'Modo edición';
  position: absolute;
  top: 0px; /* ← posición fija */
  right: 8px;
  font-size: 13px;
  color: #666;
  background: #a3e2ff;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 2px 6px;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

/* --- Cuando está en modo lectura --- */
.modo-lectura.grid.main_gridXXX::after {
  content: 'Modo lectura';
  opacity: 1;
}

/* --- Cuando está en modo edición --- */
.grid.main_gridXXX:not(.modo-lectura)::after {
  content: 'Modo edición';
  opacity: 1;
}

/* --- Bloqueo de grid --- */
.grid-bloqueado {
  pointer-events: none;
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

/* ==========================================================
   EDITOR HTML / TOOLBAR
   ========================================================== */

.editor-html {
  border: 1px solid #ccc;
  border-radius: 8px;
  min-height: 120px;
  padding: 0.5rem;
  background: #fff;
  overflow-y: auto;
}
.editor-html:focus {
  outline: 2px solid #007bff33;
}

.editor-toolbar .btn {
  padding: 0.25rem 0.5rem;
}
.editor-toolbar i {
  font-size: 1rem;
}

.q4-seguimiento img {
  max-width: 100%;
  height: auto;
  border: 3px solid #a3c9ff; /* azul clarito */
  border-radius: 4px;
  margin: 0.5rem 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* --- Contenido de los bloques dentro del seguimiento --- */
.q4-seguimiento .bloque-seguimiento {
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  overflow-x: hidden;
}

/* --- Además, asegura que los párrafos y textos se ajusten --- */
.q4-seguimiento .bloque-seguimiento p,
.q4-seguimiento .bloque-seguimiento div,
.q4-seguimiento .bloque-seguimiento span {
  white-space: normal !important;
  word-break: break-word !important;
}

.resizer.disabled {
  pointer-events: none !important;
  opacity: 0.5; /* opcional: lo hace ver inactivo */
  cursor: default !important;
}

/* --- Panel principal del seguimiento --- */
.q4-seguimiento {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  background-color: #fff;
  xpadding-top: 3.5rem; /* deja espacio para el header fijo */
}

/* --- Encabezado fijo dentro del seguimiento --- */
.q4-seguimiento .seguimiento-header {
  position: sticky;
  top: -15px;
  z-index: 20;
  background: #f8f9fa;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #ccc;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* --- Ajustes visuales del header --- */
.q4-seguimiento .seguimiento-header h4 {
  margin: 0;
  font-size: 16px;
  color: #333;
  font-weight: 600;
}

.q4-seguimiento .seguimiento-header .btn-cerrar {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #666;
  transition: color 0.2s;
}

.q4-seguimiento .seguimiento-header .btn-cerrar:hover {
  color: #000;
}

.loader {
  display: block;
  position: relative;
  height: 10px;
  width: 140px;
  background-image: linear-gradient(#fff 20px, transparent 0), linear-gradient(#fff 20px, transparent 0), linear-gradient(#fff 20px, transparent 0), linear-gradient(#fff 20px, transparent 0);
  background-repeat: no-repeat;
  background-size: 10px auto;
  background-position:
    0 0,
    40px 0,
    80px 0,
    120px 0;
  animation: pgfill 1s linear infinite;
}

@keyframes pgfill {
  0% {
    background-image: linear-gradient(#fff 20px, transparent 0), linear-gradient(#fff 20px, transparent 0), linear-gradient(#fff 20px, transparent 0), linear-gradient(#fff 20px, transparent 0);
  }
  25% {
    background-image: linear-gradient(#0088a0 20px, transparent 0), linear-gradient(#fff 20px, transparent 0), linear-gradient(#fff 20px, transparent 0), linear-gradient(#fff 20px, transparent 0);
  }
  50% {
    background-image: linear-gradient(#0088a0 20px, transparent 0), linear-gradient(#0088a0 20px, transparent 0), linear-gradient(#fff 20px, transparent 0), linear-gradient(#fff 20px, transparent 0);
  }
  75% {
    background-image: linear-gradient(#0088a0 20px, transparent 0), linear-gradient(#0088a0 20px, transparent 0), linear-gradient(#0088a0 20px, transparent 0), linear-gradient(#fff 20px, transparent 0);
  }
  100% {
    background-image: linear-gradient(#0088a0 20px, transparent 0), linear-gradient(#0088a0 20px, transparent 0), linear-gradient(#0088a0 20px, transparent 0), linear-gradient(#0088a0 20px, transparent 0);
  }
}

/* ==========================================================
   ESTILOS ADICIONALES PARA CELDAS ESPECÍFICAS
   ========================================================== */

.q1 .dropdown-menu {
  min-width: 180px;
  animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.font-size-12 {
  font-size: 12px !important;
}

.cursor-pointer {
  cursor: pointer;
}

.panel-etiquetas {
  max-height: 120px;
  overflow-y: auto;
  background: #fafafa;
  border: 1px solid #ddd;
  border-radius: 6px;
}

.badge {
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 20px;
  user-select: none;
  transition: all 0.2s;
}
.badge.cursor-pointer:hover {
  background-color: #e7f1ff;
  border-color: #9ac3ff;
}

.modal-content {
  animation: fadeIn 0.2s ease-in-out;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ==========================================================
   ESTILOS PARA TOASTS
   ========================================================== */

.toast-slide {
  transform: translateX(120%);
  opacity: 0;
  animation: slideIn 0.5s ease forwards;
}

@keyframes slideIn {
  from {
    transform: translateX(120%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Efecto de salida opcional (si quieres fade-out slide) */
.toast-slide.fade-out {
  animation: slideOut 0.4s ease forwards;
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(120%);
    opacity: 0;
  }
}
/* ==========================================================
   FIN DE ESTILOS PARA TOASTS
   ========================================================== */

.q4 tr td.estilo_en_rango {
  background-color: #86bff8 !important; /* Amarillo */
  color: #313131 !important; /* Negro */
}

.q4 tr td.estilo_en_rango {
  background-color: #86bff8 !important;
  color: #313131 !important;
  box-shadow: inset 0 -4px 0 0 #022b9b !important;
}

.txt10 {
  font-size: 10px !important;
}

.txt11 {
  font-size: 11px !important;
}

/* estilos generales */

tr.text-center td,
tr.text-center th {
  text-align: center;
}

.col-azulsec-0 {
  background-color: #86bff8 !important;
}

.col-azulsec-1 {
  background-color: #a9d2fc !important;
}

.q4 .tabla-q4 colgroup col,
.q2 .tabla-semanas tr.dia-mes td,
.q2 .tabla-semanas tr.num-semana td {
  width: 55px;
  min-width: 55px;
  max-width: 55px;
}

/**********************/

:root {
  --bs-gray-100: #f8f9fa;
  --bs-gray-200: #e9ecef;
  --bs-gray-300: #dee2e6;
  --bs-gray-400: #ced4da;
  --bs-gray-500: #adb5bd;
  --bs-gray-600: #6c757d;
  --bs-gray-700: #495057;
  --bs-gray-800: #343a40;
  --bs-gray-900: #212529;
}

/* Utilidades estilo Bootstrap para texto */
.text-gray-100 {
  color: var(--bs-gray-100) !important;
}
.text-gray-200 {
  color: var(--bs-gray-200) !important;
}
.text-gray-300 {
  color: var(--bs-gray-300) !important;
}
.text-gray-400 {
  color: var(--bs-gray-400) !important;
}
.text-gray-500 {
  color: var(--bs-gray-500) !important;
}
.text-gray-600 {
  color: var(--bs-gray-600) !important;
}
.text-gray-700 {
  color: var(--bs-gray-700) !important;
}
.text-gray-800 {
  color: var(--bs-gray-800) !important;
}
.text-gray-900 {
  color: var(--bs-gray-900) !important;
}

.fs-7 {
  font-size: 0.875rem !important;
}

.fs-8 {
  font-size: 0.6rem !important;
}

/* ==========================================================
   VISTA TABLA (VistaTablaQ34) — aislada del grid Q1–Q4
   ========================================================== */

.grid.vista-tabla-mode {
  grid-template-rows: auto 1fr;
}

.grid.vista-tabla-mode .q1 {
  grid-column: 1 / -1;
  grid-row: 1;
}

.grid.vista-tabla-mode .vista-tabla-q34 {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: #fff;
  border: 1px solid #aaa;
  box-sizing: border-box;
}

.grid.vista-tabla-mode.vista-tabla-con-seguimiento .vista-tabla-q34 {
  grid-column: 1;
}

/* Divisor redimensionable entre tabla y anotaciones (solo fila de contenido) */
.grid.vista-tabla-mode .resizer-tabla {
  grid-row: 2;
  grid-column: 2;
  width: 5px;
  cursor: col-resize;
  background: #e9ecef;
  z-index: 10;
  margin-left: 0;
}

.grid.vista-tabla-mode .vista-tabla-seguimiento {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: auto;
  background: #f8f9fa;
  border: 1px solid #aaa;
  border-left: none;
  padding: 0.75rem;
  box-sizing: border-box;
}

.vista-tabla-q34 .vista-tabla-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.vista-tabla-q34 .vista-tabla-table {
  font-size: 12px;
  table-layout: auto;
  width: max(100%, 960px);
}

.vista-tabla-q34 .vista-tabla-table thead th {
  white-space: nowrap;
  font-size: 11px;
  vertical-align: middle;
  z-index: 2;
}

.vista-tabla-q34 .vt-sortable {
  cursor: pointer;
  user-select: none;
}

.vista-tabla-q34 .vt-th-move,
.vista-tabla-q34 .vt-move {
  width: 28px;
  text-align: center;
  vertical-align: middle;
}

.vista-tabla-q34 .vt-move-on {
  cursor: grab;
  color: #6c757d;
}

.vista-tabla-q34 .vt-move-on:active {
  cursor: grabbing;
}

.vista-tabla-q34 .vt-move-off {
  cursor: not-allowed;
  opacity: 0.35;
}

.vista-tabla-q34 .vt-editable {
  cursor: text;
}

.vista-tabla-q34 .vt-tarea {
  min-width: 160px;
  max-width: 320px;
}

.vista-tabla-q34 .vt-depende {
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #555;
}

.vista-tabla-q34 .vt-fecha-vencida {
  background-color: #dc3545 !important;
  color: #fff !important;
  font-weight: 600;
}

.vista-tabla-q34 tr.vt-row-seguimiento > td {
  outline: 2px solid #0d6efd;
  outline-offset: -2px;
  background-color: rgba(13, 110, 253, 0.06);
}

.vista-tabla-q34 tr.row-dragging {
  opacity: 0.55;
}

.vista-tabla-q34 tr.drop-above td {
  box-shadow: inset 0 2px 0 #0d6efd;
}

.vista-tabla-q34 tr.drop-below td {
  box-shadow: inset 0 -2px 0 #0d6efd;
}

/* ==========================================================
   CHAT IA
   ========================================================== */

.ia-chat-root {
  --ia-bg: #f4f6f8;
  --ia-sidebar-bg: #ffffff;
  --ia-sidebar-border: #e2e6ea;
  --ia-bubble-user: #212529;
  --ia-bubble-user-fg: #ffffff;
  --ia-bubble-assistant: #ffffff;
  --ia-bubble-assistant-border: #dee2e6;
  --ia-accent: #0d6efd;
  --ia-ref-bg: #eef3f8;
  --ia-ref-fg: #1a3a5c;
  --ia-highlight: rgba(255, 193, 7, 0.35);
  --ia-line-num: #8a939c;
  --ia-composer-bg: #ffffff;
  height: calc(100vh - 56px);
  background: var(--ia-bg);
  overflow: hidden;
}

.ia-chat-layout {
  display: flex;
  height: 100%;
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
}

.ia-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--ia-sidebar-bg);
  border-right: 1px solid var(--ia-sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 20;
  position: relative;
}

.ia-sidebar-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 25;
  touch-action: none;
}

.ia-sidebar-resizer:hover,
.ia-sidebar-resizer:active {
  background: rgba(13, 110, 253, 0.25);
}

body.ia-sidebar-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

body.ia-sidebar-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

.ia-sidebar-header {
  padding: 0.75rem;
  border-bottom: 1px solid var(--ia-sidebar-border);
}

.ia-conv-list {
  flex: 1;
  overflow-y: auto;
}

.ia-proy-group {
  border-bottom: 1px solid #eef1f4;
}

.ia-proy-head {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.45rem 0.35rem 0.35rem;
  background: var(--ia-accent, #0d6efd);
  position: sticky;
  top: 0;
  z-index: 1;
}

.ia-proy-head.is-active {
  background: #0a58ca;
}

.ia-proy-toggle {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  border: 0;
  background: transparent;
  padding: 0.2rem 0.25rem;
  font-size: 0.78rem;
  font-weight: 650;
  color: #ffffff;
  text-align: left;
}

.ia-proy-toggle:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.ia-proy-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ia-proy-count {
  font-size: 0.68rem;
  font-weight: 600;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
  flex-shrink: 0;
}

.ia-proy-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  opacity: 0.75;
  flex-shrink: 0;
}

.ia-proy-actions .btn-link {
  color: #ffffff !important;
}

.ia-proy-actions .btn-link.text-danger {
  color: #ffd4d4 !important;
}

.ia-proy-head:hover .ia-proy-actions,
.ia-proy-head.is-active .ia-proy-actions {
  opacity: 1;
}

.ia-proy-add-chat {
  color: #ffffff !important;
  line-height: 1;
  padding: 0.1rem 0.2rem !important;
}

.ia-proy-add-chat:hover:not(:disabled) {
  color: #e9ecef !important;
}

.ia-proy-rename {
  max-width: 140px;
  flex: 1;
  min-width: 0;
}

.ia-proy-empty {
  padding: 0.35rem 0.85rem 0.55rem 1.75rem;
}

.ia-main-proy-badge {
  display: inline-block;
  margin-left: 0.45rem;
  font-size: 0.68rem;
  font-weight: 600;
  vertical-align: middle;
  color: #495057;
  background: #e9ecef;
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
}

.ia-conv-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.65rem 0.45rem 1.15rem;
  border-bottom: 1px solid #f0f2f4;
  cursor: pointer;
  transition: background 0.15s ease;
}

.ia-chat-root.is-busy .ia-sidebar,
.ia-chat-root.is-busy .ia-composer.is-locked,
.ia-chat-root.is-busy .ia-toolbar-actions {
  cursor: not-allowed;
}

.ia-chat-root.is-busy .ia-sidebar button:disabled,
.ia-chat-root.is-busy .ia-composer button:disabled,
.ia-chat-root.is-busy .ia-composer textarea:disabled,
.ia-chat-root.is-busy .ia-composer select:disabled {
  cursor: not-allowed;
}

.ia-send-btn {
  min-width: 2.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ia-send-btn .spinner-border {
  width: 1rem;
  height: 1rem;
  border-width: 0.15em;
}

.ia-messages.is-busy {
  position: relative;
}

.ia-busy-banner {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 0 0.75rem;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(90deg, #0d6efd12, #6610f212, #0d6efd12);
  border: 1px solid #cfe2ff;
  box-shadow: 0 4px 18px rgba(13, 110, 253, 0.08);
}

.ia-busy-shimmer {
  height: 3px;
  background: linear-gradient(90deg, transparent, #0d6efd, #6610f2, transparent);
  background-size: 200% 100%;
  animation: ia-busy-shimmer 1.4s linear infinite;
}

.ia-busy-copy {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #0b3d7a;
}

.ia-busy-pulse {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #0d6efd;
  box-shadow: 0 0 0 0 rgba(13, 110, 253, 0.55);
  animation: ia-busy-pulse 1.2s ease-out infinite;
}

@keyframes ia-busy-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@keyframes ia-busy-pulse {
  0% {
    transform: scale(0.9);
    box-shadow: 0 0 0 0 rgba(13, 110, 253, 0.55);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 8px rgba(13, 110, 253, 0);
  }
  100% {
    transform: scale(0.9);
    box-shadow: 0 0 0 0 rgba(13, 110, 253, 0);
  }
}

.ia-conv-item:hover {
  background: #f7f9fb;
}

.ia-conv-item.active {
  background: #e8f0fe;
  border-left: 3px solid var(--ia-accent);
}

.ia-conv-main {
  flex: 1;
  min-width: 0;
}

.ia-conv-title {
  font-size: calc(0.875rem - 2px);
  font-weight: 400;
  color: #000000;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  word-break: break-word;
}

.ia-conv-date {
  display: none;
}

.ia-conv-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.2rem;
  opacity: 0.35;
  transition: opacity 0.15s ease;
  flex-shrink: 0;
}

.ia-conv-item:hover .ia-conv-actions,
.ia-conv-item.active .ia-conv-actions {
  opacity: 1;
}

.ia-sidebar-backdrop {
  display: none;
}

.ia-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--ia-bg);
}

.ia-main-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  background: #fff;
  border-bottom: 1px solid var(--ia-sidebar-border);
}

.ia-main-title {
  font-weight: 600;
  color: #343a40;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ia-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.ia-conv-indicator {
  max-width: 14rem;
  line-height: 1.2;
}

.ia-conv-indicator--active {
  color: #0d6efd !important;
}

@keyframes ia-conv-spin {
  to {
    transform: rotate(360deg);
  }
}

.ia-conv-spin {
  display: inline-block;
  animation: ia-conv-spin 1s linear infinite;
}

.ia-task-log-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.ia-task-log-card {
  border: 1px solid #dee2e6;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  background: #fafbfc;
}

.ia-task-log-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.ia-task-log-model {
  text-align: right;
  white-space: nowrap;
}

.ia-task-log-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 0.45rem;
}

.ia-task-stat {
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  text-align: center;
}

.ia-task-stat-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #6c757d;
}

.ia-task-stat-value {
  display: block;
  font-weight: 650;
  font-size: 0.92rem;
  color: #212529;
}

.ia-task-tools {
  list-style: none;
  margin: 0.65rem 0 0;
  padding: 0;
}

.ia-task-tools li {
  font-size: 0.85rem;
  padding: 0.2rem 0;
  border-top: 1px dashed #e9ecef;
}

.ia-task-detail-toggle {
  text-decoration: none;
  color: #495057;
}

.ia-task-transfer-detail {
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 8px;
}

.ia-task-context-detail {
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 8px;
}

.ia-ctx-round {
  border-left: 3px solid #ced4da;
  padding-left: 0.55rem;
}

.ia-ctx-fragments {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ia-ctx-fragments li {
  font-size: 0.82rem;
  padding: 0.25rem 0;
  border-top: 1px dashed #e9ecef;
  word-break: break-word;
}

.ia-ctx-inspect {
  margin: 0.35rem 0 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  border: 1px solid #dee2e6;
  background: #f8f9fa;
}

.ia-ctx-inspect--full {
  border-color: #198754;
  background: #f4fbf7;
}

.ia-ctx-inspect--truncated {
  border-color: #fd7e14;
  background: #fff8f1;
}

.ia-ctx-inspect--missing {
  border-color: #adb5bd;
  background: #f1f3f5;
}

.ia-ctx-inspect-text {
  max-height: 220px;
  overflow: auto;
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 0.5rem;
  padding: 0.4rem;
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 4px;
}

.ia-clarify {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px dashed #dee2e6;
}

.ia-clarify-label {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.ia-clarify-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.ia-clarify-btn {
  text-align: left;
  white-space: normal;
  max-width: 100%;
}

.ia-intent-trace {
  margin-top: 0.65rem;
  padding: 0.55rem 0.65rem;
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  font-size: 0.82rem;
}

.ia-intent-trace ul {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
}

.ia-transfer-table {
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.ia-transfer-table th {
  white-space: nowrap;
  background: #f1f3f5;
}

.ia-content-breakdown ul {
  padding-left: 1.1rem;
  margin-bottom: 0.35rem;
}

.ia-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ia-empty {
  margin: auto;
  text-align: center;
  color: #6c757d;
  max-width: 360px;
}

.ia-empty-icon {
  font-size: 2.5rem;
  opacity: 0.4;
  display: block;
  margin-bottom: 0.5rem;
}

.ia-bubble-wrap {
  display: flex;
  max-width: 100%;
}

.ia-bubble-wrap.is-user {
  justify-content: flex-end;
}

.ia-bubble-wrap.is-assistant {
  justify-content: flex-start;
  width: 100%;
}

.ia-bubble {
  max-width: min(720px, 92%);
  padding: 0.7rem 0.95rem;
  border-radius: 12px;
  font-size: 0.925rem;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.ia-bubble-user {
  background: var(--ia-bubble-user);
  color: var(--ia-bubble-user-fg);
  border-bottom-right-radius: 4px;
}

.ia-bubble-assistant {
  width: 100%;
  max-width: 100%;
  background: var(--ia-bubble-assistant);
  border: 1px solid var(--ia-bubble-assistant-border);
  border-bottom-left-radius: 4px;
  color: #212529;
}

.ia-bubble-plain {
  white-space: pre-wrap;
  word-break: break-word;
}

.ia-typing {
  display: flex;
  align-items: center;
  min-height: 2.2rem;
}

.ia-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6c757d;
  margin-right: 4px;
  animation: ia-bounce 1.2s infinite ease-in-out;
}

.ia-typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.ia-typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes ia-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* Markdown inside assistant bubbles */
.ia-md > *:first-child {
  margin-top: 0;
}

.ia-md > *:last-child {
  margin-bottom: 0;
}

.ia-md-p {
  margin: 0 0 0.55rem;
}

.ia-md-h {
  margin: 0.6rem 0 0.35rem;
  font-weight: 700;
  line-height: 1.25;
}

/* Tamaños vs Bootstrap estándar (h1 2.5rem, h2 2rem, h3 1.75rem, h4 1.5rem) */
.ia-md h1.ia-md-h {
  font-size: 1.875rem; /* -25% → 75% de 2.5rem */
}

.ia-md h2.ia-md-h {
  font-size: 1.6rem; /* -20% → 80% de 2rem */
}

.ia-md h3.ia-md-h {
  font-size: 1.4875rem; /* -15% → 85% de 1.75rem */
}

.ia-md h4.ia-md-h {
  font-size: 1.425rem; /* -5% → 95% de 1.5rem */
}

.ia-md-ul,
.ia-md-ol {
  margin: 0 0 0.55rem;
  padding-left: 1.25rem;
}

.ia-md-hr {
  margin: 0.85rem 0;
  border: 0;
  border-top: 1px solid #ced4da;
  opacity: 1;
}

.ia-md-table-wrap {
  margin: 0.45rem 0 0.7rem;
  max-width: 100%;
}

.ia-md-table {
  margin-bottom: 0;
  background: #fff;
  font-size: 0.88rem;
  vertical-align: middle;
}

.ia-md-table > :not(caption) > * > * {
  padding: 0.35rem 0.55rem;
}

.ia-md-table thead th {
  background: #f1f3f5;
  font-weight: 650;
  border-bottom-width: 1px;
  white-space: nowrap;
}

.ia-md-table tbody td {
  vertical-align: middle;
}

.ia-code-container > .ia-code-preview-pane .ia-md-table-wrap {
  margin: 0.4rem 0 0.55rem;
}

.ia-code-container > .ia-code-preview-pane .ia-md-table {
  background: #fff;
  color: #212529;
}

@media (prefers-color-scheme: dark) {
  .ia-code-container > .ia-code-preview-pane .ia-md-table {
    background: #1e2430;
    color: #e8ecf1;
    --bs-table-bg: #1e2430;
    --bs-table-color: #e8ecf1;
    --bs-table-border-color: #3a4250;
  }

  .ia-code-container > .ia-code-preview-pane .ia-md-table thead th {
    background: #2a3140;
  }

  .ia-code-container > .ia-code-preview-pane .ia-md-hr {
    border-top-color: #4a5568;
  }
}

.ia-md-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: #f0f2f5;
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

/* Contenedor de bloques de código + barra COPIAR / AJUSTAR */
.ia-code-container {
  position: relative;
  margin: 0.4rem 0 0.65rem;
}

.ia-code-toolbar {
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: none; /* solo los botones reciben clics */
}

.ia-code-toolbar > * {
  pointer-events: auto;
}

.ia-code-lang {
  display: none;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(232, 236, 241, 0.55);
  margin-right: 2px;
  user-select: none;
}

@media (min-width: 576px) {
  .ia-code-lang {
    display: inline;
  }
}

.ia-code-preview,
.ia-code-wrap,
.ia-code-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(30, 36, 48, 0.88);
  color: #e8ecf1;
  border-radius: 5px;
  padding: 0.18rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
  cursor: pointer;
  backdrop-filter: blur(4px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.ia-code-preview:hover,
.ia-code-wrap:hover,
.ia-code-copy:hover {
  background: rgba(55, 65, 85, 0.95);
  border-color: rgba(255, 255, 255, 0.3);
}

.ia-code-wrap.is-active,
.ia-code-preview.is-active {
  background: rgba(13, 110, 253, 0.35);
  border-color: rgba(110, 168, 254, 0.55);
}

.ia-code-wrap.is-disabled,
.ia-code-wrap:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ia-code-copy.is-copied {
  background: rgba(25, 135, 84, 0.4);
  border-color: rgba(75, 195, 140, 0.55);
}

.ia-code-preview i,
.ia-code-wrap i,
.ia-code-copy i {
  font-size: 0.85rem;
}

.ia-code-copy-label,
.ia-code-preview-label {
  font-size: 0.65rem;
}

@media (max-width: 520px) {
  .ia-code-copy-label,
  .ia-code-preview-label {
    display: none;
  }
}

/* Tema claro: botones sobre fondo oscuro del bloque */
.ia-bubble-assistant .ia-code-preview,
.ia-bubble-assistant .ia-code-wrap,
.ia-bubble-assistant .ia-code-copy {
  color: #e8ecf1;
}

/* Panel de vista previa Markdown (sustituye visualmente al <pre>) */
.ia-code-container > .ia-code-preview-pane {
  display: block;
  background: #f8f9fb;
  color: #212529;
  border: 1px solid #e2e6ea;
  border-radius: 8px;
  padding: 2.15rem 0.9rem 0.85rem;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  overflow-x: auto;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.ia-code-container > .ia-code-preview-pane[hidden] {
  display: none !important;
}

.ia-code-container > .ia-code-preview-pane > *:first-child {
  margin-top: 0;
}

.ia-code-container > .ia-code-preview-pane > *:last-child {
  margin-bottom: 0;
}

/* Hereda tipografía/márgenes de .ia-md para h/p/ul dentro del panel */
.ia-code-container > .ia-code-preview-pane .ia-md-h {
  margin: 0.55rem 0 0.3rem;
}

.ia-code-container > .ia-code-preview-pane .ia-md-p {
  margin: 0 0 0.5rem;
}

/* En modo preview, el pre original queda oculto pero conserva el texto para COPIAR */
.ia-code-container.ia-code-preview-mode > pre.ia-md-pre[hidden] {
  display: none !important;
}

@media (prefers-color-scheme: dark) {
  .ia-code-container > .ia-code-preview-pane {
    background: #252b36;
    color: #e8ecf1;
    border-color: #3a4250;
  }
}

.ia-md-pre {
  background: #1e2430;
  color: #e8ecf1;
  /* espacio superior para que la toolbar no tape la 1.ª línea */
  padding: 2.15rem 0.9rem 0.75rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0;
  font-size: 0.82rem;
  white-space: pre;
  tab-size: 2;
}

.ia-md-pre.ia-wrap-enabled {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  overflow-x: hidden;
}

.ia-md-pre code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: transparent;
  color: inherit;
  padding: 0;
  white-space: inherit;
}

.ia-md a {
  color: var(--ia-accent);
}

.ia-refs {
  margin-top: 0.65rem;
  padding-top: 0.5rem;
  border-top: 1px solid #e9ecef;
}

.ia-refs-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6c757d;
  margin-bottom: 0.35rem;
}

.ia-ref-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid #c5d4e4;
  background: var(--ia-ref-bg);
  color: var(--ia-ref-fg);
  border-radius: 6px;
  font-size: 0.78rem;
  padding: 0.2rem 0.5rem;
  margin: 0 0.3rem 0.3rem 0;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ia-ref-chip:hover {
  background: #dde7f2;
  border-color: #9bb4ce;
}

.ia-docs-gen {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.ia-doc-card {
  border: 1px solid #c5d4e4;
  background: #f7fafc;
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
}

.ia-doc-card-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: #1a3a5c;
  margin-bottom: 0.25rem;
}

.ia-doc-card-meta,
.ia-doc-card-origin {
  font-size: 0.75rem;
  color: #6c757d;
  margin-bottom: 0.2rem;
}

.ia-doc-download {
  margin-top: 0.45rem;
}

.ia-html-card {
  border-color: #b7c9a8;
  background: #f7faf4;
}

.ia-html-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

/* —— Vista previa HTML (modal resizable, iframe sandbox) —— */
.ia-html-preview-root {
  position: fixed;
  inset: 0;
  z-index: 1080;
  pointer-events: none;
}

.ia-html-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 32, 0.45);
  pointer-events: auto;
}

.ia-html-preview-panel {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #c5d4e4;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  pointer-events: auto;
  min-width: 280px;
  min-height: 220px;
}

.ia-html-preview-panel.is-maximized {
  border-radius: 0;
}

.ia-html-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem 0.45rem 0.75rem;
  background: #1a3a5c;
  color: #fff;
  cursor: move;
  user-select: none;
  flex-shrink: 0;
}

.ia-html-preview-title {
  display: flex;
  align-items: center;
  min-width: 0;
  font-weight: 600;
  font-size: 0.92rem;
}

.ia-html-preview-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ia-html-preview-ver {
  margin-left: 0.45rem;
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.85;
  background: rgba(255, 255, 255, 0.15);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.ia-html-preview-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.ia-html-preview-actions .btn {
  padding: 0.15rem 0.4rem;
}

.ia-html-version-select {
  max-width: 160px;
  font-size: 0.75rem;
  padding: 0.15rem 0.35rem;
}

.ia-html-preview-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #e9ecef;
  display: flex;
  flex-direction: column;
}

.ia-html-preview-iframe {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
  /* Scroll nativo del documento dentro del iframe; no propaga al chat */
  overflow: auto;
}

.ia-html-preview-status {
  padding: 1.25rem;
  text-align: center;
  color: #495057;
}

.ia-html-preview-banner {
  flex-shrink: 0;
  padding: 0.35rem 0.75rem;
  background: #fff3cd;
  color: #664d03;
  font-size: 0.8rem;
  border-bottom: 1px solid #ffe69c;
}

.ia-html-code-view {
  margin: 0;
  padding: 0.75rem 1rem;
  overflow: auto;
  flex: 1 1 auto;
  font-size: 0.78rem;
  background: #1e1e1e;
  color: #d4d4d4;
  white-space: pre;
}

.ia-html-resize {
  position: absolute;
  z-index: 2;
  background: transparent;
}

.ia-html-resize-n,
.ia-html-resize-s {
  left: 8px;
  right: 8px;
  height: 6px;
  cursor: ns-resize;
}

.ia-html-resize-n {
  top: 0;
}

.ia-html-resize-s {
  bottom: 0;
}

.ia-html-resize-e,
.ia-html-resize-w {
  top: 8px;
  bottom: 8px;
  width: 6px;
  cursor: ew-resize;
}

.ia-html-resize-e {
  right: 0;
}

.ia-html-resize-w {
  left: 0;
}

.ia-html-resize-ne,
.ia-html-resize-nw,
.ia-html-resize-se,
.ia-html-resize-sw {
  width: 12px;
  height: 12px;
}

.ia-html-resize-ne {
  top: 0;
  right: 0;
  cursor: nesw-resize;
}

.ia-html-resize-nw {
  top: 0;
  left: 0;
  cursor: nwse-resize;
}

.ia-html-resize-se {
  bottom: 0;
  right: 0;
  cursor: nwse-resize;
}

.ia-html-resize-sw {
  bottom: 0;
  left: 0;
  cursor: nesw-resize;
}

@media (max-width: 576px) {
  .ia-html-preview-actions .btn .bi + span,
  .ia-html-card-actions {
    width: 100%;
  }

  .ia-html-version-select {
    max-width: 110px;
  }
}

.ia-composer {
  background: var(--ia-composer-bg);
  border-top: 1px solid var(--ia-sidebar-border);
  padding: 0.65rem 0.85rem 0.85rem;
}

.ia-fuente-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
}

.ia-fuente-chip {
  display: inline-flex;
  align-items: center;
  background: #495057;
  color: #fff;
  font-weight: 500;
  padding: 0.35em 0.55em;
}

.ia-fuente-chip-name {
  color: #fff !important;
  font-size: 0.78rem;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ia-composer-row {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
}

.ia-model-select {
  max-width: 180px;
  flex-shrink: 0;
}

.ia-review-select {
  max-width: 160px;
  flex-shrink: 0;
  font-size: 0.82rem;
}

.ia-recovery-log {
  border-top: 1px dashed #dee2e6;
  padding-top: 0.5rem;
}

.ia-recovery-op {
  background: #f8fafc;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  margin-top: 0.35rem;
}

.ia-recovery-op-line {
  color: #495057;
  margin-top: 0.15rem;
  padding-left: 0.35rem;
  border-left: 2px solid #cfe2ff;
}

.ia-composer-input {
  flex: 1;
  min-height: 40px;
  max-height: 140px;
  resize: vertical;
}

/* Document viewer (panel flotante resizable) */
.ia-float-viewer-root {
  position: fixed;
  inset: 0;
  z-index: 1080;
  pointer-events: none;
}

.ia-float-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 32, 0.45);
  pointer-events: auto;
}

.ia-float-viewer-panel {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #c5d4e4;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  pointer-events: auto;
  min-width: 280px;
  min-height: 220px;
}

.ia-float-viewer-panel.is-maximized {
  border-radius: 0;
}

.ia-float-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem 0.45rem 0.75rem;
  background: #1a3a5c;
  color: #fff;
  cursor: move;
  user-select: none;
  flex-shrink: 0;
}

.ia-float-viewer-title {
  display: flex;
  align-items: center;
  min-width: 0;
  font-weight: 600;
  font-size: 0.92rem;
}

.ia-float-viewer-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ia-float-viewer-meta {
  margin-left: 0.45rem;
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.85;
  background: rgba(255, 255, 255, 0.15);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.ia-float-viewer-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.ia-float-viewer-actions .btn {
  padding: 0.15rem 0.4rem;
}

.ia-float-viewer-actions .text-white-50 {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.75rem;
}

.ia-float-viewer-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #fff;
}

.ia-float-resize {
  position: absolute;
  z-index: 2;
}

.ia-float-resize-n,
.ia-float-resize-s {
  left: 8px;
  right: 8px;
  height: 6px;
  cursor: ns-resize;
}

.ia-float-resize-n {
  top: 0;
}

.ia-float-resize-s {
  bottom: 0;
}

.ia-float-resize-e,
.ia-float-resize-w {
  top: 8px;
  bottom: 8px;
  width: 6px;
  cursor: ew-resize;
}

.ia-float-resize-e {
  right: 0;
}

.ia-float-resize-w {
  left: 0;
}

.ia-float-resize-ne,
.ia-float-resize-nw,
.ia-float-resize-se,
.ia-float-resize-sw {
  width: 12px;
  height: 12px;
}

.ia-float-resize-ne {
  top: 0;
  right: 0;
  cursor: nesw-resize;
}

.ia-float-resize-nw {
  top: 0;
  left: 0;
  cursor: nwse-resize;
}

.ia-float-resize-se {
  bottom: 0;
  right: 0;
  cursor: nwse-resize;
}

.ia-float-resize-sw {
  bottom: 0;
  left: 0;
  cursor: nesw-resize;
}

.ia-goto-line {
  width: 72px;
}

.ia-doc-viewer-status {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.35rem;
  padding: 0.28rem 0.75rem;
  font-size: 0.72rem;
  color: #5b6b7c;
  background: #f3f6f9;
  border-bottom: 1px solid #e2e8f0;
  line-height: 1.3;
}

.ia-doc-viewer-status-sep {
  opacity: 0.45;
}

.ia-doc-viewer-status-busy {
  color: #1a3a5c;
  font-style: italic;
}

.ia-line-gutter-wrap {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.45;
}

.ia-line-virtual-root {
  width: 100%;
}

.ia-line-virtual-window {
  will-change: transform;
}

.ia-line-row {
  display: flex;
  border-bottom: 1px solid #f1f3f5;
}

.ia-line-row:hover {
  background: #f8f9fa;
}

.ia-line-highlight {
  background: var(--ia-highlight) !important;
}

.ia-line-num {
  flex: 0 0 var(--ia-line-gutter-ch, 4.5ch);
  min-width: var(--ia-line-gutter-ch, 4.5ch);
  text-align: right;
  padding: 0.1rem 0.55rem 0.1rem 0.4rem;
  color: var(--ia-line-num);
  user-select: none;
  background: #f8f9fa;
  border-right: 1px solid #e9ecef;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ia-line-text {
  flex: 1;
  padding: 0.1rem 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 991.98px) {
  .ia-sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.12);
  }

  .ia-sidebar.is-open {
    transform: translateX(0);
  }

  .ia-sidebar-resizer {
    display: none;
  }

  .ia-sidebar-backdrop {
    display: block;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 15;
  }

  .ia-model-select {
    max-width: 120px;
  }

  .ia-review-select {
    max-width: 110px;
    font-size: 0.75rem;
  }
}
