/* ============================================================
   Plataforma Oppermando · línea gráfica de Transcript
   Tokens y componentes replicados de "Transcript" (React+Vite+Tailwind,
   dark mode por defecto):
   · Paleta brand = indigo (tailwind.config.js de Transcript)
   · Neutros slate (bg-slate-950 fondo, slate-900/800 superficies)
   · Tarjetas rounded-2xl bg-slate-900 border-slate-700 shadow-sm
   · Inputs/buttons rounded-lg con focus ring brand-500
   · Badges de estado en píldora con tinte suave por estado
   · Sidebar (desktop) + drawer (móvil), como Layout de Transcript
   · Tablas: cabecera uppercase tracking-wider sobre bg-slate-800/70
   ============================================================ */
:root {
  --brand-50:#eef2ff; --brand-100:#e0e7ff; --brand-200:#c7d2fe; --brand-300:#a5b4fc;
  --brand-400:#818cf8; --brand-500:#6366f1; --brand-600:#4f46e5; --brand-700:#4338ca;
  --brand-800:#3730a3; --brand-900:#312e81;
  --c-bg:#020617; --c-panel:#0f172a; --c-panel2:#1e293b; --c-panel3:#334155;
  --c-brd:#1e293b; --c-brd2:#334155;
  --c-txt:#e2e8f0; --c-txt2:#94a3b8; --c-txt3:#64748b;
  --c-ok:#10b981; --c-warn:#f59e0b; --c-err:#ef4444; --c-info:#38bdf8;
  --r-card:1rem; --r-ctl:.5rem; --sh-card:0 1px 2px 0 rgba(0,0,0,.05);
  --font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
*{box-sizing:border-box}
body,button,input,select,textarea{font-family:var(--font)}
body{background:var(--c-bg);color:var(--c-txt)}

/* -------- APP SHELL: sidebar desktop + topbar/drawer móvil -------- */
@media (min-width:768px){ body.hac-shell{padding-left:16rem} }
.hac-side{display:none;position:fixed;top:0;bottom:0;left:0;z-index:50;width:16rem;
  flex-direction:column;background:var(--c-panel);border-right:1px solid var(--c-brd)}
@media (min-width:768px){ .hac-side{display:flex} }
.hac-side-brand{display:flex;align-items:center;gap:.55rem;padding:1rem 1.1rem;
  border-bottom:1px solid var(--c-brd);color:#fff;text-decoration:none;font-weight:800;font-size:1.02rem;white-space:nowrap}
.hac-side-brand:hover{background:var(--c-panel2)}
.hac-brand-ic{display:grid;place-items:center;width:30px;height:30px;border-radius:10px;
  background:var(--brand-600);font-size:1rem;flex-shrink:0;box-shadow:0 4px 10px -4px rgba(99,102,241,.6)}
.hac-side-nav{flex:1;overflow-y:auto;padding:.7rem .6rem;display:flex;flex-direction:column;gap:2px}
.hac-nav-i{display:flex;align-items:center;gap:.55rem;padding:.5rem .75rem;border-radius:.5rem;
  font-size:1rem;font-weight:500;color:var(--c-txt2);text-decoration:none;transition:.12s}
.hac-nav-i:hover{background:var(--c-panel2);color:#fff}
.hac-nav-i.act{background:var(--brand-600);color:#fff;box-shadow:0 4px 12px -6px rgba(99,102,241,.7)}
.hac-side-nav-sep{margin:.45rem .3rem .15rem;border-top:1px solid var(--c-brd)}
.hac-switch-user{display:inline-block;margin-top:.25rem;font-size:1rem;color:var(--brand-300);text-decoration:none}
.hac-switch-user:hover{text-decoration:underline}
/* Pestañas del panel administrativo (estilo Admin.jsx de Transcript) */
.hac-admin-tabs{display:flex;flex-wrap:wrap;gap:.5rem;max-width:1200px;margin:0 auto;padding:.9rem 1rem 0;border-bottom:1px solid var(--c-brd)}
.hac-admin-tab{padding:.45rem .95rem;border-radius:.5rem;font-size:1rem;font-weight:500;text-decoration:none;
  color:var(--c-txt2);border:1px solid var(--c-brd2);background:var(--c-panel);transition:.13s}
.hac-admin-tab:hover{color:#fff;border-color:var(--brand-500);background:var(--c-panel2)}
.hac-admin-tab.act{background:var(--brand-600);color:#fff;border-color:var(--brand-600);box-shadow:0 4px 12px -6px rgba(99,102,241,.7)}
.hac-side-foot{border-top:1px solid var(--c-brd);padding:.8rem 1rem;display:flex;align-items:center;gap:.7rem}
.hac-avatar{width:2.25rem;height:2.25rem;border-radius:50%;background:var(--brand-600);color:#fff;
  display:grid;place-items:center;font-weight:700;flex-shrink:0}
.hac-side-who{flex:1;min-width:0}
.hac-role{padding:.1rem .5rem;border-radius:999px;font-weight:700;font-size:1rem;letter-spacing:.02em;text-transform:uppercase}
.hac-role.admin{color:var(--brand-300);background:rgba(99,102,241,.16)}
.hac-role.user{color:var(--c-info);background:rgba(56,189,248,.12)}
.hac-mail{display:block;color:var(--c-txt3);font-size:1rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.hac-logout{text-decoration:none;color:var(--c-txt3);border:1px solid var(--c-brd2);width:30px;height:30px;
  display:grid;place-items:center;border-radius:.5rem;font-size:1rem;flex-shrink:0}
.hac-logout:hover{color:var(--c-err);border-color:var(--c-err)}
.hac-exit-imp{background:rgba(245,158,11,.14);color:var(--c-warn);border:1px solid rgba(245,158,11,.45);
  padding:.35rem .7rem;border-radius:.5rem;font-size:1rem;font-weight:600;cursor:pointer;margin-top:.4rem}
.hac-exit-imp:hover{background:rgba(245,158,11,.28)}
.hac-topbar{display:flex;align-items:center;gap:.7rem;position:sticky;top:0;z-index:40;
  padding:.7rem 1rem;background:rgba(2,6,23,.9);border-bottom:1px solid var(--c-brd);backdrop-filter:blur(8px)}
@media (min-width:768px){ .hac-topbar{display:none} }
.hac-burger{background:transparent;border:1px solid var(--c-brd2);color:var(--c-txt2);border-radius:.5rem;
  width:36px;height:36px;font-size:1.15rem;cursor:pointer}
.hac-burger:hover{color:#fff;border-color:var(--brand-500)}
.hac-drawer-bg{position:fixed;inset:0;z-index:60;background:rgba(0,0,0,.5)}
.hac-drawer{position:fixed;top:0;bottom:0;left:0;z-index:61;width:18rem;max-width:86vw;
  background:var(--c-panel);box-shadow:0 20px 45px -12px rgba(0,0,0,.6);display:flex;flex-direction:column;overflow-y:auto}
/* El atributo hidden debe poder ocultar drawer/fondo/modal aunque tengan display
   declarado (los estilos de autor anulan el [hidden] del navegador). */
.hac-drawer[hidden],.hac-drawer-bg[hidden],.hac-modal[hidden]{display:none!important}
/* Regla general: cualquier elemento con [hidden] se oculta aunque su clase
   declare display (p. ej. .hac-btn tiene display:inline-flex). */
[hidden]{display:none!important}

/* Tarjetas (Transcript .card) */
.hac-card{background:var(--c-panel);border:1px solid var(--c-brd);border-radius:var(--r-card);
  padding:1rem;box-shadow:var(--sh-card)}
.hac-grid{display:grid;gap:1rem}

/* Botones (Transcript Btn) */
.hac-btn{display:inline-flex;align-items:center;justify-content:center;gap:.4rem;padding:.5rem .95rem;
  border-radius:var(--r-ctl);font-size:1rem;font-weight:500;cursor:pointer;border:1px solid var(--c-brd2);
  background:var(--c-panel2);color:var(--c-txt2);text-decoration:none;transition:.13s;white-space:nowrap}
.hac-btn:hover{background:var(--c-panel3);color:#fff}
.hac-btn.primary{background:var(--brand-600);color:#fff;border-color:transparent}
.hac-btn.primary:hover{background:var(--brand-700)}
.hac-btn.danger{color:#fca5a5;border-color:rgba(239,68,68,.45);background:transparent}
.hac-btn.danger:hover{background:rgba(239,68,68,.15);color:#fecaca}
.hac-btn.sm{padding:.25rem .6rem;font-size:1rem}
/* Opción aún no disponible (paso previo sin cumplir): debe LEERSE como bloqueada,
   no solo no responder. Va tras .primary/.danger para ganarles también ahí. */
.hac-btn:disabled,.hac-btn[disabled]{opacity:.45;cursor:not-allowed;filter:grayscale(.55);
  background:var(--c-panel2);color:#64748b;border-color:var(--c-brd);box-shadow:none}
.hac-btn:disabled:hover,.hac-btn[disabled]:hover{background:var(--c-panel2);color:#64748b}
/* El .hidden de tailwind pierde contra .hac-btn (display:inline-flex, cargado
   después). Para ocultar de verdad un botón con la clase .hidden hace falta
   ganarle la especificidad y el display. */
.hac-btn.hidden{display:none!important}

/* Inputs (Transcript .input) */
.hac-input,.hac-select,.hac-textarea{width:100%;background:var(--c-panel2);border:1px solid var(--c-brd2);
  color:var(--c-txt);border-radius:var(--r-ctl);padding:.5rem .8rem;font-size:1rem;outline:none;transition:.13s}
.hac-input::placeholder,.hac-textarea::placeholder{color:var(--c-txt3)}
.hac-input:focus,.hac-select:focus,.hac-textarea:focus{border-color:var(--brand-500);box-shadow:0 0 0 3px rgba(99,102,241,.2)}
@media (max-width:640px){ .hac-input,.hac-select,.hac-textarea{font-size:16px} }

/* Badges píldora (Transcript StatusBadge) */
.hac-badge{padding:.2rem .65rem;border-radius:999px;font-size:1rem;font-weight:600;letter-spacing:.01em}
.hac-badge.idle{color:var(--c-txt2);background:rgba(148,163,184,.15)}
.hac-badge.run{color:var(--brand-300);background:rgba(99,102,241,.18)}
.hac-badge.ok{color:#34d399;background:rgba(16,185,129,.16)}
.hac-badge.error{color:#f87171;background:rgba(239,68,68,.15)}
.hac-badge.stopped{color:var(--c-info);background:rgba(56,189,248,.15)}

/* Barra de progreso */
.hac-progress{height:9px;border-radius:999px;background:var(--c-panel3);overflow:hidden}
.hac-progress>i{display:block;height:100%;border-radius:999px;
  background:linear-gradient(90deg,var(--brand-500),var(--brand-400));transition:width .4s ease}

/* Modal */
.hac-modal{position:fixed;inset:0;z-index:60;display:none;background:rgba(2,6,23,.75);padding:1rem}
.hac-modal.open{display:grid;place-items:center;overflow-y:auto;overflow-x:hidden}
.hac-modal.open > *{margin:auto}
.hac-modal-box{width:min(680px,100%);max-height:88vh;overflow:auto;background:var(--c-panel);
  border:1px solid var(--c-brd);border-radius:1rem;box-shadow:0 25px 50px -12px rgba(0,0,0,.5)}
.hac-modal-head{display:flex;align-items:center;justify-content:space-between;gap:.75rem;padding:1rem 1.1rem;
  border-bottom:1px solid var(--c-brd);margin-bottom:0;
  position:sticky;top:0;z-index:40;background:var(--c-panel);border-radius:1rem 1rem 0 0}

/* Tablas (Transcript: cabecera uppercase + hover) */
.hac-table{width:100%;border-collapse:collapse;font-size:1rem}
.hac-table th{text-align:left;padding:.65rem .75rem;background:rgba(30,41,59,.55);color:var(--c-txt3);
  font-weight:600;font-size:1rem;text-transform:uppercase;letter-spacing:.05em;border-bottom:1px solid var(--c-brd);white-space:nowrap}
.hac-table td{padding:.6rem .75rem;border-bottom:1px solid rgba(30,41,59,.65);vertical-align:middle}
.hac-table tbody tr{transition:background .1s}
.hac-table tbody tr:hover td{background:rgba(30,41,59,.4)}
.hac-table tbody tr:last-child td{border-bottom:none}

/* Empty states */
.hac-empty{text-align:center;padding:2.5rem 1rem;color:var(--c-txt3)}
.hac-empty b{color:var(--c-txt);font-size:1.02rem}
.hac-empty p{font-size:1rem}

/* Caja única (usuario) */
.hac-box{background:linear-gradient(160deg,rgba(99,102,241,.14),rgba(129,140,248,.06) 45%,transparent);
  border:1px solid rgba(99,102,241,.4);border-radius:1.1rem;padding:1.4rem}
.hac-box-title{font-size:1.02rem;font-weight:800;color:#fff}

/* Editor MD */
.hac-mded{display:grid;grid-template-columns:1fr 1fr;gap:1rem}
@media (max-width:760px){.hac-mded{grid-template-columns:1fr}}
.hac-preview{background:var(--c-panel2);border:1px solid var(--c-brd);border-radius:.7rem;
  padding:.8rem 1rem;min-height:300px;overflow:auto;font-size:1rem;line-height:1.55}
.hac-preview h1,.hac-preview h2,.hac-preview h3{color:#fff;margin:.6em 0 .3em}
.hac-preview a{color:var(--brand-300)}
.hac-preview code{background:var(--c-panel3);padding:.1em .35em;border-radius:.3em}
.hac-preview pre{background:#0d1526;border:1px solid var(--c-brd);padding:.7rem;border-radius:.6rem;overflow:auto}

/* Login */
.hac-login-wrap{min-height:100vh;display:grid;place-items:center;padding:1rem;
  background:radial-gradient(1000px 420px at 50% -10%,rgba(99,102,241,.25),transparent 60%),var(--c-bg)}
.hac-login-card{width:min(400px,100%);background:var(--c-panel);border:1px solid var(--c-brd);
  border-radius:1rem;padding:1.5rem;box-shadow:0 25px 50px -12px rgba(0,0,0,.5)}

/* Sidebar colapsable (escritorio, iconos SVG) */
.hac-side { transition: transform .2s ease; }
.hac-side-head { display: flex; align-items: center; padding-right: .5rem; }
.hac-side-head .hac-side-brand { flex: 1; min-width: 0; padding-right: 0; }
.hac-side-close { display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--c-brd2); background: transparent; color: var(--c-txt3);
  width: 32px; height: 32px; border-radius: .5rem; cursor: pointer; flex-shrink: 0; line-height: 1; }
.hac-side-close:hover { color: #fff; border-color: var(--brand-500); background: var(--c-panel2); }
.hac-side-close svg { display: block; }

body.hac-side-collapsed .hac-side { transform: translateX(-100%); }
@media (min-width:768px){ body.hac-side-collapsed.hac-shell { padding-left: 0 !important; } }

.hac-side-open { position: fixed; left: 0; top: 50%; transform: translateY(-50%); z-index: 60;
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 64px; border-radius: 0 12px 12px 0; border: 1px solid var(--c-brd2);
  border-left: none; background: var(--c-panel); color: var(--c-txt2); font-size:1rem; cursor: pointer; }
.hac-side-open:hover { color: #fff; border-color: var(--brand-500); }
.hac-side-open svg { display: block; }
body:not(.hac-side-collapsed) .hac-side-open { display: none; }
@media (max-width:767px){ .hac-side-open { display: none !important; } }

/* ============================================================
   ESTANDARIZACIÓN GLOBAL (2026-09)
   1) Tipografía: texto base mínimo 16px + jerarquía lógica h1/h2/h3
   2) Modales: X de cierre siempre visible arriba-derecha en círculo grande
   ============================================================ */

/* ---------- 1) Tipografía base y jerarquía ---------- */
html { font-size: 16px; }
body { font-size: 16px; }

/* Jerarquía de títulos con lógica proporcional */
h1 { font-size: 1.75rem; line-height: 1.2; }
h2 { font-size: 1.4rem; line-height: 1.25; }
h3 { font-size: 1.15rem; line-height: 1.3; }
h4 { font-size: 1rem; line-height: 1.35; }
h1, h2, h3, h4 { font-weight: 800; color: #fff; }

/* Textos de cuerpo: mínimo 16px */
p, li, td, th, label, .hac-card, .hac-modal-box, .hac-box,
.hac-preview, .hac-empty, .hac-table, .hac-input, .hac-select, .hac-textarea {
  font-size: 16px;
}
/* Textos secundarios / pequeños: mínimo 14px */
.hac-badge, .hac-role, .hac-mail, .hac-nav-i, .hac-admin-tab,
.hac-table th, .hac-table td, .hac-empty p, .hac-switch-user, .hac-exit-imp,
.hac-side-open, .hac-side-close, .hac-logout, .hac-btn.sm, .hac-btn {
  font-size: 16px;
}

/* ---------- 2) X de cierre de modales: círculo grande, siempre arriba-derecha ---------- */
/* Cabecera de modal sticky: la X nunca se pierde con scroll */
.hac-modal-head { position: sticky; top: 0; z-index: 40; background: var(--c-panel); }

/* Botón de cierre circular grande, estandarizado para todas las modales.
   OJO: es SOLO para la ✕ de cierre. Un botón de ACCIÓN con texto (PDF,
   Descargar, Actualizar…) dentro de la cabecera NO debe caer aquí: con
   width/height fijos de 38px el texto se desborda sobre los botones vecinos.
   Para eso está la lista de ids/clases + `.hac-btn.sm` (las ✕ del resto de
   plantillas) y `[data-close]` / `[data-am-close]`. */
.hac-modal-head button[data-close],
.hac-modal-head button[data-am-close],
.hac-modal-head button.hac-btn.sm,
.hac-modal-head #ub-close, .hac-modal-head #um-close, .hac-modal-head #pr-close,
.hac-modal-head #ur-modal-x, .hac-modal-head #gt-close,
.ds-modal-x,
.fl-rm-close,
.fl-artmodal-close,
.cx-close,
.fl-run-close,
#fl-pick-x, #fl-bulk-x, #fl-vars-x, #fl-lib-x,
#del-x, #sc-x {
  flex: none; width: 38px; height: 38px; min-width: 38px; min-height: 38px;
  border-radius: 9999px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--c-brd2); background: var(--c-panel2); color: var(--c-txt2);
  font-size: 18px; font-weight: 700; line-height: 1; cursor: pointer;
  padding: 0; transition: background .15s, color .15s, border-color .15s;
}
.hac-modal-head button[data-close]:hover,
.hac-modal-head button[data-am-close]:hover,
.hac-modal-head button.hac-btn.sm:hover,
.hac-modal-head #ub-close:hover, .hac-modal-head #um-close:hover, .hac-modal-head #pr-close:hover,
.hac-modal-head #ur-modal-x:hover, .hac-modal-head #gt-close:hover,
.ds-modal-x:hover,
.fl-rm-close:hover,
.fl-artmodal-close:hover,
.cx-close:hover,
.fl-run-close:hover,
#fl-pick-x:hover, #fl-bulk-x:hover, #fl-vars-x:hover, #fl-lib-x:hover,
#del-x:hover, #sc-x:hover {
  background: var(--c-panel3); color: #fff; border-color: var(--brand-500);
}
/* El ✕ dentro del botón debe quedar centrado y sin padding heredado */
.hac-modal-head button[data-close], .hac-modal-head button[data-am-close] { padding: 0; }
.hac-modal-head .hac-btn.sm { padding: 0; }

/* Cabeceras de modales que usan layout Tailwind → sticky para que la X
   nunca se pierda con scroll (board.html: picker, bulk, vars, lib;
   agent.html: del-modal, sc-modal). */
#fl-picker .fl-pick-box > div:first-child,
#fl-bulk .fl-pick-box > div:first-child,
#fl-vars .fl-pick-box > div:first-child,
#fl-lib .fl-pick-box > div:first-child,
#del-modal .w-full > div:first-child,
#sc-modal .w-full > div:first-child {
  position: sticky; top: 0; z-index: 40; background: #0f172a; border-radius: 1rem 1rem 0 0;
}
/* El SVG de la X en agent.html debe heredar el color del botón y verse bien */
#del-x svg, #sc-x svg { width: 18px; height: 18px; pointer-events: none; }

/* ============================================================
   Loader de botón (HAC.withBusy) e iconografía SVG inline
   ============================================================ */
.hac-spin { display: inline-block; width: 13px; height: 13px; flex: none;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%;
  animation: hac-spin .7s linear infinite; vertical-align: -2px; }
@keyframes hac-spin { to { transform: rotate(360deg); } }
.hac-btn.is-busy { cursor: progress; }
.hac-ic { width: 1em; height: 1em; display: inline-block; vertical-align: -0.14em; flex: none; }

/* Tablas Markdown: scroll horizontal para que las tablas anchas no rompan el layout */
.md-table-wrap { overflow-x: auto; margin: .9em 0; max-width: 100%; }
.md-table-wrap table { margin: 0; }

/* ============================================================
   Notificación no bloqueante (HAC.toast)
   ============================================================ */
#hac-toasts { position: fixed; top: 18px; right: 18px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.hac-toast { position: relative; pointer-events: auto; min-width: 260px; max-width: 360px; background: #0f172a; border: 1px solid #334155; border-left: 4px solid #4ade80; border-radius: 10px; padding: 12px 34px 12px 14px; box-shadow: 0 8px 30px rgba(0,0,0,.4); font-size: 14px; color: #e2e8f0; transform: translateX(120%); opacity: 0; transition: transform .25s ease, opacity .25s ease; }
.hac-toast.show { transform: translateX(0); opacity: 1; }
.hac-toast.error { border-left-color: #f87171; }
.hac-toast-title { font-weight: 800; margin-bottom: 3px; }
.hac-toast-msg { color: #94a3b8; }
.hac-toast-x { position: absolute; top: 5px; right: 6px; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 7px; background: transparent; color: #94a3b8; font-size: 14px; line-height: 1; cursor: pointer; transition: .12s; }
.hac-toast-x:hover { background: #334155; color: #f1f5f9; }

/* ============================================================
   Tipografía de Markdown (.prose-hermes) — GLOBAL
   Antes vivía solo en process_editor.html, así que el MD del área
   (radicación de fuente, fuente radicada, chat) salía sin tablas ni
   estilos. Al centralizarla aquí, área y proceso renderizan igual.
   ============================================================ */
.prose-hermes { line-height: 1.7; color: #cbd5e1; font-size: 15px; }
.prose-hermes > *:first-child { margin-top: 0; }
.prose-hermes > *:last-child { margin-bottom: 0; }
.prose-hermes h1, .prose-hermes h2, .prose-hermes h3, .prose-hermes h4, .prose-hermes h5, .prose-hermes h6 { color: #f1f5f9; font-weight: 700; margin: 1.2em 0 .5em; }
.prose-hermes h1 { font-size: 1.5rem; } .prose-hermes h2 { font-size: 1.25rem; }
.prose-hermes h3 { font-size: 1.1rem; } .prose-hermes h4 { font-size: 1rem; }
.prose-hermes h5, .prose-hermes h6 { font-size: 1rem; }
.prose-hermes p { margin: .7em 0; }
.prose-hermes ul, .prose-hermes ol { margin: .55em 0 .55em 1.3em; }
.prose-hermes ul { list-style: disc; } .prose-hermes ol { list-style: decimal; }
.prose-hermes li { margin: .2em 0; }
.prose-hermes li > ul, .prose-hermes li > ol { margin: .2em 0 .2em 1.1em; }
.prose-hermes strong { color: #fff; font-weight: 700; }
.prose-hermes em { color: #c7d2fe; }
.prose-hermes blockquote { border-left: 3px solid #6366f1; padding: .2em 1em; color: #94a3b8; margin: .7em 0; background: rgba(99,102,241,.06); border-radius: 0 .5rem .5rem 0; }
.prose-hermes code { background: #0f172a; border: 1px solid #1e293b; border-radius: .35rem; padding: .1em .35em; color: #a5b4fc; font-size: .92em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.prose-hermes pre { background: #0b1220; border: 1px solid #1e293b; border-radius: .6rem; padding: .8em 1em; overflow-x: auto; margin: .7em 0; }
.prose-hermes pre code { background: none; border: none; padding: 0; color: #e2e8f0; }
.prose-hermes a { color: #818cf8; text-decoration: underline; text-underline-offset: 3px; }
.prose-hermes hr { border-color: #1e293b; margin: 1.2em 0; }
/* --- Tablas ---
   Contraste FUERTE contra la burbuja del chat (fondo #0f172a): la tabla lleva una
   superficie propia más oscura (#050b16), banda de cabecera clara y filas alternas
   visibles, con marco y esquinas. Antes la cabecera (#111c2d) y las filas
   (rgba(30,41,59,.35)) se confundían con el fondo del burbujón.
   `overflow-wrap: break-word` (no `anywhere`) es CLAVE: `anywhere` reduce el
   min-content de la celda a UN carácter, así que la tabla comprimía la columna y
   partía los números («10» salía como «1» y «0» debajo). Con `break-word` el ancho
   mínimo es la palabra completa y `.md-table-wrap` da scroll horizontal si hace falta. */
.prose-hermes .md-table-wrap { overflow-x: auto; margin: 1em 0; border-radius: .6rem;
  border: 1px solid #3b5285; box-shadow: 0 6px 18px rgba(2,6,23,.45); }
.prose-hermes table { border-collapse: collapse; width: 100%; margin: 0; font-size: .95em;
  background: #050b16; }
.prose-hermes .md-table-wrap table { margin: 0; }
.prose-hermes th, .prose-hermes td { border: 1px solid #26385c; padding: .5em .7em;
  text-align: left; vertical-align: top; line-height: 1.4;
  overflow-wrap: break-word; word-break: normal; }
.prose-hermes thead th { background: linear-gradient(180deg, #24365c, #1b2947);
  color: #fff; font-weight: 700; letter-spacing: .01em; white-space: nowrap;
  border-bottom: 1px solid #46608f; }
.prose-hermes tbody tr { background: #050b16; }
.prose-hermes tbody tr:nth-child(even) { background: #0d1830; }
.prose-hermes tbody tr:hover { background: rgba(99,102,241,.16); }
/* Celdas numéricas: nunca parten el número y alinean por la derecha (tabular). */
.prose-hermes td.md-num, .prose-hermes th.md-num { white-space: nowrap;
  font-variant-numeric: tabular-nums; text-align: right; }
.prose-hermes img { max-width: 100%; border-radius: .5rem; }

/* ============================================================
   Línea de tiempo (`.pe-tl-*`) — portada de v1.5.7
   ============================================================ */
.pe-tl-box { width: min(96vw, 1440px); height: 80vh; max-height: 80vh; display: flex; flex-direction: column; }
.pe-tl-box .hac-modal-head, .pe-tl-view-box .hac-modal-head { flex-wrap: wrap; row-gap: 8px; }
.pe-tl-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pe-tl-actions .pe-btn { white-space: nowrap; }
.pe-tl-sub { font-size: 13px; color: #94a3b8; }
.pe-tl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid #1e293b; background: #0b1220; }
.pe-tl-search { flex: 1 1 240px; min-width: 160px; }
.pe-tl-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.pe-tl-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #1e293b; background: #0f172a; color: #94a3b8; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; cursor: pointer; transition: .12s; }
.pe-tl-chip:hover { background: #1e293b; color: #e2e8f0; }
.pe-tl-chip.on { background: rgba(99,102,241,.18); border-color: rgba(99,102,241,.55); color: #e0e7ff; }
.pe-tl-chip .pe-tl-n { font-size: 11px; opacity: .8; }
.pe-tl-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 8px 14px 22px; }
.pe-tl-day { position: sticky; top: 0; z-index: 2; margin: 10px 0 6px; padding: 4px 8px; font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: #94a3b8; background: linear-gradient(180deg, #0f172a 72%, rgba(15,23,42,0)); }
.pe-tl-ev { position: relative; padding-left: 42px; margin-bottom: 8px; }
.pe-tl-ev::before { content: ""; position: absolute; left: 13px; top: 12px; bottom: -10px; width: 2px; background: #1e293b; }
.pe-tl-ev:last-child::before { bottom: 12px; }
.pe-tl-dot { position: absolute; left: 0; top: 6px; width: 28px; height: 28px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; line-height: 1; background: #0b1220; border: 2px solid #334155; box-sizing: border-box; }
.pe-tl-dot.ok { border-color: #22c55e; }
.pe-tl-dot.error { border-color: #ef4444; }
.pe-tl-dot.warn, .pe-tl-dot.yellow { border-color: #f59e0b; }
.pe-tl-dot.red { border-color: #ef4444; }
.pe-tl-dot.green { border-color: #22c55e; }
.pe-tl-dot.run, .pe-tl-dot.running { border-color: #6366f1; }
.pe-tl-card { border: 1px solid #1e293b; border-radius: 12px; background: #0b1220; padding: 8px 12px; }
.pe-tl-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pe-tl-kind { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: #818cf8; border: 1px solid #312e81; background: rgba(99,102,241,.12); border-radius: 999px; padding: 1px 7px; }
.pe-tl-title { font-size: 14px; font-weight: 700; color: #e2e8f0; }
.pe-tl-time { margin-left: auto; font-size: 11px; color: #64748b; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pe-tl-where { font-size: 12px; color: #94a3b8; }
.pe-tl-state { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 8px; border: 1px solid #334155; color: #cbd5e1; }
.pe-tl-state.ok, .pe-tl-state.done { color: #86efac; border-color: rgba(34,197,94,.5); background: rgba(34,197,94,.1); }
.pe-tl-state.error { color: #fca5a5; border-color: rgba(239,68,68,.5); background: rgba(239,68,68,.1); }
.pe-tl-state.waiting_validation, .pe-tl-state.warn { color: #fcd34d; border-color: rgba(245,158,11,.5); background: rgba(245,158,11,.1); }
.pe-tl-state.running, .pe-tl-state.run { color: #a5b4fc; border-color: rgba(99,102,241,.5); background: rgba(99,102,241,.12); }
.pe-tl-vars { font-size: 11px; font-weight: 700; color: #fcd34d; border: 1px solid rgba(245,158,11,.45); background: rgba(245,158,11,.1); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.pe-tl-del { font-size: 11px; font-weight: 700; color: #cbd5e1; border: 1px solid rgba(148,163,184,.45); background: rgba(148,163,184,.12); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.pe-tl-detail { font-size: 12px; color: #94a3b8; margin-top: 4px; white-space: pre-wrap; }
.pe-tl-qa { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.pe-tl-q { color: #cbd5e1; border-left: 3px solid #0e7490; padding-left: 8px; white-space: pre-wrap; }
.pe-tl-a { color: #94a3b8; border-left: 3px solid #1e293b; padding-left: 8px; white-space: pre-wrap; }
.pe-tl-refs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pe-tl-ref { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: #7dd3fc; background: #0c1526; border: 1px solid #1e293b; border-radius: 8px; padding: 3px 9px; cursor: pointer; text-decoration: none; transition: .12s; }
.pe-tl-ref:hover { background: #0f172a; border-color: #334155; color: #38bdf8; }
.pe-tl-ref.pdf { color: #86efac; }
.pe-tl-ref.pdf:hover { color: #4ade80; }
.pe-tl-ref.pending { color: #64748b; cursor: default; border-style: dashed; }
.pe-tl-ref.pending:hover { background: #0c1526; color: #64748b; border-color: #1e293b; }
/* «Ver lo enviado a Open Mercato»: cabecera con destino/interacción/título. */
.pe-tl-om-meta { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(56,189,248,.08); border: 1px solid rgba(56,189,248,.25); font-size: 13px; color: #cbd5e1; }
.pe-tl-om-meta b { color: #7dd3fc; }
.pe-tl-empty { padding: 34px 20px; text-align: center; color: #64748b; font-size: 14px; }
.pe-tl-view-box { width: min(96vw, 1100px); max-height: 92vh; display: flex; flex-direction: column; }
.pe-tl-view-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 10px 16px 18px; }
.pe-tl-view-body .pe-tl-file-pre { white-space: pre-wrap; word-break: break-word; background: #020617; border: 1px solid #1e293b; border-radius: 10px; padding: 10px 12px; font-size: 12px; color: #cbd5e1; }

/* ============================================================
   Interactuar (`.pe-interact-*`, `.pe-act-*`, `.pe-msg`) — de v1.5.7
   ============================================================ */
.pe-interact-box { width: min(96vw, 1440px); height: calc(100vh - 120px); max-height: calc(100vh - 120px); display: flex; flex-direction: column; background: #0b1220; border: 1px solid #1e293b; border-radius: 16px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.pe-interact-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: #0f172a; border-bottom: 1px solid #1e293b; }
.pe-interact-sub { font-size: 12px; color: #64748b; }
.pe-interact-body { display: flex; flex: 1 1 auto; min-height: 0; }
.pe-interact-side { width: 280px; min-width: 240px; flex: 0 0 auto; display: flex; flex-direction: column; border-right: 1px solid #1e293b; background: #0b1220; }
.pe-interact-side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; border-bottom: 1px solid #1e293b; }
.pe-interact-side-title { font-size: 15px; font-weight: 800; color: #e2e8f0; }
.pe-interact-sessions { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.pe-act-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 8px 10px; border-radius: 10px; background: #0f172a; border: 1px solid transparent; cursor: pointer; transition: .12s; color: #cbd5e1; }
.pe-act-item:hover { background: #1e293b; }
.pe-act-item.active { background: rgba(14,116,144,.18); border-color: rgba(34,211,238,.4); }
.pe-act-item .pe-act-name { font-size: 14px; font-weight: 700; color: #e2e8f0; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-act-item .pe-act-meta { font-size: 11px; color: #64748b; }
.pe-act-item .pe-act-acts { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 2px; }
.pe-act-item .pe-act-icon { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; background: transparent; border: 1px solid transparent; color: #94a3b8; cursor: pointer; border-radius: 8px; transition: .12s; }
.pe-act-item .pe-act-icon svg { width: 17px; height: 17px; }
.pe-act-item .pe-act-icon:hover { color: #a5f3fc; background: rgba(8,145,178,.22); border-color: rgba(34,211,238,.45); }
.pe-act-item .pe-act-icon.del:hover { color: #fecaca; background: rgba(127,29,29,.35); border-color: rgba(185,28,28,.55); }
.pe-interact-side-sources-head { padding: 10px 12px 4px; font-size: 12px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: .04em; }
.pe-interact-sources { flex: 0 1 auto; max-height: 30%; overflow-y: auto; padding: 6px 10px 10px; display: flex; flex-direction: column; gap: 4px; }
.pe-act-src { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #94a3b8; padding: 3px 8px; background: #0f172a; border: 1px solid #1e293b; border-radius: 8px; }
.pe-act-src .pe-act-src-icon { flex: 0 0 auto; }
.pe-act-src .pe-act-src-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-interact-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; min-height: 0; position: relative; }
.pe-interact-chat { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.pe-chat-empty { margin: auto; text-align: center; color: #64748b; font-size: 15px; max-width: 480px; }
.pe-chat-empty b { color: #94a3b8; display: block; font-size: 18px; margin-bottom: 6px; }
.pe-msg { display: flex; flex-direction: column; max-width: min(760px, 92%); }
.pe-msg.assistant { max-width: min(900px, 96%); align-self: flex-start; align-items: flex-start; }
.pe-msg.user { align-self: flex-end; align-items: flex-end; }
.pe-msg .pe-msg-meta { display: flex; align-items: center; gap: 8px; font-size: 11px; color: #64748b; margin-bottom: 4px; }
.pe-msg .pe-msg-bubble { padding: 10px 14px; border-radius: 14px; font-size: 15px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.pe-msg.user .pe-msg-bubble { background: #0e7490; color: #ecfeff; border-bottom-right-radius: 4px; }
.pe-msg.assistant .pe-msg-bubble { background: #0f172a; border: 1px solid #1e293b; color: #e2e8f0; border-bottom-left-radius: 4px; }
.pe-msg.assistant .pe-msg-bubble.prose-hermes { white-space: normal; overflow-wrap: anywhere; padding: 14px 18px; }
.pe-interact-composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid #1e293b; background: #0f172a; }
.pe-interact-input { flex: 1 1 auto; resize: vertical; min-height: 44px; }
.pe-interact-chat .pe-act-live { display: flex; flex-direction: column; gap: 8px; }
/* Aviso flotante de «ya tienes tu respuesta»: aparece sobre el composer cuando la
   respuesta llega mientras el usuario está leyendo más arriba. Al pulsarlo salta
   al principio del mensaje nuevo; si nadie lo pulsa, se cierra solo. */
.pe-chat-jump { position: absolute; left: 50%; transform: translateX(-50%); bottom: 76px; z-index: 6;
  display: flex; align-items: center; gap: 10px; max-width: min(520px, 92%);
  padding: 9px 12px; border-radius: 999px; cursor: pointer;
  background: linear-gradient(180deg, #0e7490, #0b5e75); color: #ecfeff;
  border: 1px solid #22d3ee; box-shadow: 0 10px 28px rgba(2, 6, 23, .55);
  font: inherit; text-align: left; animation: pe-jump-in .18s ease-out; }
.pe-chat-jump:hover, .pe-chat-jump:focus-visible { border-color: #67e8f9; outline: none;
  box-shadow: 0 12px 32px rgba(2, 6, 23, .65), 0 0 0 2px rgba(34, 211, 238, .35); }
.pe-chat-jump-ic { flex: 0 0 auto; font-size: 16px; }
.pe-chat-jump-tx { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.pe-chat-jump-tx b { font-size: 13px; }
.pe-chat-jump-tx span { font-size: 11.5px; color: #a5f3fc; }
.pe-chat-jump-x { flex: 0 0 auto; padding: 0 4px; font-size: 12px; color: #a5f3fc; border-radius: 999px; }
.pe-chat-jump-x:hover { color: #ecfeff; background: rgba(255,255,255,.12); }
@keyframes pe-jump-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
/* Destello del mensaje al que salta el aviso, para no perderlo de vista. */
.pe-msg-flash .pe-msg-bubble { box-shadow: 0 0 0 2px #22d3ee; transition: box-shadow .25s ease; }
.pe-act-think { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; background: rgba(14,116,144,.1); border: 1px solid #155e70; color: #a5f3fc; font-size: 14px; font-weight: 600; }
.pe-act-think .pe-spin { flex: 0 0 auto; }
.pe-act-ronda { border: 1px solid #1e293b; border-radius: 12px; background: #0d1628; overflow: hidden; }
.pe-act-ronda + .pe-act-ronda { margin-top: 6px; }
.pe-act-ronda::before { content: ""; display: block; height: 3px; background: linear-gradient(90deg,#0e7490,#22d3ee); }
.pe-act-ronda-head { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 8px 12px; background: rgba(14,116,144,.08); border: none; cursor: pointer; }
.pe-act-ronda-chev { color: #64748b; font-size: 14px; transition: transform .15s; flex: 0 0 auto; }
.pe-act-ronda.open .pe-act-ronda-chev { transform: rotate(90deg); }
.pe-act-ronda-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 22px; padding: 0 7px; border-radius: 9999px; background: #0e7490; color: #fff; font-size: 14px; font-weight: 800; }
.pe-act-ronda-title { font-size: 14px; font-weight: 700; color: #e2e8f0; }
.pe-act-ronda-time { margin-left: auto; font-size: 12px; color: #64748b; font-variant-numeric: tabular-nums; }
.pe-act-ronda-body { display: none; padding: 8px 12px 10px; }
.pe-act-ronda.open .pe-act-ronda-body { display: block; }
.pe-act-ronda-body pre { margin: 0; white-space: pre-wrap; font-size: 14px; line-height: 1.5; color: #cbd5e1; }
.pe-act-partial { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: #94a3b8; padding: 2px 0; }
.pe-act-partial .pe-act-partial-dot { flex: 0 0 auto; width: 6px; height: 6px; border-radius: 9999px; background: #22d3ee; margin-top: 6px; }
.pe-act-partial .pe-act-partial-msg { flex: 1 1 auto; white-space: pre-wrap; }
.pe-act-src-pick { flex: 0 0 auto; border: 1px solid #1e293b; border-radius: 12px; overflow: hidden; background: #0f172a; }
.pe-act-src-pick + .pe-act-src-pick { margin-top: 8px; }
.pe-act-src-pick-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 14px; font-weight: 700; color: #e2e8f0; background: #0f172a; border-bottom: 1px solid #1e293b; cursor: pointer; }
.pe-act-src-pick-head .pe-act-caret { margin-left: auto; color: #64748b; font-size: 12px; transition: transform .15s; }
.pe-act-src-pick.open .pe-act-src-pick-head .pe-act-caret { transform: rotate(90deg); }
.pe-act-src-pick-body { display: none; padding: 8px; }
.pe-act-src-pick.open .pe-act-src-pick-body { display: block; max-height: 36vh; overflow-y: auto; }
.pe-act-src-pick-body label { display: flex; align-items: flex-start; gap: 8px; padding: 4px 6px; border-radius: 6px; font-size: 13px; color: #cbd5e1; cursor: pointer; }
.pe-act-src-pick-body label:hover { background: #1e293b; }
.pe-act-src-empty { font-size: 13px; color: #64748b; padding: 6px 8px; }
.pe-act-src-hint { font-size: 12px; line-height: 1.5; color: #94a3b8; padding: 6px 8px 8px; margin-bottom: 6px; border-bottom: 1px dashed #1e293b; }
.pe-act-src-pick-body label input[type="checkbox"], .pe-act-cat-head input[type="checkbox"] { flex: 0 0 auto; margin-top: 3px; }
.pe-act-cat { border-top: 1px solid #1e293b; }
.pe-act-cat:first-child { border-top: none; }
.pe-act-cat-head { display: flex; align-items: center; gap: 8px; padding: 6px; font-size: 13px; color: #e2e8f0; cursor: pointer; border-radius: 6px; }
.pe-act-cat-head:hover { background: #1e293b; }
.pe-act-cat-head b { font-weight: 700; }
.pe-act-cat-body { padding-left: 16px; }
.pe-act-opt.off { opacity: .5; }

/* ============================================================
   Conciliación de variables (`.pe-conc-*`, `.pe-card`, `.pe-hist`) — de v1.5.7
   ============================================================ */
.pe-conc-count { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; cursor: pointer; border: 1px solid; }
.pe-conc-count.red { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.35); color: #fca5a5; }
.pe-conc-count.yellow { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.35); color: #fcd34d; }
.pe-conc-count.green { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.35); color: #86efac; }
.pe-conc-count.off { opacity: .45; }
.pe-conc-count .pe-faltan { color: #f87171; }
.pe-conc-sec { margin-bottom: 14px; }
.pe-conc-sec-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 800; letter-spacing: .02em; margin-bottom: 8px; text-transform: uppercase; color: #94a3b8; }
.pe-conc-sec-title .cnt { color: #64748b; font-weight: 600; }
.pe-conc-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer; border: 1px solid #334155; background: #1e293b; color: #e2e8f0; transition: .12s; max-width: 460px; }
.pe-conc-chip:hover { border-color: #818cf8; background: #283548; color: #fff; }
.pe-conc-chip.on { border-color: #818cf8; background: rgba(99,102,241,.22); color: #e0e7ff; }
.pe-conc-chip .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pe-conc-chip .dot.red { background: #ef4444; } .pe-conc-chip .dot.yellow { background: #f59e0b; } .pe-conc-chip .dot.green { background: #22c55e; }
.pe-conc-empty { padding: 18px; text-align: center; font-size: 14px; color: #64748b; }
.pe-card { border: 1px solid #1e293b; background: #0b1423; border-radius: 12px; padding: 12px 14px; }
.pe-card-before { border-color: rgba(100,116,139,.35); }
.pe-card-after { border-color: rgba(245,158,11,.5); background: rgba(245,158,11,.05); }
.pe-card-final { border-color: rgba(34,197,94,.4); background: rgba(34,197,94,.05); }
.pe-card-label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: #64748b; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.pe-card-value { font-size: 14px; color: #e2e8f0; white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.pe-card-empty { font-style: italic; color: #64748b; }
.pe-info-line { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; color: #cbd5e1; line-height: 1.55; }
.pe-info-line .ico { flex: none; }
.pe-hist-item { border: 1px solid #1e293b; background: #0b1423; border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.pe-hist-item .meta { color: #94a3b8; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pe-hist-item .meta b { color: #cbd5e1; font-weight: 600; }
.pe-hist-item pre { margin-top: 5px; white-space: pre-wrap; color: #cbd5e1; font-size: 13px; }
.pe-action-lg { padding: 9px 18px; border-radius: 10px; font-size: 14px; font-weight: 700; border: 1px solid; cursor: pointer; }
.pe-action-ok { background: rgba(34,197,94,.15); border-color: rgba(34,197,94,.5); color: #86efac; }
.pe-action-ok:hover { background: rgba(34,197,94,.25); }
.pe-action-no { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.45); color: #fca5a5; }
.pe-action-no:hover { background: rgba(239,68,68,.22); }
.pe-action-edit { background: rgba(99,102,241,.12); border-color: rgba(99,102,241,.45); color: #a5b4fc; }
.pe-action-edit:hover { background: rgba(99,102,241,.22); }
.pe-action-skip { background: rgba(148,163,184,.12); border-color: rgba(148,163,184,.45); color: #cbd5e1; }
.pe-action-skip:hover { background: rgba(148,163,184,.22); }
.pe-action-lg:disabled { opacity: .35; cursor: not-allowed; background: rgba(100,116,139,.08); border-color: rgba(100,116,139,.3); color: #94a3b8; }
.pe-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 768px) { .pe-grid-2 { grid-template-columns: 1fr; } }
.pe-acc { border: 1px solid #1e293b; background: #0b1423; border-radius: 12px; overflow: hidden; }
.pe-acc-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; font-size: 13px; font-weight: 800; color: #94a3b8; cursor: pointer; background: transparent; border: none; letter-spacing: .03em; text-transform: uppercase; }
.pe-acc-toggle:hover { color: #e2e8f0; }
.pe-acc-toggle .chev { transition: transform .15s; font-size: 14px; }
.pe-acc.open .pe-acc-toggle .chev { transform: rotate(90deg); }
.pe-acc-body { display: none; padding: 0 14px 12px; }
.pe-acc.open .pe-acc-body { display: block; }

/* ============================================================
   Scrollbars oscuros (v1.32). En fondo #020617 el scroll nativo se ve
   blanco y «torpe»; se le da el mismo tono del panel. Es solo estética:
   no cambia tamaños ni el scroll en sí.
   ============================================================ */
* { scrollbar-width: thin; scrollbar-color: #334155 transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #334155; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: #475569; background-clip: padding-box; }

/* ============================================================
   Lista de fuentes en DOS columnas (datos + acciones). Antes las
   etiquetas de los campos y los botones se veían iguales y pegados;
   ahora los datos quedan a la izquierda y las acciones en vertical.
   ============================================================ */
.pe-fuente-item.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(150px, auto); gap: 14px; align-items: start; }
.pe-fuente-item.split .pe-fuente-main { min-width: 0; }
.pe-fuente-item.split .pe-fuente-acts { margin-top: 0; flex-direction: column; align-items: stretch; }
.pe-fuente-item.split .pe-fuente-acts .pe-btn { justify-content: center; white-space: nowrap; }
@media (max-width: 640px) {
  .pe-fuente-item.split { grid-template-columns: 1fr; }
  .pe-fuente-item.split .pe-fuente-acts { flex-direction: row; flex-wrap: wrap; }
}

/* ============================================================
   Conciliación de variables: jerarquía CATEGORÍA › SUBCATEGORÍA ›
   variable (aprendizaje de la modal de variables del Constructor).
   ============================================================ */
.pe-conc-cat { margin-bottom: 16px; }
.pe-conc-cat-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px;
  background: rgba(99,102,241,.12); border: 1px solid rgba(99,102,241,.32); border-left: 3px solid #6366f1; }
.pe-conc-cat-name { font-size: 14px; font-weight: 800; color: #e0e7ff; }
.pe-conc-cat-count { margin-left: auto; font-size: 12px; font-weight: 700; color: #a5b4fc; }
.pe-conc-sub { margin: 10px 0 0 8px; padding-left: 12px; border-left: 2px solid rgba(34,211,238,.32); }
.pe-conc-sub-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 12.5px; font-weight: 700; color: #7dd3fc; }
.pe-conc-sub-count { color: #64748b; font-weight: 600; }
.pe-conc-items { display: flex; flex-wrap: wrap; gap: 6px; }

/* ============================================================
   Nueva sesión de Interactuar: mesa de trabajo amplia (96vw × 80vh).
   Objetivo: elegir contexto con el MÍNIMO scroll. La columna izquierda
   concentra fuentes › variables › documentos (las variables son la
   sección principal y su tabla scrollea dentro) y la derecha muestra en
   vivo QUÉ se lleva seleccionado. Antes la modal era estrecha (760px) y
   todo quedaba apretado en un solo hilo.
   ============================================================ */
.pe-newsess-box { width: min(96vw, 1520px); height: 80vh; max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; }
.pe-newsess-head { gap: 12px; }
.pe-newsess-name { flex: 1 1 380px; min-width: 220px; display: flex; align-items: center; gap: 8px; }
.pe-newsess-name label { font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: #64748b; white-space: nowrap; }
.pe-newsess-name .hac-input { flex: 1 1 auto; }
.pe-newsess-count { font-size: 12px; font-weight: 700; color: #a5b4fc; border: 1px solid rgba(99,102,241,.42); background: rgba(99,102,241,.14); border-radius: 999px; padding: 4px 12px; white-space: nowrap; }
.pe-newsess-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 360px; grid-template-rows: minmax(0, 1fr); }
.pe-newsess-main { min-width: 0; min-height: 0; overflow: hidden; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.pe-newsess-side { min-width: 0; min-height: 0; border-left: 1px solid #1e293b; background: #0b1220; display: flex; flex-direction: column; }
.pe-newsess-side-head { flex: 0 0 auto; padding: 11px 14px; font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: #94a3b8; border-bottom: 1px solid #1e293b; }
.pe-newsess-summary { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.pe-newsess-empty { font-size: 12.5px; color: #64748b; line-height: 1.55; }
.pe-newsess-foot { flex: 0 0 auto; padding: 10px 16px 12px; border-top: 1px solid #1e293b; display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.pe-newsess-foot .hac-btn { width: auto; min-width: 220px; }
.pe-newsess-foot #ar-chat-new-error { margin-right: auto; }
@media (max-width: 1100px) {
  .pe-newsess-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 34%); }
  .pe-newsess-side { border-left: none; border-top: 1px solid #1e293b; }
}

/* Secciones del selector (fuentes · variables · documentos). Acordeón EXCLUSIVO:
   solo una sección abierta a la vez y esa se lleva el alto disponible; las demás
   quedan como simple cabecera. Antes la de variables ocupaba todo y las otras no
   tenían espacio para mostrar su contenido. */
.pe-pick-sec { flex: 0 0 auto; display: flex; flex-direction: column; min-height: 0; border: 1px solid #1e293b; border-radius: 12px; background: #0f172a; overflow: hidden; }
.pe-pick-sec.expanded { flex: 1 1 auto; min-height: 0; }
.pe-pick-sec-head { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 9px 12px; background: #0f172a; border: none; border-bottom: 1px solid #1e293b; font-size: 13px; font-weight: 800; color: #e2e8f0; cursor: pointer; }
.pe-pick-sec-head:hover { background: #131e33; }
.pe-pick-sec-n { font-size: 12px; font-weight: 600; color: #64748b; }
.pe-pick-sec-hint { font-size: 11.5px; font-weight: 500; color: #64748b; }
.pe-pick-sec .pe-act-caret { margin-left: 4px; color: #64748b; font-size: 12px; }
.pe-pick-sec-content { display: none; flex: 1 1 auto; min-height: 0; flex-direction: column; overflow: hidden; }
.pe-pick-sec.expanded .pe-pick-sec-content { display: flex; }
.pe-pick-sec-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px 10px 10px; }
.pe-pick-sec-body label { display: flex; align-items: flex-start; gap: 8px; padding: 5px 6px; border-radius: 6px; font-size: 13px; color: #cbd5e1; cursor: pointer; }
.pe-pick-sec-body label:hover { background: #1e293b; }
/* Filtros de las variables: plegados por defecto (botón «Filtros» en la cabecera
   de su sección). */
.pe-pick-varfilters { flex: 0 0 auto; padding: 8px 10px 0; border-bottom: 1px dashed #1e293b; margin-bottom: 4px; }
.pe-pick-varfilters .pe-pick-filters:first-child { padding-top: 0; }
.pe-pick-varfilters .pe-pick-filters { border-bottom: none; }
/* La sección de variables: filtros fijos arriba y tabla con su propio scroll. */
.pe-varwrap { display: flex; flex-direction: column; overflow: hidden; }
.pe-varscroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.pe-pick-badge { margin-left: auto; font-size: 12px; font-weight: 700; color: #c7d2fe; background: rgba(99,102,241,.16); border: 1px solid rgba(99,102,241,.42); border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.pe-pick-table thead th { position: sticky; top: 0; z-index: 1; background: #0f172a; }
.pe-pick-filtersbtn { display: inline-flex; align-items: center; gap: 5px; border: 1px solid #1e293b; background: #0b1220; color: #94a3b8; border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 700; cursor: pointer; white-space: nowrap; transition: .12s; }
.pe-pick-filtersbtn:hover { background: #1e293b; color: #e2e8f0; }
.pe-pick-filtersbtn.on { background: rgba(99,102,241,.18); border-color: rgba(99,102,241,.55); color: #e0e7ff; }

/* Resumen de la selección (columna derecha) */
.pe-sum-group { display: flex; flex-direction: column; gap: 4px; }
.pe-sum-group-head { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: #94a3b8; }
.pe-sum-group-n { margin-left: auto; color: #64748b; font-weight: 700; }
.pe-sum-item { display: flex; align-items: flex-start; gap: 6px; font-size: 12.5px; color: #cbd5e1; padding: 4px 8px; background: #0f172a; border: 1px solid #1e293b; border-radius: 8px; overflow-wrap: anywhere; }
.pe-sum-item .ico { flex: 0 0 auto; }
.pe-sum-item.pe-sum-all { border-color: rgba(99,102,241,.42); background: rgba(99,102,241,.1); color: #e0e7ff; font-weight: 600; }

/* ============================================================
   Interactuar: contexto de la sesión legible y composer guiado.
   ============================================================ */
.pe-interact-side { width: 320px; min-width: 264px; }
.pe-interact-sources { flex: 0 1 auto; max-height: 42%; }
.pe-act-src { align-items: flex-start; }
.pe-act-src .pe-act-src-name { overflow: visible; text-overflow: clip; white-space: normal; overflow-wrap: anywhere; }
.pe-act-src-group { margin-top: 6px; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: #64748b; }
.pe-act-src-group:first-child { margin-top: 0; }
.pe-interact-composer button:disabled, .pe-interact-composer .pe-interact-input:disabled { opacity: .5; cursor: not-allowed; }
.pe-chat-empty .pe-empty-cta { margin-top: 14px; }

/* ============================================================
   Interactuar · estado de arranque en 3 pasos (sin sesión)
   ============================================================ */
.pe-chat-home { margin: auto; max-width: 760px; width: 100%; padding: 16px 10px; }
.pe-home-head { text-align: center; margin-bottom: 18px; }
.pe-home-badge { display: inline-flex; width: 52px; height: 52px; align-items: center; justify-content: center; font-size: 26px; border-radius: 16px; background: rgba(14,116,144,.18); border: 1px solid rgba(34,211,238,.35); }
.pe-home-head h3 { margin: 10px 0 4px; font-size: 20px; font-weight: 800; color: #e2e8f0; }
.pe-home-head p { font-size: 14px; color: #94a3b8; line-height: 1.6; margin: 0; }
.pe-home-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); text-align: left; }
.pe-home-steps li { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid #1e293b; border-radius: 12px; background: #0b1220; }
.pe-home-n { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 999px; background: rgba(99,102,241,.2); border: 1px solid rgba(99,102,241,.5); color: #c7d2fe; font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.pe-home-ic { flex: 0 0 auto; font-size: 17px; line-height: 1.25; }
.pe-home-b { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pe-home-t { font-size: 14px; font-weight: 700; color: #e2e8f0; }
.pe-home-d { font-size: 12.5px; color: #94a3b8; line-height: 1.5; }
.pe-home-cta { margin-top: 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pe-home-note { font-size: 12px; color: #64748b; text-align: center; }

/* ============================================================
   Selector de variables de nueva sesión: filtros + tabla con checks
   ============================================================ */
.pe-pick-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 2px; border-bottom: 1px dashed #1e293b; }
.pe-pick-flabel { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: #64748b; margin-right: 4px; }
.pe-pick-chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid #1e293b; background: #0f172a; color: #94a3b8; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; cursor: pointer; transition: .12s; }
.pe-pick-chip:hover { background: #1e293b; color: #e2e8f0; }
.pe-pick-chip.on { background: rgba(99,102,241,.2); border-color: rgba(99,102,241,.55); color: #e0e7ff; }
.pe-pick-n { font-size: 11px; opacity: .75; }
.pe-pick-bar { display: flex; justify-content: space-between; gap: 10px; padding: 8px 2px 6px; font-size: 12px; color: #64748b; }
.pe-pick-bar b { color: #cbd5e1; }
.pe-pick-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pe-pick-table thead th { text-align: left; padding: 7px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #64748b; border-bottom: 1px solid #1e293b; }
.pe-pick-table td { padding: 5px 8px; border-bottom: 1px solid #0f172a; vertical-align: top; }
.pe-pick-table tr.pe-pt-cat td { padding: 12px 8px 6px; border-bottom: 1px solid #1e293b; background: rgba(99,102,241,.07); }
.pe-pt-catlabel { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.pe-pt-catname { font-size: 13px; font-weight: 800; color: #e0e7ff; }
.pe-pt-count { margin-left: auto; font-size: 11px; color: #64748b; font-weight: 600; }
.pe-pick-table tr.pe-pt-sub td { background: rgba(34,211,238,.05); }
.pe-pt-sublabel { display: flex; align-items: center; gap: 8px; cursor: pointer; padding-left: 10px; }
.pe-pt-subname { font-size: 12.5px; font-weight: 700; color: #7dd3fc; }
.pe-pt-var .pe-pt-name { width: 42%; }
.pe-pt-varlabel { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.pe-pt-varname { font-weight: 600; color: #cbd5e1; overflow-wrap: anywhere; }
.pe-pt-desc { color: #94a3b8; line-height: 1.5; }
.pe-pt-desc.is-empty { font-style: italic; color: #64748b; }
.pe-pick-table input[type="checkbox"] { flex: 0 0 auto; margin-top: 3px; accent-color: #6366f1; }
.pe-pt-catlabel.off, .pe-pt-sublabel.off, .pe-pt-varlabel.off { opacity: .55; }

/* ============================================================
   Tooltip del contexto de Interactuar (descripción de la variable)
   ============================================================ */
.pe-tip { position: fixed; z-index: 90; max-width: 340px; padding: 9px 11px; border-radius: 10px;
  background: #0b1220; border: 1px solid #334155; box-shadow: 0 10px 30px rgba(0,0,0,.5);
  opacity: 0; visibility: hidden; transition: opacity .1s; pointer-events: none; }
.pe-tip.show { opacity: 1; visibility: visible; }
.pe-tip-name { font-size: 13px; font-weight: 800; color: #e2e8f0; }
.pe-tip-path { font-size: 11px; color: #7dd3fc; margin-top: 2px; }
.pe-tip-desc { font-size: 12.5px; color: #cbd5e1; line-height: 1.5; margin-top: 5px; }
.pe-tip-desc.empty { font-style: italic; color: #64748b; }
.pe-act-src-tip { cursor: help; }
.pe-act-src-tip:focus { outline: 1px solid rgba(34,211,238,.6); outline-offset: 1px; }

/* ============================================================
   Conciliación · «Todas» en gris (es ausencia de filtro, no un estado)
   ============================================================ */
.pe-conc-count.all { background: rgba(148,163,184,.12); border-color: rgba(148,163,184,.35); color: #cbd5e1; }

/* ============================================================
   Modal de aprobación de variables (una a la vez, navegando lo filtrado).
   Altura FIJA (80vh): el contenido cambia mucho entre variables y la modal
   no debe «saltar» en mitad de un ciclo de aprobaciones seguidas.
   ============================================================ */
.pe-ap-box { width: min(900px, 100%); height: 80vh; max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; }
.pe-ap-head { align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.pe-ap-headmain { min-width: 0; flex: 1 1 auto; }
.pe-ap-sub { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 5px; font-size: 12px; color: #94a3b8; }
/* Categoría y subcategoría viven en el HEADER (junto al nombre) como etiquetas:
   es el sitio natural para el contexto y libera alto de la zona con scroll. */
.pe-ap-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700;
  color: #c7d2fe; background: rgba(99,102,241,.14); border: 1px solid rgba(99,102,241,.4);
  border-radius: 999px; padding: 2px 10px; white-space: nowrap; max-width: 260px; overflow: hidden;
  text-overflow: ellipsis; }
.pe-ap-tag.sub { color: #a5f3fc; background: rgba(14,116,144,.16); border-color: rgba(34,211,238,.35); }
.pe-ap-tag-empty { font-style: italic; color: #64748b; background: rgba(148,163,184,.1); border-color: rgba(148,163,184,.3); }
.pe-ap-headnav { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.pe-ap-pos { font-size: 12px; color: #94a3b8; font-variant-numeric: tabular-nums; min-width: 46px; text-align: center; }
.pe-ap-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px 16px 18px; display: flex; flex-direction: column; gap: 10px; }
/* Los hijos NO deben encogerse: si encogen, el contenido se recorta en vez de
   hacer scroll (era la razón de que el histórico «no dejara bajar»). */
.pe-ap-body > * { flex: 0 0 auto; }
.pe-ap-card { border: 1px solid #1e293b; background: #0b1423; border-radius: 12px; padding: 11px 13px; }
.pe-ap-card-proposed { border-color: rgba(99,102,241,.45); background: rgba(99,102,241,.06); }
.pe-ap-text { font-size: 14px; color: #e2e8f0; white-space: pre-wrap; line-height: 1.55; }
.pe-ap-src { margin-top: 6px; font-size: 12.5px; color: #94a3b8; }
.pe-ap-input { width: 100%; }
.pe-ap-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pe-ap-actions .pe-action-lg { flex: 1 1 150px; }
/* Histórico dentro de la modal de aprobación: con su propio scroll, para poder
   recorrer todo sin pelearse con el scroll de la modal. */
.pe-ap-acc .pe-acc-body { max-height: 44vh; overflow-y: auto; }

/* ============================================================
   Botón «Filtros» (plegar/desplegar la barra de filtros).
   Va en el header, a la IZQUIERDA de la ✕ y separado de ella.
   Los filtros se ocultan por defecto: en tablets apaisadas la barra
   se comía buena parte de la pantalla de trabajo.
   ============================================================ */
.vars-filterbtn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #1e293b;
  background: #0f172a; color: #94a3b8; border-radius: 8px; padding: 5px 11px; font-size: 12.5px;
  font-weight: 700; cursor: pointer; white-space: nowrap; transition: .12s; }
.vars-filterbtn:hover { background: #1e293b; color: #e2e8f0; }
.vars-filterbtn.on { background: rgba(99,102,241,.18); border-color: rgba(99,102,241,.55); color: #e0e7ff; }
.vars-filterbtn .vf-n { font-size: 11px; opacity: .8; font-weight: 600; }
.filters-collapsed { display: none !important; }


/* ============================================================
   Interactuar · panel de sesiones plegable, índice lateral de la sesión y
   botón «Copiar» por mensaje. Compartido por el chat del área (area.html) y el
   del proceso (process_editor.html): su <style> inline no define estos
   selectores, así que estas reglas aplican en las dos vistas.
   ============================================================ */

/* --- Plegado del panel de sesiones (libera ancho de trabajo) --- */
.pe-interact-body.side-collapsed .pe-interact-side { display: none; }
/* Botón grande y con relieve: el icono es un panel con la flecha hacia dentro
   (recoger) o hacia fuera (desplegar). Los « » anteriores eran ilegibles. */
.pe-interact-toggle { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 38px; padding: 0; color: #e2e8f0; background: #1e293b; border: 1px solid #475569; border-radius: 10px; cursor: pointer; transition: .12s; }
.pe-interact-toggle svg { width: 22px; height: 22px; }
.pe-interact-toggle:hover { color: #fff; background: #334155; border-color: #818cf8; }
.pe-interact-toggle:focus-visible { outline: 2px solid #818cf8; outline-offset: 2px; }

/* --- Índice lateral derecho de la sesión (cerrado por defecto) --- */
.pe-interact-rail { width: 384px; min-width: 264px; flex: 0 0 auto; display: flex; flex-direction: column; border-left: 1px solid #1e293b; background: #0b1220; }
.pe-interact-body:not(.rail-open) .pe-interact-rail { display: none; }
.pe-rail-head { display: flex; align-items: center; gap: 8px; padding: 12px; border-bottom: 1px solid #1e293b; }
.pe-rail-head-title { flex: 1 1 auto; min-width: 0; font-size: 14px; font-weight: 800; color: #e2e8f0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-rail-head-sub { display: block; font-size: 11px; font-weight: 500; color: #64748b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-rail-close { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; background: transparent; border: 1px solid transparent; color: #94a3b8; cursor: pointer; }
.pe-rail-close:hover { color: #e2e8f0; background: #1e293b; border-color: #334155; }
.pe-rail-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.pe-rail-empty { margin: auto; padding: 16px 10px; text-align: center; font-size: 12.5px; color: #64748b; }
.pe-rail-item { display: flex; align-items: flex-start; gap: 8px; box-sizing: border-box; padding: 8px 8px 8px 10px; border-radius: 10px; background: #0f172a; border: 1px solid #1e293b; cursor: pointer; transition: .12s; }
/* El COLOR DEL FONDO es lo que distingue quién habló (los mismos colores que el
   chat: teal para lo tuyo, slate oscuro para el agente). Al quedar claro por el
   color, no hacen falta ni el icono ni el nombre en cada turno: se ahorran dos
   líneas y el texto respira. Además cada autor se desplaza a su lado, como en el
   chat, y el borde izquierdo refuerza el mismo matiz. */
.pe-rail-item.user { margin-left: 26px; background: rgba(14,116,144,.45); border-color: rgba(34,211,238,.30); border-left: 3px solid #22d3ee; }
.pe-rail-item.user:hover { background: rgba(14,116,144,.60); border-color: rgba(34,211,238,.5); }
.pe-rail-item.assistant { margin-right: 26px; border-left: 3px solid #6366f1; }
.pe-rail-item.assistant:hover { background: #1e293b; border-color: #334155; }
/* Separador de día: la fecha se dice UNA vez y todo lo de debajo es de ese día. */
.pe-rail-day { display: flex; align-items: center; gap: 8px; margin: 12px 0 2px; font-size: 10.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: #94a3b8; }
.pe-rail-day:first-child { margin-top: 0; }
.pe-rail-day::after { content: ""; flex: 1 1 auto; height: 1px; background: linear-gradient(90deg, #1e293b, transparent); }
.pe-rail-flag { flex: 0 0 auto; border-radius: 9999px; padding: 0 6px; font-size: 10px; font-weight: 800; }
.pe-rail-flag.error { background: rgba(127,29,29,.4); color: #fecaca; }
.pe-rail-flag.stopped { background: rgba(120,53,15,.4); color: #fde68a; }
.pe-rail-title { flex: 1 1 auto; min-width: 0; font-size: 12.5px; color: #e2e8f0; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.pe-rail-item.user .pe-rail-title { color: #ecfeff; }
.pe-rail-item:hover .pe-rail-title { color: #fff; }
/* Solo la hora: la fecha completa vive en el separador de día (y en el tooltip). */
.pe-rail-hora { flex: 0 0 auto; font-size: 11px; line-height: 1.35; color: #94a3b8; font-variant-numeric: tabular-nums; }
.pe-rail-item.user .pe-rail-hora { color: #a5f3fc; }
.pe-rail-copy { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; margin: -4px -2px -4px 0; border-radius: 8px; background: transparent; border: 1px solid transparent; color: #64748b; cursor: pointer; opacity: 0; transition: .12s; }
.pe-rail-copy svg { width: 15px; height: 15px; }
.pe-rail-item:hover .pe-rail-copy, .pe-rail-item:focus-within .pe-rail-copy { opacity: 1; }
.pe-rail-copy:hover { color: #a5f3fc; background: rgba(8,145,178,.22); border-color: rgba(34,211,238,.45); }
.pe-rail-copy.ok { color: #6ee7b7; opacity: 1; }

/* --- Turno por el que va el chat (seguimiento del scroll) ---
   Al desplazar el chat, el índice marca la interacción que se está leyendo. El
   anillo va en el color de marca para que se vea igual sobre el turno tuyo
   (teal) y sobre el del agente (slate). */
.pe-rail-item.pe-rail-current { box-shadow: 0 0 0 2px #818cf8; }
.pe-rail-item.pe-rail-current .pe-rail-title { color: #fff; font-weight: 600; }
.pe-rail-item.pe-rail-current .pe-rail-hora { color: #e0e7ff; }
.pe-rail-item.pe-rail-current:hover { box-shadow: 0 0 0 2px #a5b4fc; }

/* --- Tooltip del índice: autor + fecha/hora + hasta 4 líneas del texto ---
   Es más que un «terminar de ver el título»: enseña el arranque de la duda para
   decidir si ese turno es el que se buscaba, sin necesidad de hacer clic. */
.pe-rail-tip { position: fixed; z-index: 80; max-width: 440px; padding: 10px 12px; border-radius: 10px; background: #0b1220; border: 1px solid #475569; box-shadow: 0 14px 36px rgba(0,0,0,.6); pointer-events: none; opacity: 0; transform: translateY(2px); transition: opacity .12s ease, transform .12s ease; }
.pe-rail-tip.show { opacity: 1; transform: none; }
.pe-rail-tip-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.pe-rail-tip-who.user { color: #a5f3fc; }
.pe-rail-tip-who.assistant { color: #c7d2fe; }
.pe-rail-tip-time { margin-left: auto; font-size: 11px; font-weight: 600; letter-spacing: 0; text-transform: none; color: #94a3b8; font-variant-numeric: tabular-nums; }
/* 4 líneas y puntos suspensivos si aún queda texto. */
.pe-rail-tip-body { font-size: 12.5px; line-height: 1.5; color: #e2e8f0; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }

/* --- Contexto de la sesión: cada elemento es un ATAJO al contenido original ---
   Al pulsar una fuente/variable/documento se abre su contenido tal cual lo
   recibió el agente. Se marca como pulsable (cursor, realce y un 👁 que aparece
   al pasar por encima) porque antes eran solo etiquetas de texto. */
.pe-act-src.is-clickable, .pe-act-src-group.is-clickable { cursor: pointer; }
.pe-act-src.is-clickable { transition: .12s; }
.pe-act-src.is-clickable:hover { background: #1e293b; border-color: rgba(34,211,238,.45); color: #e2e8f0; }
.pe-act-src.is-clickable:focus-visible, .pe-act-src-group.is-clickable:focus-visible { outline: 2px solid #818cf8; outline-offset: 1px; }
.pe-act-src-group.is-clickable { display: flex; align-items: center; gap: 6px; border-radius: 6px; padding: 2px 4px; margin-left: -4px; transition: .12s; }
.pe-act-src-group.is-clickable:hover { color: #c7d2fe; background: rgba(99,102,241,.12); }
/* El 👁 solo se insinúa al pasar por encima (o al enfocar): señala que se puede pulsar. */
.pe-act-src-eye { flex: 0 0 auto; font-size: 11px; opacity: 0; transition: .12s; }
.pe-act-src.is-clickable:hover .pe-act-src-eye,
.pe-act-src.is-clickable:focus-visible .pe-act-src-eye,
.pe-act-src-group.is-clickable:hover .pe-act-src-eye,
.pe-act-src-group.is-clickable:focus-visible .pe-act-src-eye { opacity: .85; }

/* --- Visor del contenido original de una fuente del contexto --- */
.pe-srcv-ficha { display: flex; flex-direction: column; gap: 8px; }
.pe-srcv-fila { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; background: #0f172a; border: 1px solid #1e293b; border-radius: 8px; }
.pe-srcv-k { font-size: 10.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: #94a3b8; }
.pe-srcv-v { font-size: 13.5px; color: #e2e8f0; overflow-wrap: anywhere; }
#ar-src-view-kind { flex: 0 0 auto; font-size: 11px; }
#ar-src-view-modal .pe-tl-view-body { padding: 14px 18px 18px; }

/* --- Botón «Copiar» del mensaje: pegado ARRIBA del mensaje (sticky) ---
   El envoltorio mide 0 de alto (no altera el diseño) y se pega al borde
   superior del chat: por eso el botón sigue a mano aunque se lea la mitad de
   un texto largo. Solo se ve con el cursor encima del mensaje; en pantallas
   táctiles (sin hover) queda siempre visible. */
.pe-msg { position: relative; scroll-margin-top: 10px; }
.pe-msg-copywrap { position: sticky; top: 8px; align-self: flex-end; height: 0; z-index: 4; display: flex; justify-content: flex-end; pointer-events: none; }
.pe-msg-copy { position: absolute; top: 0; right: 0; pointer-events: auto; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; background: rgba(15,23,42,.92); border: 1px solid #334155; color: #cbd5e1; cursor: pointer; opacity: 0; transition: opacity .14s; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.pe-msg-copy svg { width: 15px; height: 15px; }
.pe-msg:hover .pe-msg-copy, .pe-msg:focus-within .pe-msg-copy { opacity: 1; }
.pe-msg-copy:hover { color: #a5f3fc; border-color: rgba(34,211,238,.55); background: rgba(8,145,178,.35); }
.pe-msg-copy.ok { color: #6ee7b7; border-color: rgba(16,185,129,.55); opacity: 1; }
@media (hover: none) { .pe-msg-copy { opacity: .9; } }
.pe-msg .pe-msg-meta { padding-right: 36px; }
.pe-msg.pe-msg-target .pe-msg-bubble { animation: peMsgTarget 1.5s ease-out; }
@keyframes peMsgTarget {
  0% { box-shadow: 0 0 0 0 rgba(34,211,238,0); }
  25% { box-shadow: 0 0 0 3px rgba(34,211,238,.55); }
  100% { box-shadow: 0 0 0 0 rgba(34,211,238,0); }
}

/* --- Botones del encabezado que gobiernan ambos paneles --- */
.pe-interact-head .pe-btn.on { background: rgba(99,102,241,.22); border-color: rgba(99,102,241,.55); color: #e0e7ff; }

/* ---------------------------------------------------------------------------
   Componentes compartidos por las vistas de chat (Interactuar / Planeacion).
   Vivian en el <style> de area.html y process_editor.html; se centralizan aqui
   para que cualquier vista que reuse el shell `.pe-interact-*` los tenga
   (p. ej. el copiloto de Plane en plane.html).
   --------------------------------------------------------------------------- */
.pe-btn { border: 1px solid #334155; background: #1e293b; color: #e2e8f0; border-radius: 10px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.pe-btn:hover { background: #334155; }
.pe-btn.primary { background: #4f46e5; border-color: #4f46e5; color: #fff; }
.pe-btn.primary:hover { background: #4338ca; }
.pe-btn.danger { background: #7f1d1d; border-color: #7f1d1d; color: #fecaca; }
.pe-btn:disabled { opacity: .4; cursor: not-allowed; }
.pe-btn.sm { padding: 3px 8px; font-size: 12px; }
.pe-spin { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: pe-spin .7s linear infinite; vertical-align: -2px; }
.pe-spin.sm { width: 12px; height: 12px; }
@keyframes pe-spin { to { transform: rotate(360deg); } }

/* ===========================================================================
   PWA / INSTALACIÓN EN EL MÓVIL
   · Botón «Instalar app» del menú (lo enciende pwa.js con data-pwa-install).
   · Aviso de una sola vez en iPhone y guía «Compartir → Añadir a inicio».
   · Barra de versión nueva.
   · Área segura (notch / barra de estado) cuando corre a pantalla completa.
   =========================================================================== */
.hac-install { width: 100%; text-align: left; background: transparent; border: 0;
  cursor: pointer; font-family: inherit; }
.hac-install:hover { background: var(--c-panel2); }
[data-hac-install] { display: none !important; }
html[data-pwa-install="1"] [data-hac-install] { display: flex !important; }

/* --- Guía de instalación --- */
.hac-install-body { padding: 1rem 1.1rem 1.2rem; }
.hac-install-body p { margin: 0 0 .9rem; color: #cbd5e1; font-size: 16px; line-height: 1.6; }
.hac-install-steps { margin: 0 0 .4rem; padding-left: 1.3rem; display: grid; gap: .7rem;
  color: #e2e8f0; font-size: 16px; line-height: 1.55; }
.hac-install-steps b { color: #fff; }
.hac-install-ic { display: inline-grid; place-items: center; width: 26px; height: 26px;
  border-radius: 8px; background: rgba(99,102,241,.22); border: 1px solid rgba(129,140,248,.5);
  vertical-align: -6px; font-size: 15px; }
.hac-install-note { margin: .9rem 0 0; padding: .8rem .9rem; border-radius: 12px;
  background: rgba(99,102,241,.12); border: 1px solid rgba(129,140,248,.35);
  color: #c7d2fe !important; font-size: 15px !important; }

/* --- Aviso inferior (iPhone) --- */
.hac-install-tip { position: fixed; z-index: 70; left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem;
  background: #0f172a; border: 1px solid #4338ca; border-radius: 14px;
  box-shadow: 0 18px 45px -12px rgba(0,0,0,.85); color: #e2e8f0; }
.hac-install-tip-ic { font-size: 1.35rem; flex: 0 0 auto; }
.hac-install-tip-tx { flex: 1 1 auto; min-width: 0; font-size: 15px; line-height: 1.35; color: #cbd5e1; }
.hac-install-tip-tx b { display: block; color: #fff; font-size: 15px; }
.hac-install-tip-go { flex: 0 0 auto; border: 1px solid #6366f1; background: #4f46e5;
  color: #fff; border-radius: 10px; padding: .45rem .8rem; font-size: 15px; font-weight: 700;
  cursor: pointer; }
.hac-install-tip-x { flex: 0 0 auto; border: 0; background: transparent; color: #94a3b8;
  font-size: 16px; padding: .3rem .4rem; cursor: pointer; }
.hac-install-tip-x:hover { color: #fff; }

/* --- Versión nueva --- */
.hac-update { position: fixed; z-index: 75; left: 12px; right: 12px;
  top: calc(12px + env(safe-area-inset-top, 0px));
  display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem;
  background: #1e1b4b; border: 1px solid #6366f1; border-radius: 12px;
  box-shadow: 0 18px 45px -12px rgba(0,0,0,.85); color: #e0e7ff; font-size: 15px; }
.hac-update-tx { flex: 1 1 auto; min-width: 0; }
.hac-update-btn { flex: 0 0 auto; border: 1px solid #818cf8; background: #4f46e5; color: #fff;
  border-radius: 9px; padding: .35rem .75rem; font-size: 15px; font-weight: 700; cursor: pointer; }
.hac-update-x { flex: 0 0 auto; border: 0; background: transparent; color: #c7d2fe;
  font-size: 16px; cursor: pointer; }

/* --- Pantalla completa en iOS: respetar notch y barra de estado --- */
@supports (padding: env(safe-area-inset-top)) {
  @media (display-mode: standalone), (display-mode: fullscreen) {
    .hac-topbar { padding-top: calc(.7rem + env(safe-area-inset-top));
      padding-left: calc(1rem + env(safe-area-inset-left));
      padding-right: calc(1rem + env(safe-area-inset-right)); }
    .hac-side { padding-top: env(safe-area-inset-top);
      padding-bottom: env(safe-area-inset-bottom); }
    .hac-drawer { padding-top: env(safe-area-inset-top);
      padding-bottom: env(safe-area-inset-bottom); }
    body.hac-shell { padding-bottom: env(safe-area-inset-bottom); }
    body:not(.hac-shell) { padding-top: env(safe-area-inset-top); }
    .hac-install-tip { left: calc(12px + env(safe-area-inset-left));
      right: calc(12px + env(safe-area-inset-right)); }
  }
}

/* La altura de los modales no debe comerse el pie en Safari (barras dinámicas). */
@supports (height: 100dvh) {
  .hac-modal-box { max-height: 88dvh; }
}

/* ============================================================
   NOTA DE VOZ COMPARTIDA (copiloto de Planeación y 🤝 Interactuar del área)
   Un solo componente (static/voice_note.js) y un solo estilo para las dos
   vistas: grabar, PAUSAR (escuchando los últimos segundos) y reanudar.
   ============================================================ */
.hac-voz { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 0;
  border-top: 1px solid #1e293b; background: rgba(15, 23, 42, .7); }
/* El CSS propio trae `display`, así que el [hidden] del navegador no basta. */
.hac-voz.hidden, .hac-voz-fila.hidden, .hac-voz-estado.hidden, .hac-voz-chip.hidden {
  display: none !important; }
.hac-voz-chip { display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  border-radius: 999px; background: rgba(14, 116, 144, .22);
  border: 1px solid rgba(34, 211, 238, .45); color: #a5f3fc;
  font-size: 13px; font-weight: 600; align-self: flex-start; }
.hac-voz-x { background: none; border: 0; color: #a5f3fc; cursor: pointer; font-size: 13px;
  padding: 0 2px; border-radius: 999px; }
.hac-voz-x:hover { color: #fff; background: rgba(255, 255, 255, .14); }
.hac-voz-fila { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hac-voz-punto { flex: 0 0 auto; width: 11px; height: 11px; border-radius: 999px;
  background: #ef4444; animation: hac-latido 1s infinite; }
@keyframes hac-latido { 50% { opacity: .25; transform: scale(.85); } }
.hac-voz-reloj { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 15px;
  color: #f1f5f9; }
.hac-voz-onda { flex: 1 1 auto; height: 34px; min-width: 120px; border-radius: 9px;
  background: #0b1220; border: 1px solid #1e293b; }
.hac-voz-onda.silencioso { border-color: #b45309; }
.hac-voz-pausa { background: rgba(245, 158, 11, .08); border: 1px solid rgba(245, 158, 11, .32);
  border-radius: 12px; padding: 7px 9px; }
.hac-voz-pausa-ic { font-size: 15px; }
.hac-voz-pausa-tx { font-size: 13px; color: #fcd34d; white-space: nowrap; }
.hac-voz-pausa-tx b { font-variant-numeric: tabular-nums; }
.hac-voz-last { display: inline-flex; align-items: center; gap: 5px; font-size: 12px;
  color: #cbd5e1; white-space: nowrap; }
.hac-voz-seg { background: #0f172a; color: #e2e8f0; border: 1px solid #334155;
  border-radius: 8px; padding: 3px 6px; font-size: 12px; }
.hac-voz-estado { font-size: 13px; color: #94a3b8; display: flex; align-items: center;
  gap: 8px; padding-bottom: 8px; }
.hac-voz-estado.err { color: #fca5a5; }
.hac-voz-estado.ok { color: #6ee7b7; }
.hac-voz-barra { position: relative; overflow: hidden; height: 3px; border-radius: 999px;
  background: #1e293b; margin-top: 2px; flex: 1 1 80px; }
.hac-voz-barra::after { content: ""; position: absolute; inset: 0; width: 40%;
  background: linear-gradient(90deg, transparent, #22d3ee, transparent);
  animation: hac-voz-barra 1.2s linear infinite; }
@keyframes hac-voz-barra { from { transform: translateX(-40%); } to { transform: translateX(250%); } }
.hac-voz-btn { font-size: 17px; line-height: 1; padding: 8px 11px; }
.hac-voz-btn.grabando { background: rgba(239, 68, 68, .22); border-color: #ef4444;
  color: #fecaca; }
/* Pegar un audio copiado: botón junto al micro (vía rápida en iPhone). */
.hac-voz-paste { display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 9px; color: #a5f3fc; }
.hac-voz-paste svg { display: block; }
.hac-voz-paste:hover { border-color: #22d3ee; background: rgba(14, 116, 144, .22); }
.hac-voz-pegar-box { max-width: 560px; width: 100%; }
.hac-voz-pegar { display: flex; flex-direction: column; gap: 12px; padding: 4px 2px 12px; }
.hac-voz-hint { margin: 0; font-size: 16px; color: #cbd5e1; line-height: 1.55; }
.hac-voz-hint b { color: #f1f5f9; }
.hac-voz-hint-sm { font-size: 16px; color: #94a3b8; }
.hac-voz-drop { min-height: 118px; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 16px; border: 2px dashed #334155; border-radius: 14px;
  background: #0b1220; color: #94a3b8; font-size: 16px; outline: none;
  user-select: text; -webkit-user-select: text; }
.hac-voz-drop:focus { border-color: #22d3ee; box-shadow: 0 0 0 3px rgba(34, 211, 238, .18); }
.hac-voz-drop.is-over { border-color: #22d3ee; background: rgba(14, 116, 144, .18); }
.hac-voz-drop:empty::before { content: attr(data-ph); pointer-events: none; }
.hac-voz-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hac-voz-file { position: fixed; left: -10000px; width: 1px; height: 1px; opacity: 0; }
.hac-voz-err { margin: 0; font-size: 16px; color: #fca5a5; }
.hac-voz-err:empty { display: none; }
.hac-voz-pegar-foot { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
@media (max-width: 640px) {
  .hac-voz-pegar-box { max-height: 92vh; }
  .hac-voz-drop { min-height: 140px; }
}
/* Chip del turno dictado (burbuja del chat), en las dos vistas. */
.pe-msg .pe-msg-voz, .pe-msg .pl-msg-voz { display: inline-flex; align-items: center; gap: 5px;
  margin-left: 6px; font-size: 11px; font-weight: 800; color: #a5f3fc;
  background: rgba(14, 116, 144, .28); border: 1px solid rgba(34, 211, 238, .45);
  border-radius: 999px; padding: 1px 8px; }

/* Nota de voz RETENIDA: la grabación no se pierde si falla la subida. */
.hac-voz-fallo { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; border-radius: 12px;
  background: rgba(239, 68, 68, .10); border: 1px solid rgba(248, 113, 113, .45); }
.hac-voz-fallo.hidden { display: none !important; }
.hac-voz-fallo-tx { flex: 1 1 220px; min-width: 0; font-size: 13px; color: #fecaca; }
