/* Neurofic — panel interno. Sistema de diseño propio (reemplaza Pico.css).
   Paleta y tipografia comparten familia con la bitacora tecnica del
   proyecto (IBM Plex + teal/ambar) para que las herramientas internas se
   sientan de un mismo set. Referencias de patron: Linear (listas/pildoras
   de estado), Stripe Dashboard (tablas densas y calmadas), Vercel
   (nav minimo, tokens claro/oscuro), Attio (linea de tiempo de
   conversacion en vez de burbujas de chat), Notion (un solo acento, con
   disciplina). */

:root {
  /* Fase 3 (ajuste 2026-09-17): grises neutros de verdad -- la version
     anterior tenia un sesgo verdoso (mezclaba el gris con el teal) que el
     usuario pidio quitar. El acento (teal) sigue siendo teal, pero el
     fondo/texto/bordes ahora son gris puro. */
  --paper: #F5F5F6;
  --surface: #FFFFFF;
  --surface-2: #ECECEF;
  --ink: #1B1B1F;
  --ink-soft: #55555C;
  --ink-faint: #8B8B93;
  --line: #E2E2E6;
  --line-strong: #D0D0D6;

  /* Acento (2026-09-22, revertido a pedido del usuario): de vuelta a un
     azul-verde clinico con presencia real -- la version gris de la Fase 3
     se sentia fria/sin marca para una clinica de salud. Sigue llamandose
     --teal en el codigo (no se renombra para no tocar cada .css/.ejs que
     lo usa), y ahora si es un teal de verdad. */
  --teal: #0E7C86;
  --teal-strong: #085158;
  --teal-soft: #DFF3F4;
  --amber: #A9691C;
  --amber-soft: #F3E1C4;
  --green: #1F7A4D;
  --green-soft: #DCEFE2;
  --red: #C03A2B;
  --red-soft: #FBE2DE;
  --neutral: #68686F;
  --neutral-soft: #E9E9EC;

  /* Fase 4 (2026-09-22, "mas delicado, mas estilizado" -- referencia: Boluda):
     sombras casi imperceptibles, el borde fino hace el trabajo de separar
     tarjetas, no la sombra. */
  --shadow: 0 1px 2px rgba(20, 20, 25, .03);
  --shadow-hover: 0 2px 8px rgba(20, 20, 25, .06);
  --radius: 10px;
  --radius-sm: 7px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121214;
    --surface: #1B1B1E;
    --surface-2: #232326;
    --ink: #ECECEE;
    --ink-soft: #ABABB3;
    --ink-faint: #7B7B83;
    --line: #2B2B2F;
    --line-strong: #38383D;

    --teal: #4FC3CC;
    --teal-strong: #8CDEE4;
    --teal-soft: #10373A;
    --amber: #E3A85E;
    --amber-soft: #3A2C14;
    --green: #6FCB9A;
    --green-soft: #163325;
    --red: #E28277;
    --red-soft: #3B211D;
    --neutral: #9C9CA4;
    --neutral-soft: #232327;

    --shadow: 0 1px 2px rgba(0, 0, 0, .2);
    --shadow-hover: 0 2px 8px rgba(0, 0, 0, .3);
  }
}

/* Tema explicito (Fase 3 -- switch en el sidebar, guardado en localStorage).
   Repite el mismo bloque oscuro para cuando el usuario elige "oscuro" a mano
   sin importar el sistema operativo, y fuerza claro cuando elige "claro"
   aunque el sistema este en oscuro. */
:root[data-theme="dark"] {
  --paper: #121214;
  --surface: #1B1B1E;
  --surface-2: #232326;
  --ink: #ECECEE;
  --ink-soft: #ABABB3;
  --ink-faint: #7B7B83;
  --line: #2B2B2F;
  --line-strong: #38383D;

  --teal: #4FC3CC;
  --teal-strong: #8CDEE4;
  --teal-soft: #10373A;
  --amber: #E3A85E;
  --amber-soft: #3A2C14;
  --green: #6FCB9A;
  --green-soft: #163325;
  --red: #E28277;
  --red-soft: #3B211D;
  --neutral: #9C9CA4;
  --neutral-soft: #232327;

  --shadow: 0 1px 2px rgba(0, 0, 0, .2);
  --shadow-hover: 0 2px 8px rgba(0, 0, 0, .3);
}

:root[data-theme="light"] {
  --paper: #F5F5F6;
  --surface: #FFFFFF;
  --surface-2: #ECECEF;
  --ink: #1B1B1F;
  --ink-soft: #55555C;
  --ink-faint: #8B8B93;
  --line: #E2E2E6;
  --line-strong: #D0D0D6;

  --teal: #0E7C86;
  --teal-strong: #085158;
  --teal-soft: #DFF3F4;
  --amber: #A9691C;
  --amber-soft: #F3E1C4;
  --green: #1F7A4D;
  --green-soft: #DCEFE2;
  --red: #C03A2B;
  --red-soft: #FBE2DE;
  --neutral: #68686F;
  --neutral-soft: #E9E9EC;

  --shadow: 0 1px 2px rgba(20, 20, 25, .03);
  --shadow-hover: 0 2px 8px rgba(20, 20, 25, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}
/* Fase 4: tinte casi invisible -- la referencia (Boluda) es blanco puro con
   apenas un dejo de color, no un lavado de fondo notorio. */
body.con-sidebar {
  background-image: radial-gradient(ellipse 1000px 500px at 10% -15%, var(--teal-soft) 0%, transparent 45%);
  background-repeat: no-repeat;
}
@media (prefers-color-scheme: dark) { body.con-sidebar { background-image: none; } }
:root[data-theme="dark"] body.con-sidebar { background-image: none; }

body {
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono, code, table.datos td.mono, input, textarea, select {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

h1, h2, h3, h4 { font-weight: 600; text-wrap: balance; margin: 0 0 .3rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); }
p { margin: .3rem 0; }
small { color: var(--ink-soft); font-size: .82rem; }
a { color: var(--teal-strong); }

/* ---------- layout: sidebar izquierdo (referencia Kommo) ---------- */
/* Fase 3: se quito el max-width fijo (causaba el "cuadro recortado" en
   medio de la pantalla que reporto el usuario) -- el contenido ahora usa
   todo el ancho disponible, con gutter lateral fijo. Tablas y kanban ya
   traen su propio overflow-x, asi que no se rompen. */
.container {
  width: 100%;
  padding-inline: 20px;
}

body.con-sidebar { display: flex; align-items: stretch; min-height: 100vh; }

.sidebar {
  width: 76px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-block: 1rem;
  gap: .3rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--teal); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .95rem;
  margin-bottom: .8rem; flex: none;
}
.sidebar nav { display: flex; flex-direction: column; gap: .3rem; flex: 1; width: 100%; align-items: center; }
.sidebar nav a, .sidebar .salir {
  display: flex; flex-direction: column; align-items: center; gap: .2rem;
  text-decoration: none; color: var(--ink-faint);
  font-size: .6rem; font-weight: 600; text-align: center;
  padding: .5rem .2rem;
  border-radius: var(--radius-sm);
  width: 62px;
}
.sidebar nav a:hover, .sidebar .salir:hover { color: var(--ink); }
/* Fase 4: activo = solo cambio de color, sin bloque solido de fondo
   (referencia Boluda: el estado activo apenas se nota, nada de relleno). */
.sidebar nav a.activo { color: var(--teal-strong); font-weight: 700; }

.tema-toggle {
  display: flex; flex-direction: column; align-items: center; gap: .2rem;
  font-family: inherit; font-size: .6rem; font-weight: 600; text-align: center;
  padding: .5rem .2rem; width: 62px;
  border: none; border-radius: var(--radius-sm);
  background: none; color: var(--ink-faint); cursor: pointer;
}
.tema-toggle:hover { background: var(--surface-2); color: var(--ink); }
.sidebar .icon-wrap { position: relative; display: inline-flex; }
.sidebar .badge {
  position: absolute; top: -6px; right: -10px;
  background: var(--red); color: #fff;
  font-size: .6rem; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 100px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px; line-height: 1;
}

main.container { padding-block: 1.4rem 3rem; flex: 1; min-width: 0; }

.page-head { margin-bottom: 1.1rem; }
.page-head p { color: var(--ink-soft); font-size: .88rem; max-width: 60ch; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem;
  transition: box-shadow .15s ease;
}
.card h4 { margin-bottom: .5rem; }
/* dentro del panel de conversacion (Fase 3): tarjetas de datos bien
   ajustadas, pidio expresamente no gastar espacio de mas */
.split-izq .card { padding: .65rem .75rem; }
.split-izq .card p { margin: .18rem 0; font-size: .84rem; line-height: 1.35; }

/* ---------- avatar (iniciales + color determinista) ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
  width: 32px; height: 32px; border-radius: 50%;
  color: #fff; font-size: .74rem; font-weight: 700;
}
.avatar.sm { width: 24px; height: 24px; font-size: .62rem; }
.avatar.lg { width: 46px; height: 46px; font-size: .98rem; }

/* ---------- pills (estado) ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .01em;
  padding: .15rem .55rem;
  border-radius: 100px;
  white-space: nowrap;
}
.pill-neutral { background: var(--neutral-soft); color: var(--neutral); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }
.pill-teal { background: var(--teal-soft); color: var(--teal-strong); }
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-red { background: var(--red-soft); color: var(--red); }

/* ---------- buttons / forms ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  padding: .45rem .9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--teal); color: var(--teal-strong); }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-strong); border-color: var(--teal-strong); color: #fff; }

input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  font-size: .88rem;
  padding: .5rem .6rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
label { display: block; font-size: .82rem; color: var(--ink-soft); margin-bottom: .8rem; }
label > span, label > b { display: block; margin-bottom: .25rem; color: var(--ink); font-weight: 600; }

/* ---------- tables ---------- */
table.datos { width: 100%; border-collapse: collapse; font-size: .87rem; }
table.datos th {
  text-align: left;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-faint);
  font-weight: 600;
  padding: .5rem .6rem;
  border-bottom: 1px solid var(--line-strong);
}
table.datos td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.datos tr:last-child td { border-bottom: none; }
table.datos tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.table-wrap table.datos { margin: 0; }

/* ---------- barra de etapas (Fase 3: crear/borrar arriba del embudo) ---------- */
.etapas-barra {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
  margin-bottom: .9rem; padding-bottom: .9rem; border-bottom: 1px solid var(--line);
}
.etapa-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .72rem; font-weight: 600; color: var(--teal-strong);
  background: var(--teal-soft); border: 1px solid var(--teal-soft);
  border-radius: 100px; padding: .25rem .35rem .25rem .65rem;
  cursor: pointer; user-select: none;
}
.etapa-chip.base { color: var(--ink-soft); background: var(--surface-2); border-color: var(--line); }
/* click para ocultar/mostrar la columna -- pedido del usuario: "quitar esas
   etapas que no me sirven ahora" pero poder activarlas de nuevo aqui mismo */
.etapa-chip.inactiva { color: var(--ink-faint); background: transparent; border-color: var(--line); opacity: .6; }
.etapa-chip:hover { border-color: var(--line-strong); }
.etapa-chip button {
  border: none; background: none; cursor: pointer; color: var(--ink-faint);
  font-size: .85rem; line-height: 1; padding: .1rem .3rem; border-radius: 50%;
}
.etapa-chip button:hover { background: var(--red-soft); color: var(--red); }
.etapa-chip button.btn-editar-etapa:hover { background: var(--teal-soft); color: var(--teal-strong); }

.columna.oculta { display: none; }
.etapa-nueva {
  display: inline-flex; align-items: center; gap: .3rem;
}
.etapa-nueva input {
  width: 150px; font-size: .78rem; padding: .3rem .5rem;
}
.etapa-nueva button {
  font-size: .78rem; padding: .32rem .6rem;
}

/* ---------- controles del embudo: buscar / filtrar mes / exportar ---------- */
.embudo-controles { display: flex; gap: .5rem; align-items: center; margin-bottom: .9rem; flex-wrap: wrap; }
.buscador-input { max-width: 280px; }
.embudo-controles select { width: auto; min-width: 150px; }

/* ---------- kanban (embudo) ---------- */
.kanban { display: flex; gap: .7rem; overflow-x: auto; padding-bottom: .5rem; align-items: flex-start; }
.columna { min-width: 190px; max-width: 190px; flex: none; }
.columna-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 .2rem .5rem;
}
.columna-head h4 { margin: 0; display: flex; align-items: center; gap: .4rem; }
.orden-num {
  display: inline-flex; align-items: center; justify-content: center;
  flex: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--teal-soft); color: var(--teal-strong);
  font-size: .62rem; font-weight: 700; font-family: "IBM Plex Mono", monospace;
}
.columna-head .n { font-family: "IBM Plex Mono"; font-size: .75rem; color: var(--ink-faint); }
.tarjetas { display: flex; flex-direction: column; gap: .45rem; min-height: 12px; }
.tarjeta {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .65rem .75rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-decoration: none;
  display: block;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.tarjeta:hover { box-shadow: var(--shadow-hover); border-color: var(--line-strong); }
/* Fase 4: aviso de vencimiento MUY visible -- franja de color arriba de toda
   la tarjeta, ademas de la pildora (pedido del usuario: la pildora sola
   pasaba desapercibida). */
.tarjeta.venc-por-vencer { box-shadow: inset 0 3px 0 var(--amber), var(--shadow); }
.tarjeta.venc-vencida { box-shadow: inset 0 3px 0 var(--red), var(--shadow); }
.tarjeta.venc-por-vencer:hover { box-shadow: inset 0 3px 0 var(--amber), var(--shadow-hover); }
.tarjeta.venc-vencida:hover { box-shadow: inset 0 3px 0 var(--red), var(--shadow-hover); }
.tarjeta.oculta-busqueda { display: none; }
/* tinte segun modo de conversacion (Fase 3: reemplaza el punto suelto de la
   Fase 2 por un tinte de fondo mas visible en toda la tarjeta) */
.tarjeta.modo-automatico { background: var(--teal-soft); border-color: var(--teal); }
.tarjeta.modo-control_humano { background: var(--red-soft); border-color: var(--red); }
.tarjeta.arrastrando { opacity: .4; }
.tarjeta-fantasma { opacity: .5; }
.tarjeta .cabeza { display: flex; align-items: center; gap: .5rem; }
.tarjeta .info { min-width: 0; flex: 1; }
.tarjeta .nombre { color: var(--ink); font-weight: 600; font-size: .82rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tarjeta .doc, .tarjeta .servicio { display: block; font-size: .7rem; color: var(--ink-soft); margin-top: .1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tarjeta .doc { font-family: "IBM Plex Mono"; }
.tarjeta .badges { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }
.tarjeta .etapa-actual { margin-top: .4rem; font-size: .66rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .04em; }

/* burbuja de notificacion (mensajes sin responder) sobre el avatar */
.avatar-wrap { position: relative; display: inline-flex; flex: none; }
.burbuja-no-leidos {
  position: absolute; top: -5px; right: -6px;
  background: var(--red); color: #fff;
  font-size: .58rem; font-weight: 700;
  min-width: 15px; height: 15px; border-radius: 100px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
}

/* ---------- field grid (ficha de paciente) ---------- */
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .5rem 1rem;
}
.field-grid .f-label { font-size: .64rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); }
.field-grid .f-value { font-size: .86rem; margin-top: .05rem; }

/* version compacta de una sola columna, para el panel de conversacion
   (Fase 3): mismo componente, menos aire entre filas */
.split-izq .field-grid { grid-template-columns: 1fr 1fr; gap: .4rem .6rem; }

/* ---------- chat estilo WhatsApp (Fase 3, reemplaza la linea de tiempo tipo
   Attio de la Fase 2 -- pedido explicito del usuario) ---------- */
.chat {
  display: flex; flex-direction: column; gap: .35rem;
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 1rem; background: var(--paper);
}
.burbuja { display: flex; max-width: 72%; }
.burbuja.in { align-self: flex-start; }
.burbuja.out { align-self: flex-end; }
.burbuja .globo {
  border-radius: var(--radius); padding: .5rem .7rem .45rem;
  box-shadow: var(--shadow);
}
.burbuja.in .globo { background: var(--surface); border: 1px solid var(--line); border-top-left-radius: 2px; }
.burbuja.out .globo { background: var(--teal); color: #fff; border-top-right-radius: 2px; }
.burbuja .texto { font-size: .9rem; white-space: pre-wrap; word-wrap: break-word; }
.burbuja .meta { font-size: .66rem; margin-top: .25rem; text-align: right; opacity: .7; display: flex; align-items: center; justify-content: flex-end; gap: .35rem; }
.btn-corregir {
  border: none; background: none; cursor: pointer; padding: 0;
  font-size: .66rem; font-weight: 600; text-decoration: underline;
  color: inherit; opacity: .85;
}
.btn-corregir:hover { opacity: 1; }
.burbuja.in .meta { color: var(--ink-faint); }
.burbuja.out .meta { color: rgba(255,255,255,.8); }

/* checks de enviado/entregado/leido -- el azul de "leido" es intencional
   (misma convencion que WhatsApp, la gente ya la reconoce de memoria) */
.check { flex: none; vertical-align: middle; }
.check.leido { color: #34B7F1; }
.check-fallido {
  color: var(--red); font-style: normal; font-weight: 700;
  width: 12px; height: 12px; border-radius: 50%; background: rgba(255,255,255,.25);
  display: inline-flex; align-items: center; justify-content: center; font-size: .6rem;
}

/* ---------- fotos y documentos enviados por el paciente (Fase 3) ---------- */
.burbuja .globo.con-media { padding: .3rem .3rem .35rem; }
.burbuja-img-btn { display: block; border: none; padding: 0; margin: 0; background: none; cursor: zoom-in; width: 100%; }
.burbuja-img { display: block; max-width: 220px; max-height: 260px; width: 100%; height: auto; object-fit: cover; border-radius: calc(var(--radius) - 4px); }
.burbuja .globo.con-media .texto { padding: .35rem .3rem 0; }

.burbuja-archivo {
  display: flex; align-items: center; gap: .55rem;
  padding: .5rem .6rem; border-radius: var(--radius-sm);
  background: var(--surface-2); text-decoration: none;
  min-width: 180px;
}
.burbuja.out .burbuja-archivo { background: rgba(255,255,255,.14); }
.burbuja-archivo .ext {
  flex: none; width: 34px; height: 34px; border-radius: 7px;
  background: var(--teal); color: #fff; font-size: .62rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.burbuja-archivo .nombre-archivo {
  font-size: .82rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 160px;
}
.burbuja.out .burbuja-archivo .nombre-archivo { color: #fff; }

.lightbox {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 10, 12, .85);
  align-items: center; justify-content: center; padding: 2rem;
}
.lightbox.abierto { display: flex; }
.lightbox-caja { max-width: min(90vw, 720px); display: flex; flex-direction: column; gap: .8rem; align-items: center; }
.lightbox-caja img { max-width: 100%; max-height: 75vh; border-radius: var(--radius); }
.lightbox-acciones { display: flex; gap: .6rem; }

/* ---------- vista de conversacion: paciente izquierda, chat derecha
   (Fase 3, referencia Kommo) ----------
   El "boton Enviar cortado" que reporto el usuario era porque .split usaba
   una altura fija calculada a ojo (100vh - 2.4rem) que no coincidia con el
   espacio real disponible. Ahora la pagina de conversacion (unica que lo
   necesita -- ver body.pagina-fija en base.html) fija toda la cadena
   body -> main.container -> .split a la altura real de la pantalla, y
   .split se reparte ese espacio con flex en vez de un numero adivinado. */
/* El "scroll a la mitad de la pantalla" que reporto el usuario era porque
   solo el <body> quedaba con overflow:hidden -- el <html> seguia pudiendo
   scrollear un poco (un par de px de diferencia bastan), asi que la rueda
   del mouse sobre el chat a veces movia la PAGINA en vez del chat. Ahora se
   bloquean los dos. */
html.pagina-fija, body.pagina-fija { height: 100%; overflow: hidden; }
body.pagina-fija main.container { height: 100%; display: flex; flex-direction: column; overflow: hidden; padding-block: 1rem 1rem; }
body.pagina-fija .volver-arriba { flex: none; margin-bottom: .6rem; }

.split { display: flex; gap: 1.2rem; align-items: stretch; flex: 1; min-height: 0; }
.split-izq {
  width: 300px; flex: none; overflow-y: auto; height: 100%;
  display: flex; flex-direction: column; gap: .55rem; padding-right: .2rem;
}
.split-der {
  flex: 1; min-width: 0; height: 100%;
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
}
.split-der .chat-header {
  padding: .8rem 1rem; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap;
}
.split-der .chat-footer { padding: .7rem 1rem; border-top: 1px solid var(--line); }
.ventana-estado { font-size: .78rem; display: flex; align-items: center; gap: .4rem; }
.ventana-estado.abierta { color: var(--teal-strong); }
.ventana-estado.cerrada { color: var(--red); }

/* ---------- aviso de mensaje nuevo (sonido + burbuja) ---------- */
.avisos {
  position: fixed; top: 1rem; right: 1rem; z-index: 200;
  display: flex; flex-direction: column; gap: .5rem; align-items: flex-end;
  pointer-events: none;
}
.aviso-burbuja {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  border-left: 3px solid var(--teal-strong);
  border-radius: var(--radius-sm);
  padding: .65rem .9rem; font-size: .85rem; font-weight: 600;
  text-decoration: none; max-width: 300px;
  animation: aviso-entra .25s ease-out;
}
.aviso-burbuja.saliendo { animation: aviso-sale .3s ease-in forwards; }
@keyframes aviso-entra { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes aviso-sale { from { opacity: 1; } to { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 640px) {
  .avisos { top: auto; bottom: 4.5rem; left: 1rem; right: 1rem; align-items: stretch; }
  .aviso-burbuja { max-width: none; }
}

/* ---------- selector de emojis (Fase 5, 2026-09-17) ---------- */
.campo-mensaje-wrap { position: relative; }
.campo-mensaje-wrap textarea { padding-right: 2.4rem; }
.btn-emoji {
  position: absolute; top: .4rem; right: .4rem;
  border: none; background: none; cursor: pointer;
  font-size: 1.1rem; line-height: 1; padding: .2rem; border-radius: 50%;
}
.btn-emoji:hover { background: var(--surface-2); }
.panel-emojis {
  display: none; position: absolute; bottom: calc(100% + .4rem); right: 0;
  z-index: 30; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .5rem; grid-template-columns: repeat(4, 1fr); gap: .1rem;
  width: 168px;
}
.panel-emojis.abierto { display: grid; }
.panel-emojis button {
  border: none; background: none; cursor: pointer;
  font-size: 1.25rem; padding: .35rem; border-radius: var(--radius-sm); line-height: 1;
}
.panel-emojis button:hover { background: var(--surface-2); }

/* ---------- callouts ---------- */
.callout { border-left: 3px solid var(--red); background: var(--red-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: .7rem .9rem; font-size: .88rem; }
.callout b { color: var(--red); }

/* ---------- login ---------- */
body:has(.login-wrap) {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image:
    radial-gradient(ellipse 900px 500px at 20% 10%, var(--teal-soft) 0%, transparent 55%),
    radial-gradient(ellipse 700px 500px at 85% 90%, var(--teal-soft) 0%, transparent 55%);
  background-repeat: no-repeat;
}
body:has(.login-wrap) main.container { display: flex; align-items: center; justify-content: center; }
.login-wrap {
  max-width: 340px;
  margin: 0;
  position: relative;
  padding-top: 1.1rem;
  overflow: hidden;
}
.login-wrap::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--teal) 0%, var(--teal-strong) 100%);
}
.login-wrap h2 { display: flex; align-items: center; gap: .55rem; margin-bottom: 1rem; }
.login-wrap h2::before {
  content: "N";
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: var(--teal); color: #fff; font-size: .85rem; font-weight: 700;
}

/* ---------- responsive stacking table -> cards ---------- */
@media (max-width: 640px) {
  .container { padding-inline: 16px; }
  .kanban { gap: .6rem; }
  .columna { min-width: 210px; max-width: 210px; }

  html.pagina-fija, body.pagina-fija { height: auto; overflow: visible; }
  body.pagina-fija main.container { height: auto; overflow: visible; padding-block: 1rem 4.5rem; }
  .split { flex-direction: column; height: auto; }
  .split-izq { width: 100%; height: auto; }
  .split-der { height: 70vh; }
  .burbuja { max-width: 88%; }

  body.con-sidebar { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: fixed; left: 0; right: 0; top: auto; bottom: 0;
    flex-direction: row; justify-content: space-around; align-items: center;
    border-right: none; border-top: 1px solid var(--line);
    padding: .3rem .5rem calc(.3rem + env(safe-area-inset-bottom, 0px));
    z-index: 20;
  }
  .sidebar-brand { display: none; }
  .sidebar nav { flex-direction: row; width: auto; flex: none; gap: .1rem; }
  main.container { padding-bottom: 4.5rem; }

  table.stack-mobile thead { display: none; }
  table.stack-mobile, table.stack-mobile tbody, table.stack-mobile tr, table.stack-mobile td { display: block; width: 100%; }
  table.stack-mobile tr { border-bottom: 1px solid var(--line-strong); padding: .6rem 0; }
  table.stack-mobile tr:last-child { border-bottom: none; }
  table.stack-mobile td { padding: .15rem 0; border-bottom: none; }
  table.stack-mobile td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint);
  }
}
