:root {
  --fondo: #f6f5f1; --panel: #ffffff; --panel-2: #efede7; --borde: #dedad0; --borde-fuerte: #c4bfb2;
  --texto: #1f2421; --tenue: #636b65; --muy-tenue: #8b918b;
  --acento: #0f6b5c; --acento-fuerte: #0a4f44; --acento-suave: #dcefe9; --sobre-acento: #ffffff;
  --ok: #1d7a46; --ok-suave: #dff1e6; --aviso: #96600a; --aviso-suave: #fbefd3;
  --mal: #b3312c; --mal-suave: #fbe3e0; --info: #2c5fa8; --info-suave: #e2ecfa;
  --radio: 8px; --sombra: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .05);
  --mono: ui-monospace, "SF Mono", "JetOraculos Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #121614; --panel: #1a201d; --panel-2: #222a26; --borde: #2c3530; --borde-fuerte: #404b45;
    --texto: #e6eae6; --tenue: #a3ada6; --muy-tenue: #7b857e;
    --acento: #4fbfa8; --acento-fuerte: #7bd6c2; --acento-suave: #17362f; --sobre-acento: #06231d;
    --ok: #5cc98a; --ok-suave: #16301f; --aviso: #e0aa4a; --aviso-suave: #36290f;
    --mal: #f08079; --mal-suave: #3a1b19; --info: #7fb0f0; --info-suave: #172740;
    --sombra: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; background: var(--fondo); color: var(--texto); line-height: 1.5;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh;
}
a { color: var(--acento); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; letter-spacing: -.01em; text-wrap: balance; }
h2 { font-size: 1.05rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: .95rem; margin: 1.1rem 0 .4rem; }
p { margin: .5rem 0; }
code, pre, .mono { font-family: var(--mono); font-size: .88em; }
code { background: var(--panel-2); padding: .08em .35em; border-radius: 4px; }
pre { background: var(--panel-2); padding: .8rem 1rem; border-radius: var(--radio); overflow-x: auto;
      white-space: pre-wrap; word-break: break-word; margin: .6rem 0; }
pre code { background: none; padding: 0; }
.tenue { color: var(--tenue); } .peq { font-size: .87rem; }
.entrada { color: var(--tenue); margin: 0 0 1.2rem; max-width: 70ch; }

/* --- navegación ------------------------------------------------------------ */
.nav { background: var(--panel); border-right: 1px solid var(--borde); padding: 1rem .7rem;
       position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: .15rem; }
.marca { font-weight: 700; font-size: 1.05rem; padding: .2rem .6rem 1rem; display: flex;
         align-items: center; gap: .5rem; color: var(--texto); }
.marca i { width: 22px; height: 22px; border-radius: 6px; background: var(--acento); display: grid;
           place-items: center; color: var(--sobre-acento); font-style: normal; font-size: .8rem; }
.nav a.item { display: flex; align-items: center; justify-content: space-between; padding: .42rem .6rem;
              border-radius: 6px; color: var(--texto); }
.nav a.item:hover { background: var(--panel-2); text-decoration: none; }
.nav a.item.activo { background: var(--acento-suave); color: var(--acento-fuerte); font-weight: 600; }
.nav .grupo { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muy-tenue);
              padding: .9rem .6rem .25rem; }
.nav .pie { margin-top: auto; border-top: 1px solid var(--borde); padding-top: .7rem; font-size: .85rem; }
.nav .pie .quien { padding: 0 .6rem .4rem; }
.nav .pie form { margin: 0; }
.contador { background: var(--acento); color: var(--sobre-acento); border-radius: 99px; font-size: .72rem;
            padding: 0 .45rem; font-weight: 600; }
main { padding: 1.6rem 2rem 4rem; min-width: 0; }
main.ancho { max-width: 1180px; }
main.estrecho { max-width: 860px; }

/* --- piezas ---------------------------------------------------------------- */
.tarjeta { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio);
           padding: 1rem 1.15rem; margin-bottom: .8rem; }
.tarjeta > :first-child { margin-top: 0; } .tarjeta > :last-child { margin-bottom: 0; }
.fila { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.fila.entre { justify-content: space-between; }
.rejilla { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.dato { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: .7rem .9rem; }
.dato b { display: block; font-size: 1.5rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.dato span { color: var(--tenue); font-size: .85rem; }

.sello { display: inline-block; font-size: .74rem; font-weight: 600; padding: .08rem .5rem; border-radius: 99px;
         border: 1px solid transparent; white-space: nowrap; vertical-align: middle; }
.sello.verificado, .sello.vigente, .sello.aceptada, .sello.resuelta, .sello.validado { background: var(--ok-suave); color: var(--ok); }
.sello.probable, .sello.propuesta, .sello.nueva, .sello.necesita_info, .sello.corregido, .sello.en_curso { background: var(--aviso-suave); color: var(--aviso); }
.sello.en_duda, .sello.contradicho, .sello.objetada, .sello.rechazado, .sello.revocada, .sello.p0 { background: var(--mal-suave); color: var(--mal); }
.sello.caducado, .sello.caducada, .sello.reemplazada, .sello.duplicada, .sello.descartada, .sello.neutro { background: var(--panel-2); color: var(--tenue); }
.sello.info, .sello.p1 { background: var(--info-suave); color: var(--info); }
.sello.nivel { border-color: var(--borde-fuerte); color: var(--tenue); background: transparent; }
.clave { font-family: var(--mono); font-size: .84rem; font-weight: 600; white-space: nowrap; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--borde);
        border-radius: var(--radio); overflow: hidden; }
th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--tenue);
     font-weight: 600; padding: .55rem .8rem; border-bottom: 1px solid var(--borde); background: var(--panel-2); }
td { padding: .55rem .8rem; border-bottom: 1px solid var(--borde); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tabla-envoltura { overflow-x: auto; }

input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; background: var(--panel); border: 1px solid var(--borde-fuerte); border-radius: 6px;
  padding: .45rem .6rem; }
textarea { min-height: 5.5rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--acento); outline-offset: 1px; border-color: transparent; }
label { display: block; font-size: .85rem; font-weight: 600; margin: .8rem 0 .25rem; }
label small { font-weight: 400; color: var(--tenue); }
.boton { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--borde-fuerte);
         background: var(--panel); border-radius: 6px; padding: .4rem .85rem; cursor: pointer; font-weight: 500;
         color: var(--texto); }
.boton:hover { background: var(--panel-2); text-decoration: none; }
.boton.primario { background: var(--acento); border-color: var(--acento); color: var(--sobre-acento); font-weight: 600; }
.boton.primario:hover { background: var(--acento-fuerte); }
.boton.peligro { color: var(--mal); border-color: var(--mal); }
.boton.mini { padding: .18rem .55rem; font-size: .84rem; }
.boton:disabled { opacity: .5; cursor: default; }
.filtros { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.filtros > *, .filtros input, .filtros select { flex: 0 1 auto; width: auto; }
.filtros input[type=search] { min-width: 280px; flex: 0 1 360px; }
.pestanas { display: flex; gap: .25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--borde); flex-wrap: wrap; }
.pestanas a { padding: .45rem .8rem; color: var(--tenue); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.pestanas a.activa { color: var(--acento-fuerte); border-color: var(--acento); font-weight: 600; }
.pestanas a:hover { text-decoration: none; color: var(--texto); }

.aviso { padding: .6rem .9rem; border-radius: var(--radio); background: var(--info-suave); color: var(--info);
         margin-bottom: 1rem; }
.aviso.mal { background: var(--mal-suave); color: var(--mal); }
.aviso.alerta { background: var(--aviso-suave); color: var(--aviso); }
.vacio { text-align: center; color: var(--tenue); padding: 2.5rem 1rem; border: 1px dashed var(--borde-fuerte);
         border-radius: var(--radio); }
details > summary { cursor: pointer; color: var(--acento); font-weight: 500; }
details[open] > summary { margin-bottom: .5rem; }
dl.ficha { display: grid; grid-template-columns: 9.5rem 1fr; gap: .3rem 1rem; margin: 0; }
dl.ficha dt { color: var(--tenue); font-size: .87rem; }
dl.ficha dd { margin: 0; }

/* --- texto generado -------------------------------------------------------- */
.prosa { max-width: 78ch; overflow-wrap: anywhere; }
.prosa > :first-child { margin-top: 0; } .prosa > :last-child { margin-bottom: 0; }
.prosa ul, .prosa ol { padding-left: 1.3rem; margin: .5rem 0; }
.prosa li { margin: .2rem 0; }
.prosa table { margin: .7rem 0; font-size: .92rem; }
.prosa blockquote { margin: .6rem 0; padding: .1rem .9rem; border-left: 3px solid var(--borde-fuerte); color: var(--tenue); }
.prosa h1, .prosa h2, .prosa h3 { font-size: 1rem; margin: 1rem 0 .3rem; }
.cita { font-family: var(--mono); font-size: .76rem; font-weight: 600; padding: .02rem .35rem; border-radius: 4px;
        background: var(--acento-suave); color: var(--acento-fuerte); white-space: nowrap; }
.cita.nodo { background: var(--info-suave); color: var(--info); }
.cita.invalida { background: var(--mal-suave); color: var(--mal); text-decoration: line-through; cursor: help; }
.texto-fuente { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: .84rem;
                background: var(--panel-2); border-radius: var(--radio); padding: .8rem 1rem; max-height: 60vh; overflow: auto; }
.texto-fuente.lectura { font-family: inherit; font-size: .95rem; }

/* --- conversación ---------------------------------------------------------- */
body.charla main { padding: 0; display: grid; grid-template-columns: 230px minmax(0, 1fr); height: 100vh; }
.hilos { border-right: 1px solid var(--borde); padding: 1rem .6rem; overflow-y: auto; }
.hilos a { display: block; padding: .38rem .55rem; border-radius: 6px; color: var(--texto); font-size: .9rem;
           white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hilos a:hover { background: var(--panel-2); text-decoration: none; }
.hilos a.activo { background: var(--acento-suave); color: var(--acento-fuerte); }
.charla-cuerpo { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.turnos { flex: 1; overflow-y: auto; padding: 1.5rem 2rem 1rem; }
.turnos-interior { max-width: 820px; margin: 0 auto; }
.turno { margin-bottom: 1.4rem; }
.turno.yo .burbuja { background: var(--panel-2); border-radius: 12px; padding: .6rem .9rem; display: inline-block;
                     max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere; }
.turno.yo { text-align: right; } .turno.yo .burbuja { text-align: left; }
.turno .pie-turno { font-size: .8rem; color: var(--muy-tenue); margin-top: .5rem; display: flex; gap: .8rem; flex-wrap: wrap; }
.estado-agente { color: var(--tenue); font-size: .88rem; display: flex; align-items: center; gap: .5rem; min-height: 1.4rem; }
.estado-agente::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--acento);
                         animation: pulso 1.1s ease-in-out infinite; }
@keyframes pulso { 50% { opacity: .25; transform: scale(.7); } }
@media (prefers-reduced-motion: reduce) { .estado-agente::before { animation: none; } }
.redactor { border-top: 1px solid var(--borde); padding: .9rem 2rem 1.1rem; background: var(--fondo); }
.redactor form { max-width: 820px; margin: 0 auto; display: flex; gap: .6rem; align-items: flex-end; }
.redactor textarea { min-height: 2.7rem; max-height: 12rem; resize: none; border-radius: 10px; padding: .6rem .8rem; }
.bienvenida { max-width: 640px; margin: 12vh auto 0; text-align: center; }
.bienvenida .sugerencias { display: grid; gap: .5rem; margin-top: 1.4rem; text-align: left; }
.bienvenida button { text-align: left; background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio);
                     padding: .6rem .85rem; cursor: pointer; }
.bienvenida button:hover { border-color: var(--acento); }

/* --- panel de fuente ------------------------------------------------------- */
#panel { position: fixed; top: 0; right: 0; width: min(560px, 94vw); height: 100vh; background: var(--panel);
         border-left: 1px solid var(--borde); box-shadow: var(--sombra); transform: translateX(105%);
         transition: transform .18s ease; z-index: 20; display: flex; flex-direction: column; }
#panel.abierto { transform: none; }
#panel header { display: flex; justify-content: space-between; align-items: center; padding: .7rem 1rem;
                border-bottom: 1px solid var(--borde); }
#panel .contenido { padding: 1rem; overflow-y: auto; flex: 1; }
@media (prefers-reduced-motion: reduce) { #panel { transition: none; } }

/* --- hallazgos y peticiones ------------------------------------------------ */
.hallazgo { border-left: 4px solid var(--borde-fuerte); }
.hallazgo.i0 { border-left-color: var(--mal); } .hallazgo.i1 { border-left-color: var(--aviso); }
.hallazgo.i2 { border-left-color: var(--info); }
.hallazgo .acciones { display: grid; gap: .5rem; margin-top: .8rem; }
.mensaje { border: 1px solid var(--borde); border-radius: var(--radio); padding: .8rem 1rem; margin-bottom: .7rem; background: var(--panel); }
.mensaje.cerebro { border-color: var(--acento); }
.mensaje.interno { background: var(--aviso-suave); border-style: dashed; border-color: var(--aviso); }
.mensaje .autor { font-size: .82rem; color: var(--tenue); margin-bottom: .35rem; display: flex; gap: .6rem; flex-wrap: wrap; }

.entrar { grid-template-columns: 1fr; place-items: center; }
.entrar main { width: min(380px, 92vw); padding: 0; }

@media (max-width: 860px) {
  body { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: .5rem; }
  .nav .grupo, .nav .pie .quien { display: none; }
  .nav .pie { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; }
  .marca { padding: .2rem .5rem; }
  main { padding: 1rem 1rem 3rem; }
  body.charla main { grid-template-columns: 1fr; height: auto; }
  .hilos { display: none; }
  .charla-cuerpo { height: calc(100vh - 56px); }
  .turnos, .redactor { padding-left: 1rem; padding-right: 1rem; }
  dl.ficha { grid-template-columns: 1fr; }
}

/* Anotaciones: lo aprendido en la conversación */
.sello.alerta { background: var(--aviso-suave); color: var(--aviso); }
.tarjeta blockquote { margin: .6rem 0; padding: .1rem .9rem; border-left: 3px solid var(--borde-fuerte); color: var(--tenue); }
.anotacion { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .6rem;
  padding: .5rem .75rem; border: 1px dashed var(--borde-fuerte); border-radius: var(--radio); font-size: .88rem; }
.anotacion .texto { flex: 1; min-width: 200px; }
