/* ============================================================
   estilos.css  —  Sistema de diseño único de AIbogado
   Un solo archivo. Todos los colores, tipografías y componentes
   se definen aquí; las páginas solo usan estas clases.
   ============================================================ */

/* ── Variables del sistema ── */
:root {
    /* Color primario de marca */
    --primario: #6b3fa0;
    --primario-oscuro: #552f80;
    --primario-suave: #efe8f8;
    --primario-borde: #c9b8e8;

    /* Fondos y superficies */
    --fondo: #f5f2ec;
    --superficie: #ffffff;
    --superficie-alt: #faf8fc;
    --borde: #e0d8cc;
    --borde-suave: #f0ece4;

    /* Texto */
    --texto: #2d2a26;
    --texto-medio: #666666;
    --texto-suave: #888888;

    /* Semánticos */
    --exito: #2e7d32;
    --exito-fondo: #e8f5e9;
    --exito-borde: #c8e6c9;
    --error: #c62828;
    --error-fondo: #ffebee;
    --error-borde: #ffcdd2;
    --alerta: #e65100;
    --alerta-fondo: #fff3e0;
    --info: #1565c0;
    --info-fondo: #e3f2fd;

    /* Consola / logs */
    --consola-fondo: #1e1e1e;
    --consola-texto: #d4d4d4;

    /* Tipografía */
    --fuente: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --mono: 'Consolas', 'Courier New', monospace;

    /* Radios */
    --radio: 14px;
    --radio-btn: 10px;

    /* Sombras */
    --sombra-card: 0 2px 10px rgba(0,0,0,0.06);
    --sombra-dialog: 0 10px 40px rgba(0,0,0,0.25);
}

/* ── Reset y base ── */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--fuente);
    background: var(--fondo);
    color: var(--texto);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ══════════════════════════════════════════════
   LAYOUT — Barra superior + contenedor + tarjetas
   ══════════════════════════════════════════════ */

/* Barra superior morada — siempre a lo ancho, fija arriba */
.topbar {
    background: var(--primario);
    color: #fff;
    padding: 0.9rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    width: 100%;
    box-sizing: border-box;
}
/* Páginas con topbar: flujo normal en bloque (la barra ocupa toda la fila) */
body.con-topbar {
    display: block;
    align-items: stretch;
    justify-content: flex-start;
}
.topbar h1 { margin: 0; font-size: 1.15rem; font-weight: 600; }
.topbar a {
    color: #fff;
    text-decoration: none;
    font-size: 0.85rem;
    opacity: 0.9;
}
.topbar a:hover { opacity: 1; text-decoration: underline; }

/* Contenedor ancho para páginas de gestión */
.page-wrap {
    max-width: 900px;
    width: 100%;
    margin: 1.5rem auto;
    padding: 0 1rem;
}

/* Tarjeta blanca estándar */
.card {
    background: var(--superficie);
    border-radius: var(--radio);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--sombra-card);
    margin-bottom: 1.5rem;
}
.card h2 {
    margin: 0 0 1rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primario);
}
.card h2 .count,
.count-chip {
    background: var(--primario-suave);
    color: var(--primario);
    border-radius: 20px;
    padding: 0.1rem 0.6rem;
    font-size: 0.8rem;
    margin-left: 0.4rem;
    text-transform: none;
    letter-spacing: normal;
}

/* Contenedor central tipo tarjeta (login, formularios) */
.container {
    background: var(--superficie);
    border-radius: 16px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    text-align: center;
}
.container-chat { max-width: 720px; text-align: left; }

/* Logo */
.logo { max-width: 100px; height: auto; margin-bottom: 1rem; }

/* Subtítulo */
.subtitulo {
    color: var(--texto-suave);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* Texto vacío / cargando */
.vacio {
    color: #999;
    font-size: 0.9rem;
    padding: 1rem 0;
    text-align: center;
}

/* ══════════════════════════════════════════════
   TIPOGRAFÍA
   ══════════════════════════════════════════════ */
h1 { font-size: 1.4rem; color: var(--texto); margin-bottom: 0.5rem; }

/* ══════════════════════════════════════════════
   BOTONES
   ══════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.8rem;
    border: none;
    border-radius: var(--radio-btn);
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--fuente);
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s, background 0.15s;
    margin-bottom: 0.75rem;
    color: #fff;
    text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primario); }
.btn-primary:hover:not(:disabled) { background: var(--primario-oscuro); }

.btn-whatsapp { background: #25D366; }
.btn-whatsapp:hover:not(:disabled) { opacity: 0.9; }

/* Botón secundario pequeño (toolbar) */
.btn-sec {
    padding: 0.5rem 0.9rem;
    border-radius: 8px;
    border: 1px solid var(--borde);
    background: var(--superficie-alt);
    color: #4a3d63;
    font-size: 0.85rem;
    font-family: var(--fuente);
    cursor: pointer;
    transition: background 0.15s;
}
.btn-sec:hover { background: var(--primario-suave); }

/* Botón grande de acción dentro de una card */
.btn-nuevo {
    width: 100%;
    padding: 0.7rem;
    border-radius: var(--radio-btn);
    border: none;
    background: var(--primario);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--fuente);
    cursor: pointer;
    margin-top: 0.75rem;
}
.btn-nuevo:hover { background: var(--primario-oscuro); }

/* Botón de icono (acciones de fila: editar/eliminar/completar) */
.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.35rem;
    border-radius: 8px;
    flex-shrink: 0;
    line-height: 1;
}
.icon-btn:hover { background: var(--primario-suave); }

/* Accesos tipo mosaico (menú principal) */
.accesos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.7rem; }
.acc-btn {
    background: var(--superficie-alt);
    border: 1px solid #e5deef;
    border-radius: 12px;
    padding: 0.85rem;
    text-align: center;
    cursor: pointer;
    font-size: 0.88rem;
    color: #4a3d63;
    transition: all 0.15s;
    text-decoration: none;
    font-family: inherit;   /* para que <button class="acc-btn"> se vea igual que <a> */
    width: auto;
    display: block;
}
.acc-btn:hover {
    background: var(--primario-suave);
    border-color: var(--primario-borde);
    transform: translateY(-1px);
}

/* Botones de navegación del chat */
.chat-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.8rem;
    border: 1px solid #d8cdbe;
    border-radius: 8px;
    background: var(--superficie);
    color: #4a3b2c;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: var(--fuente);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
}
.chat-nav-btn:hover {
    background: var(--fondo);
    border-color: var(--primario);
    color: var(--primario);
}

/* ══════════════════════════════════════════════
   FORMULARIOS
   ══════════════════════════════════════════════ */
.campo { margin-bottom: 1rem; text-align: left; }
.campo label,
label.campo-label {
    display: block;
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 0.3rem;
    font-weight: 600;
}
.campo input,
.campo select,
.campo textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--borde);
    border-radius: var(--radio-btn);
    font-size: 1rem;
    font-family: var(--fuente);
    outline: none;
    transition: border-color 0.2s;
    background: var(--superficie);
    color: #333;
}
.campo input:focus,
.campo select:focus,
.campo textarea:focus { border-color: var(--primario); }
.campo textarea { resize: vertical; min-height: 80px; }

/* Etiquetas compactas (formularios en cards) */
.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #555;
    margin: 0.7rem 0 0.25rem;
}

/* Separador "— o —" */
.separador {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: #bbb;
    font-size: 0.85rem;
}
.separador::before,
.separador::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--borde);
}

/* ══════════════════════════════════════════════
   DIÁLOGOS (<dialog>) — un solo estilo para toda la app
   ══════════════════════════════════════════════ */
dialog {
    border: none;
    border-radius: var(--radio);
    padding: 1.5rem;
    max-width: 420px;
    width: 90%;
    box-shadow: var(--sombra-dialog);
    font-family: var(--fuente);
}
dialog::backdrop { background: rgba(0,0,0,0.4); }
dialog h3 { margin-top: 0; margin-bottom: 0.7rem; color: var(--texto); }
dialog input,
dialog select,
dialog textarea {
    width: 100%;
    padding: 0.6rem;
    margin-bottom: 0.7rem;
    border: 1px solid #d8cdbe;
    border-radius: 8px;
    font-size: 0.9rem;
    box-sizing: border-box;
    font-family: var(--fuente);
    outline: none;
}
dialog input:focus,
dialog select:focus,
dialog textarea:focus { border-color: var(--primario); }
dialog textarea { resize: vertical; }
dialog .fila { display: flex; gap: 0.6rem; }
dialog button.primary {
    width: 100%;
    padding: 0.65rem;
    border: none;
    border-radius: 8px;
    background: var(--primario);
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--fuente);
}
dialog button.primary:hover { background: var(--primario-oscuro); }
dialog button.cancelar {
    width: 100%;
    padding: 0.55rem;
    border: none;
    border-radius: 8px;
    background: #eee;
    color: #666;
    cursor: pointer;
    margin-top: 0.4rem;
    font-size: 0.85rem;
    font-family: var(--fuente);
}

/* ══════════════════════════════════════════════
   MENSAJES DE ESTADO
   ══════════════════════════════════════════════ */
.mensaje {
    padding: 0.7rem 1rem;
    border-radius: var(--radio-btn);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    display: none;
}
.mensaje.error {
    display: block;
    background: var(--error-fondo);
    color: #b71c1c;
    border: 1px solid #f5c6cb;
}
.mensaje.exito {
    display: block;
    background: var(--exito-fondo);
    color: var(--exito);
    border: 1px solid var(--exito-borde);
}

.status {
    text-align: center;
    color: var(--texto-suave);
    font-size: 0.85rem;
    margin: 0.25rem 0 0.5rem;
}

/* ══════════════════════════════════════════════
   SPINNER
   ══════════════════════════════════════════════ */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.spinner-grande {
    width: 36px;
    height: 36px;
    border: 4px solid #ddd;
    border-top-color: var(--primario);
    margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Overlay de generación (redactor) */
.overlay-gen {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
    flex-direction: column;
    gap: 0.8rem;
}
.overlay-gen.active { display: flex; }
.overlay-gen .spinner-grande { margin: 0; }

/* ══════════════════════════════════════════════
   LISTAS DE ELEMENTOS (clientes, procesos, tareas, chats)
   ══════════════════════════════════════════════ */
.item-lista {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.75rem 0.4rem;
    border-bottom: 1px solid var(--borde-suave);
}
.item-lista:last-child { border-bottom: none; }
.item-lista .info { flex: 1; min-width: 0; }
.item-lista .titulo {
    font-weight: 600;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.item-lista .sub {
    font-size: 0.8rem;
    color: var(--texto-suave);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.item-lista.completada .titulo { text-decoration: line-through; color: #aaa; }

/* Alias históricos (mismos estilos) */
.cliente-item,
.tarea-item,
.agenda-item,
.proceso-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.75rem 0.4rem;
    border-bottom: 1px solid var(--borde-suave);
}
.cliente-item:last-child,
.tarea-item:last-child,
.agenda-item:last-child,
.proceso-item:last-child { border-bottom: none; }
.cliente-item .info,
.tarea-item .info,
.agenda-item .info { flex: 1; min-width: 0; }
.cliente-item .nombre,
.tarea-item .titulo,
.agenda-item .titulo {
    font-weight: 600;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cliente-item .sub,
.tarea-item .sub,
.agenda-item .sub {
    font-size: 0.8rem;
    color: var(--texto-suave);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.proceso-item { justify-content: space-between; cursor: pointer; }
.proceso-item:hover { background: var(--superficie-alt); }
.proceso-item .ref { font-weight: 600; font-size: 0.95rem; }
.proceso-item .cli { font-size: 0.8rem; color: var(--texto-suave); }
.tarea-item.completada .titulo { text-decoration: line-through; color: #aaa; }

/* ══════════════════════════════════════════════
   BADGES Y SEMÁFOROS
   ══════════════════════════════════════════════ */
.badge-tipo {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    flex-shrink: 0;
}
.tipo-plazo { background: var(--error-fondo); color: var(--error); }
.tipo-audiencia { background: var(--info-fondo); color: var(--info); }
.tipo-tarea { background: var(--primario-suave); color: var(--primario); }

.pend-badge {
    background: var(--alerta-fondo);
    color: var(--alerta);
    border-radius: 12px;
    font-size: 0.75rem;
    padding: 0.15rem 0.55rem;
    white-space: nowrap;
}

.semaforo {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}
.semaforo.rojo { background: #e53935; box-shadow: 0 0 0 3px rgba(229,57,53,0.13); }
.semaforo.amarillo { background: #fdd835; box-shadow: 0 0 0 3px rgba(253,216,53,0.13); }
.semaforo.gris { background: #bdbdbd; }
.vencido { color: var(--error); font-weight: 700; }

/* Chips de fuentes */
.fuente-chip {
    display: inline-block;
    background: var(--primario-suave);
    border: 1px solid #d9c9ef;
    color: #5a3d86;
    border-radius: 12px;
    padding: 0.15rem 0.6rem;
    font-size: 0.75rem;
    margin: 0.15rem 0.2rem 0 0;
}

/* ══════════════════════════════════════════════
   BARRAS DE PROGRESO
   ══════════════════════════════════════════════ */
.progress-track {
    background: var(--borde);
    border-radius: 8px;
    height: 12px;
    overflow: hidden;
}
.progress-fill {
    background: var(--primario);
    height: 100%;
    width: 0%;
    transition: width 0.3s;
}
.progress-bar-container {
    background: var(--borde);
    border-radius: 8px;
    height: 12px;
    width: 100%;
    overflow: hidden;
    margin: 1rem 0 0.5rem;
}
.progress-bar-fill {
    background: var(--primario);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
}

/* ══════════════════════════════════════════════
   CONSOLA / LOGS (expedientes, relaciones)
   ══════════════════════════════════════════════ */
.console-log,
.page-log {
    background: var(--consola-fondo);
    color: var(--consola-texto);
    font-family: var(--mono);
    font-size: 0.82rem;
    padding: 1rem;
    border-radius: var(--radio-btn);
    height: 260px;
    overflow-y: auto;
    margin-top: 1rem;
    line-height: 1.5;
    display: none;
}
.console-log { height: 320px; }
.log-line { margin-bottom: 0.3rem; }
.log-line.info { color: #9cdcfe; }
.log-line.success { color: #4ec9b0; }
.log-line.warn { color: #dcdcaa; }
.log-line.error { color: #f48771; }
.log-line .time { color: #6a9955; margin-right: 0.5rem; }

/* Estados del motor (doc_splitter / relaciones) */
.motor-status {
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    text-align: center;
}
.motor-status.activo {
    background: var(--exito-fondo);
    color: var(--exito);
    border: 1px solid var(--exito-borde);
}
.motor-status.inactivo {
    background: #f5f5f5;
    color: var(--texto-suave);
    border: 1px solid #e0e0e0;
}

/* Tarjetas de estadísticas (relaciones) */
.stats-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    margin: 1.25rem 0;
}
.stat-card {
    background: #fbf9f6;
    border: 1px solid var(--borde);
    border-radius: var(--radio-btn);
    padding: 1rem;
    text-align: center;
}
.stat-card .val {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primario);
    display: block;
}
.stat-card .lbl {
    font-size: 0.8rem;
    color: var(--texto-medio);
    margin-top: 0.2rem;
}

/* ══════════════════════════════════════════════
   CHAT
   ══════════════════════════════════════════════ */
.chat-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--borde);
    margin-bottom: 0.75rem;
}
.chat-title-box { flex: 1; min-width: 0; text-align: center; }
.chat-title-box h2 {
    font-size: 1.05rem;
    color: var(--texto);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-title-box small { color: var(--texto-suave); font-size: 0.75rem; }
.chat-nav-actions { display: flex; gap: 0.4rem; }

.chat-panel {
    width: 100%;
    max-height: 55vh;
    min-height: 160px;
    overflow-y: auto;
    padding: 0.75rem;
    margin: 1rem 0;
    border: 1px solid var(--borde);
    border-radius: 12px;
    background: #fbfaf7;
}
.chat-panel::-webkit-scrollbar { width: 8px; }
.chat-panel::-webkit-scrollbar-thumb { background: #d8cdbe; border-radius: 4px; }

.msg { margin-bottom: 0.9rem; }
.msg .tag {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--primario);
    margin-bottom: 0.2rem;
}
.msg.assistant .tag { color: #3a7d44; }
.msg .cuerpo {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #333;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.msg.thinking .cuerpo { color: #999; font-style: italic; }

.chat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1rem;
    border: 1px solid #ddd;
    border-radius: var(--radio-btn);
    margin-bottom: 0.6rem;
    background: var(--superficie);
}
.chat-item-info { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.chat-item-info small { color: var(--texto-suave); }

/* Citas interactivas tipo NotebookLM */
.badge-cita {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ede9fe;
    color: #5b21b6;
    border: 1px solid #c4b5fd;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    margin: 0 0.15rem;
    cursor: pointer;
    vertical-align: baseline;
    line-height: 1.2;
    transition: all 0.15s ease;
    font-family: var(--fuente);
}
.badge-cita:hover {
    background: var(--primario);
    border-color: #5b21b6;
    color: #fff;
    transform: translateY(-1px);
}

.fuentes { margin-top: 0.55rem; }
.fuentes strong { font-size: 0.8rem; color: #555; }
.fuente {
    margin-top: 0.4rem;
    padding: 0.5rem 0.7rem;
    background: var(--fondo);
    border-left: 3px solid var(--primario);
    border-radius: 6px;
    font-size: 0.82rem;
    color: #555;
}
.fuente em { color: var(--primario); font-style: normal; font-weight: 600; }
.fuente small { color: #999; }

.fuentes-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.6rem;
}
.fuentes-chips .fuente-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.55rem;
    background: #f3ede2;
    border: 1px solid #e2d7c5;
    border-radius: 6px;
    font-size: 0.75rem;
    color: #5a4634;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    margin: 0;
}
.fuentes-chips .fuente-chip:hover {
    background: var(--primario);
    border-color: var(--primario);
    color: #fff;
}
.fuente-chip .chip-num {
    background: var(--primario);
    color: #fff;
    border-radius: 4px;
    padding: 0.05rem 0.3rem;
    font-weight: 700;
    font-size: 0.7rem;
}
.fuentes-chips .fuente-chip:hover .chip-num {
    background: #fff;
    color: var(--primario);
}

/* Modal visor de fuente legal */
.modal-fuente-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.modal-fuente-overlay.activo { opacity: 1; pointer-events: auto; }
.modal-fuente-card {
    background: var(--superficie);
    border-radius: var(--radio);
    width: 100%;
    max-width: 620px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
    animation: zoomModal 0.2s ease-out;
}
@keyframes zoomModal {
    from { transform: scale(0.95); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}
.modal-fuente-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: #fbf9f6;
    border-bottom: 1px solid var(--borde);
}
.modal-fuente-header h3 { font-size: 1.05rem; color: var(--texto); line-height: 1.3; }
.modal-fuente-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 0 0.2rem;
}
.modal-fuente-close:hover { color: #333; }
.modal-fuente-body {
    padding: 1.25rem;
    overflow-y: auto;
    font-size: 0.92rem;
    line-height: 1.6;
    color: #333;
}
.modal-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.9rem;
    font-size: 0.8rem;
}
.modal-tag {
    background: #f3ede2;
    color: var(--primario);
    padding: 0.2rem 0.5rem;
    border-radius: 5px;
    font-weight: 600;
}
.modal-texto-articulo {
    background: #faf7f2;
    border-left: 4px solid var(--primario);
    padding: 1rem;
    border-radius: 6px;
    white-space: pre-wrap;
    font-size: 0.9rem;
    color: #2b2219;
}

/* ══════════════════════════════════════════════
   CÓDIGOS DE ACCESO (computador / autorizar)
   ══════════════════════════════════════════════ */
.fila-codigo {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;          /* evita desborde en pantallas estrechas */
}
.grupo-codigo {
    display: flex;
    gap: 1.4rem;
    justify-content: center;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;          /* en móvil apila los dos grupos de 4 */
}
.fila-codigo .digito,
.fila-codigo input.digito-input {
    width: clamp(40px, 11vw, 56px);   /* se encoge si no cabe el marco */
    height: 64px;
}
.fila-codigo .digito {
    text-align: center;
    font-size: 1.6rem;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--texto);
    background: var(--fondo);
    border-radius: var(--radio-btn);
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: all;
}
.fila-codigo input.digito-input {
    text-align: center;
    font-size: 1.6rem;
    font-weight: 700;
    font-family: var(--mono);
    border: 2px solid var(--borde);
    border-radius: var(--radio-btn);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    color: var(--texto);
    background: #faf8f5;
}
.fila-codigo input.digito-input:focus {
    border-color: var(--primario);
    box-shadow: 0 0 0 3px rgba(107, 63, 160, 0.15);
}
.fila-codigo input.digito-input.error {
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.15);
}
@media (max-width: 420px) {
    .grupo-codigo { gap: 0.8rem; }
    .fila-codigo { gap: 0.35rem; }
}
.codigo-label { font-size: 0.8rem; color: var(--texto-suave); margin-bottom: 0.5rem; }

.timer-wrapper { position: relative; width: 120px; height: 120px; margin: 1rem auto; }
.timer-wrapper svg { transform: rotate(-90deg); }
.timer-bg { fill: none; stroke: var(--borde); stroke-width: 6; }
.timer-progress {
    fill: none;
    stroke: var(--primario);
    stroke-width: 6;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s linear;
}
.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--texto);
}

/* ══════════════════════════════════════════════
   LAYOUTS DE PÁGINA
   ══════════════════════════════════════════════ */

/* Dashboard del despacho: 3 columnas en escritorio */
.menu-wrap {
    max-width: 1400px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: 1fr 1fr 0.8fr;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 1100px) {
    .menu-wrap { grid-template-columns: 1fr 1fr; }
    .menu-wrap .col-full { grid-column: span 2; }
}
@media (max-width: 700px) {
    .menu-wrap { grid-template-columns: 1fr; }
    .menu-wrap .col-full { grid-column: auto; }
}

/* Página ancha tipo documento (doc_splitter) */
.doc-main {
    max-width: 820px;
    margin: 0 auto;
    padding: 24px 24px 80px;
}
body.pagina-doc { padding-top: 0; }
.card.card-lg { padding: 36px; margin-bottom: 24px; }

/* Título numerado de sección (01 / 02) */
.section-title {
    font-weight: 600;
    font-size: 22px;
    margin: 0 0 6px;
    color: var(--texto);
    text-transform: none;
    letter-spacing: normal;
    display: flex;
    align-items: baseline;
    gap: 10px;
}
.section-title .n {
    font-family: var(--mono);
    font-size: 13px;
    color: var(--primario);
    font-weight: 500;
}
.section-sub {
    color: var(--texto-medio);
    font-size: 14.5px;
    margin: 0 0 24px;
}

/* Select de ancho completo fuera de form-grid/campo */
.select-full {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1px solid #d8cdbe;
    border-radius: var(--radio-btn);
    font-size: 0.95rem;
    outline: none;
    box-sizing: border-box;
    font-family: var(--fuente);
    background: var(--superficie);
    color: #333;
}
.select-full:focus { border-color: var(--primario); }

/* Buscador con sugerencias (typeahead) */
.typeahead { position: relative; }
.typeahead-input {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1px solid #d8cdbe;
    border-radius: var(--radio-btn);
    font-size: 0.95rem;
    outline: none;
    box-sizing: border-box;
    font-family: var(--fuente);
    background: var(--superficie);
    color: #333;
}
.typeahead-input:focus { border-color: var(--primario); }
.typeahead-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: var(--radio-btn);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    max-height: 240px;
    overflow-y: auto;
    z-index: 30;
    display: none;
}
.typeahead-list.active { display: block; }
.typeahead-item {
    padding: 0.6rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--texto);
    border-bottom: 1px solid var(--borde-suave);
}
.typeahead-item:last-child { border-bottom: none; }
.typeahead-item:hover, .typeahead-item.sel { background: var(--primario-suave); }
.typeahead-item .th-sub { font-size: 0.75rem; color: var(--texto-suave); margin-top: 0.1rem; }
.typeahead-item.nuevo { color: var(--primario); font-weight: 600; }

/* ══════════════════════════════════════════════
   DROPZONE Y PROCESAMIENTO DE PDF (doc_splitter)
   ══════════════════════════════════════════════ */
.dropzone {
    border: 2px dashed var(--primario-borde);
    border-radius: var(--radio);
    padding: 44px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
    background: var(--superficie-alt);
}
.dropzone:hover, .dropzone:focus-visible {
    border-color: var(--primario);
    background: var(--primario-suave);
}
.dropzone.dragover {
    border-color: var(--primario-oscuro);
    background: #e5dbf3;
}
.dropzone:focus-visible { outline: 2px solid var(--primario); outline-offset: 3px; }
.dropzone svg { width: 34px; height: 34px; color: var(--primario); margin-bottom: 14px; }
.dropzone .dz-title { font-size: 18px; font-weight: 600; margin: 0 0 6px; color: var(--texto); }
.dropzone .dz-sub { font-size: 13.5px; color: var(--texto-medio); margin: 0; }
.dropzone .dz-sub .browse { color: var(--primario); text-decoration: underline; font-weight: 600; }

.filename-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-size: 12.5px;
    background: var(--texto);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    margin-top: 16px;
}
.progress-wrap { display: none; margin-top: 1rem; }
.progress-wrap.active { display: block; }
.progress-status {
    font-family: var(--mono);
    font-size: 13px;
    color: var(--texto-medio);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
}
.error-box {
    display: none;
    background: var(--error-fondo);
    border: 1px solid var(--error-borde);
    color: var(--error);
    padding: 14px 18px;
    border-radius: var(--radio-btn);
    font-size: 14px;
    margin-top: 16px;
}
.error-box.active { display: block; }
.results { display: none; }
.results.active { display: block; animation: fadeUp 0.4s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.actions-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 28px; }
.search-row { margin-bottom: 14px; }
.search-row input {
    width: 100%;
    font-family: var(--fuente);
    font-size: 14px;
    padding: 10px 14px;
    border: 1px solid var(--borde);
    border-radius: var(--radio-btn);
    background: var(--superficie);
    color: var(--texto);
    outline: none;
}
.search-row input:focus { border-color: var(--primario); }
.preview-list {
    max-height: 520px;
    overflow-y: auto;
    border: 1px solid var(--borde);
    border-radius: var(--radio-btn);
    background: var(--superficie);
}
.para { padding: 14px 18px; border-bottom: 1px solid var(--borde-suave); }
.para:last-child { border-bottom: none; }
.para .tag {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--primario);
    font-weight: 600;
    margin-bottom: 5px;
    word-break: break-word;
}
.para .txt { font-size: 14px; color: var(--texto); line-height: 1.55; }
.para.hidden { display: none; }
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 28px;
}
.stat {
    background: var(--superficie-alt);
    border: 1px solid var(--borde);
    border-radius: var(--radio-btn);
    padding: 18px 14px;
    text-align: center;
}
.stat .num {
    font-size: 28px;
    font-weight: 700;
    color: var(--primario);
    display: block;
    line-height: 1;
    margin-bottom: 6px;
}
.stat .label {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--texto-medio);
}
@media (max-width: 620px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
.btn-ghost {
    background: transparent;
    color: var(--texto);
    border: 1px solid var(--borde);
}
.btn-ghost:hover { background: var(--superficie-alt); }
.btn svg { width: 16px; height: 16px; }
.btn-inline { width: auto; margin-bottom: 0; }

/* Contenedor admin compacto (master) */
.container-admin { max-width: 500px; align-self: flex-start; text-align: center; }

/* Overrides menores de detalle de proceso */
.tarea-item .sub { white-space: normal; }

/* Overrides menores de expedientes */
.progress-wrap-exp { display: none; margin-top: 1rem; }
.progress-wrap-exp.active { display: block; }

/* Pantalla de inicio/carga (index) */
.container-inicio { background: none; box-shadow: none; padding: 2rem; max-width: 480px; }
.container-inicio .logo { max-width: 240px; margin-bottom: 2rem; }
.container-inicio .spinner-grande { display: block; }
.container-inicio .mensaje {
    color: #555; font-size: 1rem; margin-top: 1rem;
    background: none; border: none; display: block;
}

/* Contenedores de login/acceso */
.container-sm { max-width: 420px; }

/* ══════════════════════════════════════════════
   SOLICITUDES (panel admin)
   ══════════════════════════════════════════════ */
.solicitud {
    background: #faf8f5;
    border: 1px solid var(--borde);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.8rem;
    text-align: left;
}
.solicitud .telefono { font-size: 1.1rem; font-weight: 700; color: var(--texto); margin-bottom: 0.2rem; }
.solicitud .codigo {
    font-family: var(--mono);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--primario);
    background: var(--primario-suave);
    display: inline-block;
    padding: 0.3rem 0.8rem;
    border-radius: 8px;
    margin-bottom: 0.6rem;
}

/* ══════════════════════════════════════════════
   REDACTOR
   ══════════════════════════════════════════════ */
.redactor-wrap {
    max-width: 1400px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: 1fr 400px;   /* editor ancho + asistente lateral */
    align-items: start;
    gap: 1.5rem;
}
/* Base del editor de párrafos numerados (el JS usa el id #docEditor) */
.doc-editor {
    width: 100%;
    min-height: 320px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    line-height: 1.6;
    font-size: 0.95rem;
    border: 1px solid var(--borde);
    border-radius: var(--radio-btn);
    background: var(--superficie);
    color: var(--texto);
    counter-reset: parrafo;
    outline: none;
    font-family: var(--fuente);
}
.doc-editor:focus { border-color: var(--primario); }
.editor-toolbar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}
.estado-guardado { font-size: 0.78rem; color: var(--texto-suave); margin-left: auto; }

.borrador-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.3rem;
    border-bottom: 1px solid var(--borde-suave);
    cursor: pointer;
    font-size: 0.88rem;
}
.borrador-item:hover { background: var(--superficie-alt); }
.borrador-item:last-child { border-bottom: none; }
.borrador-item .t {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}
.borrador-item .s { font-size: 0.72rem; color: #999; }

/* ══════════════════════════════════════════════
   EXPEDIENTES
   ══════════════════════════════════════════════ */
.exp-container {
    max-width: 900px;
    width: 100%;
    margin: 1.5rem auto;
    background: var(--superficie);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.form-grid input,
.form-grid select {
    padding: 0.7rem 1rem;
    border: 1px solid #d8cdbe;
    border-radius: var(--radio-btn);
    font-size: 0.95rem;
    outline: none;
    box-sizing: border-box;
    font-family: var(--fuente);
    background: var(--superficie);
    color: #333;
}
.form-grid input:focus,
.form-grid select:focus { border-color: var(--primario); }

.dropzone-exp {
    border: 2px dashed var(--primario-borde);
    border-radius: var(--radio);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    background: var(--superficie-alt);
    transition: background 0.2s;
}
.dropzone-exp:hover, .dropzone-exp.dragover { background: #f0e9fa; }

.resumen-box {
    display: none;
    background: var(--primario-suave);
    border: 1px solid #d9c9ef;
    border-radius: 12px;
    padding: 1.25rem;
    margin-top: 1rem;
    white-space: pre-wrap;
    font-size: 0.95rem;
    line-height: 1.6;
}
.resumen-box.active { display: block; }

/* Detalle de proceso */
.meta { color: #777; font-size: 0.88rem; margin-bottom: 0.4rem; }
.meta b { color: #444; }

/* ══════════════════════════════════════════════
   BANNERS PWA
   ══════════════════════════════════════════════ */
.install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--superficie);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
    padding: 0.8rem 1rem;
    z-index: 1000;
    animation: subirBanner 0.4s ease-out;
}
@keyframes subirBanner {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
.install-content {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    max-width: 500px;
    margin: 0 auto;
}
.install-icon { width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0; }
.install-text { flex: 1; font-size: 0.85rem; color: #555; line-height: 1.3; }
.install-text strong { display: block; color: var(--texto); font-size: 0.9rem; }
.install-btn {
    background: var(--primario);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: opacity 0.2s;
    font-family: var(--fuente);
}
.install-btn:hover { opacity: 0.9; }
.install-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #bbb;
    cursor: pointer;
    padding: 0 0.2rem;
    line-height: 1;
    flex-shrink: 0;
}
.install-close:hover { color: #555; }

.update-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--primario);
    color: #fff;
    padding: 0.6rem 1rem;
    z-index: 1001;
    animation: bajarBanner 0.3s ease-out;
}
@keyframes bajarBanner {
    from { transform: translateY(-100%); }
    to   { transform: translateY(0); }
}
.update-content {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    max-width: 500px;
    margin: 0 auto;
    font-size: 0.85rem;
}
.update-content span { flex: 1; }
.update-btn {
    background: #fff;
    color: var(--primario);
    border: none;
    border-radius: 6px;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    font-family: var(--fuente);
}
.update-btn:hover { opacity: 0.9; }

/* ══════════════════════════════════════════════
   UTILIDADES  (reutilizables en cualquier página)
   Evitan los estilos inline repetidos en el HTML.
   ══════════════════════════════════════════════ */
.oculto { display: none !important; }

/* ── Layout y flexbox ── */
.flex          { display: flex; gap: 0.5rem; }
.flex-wrap     { flex-wrap: wrap; }
.flex-col      { display: flex; flex-direction: column; gap: 0.5rem; }
.flex-1        { flex: 1; min-width: 0; }
.flex-centro   { align-items: center; }
.items-end     { align-items: flex-end; }
.space-between { justify-content: space-between; }
.block         { display: block; }
.w-100         { width: 100%; }
.w-auto        { width: auto; }

/* ── Espaciado ── */
.mt-025 { margin-top: 0.25rem; }
.mt-05  { margin-top: 0.5rem; }
.mt-075 { margin-top: 0.75rem; }
.mt-1   { margin-top: 1rem; }
.mt-15  { margin-top: 1.5rem; }
.mb-025 { margin-bottom: 0.25rem; }
.mb-05  { margin-bottom: 0.5rem; }
.mb-075 { margin-bottom: 0.75rem; }
.mb-1   { margin-bottom: 1rem; }
.mb-15  { margin-bottom: 1.5rem; }
.m-0    { margin: 0; }

/* ── Tipografía y color de texto ── */
.txt-xs     { font-size: 0.75rem; }
.txt-sm     { font-size: 0.85rem; }
.txt-md     { font-size: 0.95rem; }
.txt-suave  { color: var(--texto-suave); }
.txt-medio  { color: var(--texto-medio); }
.txt-error  { color: var(--error); }
.txt-exito  { color: var(--exito); }
.txt-primario { color: var(--primario); }
.txt-bold   { font-weight: 600; }
.txt-centro { text-align: center; }
.txt-izq    { text-align: left; }
.txt-mono   { font-family: var(--mono); }

/* ── Fondos y bordes suaves ── */
.bg-error   { background: var(--error-fondo); border: 1px solid var(--error-borde); }
.bg-exito   { background: var(--exito-fondo); border: 1px solid var(--exito-borde); }
.bg-alerta  { background: var(--alerta-fondo); }
.bg-suave   { background: var(--superficie-alt); }

/* ── Varios ── */
.nota          { display: block; color: var(--texto-suave); font-size: 0.78rem; margin-top: 0.25rem; }
.subtitulo-izq { text-align: left; margin-bottom: 1rem; }
.cursor-pointer { cursor: pointer; }

/* ── Estado de badges de expediente ── */
.badge-exito { background: var(--exito-fondo); color: var(--exito); }
.badge-error { background: var(--error-fondo); color: var(--error); }

/* ══════════════════════════════════════════════
   CHAT — composición de la consulta
   ══════════════════════════════════════════════ */

/* Barra de acciones sobre la conversación (Eliminar, etc.) */
.chat-acciones { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.chat-nav-btn.peligro { color: var(--error); border-color: var(--error-borde); }

/* Panel plegable de instrucciones del asistente (system prompt) */
.chat-prompt {
    margin-bottom: 0.75rem;
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: var(--radio-btn);
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
}
.chat-prompt summary {
    cursor: pointer;
    color: var(--primario);
    font-weight: 600;
    outline: none;
    user-select: none;
}
.chat-prompt .contenido { margin-top: 0.5rem; }
.chat-prompt textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--borde);
    border-radius: 8px;
    font-family: var(--fuente);
    font-size: 0.85rem;
    resize: vertical;
    outline: none;
}
.chat-prompt textarea:focus { border-color: var(--primario); }

/* Compositor: textarea auto-expandible + botón Enviar */
.chat-campo { margin-bottom: 0.5rem; }
.chat-composer { display: flex; gap: 0.5rem; align-items: flex-end; }
.chat-composer .btn-nuevo { width: auto; padding: 0.75rem 1.4rem; margin-bottom: 0; }
.campo textarea.chat-input {
    min-height: 46px;
    max-height: 260px;
    resize: none;          /* el alto lo controla el JS */
    overflow-y: hidden;
    line-height: 1.45;
}
.chat-composer-hint {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.3rem;
    font-size: 0.75rem;
    color: var(--texto-suave);
}

/* Conservar saltos de línea y palabras largas en la consulta del usuario */
.msg.user .cuerpo { white-space: pre-wrap; word-break: break-word; }

/* Estado vacío y spinner dentro del panel de chat */
.chat-vacio { text-align: center; padding: 2rem 1rem; }
.spinner-chat { border-top-color: var(--primario); margin-right: 0.4rem; vertical-align: middle; }

/* Markdown jurídico renderizado en las respuestas del asistente */
.md-h2 { font-size: 1.15rem; color: #3a2a1a; margin: 1rem 0 0.4rem; }
.md-h3 { font-size: 1.05rem; color: #3a2a1a; margin: 0.9rem 0 0.35rem; }
.md-h4 {
    font-size: 0.98rem;
    color: #4a2c00;
    margin: 0.8rem 0 0.3rem;
    border-bottom: 1px solid var(--borde-suave);
    padding-bottom: 0.2rem;
}
.md-li { margin-left: 1.2rem; margin-bottom: 0.2rem; }

/* ── Modal de fuente: elementos propios ── */
.modal-tag.exito { background: var(--exito-fondo); color: var(--exito); }
.modal-fuente-header h3 { margin-top: 0.35rem; }
.modal-desc { color: var(--texto-medio); font-size: 0.85rem; margin-bottom: 0.8rem; display: none; }
.modal-seccion-titulo { font-weight: 600; font-size: 0.85rem; color: var(--texto-medio); margin-bottom: 0.4rem; }
.modal-relaciones {
    margin-top: 0.9rem;
    padding: 0.75rem;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 6px;
    font-size: 0.83rem;
    display: none;
}
.modal-relaciones strong { color: #b78103; }
.modal-relaciones ul { margin-top: 0.3rem; padding-left: 1.2rem; color: #5d4037; }

/* ══════════════════════════════════════════════
   RESPONSIVE GLOBAL
   ══════════════════════════════════════════════ */
@media (max-width: 1000px) {
    .redactor-wrap { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    body:not(.con-topbar) {
        align-items: flex-start;
        padding: 0.5rem;
        display: block;
    }
    .topbar { padding: 0.7rem 1rem; }
    .container { max-width: 100%; padding: 1rem 0.9rem; border-radius: 12px; }
    .page-wrap { margin: 1rem auto; }
    .card { padding: 1rem; }
    .exp-container { padding: 1rem; margin: 1rem auto; }
    .form-grid { grid-template-columns: 1fr; }

    .container-chat {
        max-width: 100%;
        min-height: calc(100vh - 16px);
        display: flex;
        flex-direction: column;
    }
    .chat-panel { flex: 1; max-height: none; min-height: 40vh; }
    .chat-nav { flex-wrap: wrap; gap: 0.4rem; }
    .chat-nav-btn { padding: 0.4rem 0.55rem; font-size: 0.78rem; }
    .chat-title-box {
        order: -1;
        flex-basis: 100%;
        text-align: left;
        margin-bottom: 0.15rem;
    }
    .chat-nav-actions { margin-left: auto; }

    .modal-fuente-overlay { padding: 0.5rem; }
    .modal-fuente-card { max-width: 100%; max-height: 92vh; border-radius: 12px; }
    .modal-fuente-body { padding: 0.9rem; }
}

@media (max-width: 420px) {
    .chat-nav-btn { padding: 0.35rem 0.45rem; font-size: 0.75rem; }
    .campo input, .campo textarea { font-size: 0.95rem; }
    .msg .cuerpo { font-size: 0.9rem; }
    .modal-meta-row { flex-direction: column; align-items: flex-start; }
}

@media (min-width: 900px) and (orientation: landscape) {
    .container-chat { max-width: 900px; padding: 2rem; min-height: auto; }
    .chat-panel { max-height: 62vh; }
}

/* ══════════════════════════════════════════════
   UTILIDADES ADICIONALES
   ══════════════════════════════════════════════ */
/* Oculto sin !important: el JS puede mostrarlo con el.style.display='block' */
.oculto-inicial { display: none; }
.op-85       { opacity: 0.85; }
.txt-088     { font-size: 0.88rem; }
.mt-02       { margin-top: 0.2rem; }
.mt-04       { margin-top: 0.4rem; }
.hint        { font-size: 0.78rem; color: var(--texto-suave); margin-top: 0.3rem; }

/* ══════════════════════════════════════════════
   TOPBAR / DESPACHO (menu.html)
   ══════════════════════════════════════════════ */
.topbar-fecha     { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.alerta-cabecera  { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.alerta-texto     { flex: 1; min-width: 220px; }
.bloque-separado  { border-top: 1px solid var(--borde-suave); padding-top: 0.75rem; }
.fila-acciones    { display: flex; align-items: center; gap: 0.4rem; }
.btn-compacto     { padding: 0.2rem 0.5rem; }
.acc-btn-autorizar { background: var(--error-fondo); border-color: var(--error-borde); color: var(--error); }

/* Gestión de feriados */
.feriados-scroll   { max-height: 260px; overflow-y: auto; margin-bottom: 0.7rem; }
.msg-feriados      { min-height: 1.1em; margin: 0.4rem 0; }
.feriado-item      { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0; border-bottom: 1px solid var(--borde-suave); }
.feriado-dia       { min-width: 3.2em; }
.feriado-etiqueta  { font-size: 0.72rem; opacity: 0.7; border: 1px solid var(--borde); border-radius: 6px; padding: 0.1rem 0.4rem; }

/* Listas de chat */
.chevron-lista { font-size: 1.4rem; color: var(--texto-suave); line-height: 1; }

/* ══════════════════════════════════════════════
   EXPEDIENTES (expedientes.html)
   ══════════════════════════════════════════════ */
.dz-exp-sub   { margin: 0.3rem 0 0; color: var(--texto-suave); font-size: 0.85rem; }
.progress-head { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--texto-medio); margin-bottom: 0.3rem; }

/* ══════════════════════════════════════════════
   AVISOS SIMPLES (computador.html, registrarse.html)
   ══════════════════════════════════════════════ */
.texto-aviso { font-size: 0.8rem; color: var(--texto-suave); }

/* ══════════════════════════════════════════════
   UNIR IMÁGENES / RECORTE (unirpdf.html)
   ══════════════════════════════════════════════ */
.img-lista { display: flex; flex-direction: column; gap: 0.6rem; }
.img-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: var(--superficie-alt);
    border: 1px solid var(--borde);
    border-radius: var(--radio-btn);
    padding: 0.5rem 0.7rem;
    cursor: grab;
    transition: background 0.15s, border-color 0.15s;
}
.img-item.arrastrando { opacity: 0.5; border-color: var(--primario); }
.img-item img.thumb {
    width: 46px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--borde);
    background: #fff;
    flex-shrink: 0;
}
.img-info     { flex: 1; min-width: 0; }
.img-nombre   { font-size: 0.88rem; color: var(--texto); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.img-num      { font-size: 0.75rem; color: var(--texto-suave); }
.img-acciones { display: flex; gap: 0.2rem; flex-shrink: 0; }
.img-acciones .icon-btn:disabled { opacity: 0.35; cursor: default; }

.resultado-pdf { display: none; margin-top: 1rem; }
.resultado-pdf.active { display: block; }
.acciones-pdf { display: flex; gap: 0.7rem; flex-wrap: wrap; margin-top: 0.6rem; }
.acciones-pdf .btn-nuevo { width: auto; margin-top: 0; padding: 0.7rem 1.2rem; }
.btn-secundario {
    padding: 0.7rem 1.2rem;
    border: 1px solid var(--primario-borde);
    border-radius: var(--radio-btn);
    background: var(--superficie);
    color: var(--primario);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--fuente);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.btn-secundario:hover { background: var(--primario-suave); }
.fila-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
@media (max-width: 600px) { .fila-grid { grid-template-columns: 1fr; } }

/* Recorte de imagen */
.crop-wrap { position: relative; display: inline-block; max-width: 100%; user-select: none; touch-action: none; }
.crop-wrap img { display: block; max-width: 100%; max-height: 60vh; }
.crop-sel {
    position: absolute;
    border: 2px dashed var(--primario);
    background: rgba(107, 63, 160, 0.15);
    display: none;
    pointer-events: none;
}
.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #fff;
    border: 2px solid var(--primario);
    border-radius: 3px;
    pointer-events: auto;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    margin: -6px 0 0 -6px;
}
.crop-handle[data-h="n"], .crop-handle[data-h="s"]   { cursor: ns-resize; }
.crop-handle[data-h="e"], .crop-handle[data-h="w"]   { cursor: ew-resize; }
.crop-handle[data-h="ne"], .crop-handle[data-h="sw"] { cursor: nesw-resize; }
.crop-handle[data-h="nw"], .crop-handle[data-h="se"] { cursor: nwse-resize; }
.dialog-editor   { max-width: 720px; width: 100%; }
.acciones-editor { margin-top: 0.8rem; }

/* ══════════════════════════════════════════════
   DIRECCIONADOR DE TEXTOS LEGALES (doc_splitter.html)
   ══════════════════════════════════════════════ */
.chain {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 1.5rem;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--texto-medio);
}
.search-row-col { flex-direction: column; gap: 0.5rem; }
.footer-inner { display: flex; flex-direction: column; gap: 0.4rem; max-width: 440px; margin: 0 auto; }

/* ══════════════════════════════════════════════
   REDACTOR — editor de párrafos y asistente
   ══════════════════════════════════════════════ */
.redactor-agente { position: sticky; bottom: 0; align-self: end; }
@media (max-width: 1000px) { .redactor-agente { position: static; } }

.doc-editor .parrafo {
    position: relative;
    padding-left: 2.3rem;
    min-height: 1.3em;
    border-radius: 6px;
    padding-top: 0.05rem;
    padding-bottom: 0.05rem;
}
.doc-editor .parrafo:hover { background: var(--superficie-alt); }
.doc-editor .parrafo.sel { background: var(--primario-suave); }
.doc-editor .parrafo::before {
    counter-increment: parrafo;
    content: counter(parrafo);
    position: absolute;
    left: 0;
    top: 0.15rem;
    width: 1.5rem;
    height: 1.5rem;
    background: var(--primario-suave);
    color: var(--primario);
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}
.doc-editor .parrafo.modificado { background: var(--exito-fondo); }
.para-wrap { position: relative; margin-bottom: 0.55rem; }
.para-send {
    position: absolute;
    right: 0.2rem;
    top: 0.15rem;
    width: 1.5rem;
    height: 1.5rem;
    border: none;
    border-radius: 6px;
    background: var(--primario-suave);
    color: var(--primario);
    font-size: 0.8rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}
.para-wrap:hover .para-send { opacity: 1; }
.para-send:hover { background: var(--primario); color: #fff; }
.input-titulo-doc { max-width: 280px; }

.agent-chat {
    max-height: 52vh;
    min-height: 200px;
    overflow-y: auto;
    padding: 0.75rem;
    margin: 0.75rem 0;
    border: 1px solid var(--borde);
    border-radius: 12px;
    background: #fbfaf7;
}
.agent-chat::-webkit-scrollbar { width: 8px; }
.agent-chat::-webkit-scrollbar-thumb { background: #d8cdbe; border-radius: 4px; }
.agent-msg { margin-bottom: 0.9rem; }
.agent-msg .tag {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--primario);
    margin-bottom: 0.2rem;
}
.agent-msg.assistant .tag { color: var(--exito); }
.agent-msg .cuerpo { font-size: 0.92rem; line-height: 1.5; color: #333; white-space: pre-wrap; word-wrap: break-word; }
.agent-msg.thinking .cuerpo { color: var(--texto-suave); font-style: italic; }
.agent-input {
    width: 100%;
    border: 1px solid var(--borde);
    border-radius: var(--radio-btn);
    padding: 0.6rem 0.8rem;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    outline: none;
}
.agent-input:focus { border-color: var(--primario); }
.acciones-agente { display: flex; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }
.acciones-agente .btn-nuevo { width: auto; margin-top: 0; padding: 0.6rem 1rem; }
.acciones-agente .btn-sec { padding: 0.6rem 1rem; }

/* Tarjetas de sugerencia del redactor */
.sug-card {
    border: 1px solid var(--borde);
    border-radius: 10px;
    background: var(--superficie);
    padding: 0.7rem;
    margin-top: 0.6rem;
}
.sug-card.aplicada  { border-color: var(--exito-borde); background: var(--exito-fondo); }
.sug-card.rechazada { opacity: 0.55; }
.sug-head   { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.sug-num    { background: var(--primario); color: #fff; border-radius: 6px; padding: 0.1rem 0.5rem; font-size: 0.75rem; font-weight: 700; }
.sug-motivo { font-size: 0.78rem; color: var(--texto-suave); flex: 1; min-width: 0; }
.sug-cols   { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
@media (max-width: 520px) { .sug-cols { grid-template-columns: 1fr; } }
.sug-col    { border: 1px solid var(--borde-suave); border-radius: 8px; padding: 0.5rem; }
.sug-label  { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; color: var(--texto-suave); margin-bottom: 0.3rem; }
.sug-col.original .sug-label { color: var(--error); }
.sug-col.propuesto .sug-label { color: var(--exito); }
.sug-text   { font-size: 0.85rem; line-height: 1.5; color: var(--texto); white-space: pre-wrap; word-wrap: break-word; }
.sug-text del { background: var(--error-fondo); color: var(--error); text-decoration: line-through; border-radius: 3px; padding: 0 2px; }
.sug-text ins { background: var(--exito-fondo); color: var(--exito); text-decoration: none; border-radius: 3px; padding: 0 2px; }
.sug-actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; flex-wrap: wrap; }
.sug-actions .btn-sec { padding: 0.4rem 0.9rem; }
.sug-actions .btn-sec.aceptar  { background: var(--exito-fondo); border-color: var(--exito-borde); color: var(--exito); }
.sug-actions .btn-sec.rechazar { background: var(--error-fondo); border-color: var(--error-borde); color: var(--error); }
.sug-estado { font-size: 0.78rem; font-weight: 600; margin-top: 0.5rem; }
.sug-card.aplicada .sug-estado  { color: var(--exito); }
.sug-card.rechazada .sug-estado { color: var(--texto-suave); }

/* ══════════════════════════════════════════════
   PROCESO — diálogo de días hábiles (proceso.html)
   ══════════════════════════════════════════════ */
.seccion-habiles {
    border-top: 1px solid var(--borde-suave);
    margin-top: 0.75rem;
    padding-top: 0.75rem;
}
.label-habiles {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
}
.habiles-campos { display: none; margin-top: 0.5rem; }
.btn-sec-lg { padding: 0.7rem 1.2rem; }

/* ══════════════════════════════════════════════
   TOAST GLOBAL (comun.js)
   ══════════════════════════════════════════════ */
#toastGlobal {
    position: fixed;
    left: 50%;
    bottom: 1.4rem;
    transform: translateX(-50%);
    background: #2c2c3c;
    color: #fff;
    padding: 0.65rem 1.1rem;
    border-radius: 10px;
    font-size: 0.88rem;
    z-index: 10000;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, bottom 0.25s;
    max-width: 90vw;
    text-align: center;
}
#toastGlobal.visible { opacity: 1; bottom: 2rem; }
#toastGlobal.ok      { background: var(--exito); }
#toastGlobal.error   { background: var(--error); }

/* ══════════════════════════════════════════════
   ASISTENTE FLOTANTE (asistente.js)
   ══════════════════════════════════════════════ */
:root {
    --asist-primario: var(--primario, #6b3fa0);
    --asist-primario-oscuro: var(--primario-oscuro, #552f80);
    --asist-superficie: var(--superficie, #fff);
    --asist-borde: var(--borde-suave, #f0ece4);
}
#asist-fab {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 9998;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--asist-primario);
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s, background 0.15s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
#asist-fab:hover { background: var(--asist-primario-oscuro); transform: scale(1.06); }
#asist-panel {
    position: fixed;
    z-index: 9999;
    display: none;
    flex-direction: column;
    background: var(--asist-superficie);
    border: 1px solid var(--asist-borde);
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    font-family: inherit;
}
#asist-panel.abierto { display: flex; }
@media (min-width: 701px) {
    #asist-panel { right: 18px; bottom: 86px; width: 360px; height: 480px; }
}
@media (max-width: 700px) {
    #asist-panel { left: 0; right: 0; bottom: 0; width: 100%; height: 75vh; border-radius: 16px 16px 0 0; }
}
.asist-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--asist-primario);
    color: #fff;
    flex: 0 0 auto;
}
.asist-head strong { font-size: 0.95rem; letter-spacing: 0.02em; }
.asist-cerrar {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
}
.asist-cerrar:hover { background: rgba(255, 255, 255, 0.15); }
#asist-mensajes {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    background: var(--superficie-alt);
}
.asist-msg {
    max-width: 85%;
    padding: 0.55rem 0.8rem;
    border-radius: 12px;
    font-size: 0.88rem;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.asist-msg.usuario   { align-self: flex-end; background: var(--asist-primario); color: #fff; border-bottom-right-radius: 4px; }
.asist-msg.asistente { align-self: flex-start; background: var(--asist-superficie); color: #333; border: 1px solid var(--asist-borde); border-bottom-left-radius: 4px; }
.asist-msg.exito { align-self: stretch; max-width: 100%; background: var(--exito-fondo); color: var(--exito); border: 1px solid var(--exito-borde); font-weight: 600; }
.asist-msg.error { align-self: stretch; max-width: 100%; background: var(--error-fondo); color: var(--error); border: 1px solid var(--error-borde); }
.asist-pensando { align-self: flex-start; font-size: 0.85rem; color: var(--texto-suave); font-style: italic; }
.asist-lectura  { align-self: center; font-size: 0.75rem; color: var(--texto-suave); }
.asist-card {
    align-self: stretch;
    max-width: 100%;
    background: var(--asist-superficie);
    border: 1px solid var(--asist-borde);
    border-left: 3px solid var(--asist-primario);
    border-radius: 10px;
    padding: 0.7rem 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.asist-card h4  { margin: 0; font-size: 0.85rem; color: var(--asist-primario); }
.asist-card ul  { margin: 0; padding-left: 1.1rem; font-size: 0.82rem; color: #444; }
.asist-card-acc { display: flex; gap: 0.5rem; }
.asist-card-acc button {
    flex: 1;
    padding: 0.45rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
}
.asist-btn-ok { background: var(--asist-primario); color: #fff; }
.asist-btn-ok:hover { background: var(--asist-primario-oscuro); }
.asist-btn-no { background: var(--superficie-alt); color: var(--texto-medio); border: 1px solid var(--asist-borde) !important; }
.asist-btn-reload {
    margin-top: 0.3rem;
    align-self: flex-start;
    padding: 0.4rem 0.7rem;
    border-radius: 8px;
    border: 1px solid var(--exito-borde);
    background: #fff;
    color: var(--exito);
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
}
.asist-input {
    flex: 0 0 auto;
    display: flex;
    gap: 0.5rem;
    padding: 0.7rem;
    border-top: 1px solid var(--asist-borde);
    background: var(--asist-superficie);
}
.asist-input input {
    flex: 1;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--borde);
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    background: var(--superficie-alt);
    color: #333;
}
.asist-input input:focus { border-color: var(--asist-primario); }
.asist-input button {
    padding: 0.55rem 0.9rem;
    border: none;
    border-radius: 10px;
    background: var(--asist-primario);
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
}
.asist-input button:disabled { opacity: 0.5; cursor: not-allowed; }
