/* Segundo Cerebro INCOPLAN: identidad visual del portal.
   Estructura: barra superior roja, menú lateral claro y contenido sobre fondo gris claro. */
:root {
  --rojo: #b30f14;      /* rojo del logo INCOPLAN: #bf0f11 */
  --rojo-oscuro: #8a0c10;
  --rojo-suave: #fdecec;
  --rojo-borde: #f1c2c3;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1d2330;
  --text-muted: #6b7280;
  --accent: var(--rojo);
  --accent-contrast: #ffffff;
  --danger: #b3261e;
  --ok: #2f7a5c;
  --aviso: #a9711b;
  --radius: 14px;
  --sombra: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.06);
  --sombra-alta: 0 8px 28px rgba(16, 24, 40, 0.10);
  --ancho-lateral: 272px;
  --alto-barra: 64px;
  --font: "Segoe UI", -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }
[hidden] { display: none !important; }
a { color: inherit; }
.icono { width: 20px; height: 20px; flex: none; }

.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 20px; height: 44px; border: none; border-radius: 10px;
  background: var(--rojo); color: #fff; font: 600 0.92rem var(--font); cursor: pointer;
  box-shadow: 0 2px 6px rgba(179, 15, 20, 0.25); text-decoration: none; transition: background .15s;
}
.boton:hover { background: var(--rojo-oscuro); }
.boton:disabled { opacity: .55; cursor: default; }
.boton .icono { width: 18px; height: 18px; }
.boton.secundario { background: var(--surface); color: var(--rojo); border: 1px solid var(--rojo-borde); box-shadow: none; }
.boton.secundario:hover { background: var(--rojo-suave); }

/* ---------- Estructura: barra, menú lateral, contenido ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--ancho-lateral) 1fr;
  grid-template-rows: var(--alto-barra) 1fr;
  height: 100vh;
}
.barra {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: var(--ancho-lateral) 1fr auto; align-items: center;
  background: linear-gradient(90deg, var(--rojo-oscuro), var(--rojo) 60%, #c41418);
  color: #fff; box-shadow: 0 2px 10px rgba(138, 12, 16, 0.25); z-index: 3;
}
.barra-marca { display: flex; align-items: center; gap: 12px; height: 100%; padding: 0 22px; border-right: 1px solid rgba(255, 255, 255, 0.16); }
.barra-menu { display: none; background: none; border: none; color: #fff; padding: 6px; cursor: pointer; }
.marca { display: flex; align-items: center; text-decoration: none; color: #fff; height: 40px; }
.marca img { max-height: 48px; max-width: 210px; display: block; }
/* INCOPLAN | INCO+ en la barra: los dos en blanco, separados por una línea fina */
.barra .marca img { max-height: 46px; max-width: 112px; }
.marca-separador { width: 1px; height: 30px; background: rgba(255, 255, 255, 0.55); flex: none; }
.barra .marca-aliada { height: auto; }
.barra .marca-aliada img { max-height: 22px; max-width: 80px; }
.barra .marca-aliada .marca-texto { font-size: .95rem; font-style: italic; }
.marca-texto { font-weight: 800; letter-spacing: .06em; font-size: 1.15rem; }
.barra-titulo { padding: 0 22px; min-width: 0; }
.barra-nombre { font-weight: 700; font-size: 1.02rem; }
.barra-proyecto { font-size: .78rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra-usuario { display: flex; align-items: center; gap: 14px; padding: 0 20px; font-size: .9rem; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: #fff; color: var(--rojo);
  display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex: none;
}
.usuario-nombre { padding-right: 14px; border-right: 1px solid rgba(255, 255, 255, 0.3); white-space: nowrap; }
.barra-enlace { display: flex; align-items: center; gap: 6px; text-decoration: none; color: #fff; opacity: .95; }
.barra-enlace:hover { opacity: 1; text-decoration: underline; }
.boton-salir {
  display: flex; align-items: center; gap: 8px; background: transparent; color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.7); border-radius: 10px; padding: 8px 16px; font: 600 .88rem var(--font); cursor: pointer;
}
.boton-salir:hover { background: rgba(255, 255, 255, 0.12); }
.boton-salir .icono, .barra-enlace .icono { width: 18px; height: 18px; }

.lateral {
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto; z-index: 2;
}
.nuevo-chat {
  display: flex; align-items: center; gap: 12px; margin: 14px 14px 6px; padding: 12px 14px;
  border-radius: 12px; text-decoration: none; font-weight: 600; color: var(--text);
  border: 1px solid var(--border); background: var(--surface); transition: border-color .15s, background .15s;
}
.nuevo-chat:hover { border-color: var(--rojo-borde); background: var(--rojo-suave); }
.nuevo-chat .derecha { margin-left: auto; color: var(--text-muted); }
.menu { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px 14px; border-bottom: 1px solid var(--border); }
.menu a, .menu .deshabilitado {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  text-decoration: none; color: #374151; font-size: .93rem;
}
.menu a:hover { background: #f6f6f8; }
.menu a.activo { background: var(--rojo-suave); color: var(--rojo); font-weight: 600; }
.menu .deshabilitado { color: #9ca3af; cursor: default; }
.pronto {
  margin-left: auto; font-style: normal; font-size: .68rem; font-weight: 600; letter-spacing: .02em;
  color: var(--rojo); background: var(--rojo-suave); border-radius: 999px; padding: 2px 8px;
}
/* Consultas recientes: las conversaciones guardadas del usuario (api/conversaciones.php) */
.recientes { padding: 14px 14px 10px; border-bottom: 1px solid var(--border); }
.recientes ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.recientes li { display: flex; align-items: center; border-radius: 10px; }
.recientes li:hover, .recientes li.activo { background: #f6f6f8; }
.recientes li.activo a { color: var(--rojo); font-weight: 600; }
.recientes a {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 7px 4px 7px 10px;
  text-decoration: none; color: #374151; font-size: .86rem;
}
.recientes a .icono { width: 16px; height: 16px; flex: none; color: var(--text-muted); }
.recientes .reciente-texto { min-width: 0; display: flex; flex-direction: column; }
.recientes .reciente-titulo { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recientes .reciente-hora { font-size: .74rem; color: var(--text-muted); font-weight: 400; }
.recientes .en-curso .reciente-hora { color: var(--aviso); }
.recientes .en-curso .reciente-hora::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--aviso);
  margin-right: 5px; vertical-align: 1px; animation: latido 1.2s ease-in-out infinite;
}
@keyframes latido { 50% { opacity: .25; } }
.recientes .borrar {
  flex: none; border: 0; background: none; color: var(--text-muted); cursor: pointer; padding: 6px 8px;
  border-radius: 8px; opacity: 0; transition: opacity .15s;
}
.recientes li:hover .borrar, .recientes li.activo .borrar, .recientes .borrar:focus-visible { opacity: 1; }
.recientes .borrar:hover { color: var(--danger); background: var(--rojo-suave); }
.recientes .borrar .icono { width: 14px; height: 14px; }
.recientes-mas { border: 0; background: none; color: var(--rojo); font: .82rem var(--font); cursor: pointer; padding: 6px 10px; }
.recientes-nota { margin: 4px 10px 0; font-size: .74rem; color: var(--text-muted); line-height: 1.35; }
@media (hover: none) { .recientes .borrar { opacity: 1; } }
.atajos { display: flex; flex-direction: column; gap: 8px; padding: 16px 14px; }
.atajos-titulo { font-size: .82rem; color: var(--text-muted); margin: 0 4px 4px; }
.atajos a, .atajos button {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  text-decoration: none; color: #374151; font: .88rem var(--font); cursor: pointer; text-align: left;
}
.atajos a:hover, .atajos button:hover { border-color: var(--rojo-borde); color: var(--rojo); }
.atajos .icono { width: 18px; height: 18px; }
.lateral-pie { margin-top: auto; padding: 18px 22px 22px; color: var(--text-muted); font-size: .8rem; }
.marca-secundaria img { max-height: 26px; max-width: 120px; display: block; margin-top: 6px; }
.lema { line-height: 1.4; }

.contenido { position: relative; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.velo { display: none; }

/* Decoración geométrica del fondo (esquina superior derecha) */
.decoracion { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.decoracion::before, .decoracion::after { content: ""; position: absolute; }
.decoracion::before {
  top: 0; right: 0; width: 170px; height: 250px;
  background: linear-gradient(200deg, rgba(179, 15, 20, 0.9), rgba(179, 15, 20, 0.35));
  clip-path: polygon(100% 0, 100% 100%, 0 38%);
}
.decoracion::after {
  top: 120px; right: -120px; width: 420px; height: 420px; transform: rotate(45deg);
  border: 1px solid rgba(179, 15, 20, 0.10); background: linear-gradient(135deg, rgba(179, 15, 20, 0.05), transparent 60%);
}

/* ---------- Portada ---------- */
.bienvenida { max-width: 1060px; margin: 0 auto; padding: 56px 24px 24px; text-align: center; position: relative; }
.bienvenida-icono { color: var(--rojo); display: inline-grid; place-items: center; position: relative; }
.bienvenida-icono .icono { width: 64px; height: 64px; stroke-width: 1.4; }
.bienvenida-icono::before {
  content: ""; position: absolute; inset: -12px; border-radius: 50%;
  background: repeating-conic-gradient(var(--rojo) 0 2deg, transparent 2deg 30deg);
  -webkit-mask: radial-gradient(circle, transparent 42px, #000 43px, #000 46px, transparent 47px);
          mask: radial-gradient(circle, transparent 42px, #000 43px, #000 46px, transparent 47px);
}
.bienvenida h1 { font-size: 2.4rem; margin: 18px 0 6px; letter-spacing: -.01em; }
.bienvenida-sub { font-size: 1.25rem; color: #3f4654; margin: 0 0 14px; }
.bienvenida-texto { color: var(--text-muted); max-width: 560px; margin: 0 auto 36px; line-height: 1.55; }
.tarjetas { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; text-align: left; }
.tarjeta {
  position: relative; display: flex; flex-direction: column; gap: 8px; padding: 22px 22px 46px;
  background: var(--surface); border: 1px solid #eef0f3; border-radius: var(--radius); box-shadow: var(--sombra);
  text-decoration: none; color: var(--text); transition: transform .15s, box-shadow .15s, border-color .15s; min-height: 190px;
}
a.tarjeta:hover { transform: translateY(-2px); box-shadow: var(--sombra-alta); border-color: var(--rojo-borde); }
.tarjeta strong { font-size: 1.02rem; margin-top: 10px; }
.tarjeta-texto { color: var(--text-muted); font-size: .86rem; line-height: 1.5; }
.tarjeta-icono { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; }
.tarjeta-icono .icono { width: 22px; height: 22px; }
.tarjeta-flecha { position: absolute; right: 18px; bottom: 16px; color: #374151; }
.tarjeta-flecha .icono { width: 18px; height: 18px; }
.tarjeta.proxima { opacity: .78; }
.etiqueta-pronto {
  position: absolute; top: 18px; right: 18px; font-size: .7rem; font-weight: 600;
  background: #f3f4f6; color: #4b5563; border-radius: 999px; padding: 4px 10px;
}
.tono-rojo .tarjeta-icono { background: var(--rojo-suave); color: var(--rojo); }
.tono-verde .tarjeta-icono { background: #e7f5ee; color: #23845a; }
.tono-violeta .tarjeta-icono { background: #efeafc; color: #6a4bc9; }
.tono-azul .tarjeta-icono { background: #e8f1fd; color: #2c6ecb; }

/* ---------- Chat ---------- */
.vista-chat .chat-scroll { flex: 1; overflow-y: auto; padding: 0 24px 24px; position: relative; z-index: 1; }
.chat-messages { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; padding-top: 28px; }
.chat-messages:empty { display: none; }

.msg { max-width: 82%; padding: 12px 16px; border-radius: var(--radius); line-height: 1.5; font-size: .93rem; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--rojo); color: #fff; border-bottom-right-radius: 4px; box-shadow: 0 2px 6px rgba(179, 15, 20, 0.2); }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid #eef0f3; border-bottom-left-radius: 4px; box-shadow: var(--sombra); white-space: normal; max-width: 92%; }
.msg.assistant > *:first-child { margin-top: 0; }
.msg.assistant > *:last-child { margin-bottom: 0; }
.msg.assistant h1, .msg.assistant h2, .msg.assistant h3 { font-size: 1rem; margin: 16px 0 6px; font-weight: 700; color: #111827; }
.msg.assistant p { margin: 8px 0; }
.msg.assistant strong { font-weight: 600; }
.msg.assistant ul, .msg.assistant ol { margin: 8px 0; padding-left: 22px; }
.msg.assistant li { margin: 3px 0; }
.msg.assistant .aviso-asesoria { font-size: .78rem; font-weight: 600; color: #7a4a00; background: #fff6e0; border: 1px solid #f3dca6; border-radius: 8px; padding: 6px 10px; margin-bottom: 10px; }
.msg.assistant .acciones-respuesta { display: flex; justify-content: flex-end; margin-top: 10px; padding-top: 8px; border-top: 1px solid #eef0f3; }
.msg.assistant .boton-oficio { font: inherit; font-size: .82rem; font-weight: 600; color: var(--accent); background: transparent; border: 1px solid currentColor; border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.msg.assistant .boton-oficio:hover:not(:disabled) { background: #fdf2f2; }
.msg.assistant .boton-oficio:disabled { opacity: .7; cursor: wait; }
.msg.assistant hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.msg.assistant code { background: var(--bg); border-radius: 4px; padding: 1px 5px; font-size: .85em; font-family: Consolas, "SFMono-Regular", monospace; }
.msg.assistant pre { background: var(--bg); border-radius: 8px; padding: 10px 12px; overflow-x: auto; }
.msg.assistant pre code { background: none; padding: 0; }
.msg.assistant table { border-collapse: collapse; margin: 10px 0; font-size: .85rem; width: 100%; display: block; overflow-x: auto; }
.msg.assistant th, .msg.assistant td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; }
.msg.assistant th { background: #f8f8fa; font-weight: 600; }
.msg.assistant a { color: var(--rojo); }
.msg.error { align-self: flex-start; background: #fdecea; border: 1px solid #f4c7c3; color: var(--danger); }
.msg.pending { color: var(--text-muted); font-style: italic; }
.msg .sources { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.msg .sources .source-tag { font-size: .72rem; color: #4b5563; background: #f6f6f8; border: 1px solid var(--border); border-radius: 999px; padding: 3px 9px; }

.verificacion { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 13px; }
.verificacion-titulo { font-weight: 600; color: var(--ok); }
.verificacion-titulo.con-alertas { color: var(--aviso); }
.verificacion ul { margin: 6px 0 0 18px; color: var(--aviso); }
.verificacion details { margin-top: 6px; opacity: .85; }
.verificacion summary { cursor: pointer; }
.verificacion code { font-size: 12px; white-space: pre-wrap; word-break: break-word; }

.chat-input-bar { padding: 8px 24px 18px; position: relative; z-index: 1; }
.caja-pregunta {
  max-width: 920px; margin: 0 auto; display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--rojo-borde); border-radius: 16px; padding: 10px 10px 10px 16px;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.9), var(--sombra-alta);
}
.caja-pregunta:focus-within { border-color: var(--rojo); }
.caja-icono { color: var(--rojo); display: grid; }
.caja-pregunta textarea {
  flex: 1; resize: none; border: none; outline: none; font: .95rem var(--font); color: var(--text);
  max-height: 140px; padding: 10px 0; background: transparent;
}
.chat-hint { max-width: 920px; margin: 10px auto 0; font-size: .74rem; color: var(--text-muted); text-align: center; }

/* Imágenes adjuntas (adjuntos.js) */
.boton-adjuntar { border: none; background: none; color: var(--text-muted); cursor: pointer; padding: 6px; border-radius: 8px; display: grid; }
.boton-adjuntar:hover:not(:disabled) { color: var(--rojo); background: var(--rojo-suave); }
.boton-adjuntar:disabled { opacity: .5; cursor: default; }
.caja-pregunta.arrastrando { border-color: var(--rojo); border-style: dashed; }
.adjuntos-vista { max-width: 920px; margin: 0 auto 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.adjunto { position: relative; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.adjunto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.adjunto button { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; border: none; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 14px; line-height: 20px; padding: 0; }
.adjuntos-nota { flex: 1 1 220px; font-size: .74rem; color: var(--text-muted); }
.msg-imagenes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.msg-imagenes img { max-width: 160px; max-height: 120px; border-radius: 8px; display: block; background: #fff; }

.interruptor { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: #4b5563; cursor: pointer; white-space: nowrap; user-select: none; }
.interruptor input { position: absolute; opacity: 0; pointer-events: none; }
.interruptor-pista { width: 34px; height: 20px; border-radius: 999px; background: #d1d5db; position: relative; transition: background .15s; flex: none; }
.interruptor-pista::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.interruptor input:checked + .interruptor-pista { background: var(--rojo); }
.interruptor input:checked + .interruptor-pista::after { transform: translateX(14px); }
.interruptor input:focus-visible + .interruptor-pista { outline: 2px solid var(--rojo); outline-offset: 2px; }

/* ---------- Páginas de módulo (correspondencia, administración) ---------- */
.modulo-cabecera { max-width: 1060px; width: 100%; margin: 0 auto; padding: 28px 24px 0; position: relative; z-index: 1; }
.modulo-cabecera h1 { font-size: 1.6rem; margin: 0 0 4px; display: flex; align-items: center; gap: 12px; }
.modulo-cabecera h1 .tarjeta-icono { width: 42px; height: 42px; }
.modulo-cabecera p { margin: 0; color: var(--text-muted); }
.indicadores { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-top: 20px; }
.indicador { background: var(--surface); border: 1px solid #eef0f3; border-radius: var(--radius); box-shadow: var(--sombra); padding: 16px 18px; }
.indicador-etiqueta { font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.indicador-valor { font-size: 1rem; font-weight: 600; margin-top: 6px; }
.indicador-cifra { font-size: 2rem; font-weight: 700; margin-top: 4px; color: var(--rojo); line-height: 1.1; }
.tono-rojo-icono { background: var(--rojo-suave); color: var(--rojo); }
#passwordBlock, #accesoBlock { display: flex; flex-direction: column; gap: 12px; }
.tono-verde-icono { background: #e7f5ee; color: #23845a; }
.indicador-detalle { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.acciones { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.acciones .boton { height: 40px; padding: 0 16px; font-size: .86rem; }
.aviso-envio { margin-top: 10px; font-size: .86rem; color: var(--ok); }
.aviso-envio.error { color: var(--danger); }
.ejemplos { max-width: 860px; margin: 0 auto; padding-top: 24px; }
/* En las páginas de módulo, ejemplos y conversación se alinean con el ancho del encabezado */
.modulo-cabecera ~ .ejemplos, .modulo-cabecera ~ .chat-messages { max-width: 1012px; }
.ejemplos p { color: var(--text-muted); font-size: .9rem; margin: 0 0 10px; }
.ejemplos-lista { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.ejemplos button {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid #eef0f3; border-radius: 12px;
  background: var(--surface); box-shadow: var(--sombra); color: var(--text); font: .88rem var(--font); cursor: pointer; text-align: left;
}
.ejemplos button:hover { border-color: var(--rojo-borde); color: var(--rojo); }
.ejemplos button .icono { color: var(--rojo); width: 18px; height: 18px; }

.panel { background: var(--surface); border: 1px solid #eef0f3; border-radius: var(--radius); box-shadow: var(--sombra); padding: 20px 22px; margin-top: 20px; }
.panel h2 { font-size: 1.05rem; margin: 0 0 12px; }
.tabla { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabla th, .tabla td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tabla th { font-size: .78rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.tabla button { margin-right: 6px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font: .82rem var(--font); }
.tabla button:hover { border-color: var(--rojo-borde); color: var(--rojo); }
.vacio { color: var(--text-muted); font-size: .9rem; }
.agregar { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.agregar input { flex: 1; min-width: 240px; height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; font: .92rem var(--font); }
.agregar .boton { height: 42px; }
.mensaje-error { color: var(--danger); font-size: .9rem; min-height: 1.2em; margin: 12px 0 0; }
.desplazable { flex: 1; overflow-y: auto; position: relative; z-index: 1; padding-bottom: 32px; }

/* ---------- Ayuda ---------- */
.ayuda { border: none; border-radius: var(--radius); padding: 26px 28px; max-width: 560px; box-shadow: var(--sombra-alta); color: var(--text); font-family: var(--font); }
.ayuda::backdrop { background: rgba(17, 24, 39, 0.4); }
.ayuda h2 { margin: 0 0 12px; font-size: 1.15rem; }
.ayuda ul { padding-left: 20px; line-height: 1.55; font-size: .92rem; }
.ayuda li { margin-bottom: 8px; }

/* ---------- Acceso ---------- */
.acceso { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.acceso-marca {
  background: linear-gradient(150deg, var(--rojo-oscuro), var(--rojo) 55%, #c41418); color: #fff;
  display: flex; flex-direction: column; justify-content: space-between; padding: 48px 56px; position: relative; overflow: hidden;
}
.acceso-marca::after {
  content: ""; position: absolute; right: -140px; bottom: -140px; width: 420px; height: 420px; transform: rotate(45deg);
  border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(255, 255, 255, 0.05);
}
.acceso-marca .marca { height: auto; }
.acceso-marca .marca img { max-height: 64px; }
.acceso-marca h1 { font-size: 2.3rem; margin: 0 0 12px; line-height: 1.15; }
.acceso-marca p { opacity: .9; max-width: 440px; line-height: 1.55; margin: 0; }
.acceso-pie { font-size: .8rem; opacity: .75; }
.acceso-formulario { display: grid; place-items: center; padding: 32px; }
.login-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; }
.login-card h2 { margin: 0; font-size: 1.5rem; }
.login-card p.subtitle { margin: 0; color: var(--text-muted); line-height: 1.5; font-size: .92rem; }
.login-card input[type="password"], .login-card textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; font: .95rem var(--font);
}
.login-card button { height: 46px; }
.login-error { color: var(--danger); font-size: .9rem; margin: 0; min-height: 1.2em; }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; height: 48px; border-radius: 10px;
  background: var(--rojo); color: #fff; text-decoration: none; font-weight: 600; box-shadow: 0 2px 6px rgba(179, 15, 20, 0.25);
}
.google-btn:hover { background: var(--rojo-oscuro); }
.google-btn .g { width: 22px; height: 22px; border-radius: 50%; background: #fff; display: grid; place-items: center; }

/* ---------- Pantallas medianas y celulares ---------- */
@media (max-width: 1180px) {
  .tarjetas { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .barra { grid-template-columns: auto 1fr auto; }
  .barra-marca { padding: 0 12px; border-right: none; }
  .barra-menu { display: grid; }
  .barra-titulo { padding: 0 8px; }
  .usuario-nombre, .barra-enlace span, .boton-salir span { display: none; }
  .usuario-nombre { border: none; }
  .barra-usuario { gap: 10px; padding: 0 12px; }
  .boton-salir { padding: 8px; }
  .lateral { position: fixed; top: var(--alto-barra); bottom: 0; left: 0; width: var(--ancho-lateral); transform: translateX(-100%); transition: transform .2s; box-shadow: var(--sombra-alta); }
  .lateral.abierto { transform: none; }
  .velo.visible { display: block; position: fixed; inset: var(--alto-barra) 0 0 0; background: rgba(17, 24, 39, 0.35); z-index: 1; }
  .contenido { grid-column: 1; }
  .acceso { grid-template-columns: 1fr; }
  .acceso-marca { padding: 32px 24px; min-height: 260px; }
  .acceso-marca h1 { font-size: 1.7rem; }
}
@media (max-width: 640px) {
  .barra-nombre { font-size: .92rem; }
  .barra-proyecto { display: none; }
  .bienvenida { padding: 32px 16px 16px; }
  .bienvenida h1 { font-size: 1.8rem; }
  .bienvenida-sub { font-size: 1.05rem; }
  .tarjetas { grid-template-columns: 1fr; gap: 12px; }
  .tarjeta { min-height: 0; }
  .vista-chat .chat-scroll, .chat-input-bar { padding-left: 16px; padding-right: 16px; }
  .caja-pregunta { flex-wrap: wrap; padding: 8px 8px 8px 12px; }
  .caja-pregunta textarea { flex-basis: calc(100% - 40px); }
  .interruptor { margin-right: auto; }
  .msg { max-width: 92%; }
  .modulo-cabecera { padding: 20px 16px 0; }
  .decoracion { display: none; }
  .barra-marca { gap: 8px; }
  .barra .marca img { max-height: 36px; max-width: 80px; }
  .marca-separador { height: 22px; }
  .barra .marca-aliada img { max-height: 16px; max-width: 58px; }
  .barra-nombre { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
/* Teléfonos: los dos logos identifican la plataforma; el título de la barra no cabe */
@media (max-width: 480px) {
  .barra-titulo { visibility: hidden; padding: 0; }
}

/* ---------- Páginas de la cola de oficios (P02, deshabilitada en el servidor) ---------- */
.app-shell { height: 100vh; display: flex; flex-direction: column; }
.form-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 40px;
}

.form-card {
  max-width: 640px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-note {
  margin: 0 0 4px;
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
}

.form-note code {
  font-size: 0.8em;
}

.form-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text);
}

.form-card input,
.form-card select,
.form-card textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.9rem;
  font-family: inherit;
}

.form-card textarea {
  resize: vertical;
}

.form-card button {
  align-self: flex-start;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.9rem;
  cursor: pointer;
}

.form-card button:disabled { opacity: 0.6; cursor: default; }

.form-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0;
}

.form-ok {
  color: var(--accent);
  font-size: 0.85rem;
  margin: 0;
}

/* ---------- Tabla de seguimiento ---------- */
.tracking-table {
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.85rem;
}

.tracking-table th,
.tracking-table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.tracking-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
}

.tracking-table code {
  font-size: 0.78rem;
  word-break: break-all;
}

.resultado-notas {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.estado-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
}

.estado-badge.estado-listo { border-color: var(--accent); color: var(--accent); }
.estado-badge.estado-aprobado { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.estado-badge.estado-error,
.estado-badge.estado-rechazado { border-color: var(--danger); color: var(--danger); }

.tracking-table button {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  margin-right: 6px;
  background: var(--surface);
}

.btn-aprobar { border-color: var(--accent) !important; color: var(--accent); }
.btn-rechazar { border-color: var(--danger) !important; color: var(--danger); }
.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.app-header h1 {
  font-size: 1rem;
  margin: 0;
}

.app-header .project-tag {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.app-header button.logout {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-nav a {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.header-nav a:hover {
  color: var(--accent);
}

/* ---------- Formularios (solicitar.html) ---------- */

/* ---------- Preinformes ---------- */
.tono-violeta-icono { background: #efeafc; color: #6a4bc9; }
.tono-gris-icono { background: #f3f4f6; color: #6b7280; }
.barra-mes { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.barra-mes label { font-weight: 600; font-size: .9rem; }
.barra-mes select { height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; font: .92rem var(--font); background: var(--surface); }
.mes-nota { color: var(--text-muted); font-size: .82rem; }
.preinformes { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; margin-top: 18px; align-items: start; }
.preinforme { background: var(--surface); border: 1px solid #eef0f3; border-radius: var(--radius); box-shadow: var(--sombra); padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.preinforme.proxima { opacity: .75; }
.preinforme-cabecera { display: flex; align-items: center; gap: 12px; }
.preinforme-cabecera .tarjeta-icono { width: 42px; height: 42px; flex: none; }
.preinforme-cabecera > div { flex: 1; min-width: 0; }
.preinforme-sub { color: var(--text-muted); font-size: .8rem; margin-top: 2px; }
.estado-chip { font-size: .72rem; font-weight: 600; border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.estado-chip.gris { background: #f3f4f6; color: #4b5563; }
.estado-chip.azul { background: #e8f1fd; color: #2c6ecb; }
.estado-chip.verde { background: #e7f5ee; color: #23845a; }
.estado-chip.rojo { background: var(--rojo-suave); color: var(--rojo); }
.avance { height: 8px; border-radius: 999px; background: #eef0f3; overflow: hidden; }
.avance-barra { height: 100%; background: linear-gradient(90deg, #6a4bc9, #9b83e6); border-radius: 999px; transition: width .4s; }
.preinforme-paso { font-size: .86rem; }
.preinforme-meta { font-size: .8rem; color: var(--text-muted); }
.preinforme-meta.error { color: var(--danger); }
.cifras { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cifra { background: #f8f8fa; border-radius: 10px; padding: 10px; }
.cifra strong { display: block; font-size: 1.15rem; }
.cifra span { font-size: .72rem; color: var(--text-muted); line-height: 1.3; display: block; }
.preinforme .acciones { margin-top: 0; }
.pendientes summary { cursor: pointer; font-size: .86rem; color: var(--rojo); font-weight: 600; }
.pendientes ul { margin: 8px 0 0; padding-left: 18px; font-size: .84rem; line-height: 1.45; max-height: 260px; overflow-y: auto; }
.pendientes li { margin-bottom: 6px; }
.como-funciona ol { margin: 0; padding-left: 20px; line-height: 1.6; font-size: .9rem; color: #374151; }

/* ---------- Revisión del preinforme ---------- */
.estado-chip.violeta { background: #efeafc; color: #6a4bc9; }
.estado-chip.ambar { background: #fff4dc; color: #9a6b12; }
.migas { font-size: .84rem; color: var(--text-muted); margin: 0 0 6px; }
.migas a { color: var(--rojo); text-decoration: none; }
.aviso-revision { margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: #f3f0fd; border: 1px solid #e0d8fa; font-size: .9rem; }
.aviso-revision .acciones { margin-top: 10px; }
.filtros { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-top: 22px; }
.segmentos { display: flex; flex-wrap: wrap; gap: 6px; }
.segmento { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 7px 14px; font: .84rem var(--font); cursor: pointer; color: #374151; }
.segmento.activo { background: var(--rojo); border-color: var(--rojo); color: #fff; }
.observaciones { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; padding-bottom: 90px; }
.obs { background: var(--surface); border: 1px solid #eef0f3; border-left: 4px solid #d1d5db; border-radius: 12px; box-shadow: var(--sombra); padding: 14px 16px; }
.obs.tipo-pendiente { border-left-color: var(--rojo); }
.obs.tipo-decision { border-left-color: #2c6ecb; }
.obs.tipo-inconsistencia { border-left-color: #c58a12; }
.obs.respondida { background: #fbfdfc; }
.obs-cabecera { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.obs-id { font-weight: 700; font-size: .8rem; border-radius: 6px; padding: 2px 8px; color: #fff; background: #6b7280; }
.obs-id.tipo-pendiente { background: var(--rojo); }
.obs-id.tipo-decision { background: #2c6ecb; }
.obs-id.tipo-inconsistencia { background: #c58a12; }
.obs-tipo { font-size: .8rem; font-weight: 600; color: #374151; }
.obs-capitulo { font-size: .76rem; color: var(--text-muted); }
.obs-cabecera .estado-chip { margin-left: auto; }
.obs-texto { margin: 10px 0 4px; line-height: 1.5; font-size: .93rem; }
.obs-responsable { font-size: .8rem; color: var(--text-muted); }
.obs-respuesta { width: 100%; margin-top: 10px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font: .9rem var(--font); resize: vertical; min-height: 54px; }
.obs-respuesta:focus { outline: none; border-color: var(--rojo); }
.obs-pie { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; font-size: .8rem; }
.obs-sin-resolver { color: #374151; cursor: pointer; }
.obs-guardado { color: var(--text-muted); }
.obs-guardado.error { color: var(--danger); }
.obs-leida { margin-top: 10px; font-size: .88rem; line-height: 1.5; background: #f8f8fa; border-radius: 10px; padding: 10px 12px; }
.obs-ajuste { margin-top: 8px; font-size: .84rem; color: #23845a; }
/* «Responder con IA»: botón, propuesta con su soporte y aprobación del especialista */
.ia-zona { margin-top: 10px; border-top: 1px dashed #e5e7eb; padding-top: 10px; }
.ia-barra { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.boton-ia { display: inline-flex; align-items: center; gap: 7px; border: 1px solid #d9cff7; background: #f6f2fe; color: #5b3aa6; border-radius: 9px; padding: 7px 13px; font: 600 .84rem var(--font); cursor: pointer; }
.boton-ia:hover:not(:disabled) { background: #ece4fd; }
.boton-ia:disabled { opacity: .75; cursor: progress; }
.boton-ia .icono { width: 16px; height: 16px; }
.ia-nota { font-size: .78rem; color: var(--text-muted); }
.ia-panel { margin-top: 10px; background: #faf8ff; border: 1px solid #e6defb; border-radius: 10px; padding: 12px 14px; }
.ia-panel.sin-evidencia { background: #fffaf0; border-color: #f2dfb3; }
.ia-panel-cabecera { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: .84rem; }
.ia-meta { color: var(--text-muted); font-size: .76rem; }
.ia-propuesta { margin-top: 8px; white-space: pre-wrap; line-height: 1.5; font-size: .9rem; }
.ia-alerta { margin-top: 8px; font-size: .8rem; color: #9a5b00; }
.ia-detalle { margin-top: 8px; font-size: .82rem; }
.ia-detalle summary { cursor: pointer; color: #5b3aa6; font-weight: 600; }
.ia-detalle-texto { margin-top: 6px; white-space: pre-wrap; line-height: 1.45; color: #374151; max-height: 260px; overflow: auto; }
.ia-acciones { margin-top: 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ia-aprobacion { margin-top: 6px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .82rem; }
.ia-aprobar { cursor: pointer; color: #374151; font-weight: 600; }
.barra-final { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 12px 24px; background: rgba(255, 255, 255, 0.96); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(16, 24, 40, 0.06); }
.barra-final-texto { font-size: .9rem; color: #374151; }

/* Correspondencia: aviso de conversación guardada y botón para empezar otra */
.barra-conversacion {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  max-width: 860px; margin: 0 auto 8px; padding: 8px 4px; color: var(--text-muted); font-size: .85rem;
}
.barra-conversacion .boton { padding: 6px 14px; font-size: .85rem; }
