/* ==================================================================
   Laboratorio Clínico Especializado Yamína Cumplido Romero
   Sistema de consentimientos informados
================================================================== */

:root {
  --azul:        #14479A;
  --azul-osc:    #0E3271;
  --azul-claro:  #1E9CD7;
  --cyan:        #48C4F0;
  --cyan-suave:  #E8F5FD;

  --texto:       #16233A;
  --texto-2:     #5B6B85;
  --borde:       #DCE5F0;
  --fondo:       #F4F8FC;
  --blanco:      #FFFFFF;

  --ok:          #16A34A;
  --alerta:      #DC2626;
  --amarillo:    #F59E0B;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;

  --sombra-1: 0 1px 2px rgba(20, 71, 154, .06), 0 2px 8px rgba(20, 71, 154, .06);
  --sombra-2: 0 4px 12px rgba(20, 71, 154, .10), 0 12px 32px rgba(20, 71, 154, .10);
  --sombra-3: 0 12px 28px rgba(20, 71, 154, .16), 0 28px 60px rgba(20, 71, 154, .18);

  --transicion: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  color: var(--texto);
  background: var(--fondo);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0 0 .8em; }

button { font-family: inherit; }

/* ------------------------------------------------------------------
   Fondo animado con ondas (identidad de marca)
------------------------------------------------------------------- */
.fondo-ondas {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}
.fondo-ondas svg { position: absolute; width: 160%; left: -30%; }
.fondo-ondas .onda-1 { bottom: -8%;  opacity: .55; animation: deriva 26s ease-in-out infinite; }
.fondo-ondas .onda-2 { bottom: -14%; opacity: .40; animation: deriva 34s ease-in-out infinite reverse; }
.fondo-ondas .onda-3 { top: -20%;    opacity: .30; animation: deriva 30s ease-in-out infinite; }

@keyframes deriva {
  0%, 100% { transform: translateX(0) translateY(0); }
  50%      { transform: translateX(-6%) translateY(-14px); }
}

/* Burbujas flotantes */
.burbuja {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(72,196,240,.35), rgba(30,156,215,.08));
  animation: flotar linear infinite;
}
@keyframes flotar {
  0%   { transform: translateY(0) scale(.6);   opacity: 0; }
  10%  { opacity: .7; }
  90%  { opacity: .5; }
  100% { transform: translateY(-120vh) scale(1.1); opacity: 0; }
}

/* ------------------------------------------------------------------
   Vistas
------------------------------------------------------------------- */
.vista { display: none; position: relative; z-index: 1; }
.vista.activa { display: block; animation: entradaVista .45s var(--transicion) both; }

@keyframes entradaVista {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ==================================================================
   1. LOGIN
================================================================== */
#vista-login.activa {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.tarjeta-login {
  width: 100%;
  max-width: 430px;
  background: var(--blanco);
  border-radius: var(--r-lg);
  box-shadow: var(--sombra-3);
  padding: 42px 38px 34px;
  position: relative;
  overflow: hidden;
  animation: subirLogin .6s var(--transicion) both;
}
@keyframes subirLogin {
  from { opacity: 0; transform: translateY(28px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.tarjeta-login::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--azul), var(--azul-claro), var(--cyan), var(--azul));
  background-size: 300% 100%;
  animation: barraLuz 6s linear infinite;
}
@keyframes barraLuz {
  from { background-position: 0% 0; }
  to   { background-position: 300% 0; }
}

.logo-login {
  width: 96px; height: 96px;
  margin: 0 auto 18px;
  display: block;
  animation: latidoLogo 4.5s ease-in-out infinite;
}
@keyframes latidoLogo {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}

.marca { text-align: center; margin-bottom: 30px; }
.marca h1 {
  font-size: 19px;
  color: var(--azul);
  line-height: 1.25;
  text-transform: uppercase;
}
.marca h1 span { display: block; font-size: 23px; color: var(--azul-claro); }
.marca .titular {
  display: inline-block;
  margin-top: 10px;
  padding: 5px 16px;
  border-radius: 999px;
  background: linear-gradient(120deg, var(--azul-claro), var(--cyan));
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
}

/* Campos */
.campo { margin-bottom: 16px; position: relative; }
.campo label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--texto-2);
  margin-bottom: 6px;
  letter-spacing: .01em;
}
.campo label .req { color: var(--alerta); margin-left: 2px; }

.campo input,
.campo select,
.campo textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--borde);
  border-radius: var(--r-sm);
  font-size: 14.5px;
  color: var(--texto);
  background: var(--blanco);
  transition: border-color .2s, box-shadow .2s, background .2s;
  font-family: inherit;
}
.campo textarea { min-height: 78px; resize: vertical; }
.campo input:focus,
.campo select:focus,
.campo textarea:focus {
  outline: none;
  border-color: var(--azul-claro);
  box-shadow: 0 0 0 4px rgba(30,156,215,.14);
}
.campo input::placeholder, .campo textarea::placeholder { color: #A9B7CC; }
.campo .hint { font-size: 11.5px; color: var(--texto-2); margin-top: 5px; }
.campo.error input, .campo.error select, .campo.error textarea,
.campo.error .grupo-check { border-color: var(--alerta); }
.campo.error { animation: sacudir .35s; }
@keyframes sacudir {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.msg-error { color: var(--alerta); font-size: 11.5px; margin-top: 5px; display: none; }
.campo.error .msg-error { display: block; }

.campo-clave { position: relative; }
.ver-clave {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; cursor: pointer; padding: 7px;
  color: var(--texto-2); border-radius: 6px; line-height: 0;
  transition: color .2s, background .2s;
}
.ver-clave:hover { color: var(--azul); background: var(--cyan-suave); }
.ver-clave svg { width: 19px; height: 19px; }

/* Casilla "Recordar usuario y contraseña" */
.recordar {
  display: flex; align-items: center; gap: 10px;
  margin: 2px 0 16px; cursor: pointer;
  font-size: 13px; color: var(--texto-2, #55617a); user-select: none;
}
.recordar input { position: absolute; opacity: 0; width: 0; height: 0; }
.recordar-box {
  width: 20px; height: 20px; flex: none;
  border: 1.8px solid #C3CDDC; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; background: #fff; transition: background .15s, border-color .15s;
}
.recordar-box svg { width: 13px; height: 13px; opacity: 0; transition: opacity .12s; }
.recordar input:checked + .recordar-box { background: var(--azul); border-color: var(--azul); }
.recordar input:checked + .recordar-box svg { opacity: 1; }
.recordar input:focus-visible + .recordar-box { box-shadow: 0 0 0 3px rgba(30,156,215,.35); }
.recordar:hover .recordar-box { border-color: var(--azul-claro); }

/* Botón principal */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: var(--r-sm);
  padding: 12px 22px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform .18s var(--transicion), box-shadow .25s, filter .2s;
  text-decoration: none;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:active { transform: scale(.97); }
.btn-primario {
  width: 100%;
  background: linear-gradient(120deg, var(--azul), var(--azul-claro));
  color: #fff;
  box-shadow: 0 6px 18px rgba(20,71,154,.28);
  margin-top: 6px;
}
.btn-primario:hover { box-shadow: 0 10px 26px rgba(20,71,154,.36); transform: translateY(-2px); }
.btn-primario::after {
  content: '';
  position: absolute; top: 0; left: -70%;
  width: 45%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.42), transparent);
  transform: skewX(-20deg);
  animation: brilloBtn 3.4s ease-in-out infinite;
}
@keyframes brilloBtn {
  0%, 62% { left: -70%; }
  100%    { left: 130%; }
}
.btn-secundario {
  background: var(--blanco);
  color: var(--azul);
  border: 1.5px solid var(--borde);
}
.btn-secundario:hover { border-color: var(--azul-claro); background: var(--cyan-suave); transform: translateY(-1px); }
.btn-fantasma { background: transparent; color: var(--texto-2); }
.btn-fantasma:hover { background: rgba(20,71,154,.07); color: var(--azul); }
.btn[disabled] { opacity: .6; cursor: not-allowed; transform: none !important; }

/* Cargando dentro del botón */
.btn.cargando .btn-txt { visibility: hidden; }
.btn.cargando::before {
  content: '';
  position: absolute;
  width: 19px; height: 19px;
  border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: girar .7s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

.alerta-login {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #B91C1C;
  border-radius: var(--r-sm);
  padding: 10px 13px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
  animation: sacudir .35s;
}
.alerta-login.visible { display: block; }

/* Indicadores de estado de los servicios en el login */
.estado-servicios {
  margin-top: 18px;
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
}
.serv {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 11px; border-radius: 999px;
  background: #F4F6F9; border: 1px solid #E3E8EF;
  font-size: 11.5px; font-weight: 600; color: var(--texto-2, #55617a);
}
.serv-luz {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  background: #C4CBd6;                          /* gris: aún sin saber */
  transition: background .25s, box-shadow .25s;
}
.serv.cargando .serv-luz { background: #C4CBD6; }
.serv.ok  .serv-luz { background: #22C55E; box-shadow: 0 0 0 3px rgba(34,197,94,.20); animation: latido 1.8s ease-in-out infinite; }
.serv.mal .serv-luz { background: #EF4444; box-shadow: 0 0 0 3px rgba(239,68,68,.18); }
.serv.ok  { border-color: #BBF7D0; background: #F0FDF4; color: #15803D; }
.serv.mal { border-color: #FECACA; background: #FEF2F2; color: #B91C1C; }
@keyframes latido {
  0%,100% { box-shadow: 0 0 0 2px rgba(34,197,94,.18); }
  50%     { box-shadow: 0 0 0 5px rgba(34,197,94,.08); }
}

.pie-login {
  margin-top: 18px;
  text-align: center;
  font-size: 11.5px;
  color: var(--texto-2);
  line-height: 1.6;
}

/* ==================================================================
   2. CABECERA DE LA APLICACIÓN
================================================================== */
.barra-sup {
  background: var(--blanco);
  border-bottom: 1px solid var(--borde);
  box-shadow: var(--sombra-1);
  position: sticky; top: 0; z-index: 30;
}
.barra-sup .contenido {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.barra-sup .logo { width: 44px; height: 44px; flex: none; }
.barra-sup .nombre { line-height: 1.15; }
.barra-sup .nombre strong { display: block; font-size: 14px; color: var(--azul); letter-spacing: .01em; }
.barra-sup .nombre small { font-size: 11.5px; color: var(--texto-2); }
.barra-sup .espacio { flex: 1; }

.chip-usuario {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 6px 6px;
  border-radius: 999px;
  background: var(--cyan-suave);
}
.chip-usuario .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--azul), var(--azul-claro));
  color: #fff; font-size: 13px; font-weight: 700;
  display: grid; place-items: center;
}
.chip-usuario .datos { line-height: 1.2; padding-right: 6px; }
.chip-usuario .datos b { display: block; font-size: 12.5px; }
.chip-usuario .datos small { font-size: 10.5px; color: var(--texto-2); }

.reloj {
  font-size: 12px; color: var(--texto-2);
  padding: 7px 13px; border-radius: 999px;
  background: var(--fondo); border: 1px solid var(--borde);
  font-variant-numeric: tabular-nums;
}

/* ==================================================================
   3. BOTONERA CENTRAL
================================================================== */
.contenedor { max-width: 1180px; margin: 0 auto; padding: 34px 24px 60px; }

.encabezado-seccion { text-align: center; margin-bottom: 34px; }
.encabezado-seccion h2 { font-size: 27px; color: var(--azul); margin-bottom: 8px; }
.encabezado-seccion p { color: var(--texto-2); font-size: 15px; max-width: 620px; margin: 0 auto; }

.botonera {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 22px;
}

.btn-doc {
  --c1: var(--azul);
  --c2: var(--azul-claro);
  position: relative;
  border: 1px solid var(--borde);
  background: var(--blanco);
  border-radius: var(--r-md);
  padding: 26px 24px 24px;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  box-shadow: var(--sombra-1);
  transition: transform .35s var(--transicion), box-shadow .35s var(--transicion), border-color .3s;
  opacity: 0;
  transform: translateY(24px);
  animation: aparecerBoton .55s var(--transicion) forwards;
  isolation: isolate;
}
@keyframes aparecerBoton {
  to { opacity: 1; transform: none; }
}
.btn-doc:nth-child(1) { animation-delay: .05s; }
.btn-doc:nth-child(2) { animation-delay: .12s; }
.btn-doc:nth-child(3) { animation-delay: .19s; }
.btn-doc:nth-child(4) { animation-delay: .26s; }
.btn-doc:nth-child(5) { animation-delay: .33s; }
.btn-doc:nth-child(6) { animation-delay: .40s; }

/* Capa de degradado que se revela al pasar el mouse */
.btn-doc::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  opacity: 0;
  transition: opacity .35s var(--transicion);
  z-index: -1;
}
/* Halo que sigue al cursor */
.btn-doc::after {
  content: '';
  position: absolute;
  width: 260px; height: 260px;
  left: var(--mx, 50%); top: var(--my, 50%);
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255,255,255,.28), transparent 62%);
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
  z-index: -1;
}
.btn-doc:hover {
  transform: translateY(-8px) scale(1.015);
  box-shadow: var(--sombra-3);
  border-color: transparent;
}
.btn-doc:hover::before { opacity: 1; }
.btn-doc:hover::after  { opacity: 1; }
.btn-doc:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }

.btn-doc .icono {
  width: 56px; height: 56px;
  border-radius: 16px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  color: #fff;
  margin-bottom: 16px;
  transition: transform .4s var(--transicion), background .35s, box-shadow .35s;
  box-shadow: 0 6px 16px rgba(20,71,154,.2);
}
.btn-doc .icono svg { width: 28px; height: 28px; }
.btn-doc:hover .icono {
  background: rgba(255,255,255,.2);
  transform: rotate(-8deg) scale(1.12);
  box-shadow: 0 8px 20px rgba(0,0,0,.18);
}

.btn-doc .titulo {
  font-size: 16.5px; font-weight: 700;
  color: var(--azul); margin-bottom: 6px;
  transition: color .3s;
  line-height: 1.3;
}
.btn-doc .sub {
  font-size: 13px; color: var(--texto-2);
  transition: color .3s;
  line-height: 1.45;
}
.btn-doc:hover .titulo { color: #fff; }
.btn-doc:hover .sub    { color: rgba(255,255,255,.9); }

.btn-doc .flecha {
  position: absolute; right: 20px; bottom: 20px;
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--cyan-suave); color: var(--azul);
  opacity: 0; transform: translateX(-8px);
  transition: opacity .3s var(--transicion), transform .3s var(--transicion), background .3s, color .3s;
}
.btn-doc .flecha svg { width: 16px; height: 16px; }
.btn-doc:hover .flecha {
  opacity: 1; transform: none;
  background: rgba(255,255,255,.22); color: #fff;
  animation: rebotarFlecha 1.1s ease-in-out infinite;
}
@keyframes rebotarFlecha {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(4px); }
}

/* Onda de clic (ripple) */
.onda-clic {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,.55);
  transform: scale(0);
  animation: expandirOnda .65s ease-out forwards;
  pointer-events: none;
  z-index: 2;
}
@keyframes expandirOnda {
  to { transform: scale(3.2); opacity: 0; }
}
/* Pulso al presionar */
.btn-doc.presionado { animation: presionar .4s var(--transicion); }
@keyframes presionar {
  0%   { transform: translateY(-8px) scale(1.015); }
  35%  { transform: translateY(-2px) scale(.965); }
  100% { transform: translateY(-8px) scale(1.015); }
}

/* Tarjeta de accesos rápidos */
.fila-accesos { display: flex; gap: 12px; justify-content: center; margin-top: 36px; flex-wrap: wrap; }

/* ==================================================================
   4. FORMULARIO
================================================================== */
.cabecera-form {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 26px;
}
.cabecera-form .icono-form {
  width: 54px; height: 54px; border-radius: 15px;
  display: grid; place-items: center; color: #fff;
  box-shadow: var(--sombra-2);
  animation: entrarIcono .5s var(--transicion) both;
}
@keyframes entrarIcono {
  from { opacity: 0; transform: scale(.5) rotate(-25deg); }
  to   { opacity: 1; transform: none; }
}
.cabecera-form .icono-form svg { width: 27px; height: 27px; }
.cabecera-form h2 { font-size: 21px; color: var(--azul); line-height: 1.25; }
.cabecera-form p { font-size: 13px; color: var(--texto-2); margin: 3px 0 0; }

.tarjeta {
  background: var(--blanco);
  border: 1px solid var(--borde);
  border-radius: var(--r-md);
  box-shadow: var(--sombra-1);
  padding: 26px 26px 22px;
  margin-bottom: 20px;
  animation: aparecerTarjeta .5s var(--transicion) both;
}
@keyframes aparecerTarjeta {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}
.tarjeta:nth-of-type(2) { animation-delay: .08s; }
.tarjeta:nth-of-type(3) { animation-delay: .16s; }

.titulo-tarjeta {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; color: var(--azul);
  padding-bottom: 14px; margin-bottom: 18px;
  border-bottom: 2px solid var(--cyan-suave);
}
.titulo-tarjeta .n {
  width: 25px; height: 25px; border-radius: 50%;
  background: linear-gradient(135deg, var(--azul), var(--azul-claro));
  color: #fff; font-size: 12.5px; display: grid; place-items: center; flex: none;
}

/* ---------------- Caja de búsqueda ---------------- */
.caja-busqueda { display: flex; gap: 12px; align-items: stretch; }
@media (max-width: 640px) { .caja-busqueda { flex-direction: column; } }

.entrada-busqueda { position: relative; flex: 1; }
.entrada-busqueda svg {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; color: var(--texto-2); pointer-events: none;
  transition: color .2s;
}
.entrada-busqueda input {
  width: 100%;
  padding: 15px 16px 15px 48px;
  border: 2px solid var(--borde);
  border-radius: var(--r-sm);
  font-size: 16px;
  font-family: inherit;
  color: var(--texto);
  letter-spacing: .01em;
  transition: border-color .2s, box-shadow .2s;
}
.entrada-busqueda input:focus {
  outline: none;
  border-color: var(--azul-claro);
  box-shadow: 0 0 0 4px rgba(30,156,215,.14);
}
.entrada-busqueda input:focus ~ svg,
.entrada-busqueda:focus-within svg { color: var(--azul-claro); }
.entrada-busqueda input::placeholder { color: #A9B7CC; font-size: 14.5px; }
.caja-busqueda .btn { min-width: 130px; padding-left: 30px; padding-right: 30px; }

.buscando {
  display: flex; align-items: center; gap: 11px;
  padding: 30px 4px; color: var(--texto-2); font-size: 14px;
}
.anillo-mini {
  width: 18px; height: 18px; flex: none;
  border: 2.4px solid var(--cyan-suave);
  border-top-color: var(--azul-claro);
  border-radius: 50%;
  animation: girar .75s linear infinite;
}

.conteo-resultados {
  margin: 22px 0 12px;
  font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--texto-2); font-weight: 600;
}

/* ---------------- Tarjetas de paciente ---------------- */
.lista-pacientes { display: flex; flex-direction: column; gap: 12px; }

.tarjeta-paciente {
  position: relative;
  width: 100%;
  text-align: left;
  border: 2px solid var(--borde);
  border-radius: var(--r-md);
  background: var(--blanco);
  padding: 16px 52px 16px 18px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .25s var(--transicion), box-shadow .25s, transform .25s var(--transicion), background .25s;
  animation: aparecerFila .4s var(--transicion) both;
}
@keyframes aparecerFila {
  from { opacity: 0; transform: translateX(-14px); }
  to   { opacity: 1; transform: none; }
}
.lista-pacientes .tarjeta-paciente:nth-child(2) { animation-delay: .06s; }
.lista-pacientes .tarjeta-paciente:nth-child(3) { animation-delay: .12s; }
.lista-pacientes .tarjeta-paciente:nth-child(4) { animation-delay: .18s; }
.lista-pacientes .tarjeta-paciente:nth-child(n+5) { animation-delay: .24s; }

.tarjeta-paciente:hover {
  border-color: var(--azul-claro);
  background: #FAFDFF;
  transform: translateY(-2px);
  box-shadow: var(--sombra-2);
}
.tarjeta-paciente.seleccionada {
  border-color: var(--azul-claro);
  background: linear-gradient(120deg, #F2FAFE, #FFFFFF);
  box-shadow: 0 0 0 4px rgba(30,156,215,.13), var(--sombra-2);
}

.tarjeta-paciente .marca-sel {
  position: absolute; top: 50%; right: 18px; transform: translateY(-50%) scale(.5);
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--azul), var(--azul-claro));
  color: #fff; display: grid; place-items: center;
  opacity: 0; transition: all .3s var(--transicion);
}
.tarjeta-paciente .marca-sel svg { width: 14px; height: 14px; }
.tarjeta-paciente.seleccionada .marca-sel { opacity: 1; transform: translateY(-50%) scale(1); }

.pac-cabecera {
  display: flex; align-items: baseline; gap: 12px;
  flex-wrap: wrap; margin-bottom: 10px;
}
.pac-nombre { font-size: 16px; font-weight: 700; color: var(--azul); }
.pac-orden {
  font-size: 11.5px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
  background: var(--cyan-suave); color: var(--azul-osc);
  font-variant-numeric: tabular-nums;
}

.pac-datos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px 16px;
}
.pac-datos > div { line-height: 1.35; }
.pac-datos span {
  display: block; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--texto-2);
}
.pac-datos b { font-size: 13.5px; font-weight: 600; color: var(--texto); }

.pac-examenes {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 12px; padding-top: 11px;
  border-top: 1px dashed var(--borde);
}
.pac-examenes .examen {
  font-size: 11.5px; padding: 3px 9px;
  border-radius: 6px; background: var(--fondo);
  color: var(--texto-2); border: 1px solid var(--borde);
}

.error-busqueda { color: var(--alerta); }
.error-busqueda svg { color: var(--alerta); }
.error-busqueda strong { color: var(--alerta); }

.pac-examenes .examen.mas { background: var(--cyan-suave); color: var(--azul); border-color: #BFE3F7; font-weight: 600; }

.tarjeta-busqueda { padding-bottom: 26px; }

/* ------------------------------------------------------------------
   Ficha del paciente en atención (encima de la botonera)
------------------------------------------------------------------- */
.ficha-paciente {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  background: var(--blanco);
  border: 1px solid var(--borde);
  border-left: 5px solid var(--azul-claro);
  border-radius: var(--r-md);
  padding: 20px 24px;
  box-shadow: var(--sombra-1);
  animation: aparecerTarjeta .45s var(--transicion) both;
}
@media (max-width: 620px) { .ficha-paciente { flex-direction: column; gap: 12px; } }

.ficha-avatar {
  width: 52px; height: 52px; flex: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--azul), var(--azul-claro));
  color: #fff; font-size: 22px; font-weight: 700;
  display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(20,71,154,.25);
}
.ficha-cuerpo { flex: 1; min-width: 0; }
.ficha-nombre {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  font-size: 19px; font-weight: 700; color: var(--azul);
  margin-bottom: 12px;
}
.ficha-paciente .pac-datos { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.ficha-paciente .pac-examenes { margin-top: 14px; padding-top: 12px; }

/* ------------------------------------------------------------------
   Sellos sobre los botones de consentimiento
------------------------------------------------------------------- */
.sello-sugerido, .sello-firmado {
  position: absolute; top: 14px; right: 14px;
  z-index: 3;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px;
  transition: background .3s, color .3s;
}
.sello-sugerido {
  background: var(--cyan-suave); color: var(--azul);
}
.btn-doc:hover .sello-sugerido { background: rgba(255,255,255,.25); color: #fff; }

/* Por qué se propone este consentimiento */
.btn-doc .motivo {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--borde);
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--texto-2);
  transition: color .3s, border-color .3s;
}
.btn-doc .motivo span {
  font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; font-size: 10px;
  color: var(--azul-claro); margin-right: 4px;
  transition: color .3s;
}
.btn-doc:hover .motivo        { color: rgba(255,255,255,.88); border-color: rgba(255,255,255,.3); }
.btn-doc:hover .motivo span   { color: #fff; }

/* Botón que revela el resto de consentimientos */
#fila-otros .btn svg { transition: transform .3s var(--transicion); }
#fila-otros.abierto .btn svg { transform: rotate(180deg); }
#botonera-otros .btn-doc { opacity: .85; }
#botonera-otros .btn-doc:hover { opacity: 1; }

.sello-firmado {
  display: inline-flex; align-items: center; gap: 5px;
  background: #DCFCE7; color: #15803D;
  animation: none;
}
.sello-firmado svg { width: 11px; height: 11px; }
.btn-doc:hover .sello-firmado { background: rgba(255,255,255,.25); color: #fff; }
/* Si ya se firmó, el sello "Sugerido" sobra */
.btn-doc.ya-firmado .sello-sugerido { display: none; }

.btn-doc.sugerido { border-color: var(--azul-claro); }
.btn-doc.sugerido::before { opacity: .06; }
.btn-doc.sugerido:hover::before { opacity: 1; }

.btn-doc.ya-firmado { border-color: #BBF7D0; }
.btn-doc.ya-firmado .icono { opacity: .55; }
.btn-doc.ya-firmado .titulo { color: var(--texto-2); }
.btn-doc.ya-firmado:hover .titulo { color: #fff; }

/* Pulso del botón cuando se habilita */
.btn.pulso { animation: pulsoBtn .5s var(--transicion); }
@keyframes pulsoBtn {
  0%   { transform: scale(1); box-shadow: 0 6px 18px rgba(20,71,154,.28); }
  45%  { transform: scale(1.05); box-shadow: 0 12px 30px rgba(20,71,154,.4); }
  100% { transform: scale(1); box-shadow: 0 6px 18px rgba(20,71,154,.28); }
}

/* Indicador de conexión con el LIS */
.estado-lis {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--texto-2);
  padding: 7px 13px; border-radius: 999px;
  background: var(--fondo); border: 1px solid var(--borde);
  white-space: nowrap;
}
.estado-lis .punto {
  width: 8px; height: 8px; border-radius: 50%;
  background: #C3D0E2; flex: none;
}
.estado-lis.conectado .punto { background: var(--ok); animation: latir 2.4s ease-in-out infinite; }
.estado-lis.demo .punto { background: var(--amarillo); }
.estado-lis.demo { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }
.estado-lis.desconectado .punto { background: var(--alerta); }
.estado-lis.desconectado { background: #FEF2F2; border-color: #FECACA; color: #B91C1C; }
@keyframes latir {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22,163,74,.5); }
  60%      { box-shadow: 0 0 0 6px rgba(22,163,74,0); }
}

.barra-acciones {
  display: flex; gap: 12px; justify-content: flex-end;
  flex-wrap: wrap; margin-top: 24px;
}
.barra-acciones .btn { min-width: 150px; }
.barra-acciones .btn-primario { width: auto; }

/* ==================================================================
   5. DOCUMENTO GENERADO
================================================================== */
.zona-doc { background: #E7EDF5; padding: 30px 0 70px; }

.hoja {
  width: 21cm;
  min-height: 29.7cm;
  margin: 0 auto;
  background: #fff;
  padding: 1.6cm 1.8cm 1.4cm;
  box-shadow: var(--sombra-3);
  color: #1A1A1A;
  font-size: 11.2pt;
  line-height: 1.55;
  animation: aparecerHoja .55s var(--transicion) both;
}
@keyframes aparecerHoja {
  from { opacity: 0; transform: translateY(24px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
@media (max-width: 900px) {
  .hoja { width: 100%; padding: 22px 18px; min-height: auto; }
}

.doc-encabezado {
  display: flex; align-items: center; gap: 16px;
  padding-bottom: 12px;
  border-bottom: 3px solid var(--azul);
  margin-bottom: 6px;
}
.doc-encabezado .logo { width: 74px; height: 74px; flex: none; }
.doc-encabezado .txt { flex: 1; line-height: 1.25; }
.doc-encabezado .txt h1 { font-size: 14pt; color: var(--azul); text-transform: uppercase; }
.doc-encabezado .txt h2 { font-size: 12pt; color: var(--azul-claro); font-weight: 700; }
.doc-encabezado .txt small { font-size: 8pt; color: #555; display: block; margin-top: 4px; }
.doc-encabezado .codigo {
  text-align: right; font-size: 7.6pt; color: #555;
  border-left: 1px solid #DDD; padding-left: 12px; line-height: 1.5;
}

.doc-titulo {
  text-align: center;
  font-size: 12.5pt;
  color: var(--azul);
  text-transform: uppercase;
  margin: 16px 0 14px;
  padding: 9px;
  background: var(--cyan-suave);
  border-radius: 5px;
  letter-spacing: .01em;
}

.hoja h4 {
  font-size: 10.6pt;
  color: var(--azul);
  margin: 13px 0 5px;
}
.hoja p { text-align: justify; margin: 0 0 7px; }
.hoja ul { margin: 4px 0 8px; padding-left: 20px; }
.hoja li { margin-bottom: 3px; text-align: justify; }

.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 7px 0 10px;
  font-size: 9.6pt;
}
.doc-table th, .doc-table td {
  border: 1px solid #C9D6E5;
  padding: 5px 8px;
  text-align: left;
  vertical-align: top;
}
.doc-table th { background: #EEF5FB; color: var(--azul-osc); font-weight: 600; }

/* ---------------- Campos editables dentro del documento ---------------- */
.editable {
  display: inline-block;
  min-width: 90px;
  padding: 0 5px;
  border-bottom: 1px solid #9AA8BC;
  background: #EFF7FE;
  border-radius: 3px 3px 0 0;
  outline: none;
  cursor: text;
  transition: background .18s, box-shadow .18s;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}
.editable:hover { background: #E2F1FC; }
.editable:focus {
  background: #DCEFFC;
  box-shadow: inset 0 -2px 0 var(--azul-claro);
}
.editable:empty::before {
  content: attr(data-pista);
  color: #A9BACE;
  font-style: italic;
}

/* ---------------- Casillas marcables ---------------- */
.casillas {
  display: flex; flex-wrap: wrap;
  gap: 3px 14px;
  margin: 3px 0 6px;
}
.casillas.en-linea { display: inline-flex; gap: 3px 12px; margin: 0; vertical-align: middle; }

.casilla {
  cursor: pointer;
  user-select: none;
  padding: 1px 5px 1px 2px;
  border-radius: 4px;
  transition: background .16s, color .16s;
  white-space: nowrap;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}
.casilla::before { content: '\2610'; margin-right: 4px; font-size: 1.15em; line-height: 1; }
.casilla:hover { background: #EFF7FE; }
.casilla.marcada { color: var(--azul); font-weight: 600; }
.casilla.marcada::before { content: '\2611'; }

.linea-obs { min-height: 1.6em; }

/* ---------------- Firmas sobre el documento ---------------- */
.doc-firmas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 26px;
  margin-top: 26px;
  page-break-inside: avoid;
}
.doc-firmas .bloque { text-align: center; }
.doc-firmas .linea { border-top: 1px solid #333; padding-top: 5px; font-size: 9.2pt; }
.doc-firmas .linea b { display: block; font-size: 9.6pt; }
.doc-firmas .linea span { display: block; color: #555; font-size: 8.6pt; }

.firma-lienzo {
  position: relative;
  height: 92px;
  border: 2px dashed #C3D0E2;
  border-radius: 8px 8px 0 0;
  background: #FBFDFF;
  transition: border-color .25s, background .25s;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}
.firma-lienzo:hover { border-color: var(--azul-claro); background: #F5FBFF; }
.firma-lienzo.firmada { border-style: solid; border-color: #B8D8EC; background: #fff; }
.firma-lienzo canvas {
  display: block; width: 100%; height: 100%;
  touch-action: none; cursor: crosshair;
}
.pista-firma {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: #B6C6DA; font-size: 9.5pt; pointer-events: none;
  transition: opacity .25s;
}
.firma-lienzo.firmada .pista-firma { opacity: 0; }
.borrar-firma {
  position: absolute; top: 5px; right: 6px;
  border: 0; background: rgba(255,255,255,.85);
  color: var(--azul-claro); font-size: 10px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; cursor: pointer;
  opacity: 0; transition: opacity .2s, background .2s;
  font-family: inherit;
}
.firma-lienzo:hover .borrar-firma { opacity: 1; }
.borrar-firma:hover { background: var(--cyan-suave); }

/* Firma ya convertida a imagen (la que va al PDF) */
.firma-impresa { height: 92px; display: flex; align-items: flex-end; justify-content: center; }
.firma-impresa img { max-height: 88px; max-width: 100%; }

.pista-doc {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--texto-2);
  padding-left: 8px;
}
.pista-doc svg { width: 16px; height: 16px; color: var(--azul-claro); flex: none; }
@media (max-width: 980px) { .pista-doc { display: none; } }

/* Campos que el asesor completa dentro del documento */
.campos-doc {
  margin: 16px 0;
  padding: 16px 18px;
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: var(--r-sm);
}
.campos-doc-titulo {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: #92400E; margin-bottom: 12px;
}
.campo-doc-fila { display: block; margin-bottom: 14px; }
.campo-doc-fila:last-child { margin-bottom: 0; }
.campo-doc-fila > span { display: block; font-size: 12.5px; color: var(--texto); font-weight: 600; margin-bottom: 6px; }
.campo-doc-fila .req { color: var(--alerta); }
.campo-doc {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--borde);
  border-radius: var(--r-sm);
  font-size: 14px; font-family: inherit; color: var(--texto);
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.campo-doc:focus { outline: none; border-color: var(--azul-claro); box-shadow: 0 0 0 4px rgba(30,156,215,.14); }
.campo-doc.error { border-color: var(--alerta); box-shadow: 0 0 0 4px rgba(220,38,38,.12); }
textarea.campo-doc { resize: vertical; min-height: 72px; }

/* Selección múltiple con chips */
.campo-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px; border-radius: var(--r-sm); }
.campo-chips.error { outline: 2px solid var(--alerta); outline-offset: 3px; }
.chip-op {
  padding: 8px 16px;
  border: 1.5px solid var(--borde);
  border-radius: 999px;
  background: #fff;
  font-size: 13px; font-weight: 600; color: var(--texto-2);
  cursor: pointer; user-select: none;
  transition: all .18s var(--transicion);
}
.chip-op:hover { border-color: var(--azul-claro); }
.chip-op.sel {
  background: linear-gradient(120deg, var(--azul), var(--azul-claro));
  border-color: transparent; color: #fff;
  box-shadow: 0 3px 10px rgba(20,71,154,.25);
}

/* Documento con tres firmas (paciente, tutor, asesor) */
.doc-firmas.tres { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 760px) { .doc-firmas.tres { grid-template-columns: 1fr; } }

.aviso-doc-oficial {
  display: flex; align-items: flex-start; gap: 12px;
  margin: 18px 0;
  padding: 14px 16px;
  background: var(--cyan-suave);
  border: 1px solid #BFE3F7;
  border-radius: var(--r-sm);
  font-size: 12.5px; color: var(--texto-2); line-height: 1.5;
}
.aviso-doc-oficial svg { width: 20px; height: 20px; color: var(--azul-claro); flex: none; margin-top: 1px; }
.aviso-doc-oficial b { color: var(--azul); }

/* --- Botón "Leer consentimiento" --- */
.leer-consent { margin: 16px 0; }
.btn-leer-consent {
  display: inline-flex; align-items: center; gap: 10px; width: 100%;
  justify-content: center; padding: 13px 18px; cursor: pointer;
  background: var(--cyan-suave); border: 1px solid #BFE3F7; color: var(--azul);
  border-radius: var(--r-sm); font-size: 14px; font-weight: 700;
  transition: background .15s, box-shadow .15s, border-color .15s, opacity .15s;
}
.btn-leer-consent:hover:not(:disabled) { background: #E3F3FC; box-shadow: 0 3px 14px rgba(30,156,215,.18); }
.btn-leer-consent:active:not(:disabled) { transform: scale(.99); }
.btn-leer-consent:disabled { opacity: .6; cursor: default; }
.btn-leer-consent svg { width: 19px; height: 19px; flex: none; }

/* --- Bloque de lectura del consentimiento (antes de firmar) --- */
.doc-lectura { margin: 18px 0; border: 1px solid #BFE3F7; border-radius: var(--r-sm); overflow: hidden; }
.doc-lectura-cab {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 15px; background: var(--cyan-suave);
  color: var(--azul); font-size: 13px; font-weight: 700;
  border-bottom: 1px solid #BFE3F7;
}
.doc-lectura-cab svg { width: 18px; height: 18px; flex: none; color: var(--azul-claro); }
.doc-lectura-cab span { flex: 1; }
.doc-lectura-toggle, .doc-lectura-expandir {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid #BFE3F7; color: var(--azul);
  font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 999px; cursor: pointer;
  transition: background .15s, opacity .15s;
}
.doc-lectura-toggle:hover, .doc-lectura-expandir:hover { background: #EAF6FD; }
.doc-lectura-expandir svg { width: 14px; height: 14px; }
.doc-lectura-expandir:disabled { opacity: .5; cursor: default; }

/* Modal a pantalla completa del consentimiento */
.doc-modal {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 35, 60, .55); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; animation: doc-modal-in .15s ease;
}
@keyframes doc-modal-in { from { opacity: 0; } to { opacity: 1; } }
.doc-modal-caja {
  background: #fff; border-radius: var(--r-md, 14px); overflow: hidden;
  width: 100%; max-width: 1000px; height: 100%; max-height: 95vh;
  display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(0,0,0,.4);
}
.doc-modal-cab {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 18px; background: var(--azul); color: #fff;
  font-size: 14px; font-weight: 700; flex: none;
}
.doc-modal-cab > span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-modal-cerrar {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.15); border: 0; color: #fff;
  font-size: 13px; font-weight: 600; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  transition: background .15s;
}
.doc-modal-cerrar:hover { background: rgba(255,255,255,.28); }
.doc-modal-cerrar svg { width: 15px; height: 15px; }
.doc-modal-cuerpo { flex: 1; overflow: auto; background: #f3f5f8; }
.doc-modal-iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.doc-modal-cuerpo .leer-texto { padding: 24px 28px; max-width: 820px; margin: 0 auto; background: #fff; }
.doc-lectura-cuerpo {
  max-height: 380px; overflow-y: auto;
  background: #fff; padding: 16px 20px;
}
/* Cuando se muestra el documento tal cual (HTML), el iframe manda */
.doc-lectura-cuerpo-html { max-height: none; overflow: visible; padding: 0; }
.doc-iframe { width: 100%; min-height: 300px; border: 0; display: block; background: #fff; }
.leer-cargando { font-size: 12.5px; color: var(--texto-2); padding: 6px 0; }
.leer-cargando.error { color: #C0392B; }
.doc-lectura-reintentar {
  display: inline-block; margin-top: 8px; padding: 5px 14px; cursor: pointer;
  background: var(--azul); color: #fff; border: 0; border-radius: var(--r-sm); font-size: 12px;
}
.leer-texto { font-size: 12.5px; color: #222; line-height: 1.6; }
.leer-texto p { margin: 0 0 8px; }
.leer-texto p.vacio { margin: 0 0 4px; }

.btn-listo { box-shadow: 0 6px 18px rgba(22,163,74,.3) !important; background: linear-gradient(120deg, #15803D, #22C55E) !important; }
.btn-listo:hover { box-shadow: 0 10px 26px rgba(22,163,74,.4) !important; }

.doc-pie {
  margin-top: 22px; padding-top: 9px;
  border-top: 1px solid #DDD;
  font-size: 7.6pt; color: #666;
  display: flex; justify-content: space-between; gap: 14px;
}

.barra-doc {
  position: sticky; top: 69px; z-index: 20;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--borde);
  padding: 12px 24px;
  display: flex; gap: 10px; align-items: center;
  flex-wrap: wrap;
  box-shadow: var(--sombra-1);
}
.barra-doc .espacio { flex: 1; }

/* ==================================================================
   6. HISTORIAL
================================================================== */
.tabla-historial { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tabla-historial th {
  text-align: left; padding: 11px 12px;
  background: var(--cyan-suave); color: var(--azul-osc);
  font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
}
.tabla-historial th:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.tabla-historial th:last-child  { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.tabla-historial td { padding: 12px; border-bottom: 1px solid var(--borde); }
.tabla-historial tr { transition: background .2s; }
.tabla-historial tbody tr:hover { background: #F8FBFE; }
.etiqueta {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; color: #fff;
}
.vacio { text-align: center; padding: 56px 20px; color: var(--texto-2); }
.vacio svg { width: 58px; height: 58px; color: #C3D0E2; margin-bottom: 14px; }

.buscador { position: relative; margin-bottom: 18px; max-width: 420px; }
.buscador input { padding-left: 38px; }
.buscador svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--texto-2); pointer-events: none;
}

/* ==================================================================
   7. NOTIFICACIONES
================================================================== */
#avisos {
  position: fixed; bottom: 22px; right: 22px; z-index: 100;
  display: flex; flex-direction: column; gap: 10px;
}
.aviso {
  display: flex; align-items: center; gap: 11px;
  background: var(--blanco);
  border-left: 4px solid var(--ok);
  border-radius: var(--r-sm);
  box-shadow: var(--sombra-3);
  padding: 13px 18px 13px 15px;
  font-size: 13.5px;
  min-width: 265px;
  animation: entrarAviso .4s var(--transicion) both;
}
.aviso.saliendo { animation: salirAviso .3s ease-in forwards; }
.aviso.error { border-left-color: var(--alerta); }
.aviso.info  { border-left-color: var(--azul-claro); }
.aviso svg { width: 19px; height: 19px; flex: none; color: var(--ok); }
.aviso.error svg { color: var(--alerta); }
.aviso.info svg  { color: var(--azul-claro); }
@keyframes entrarAviso {
  from { opacity: 0; transform: translateX(60px) scale(.9); }
  to   { opacity: 1; transform: none; }
}
@keyframes salirAviso {
  to { opacity: 0; transform: translateX(60px) scale(.9); }
}

/* Transición de pantalla al abrir un consentimiento */
#cortina {
  position: fixed; inset: 0; z-index: 90;
  pointer-events: none;
  display: grid; place-items: center;
  background: rgba(244,248,252,.0);
  opacity: 0;
}
#cortina.activa {
  animation: cortinaFlash .55s ease-out forwards;
}
@keyframes cortinaFlash {
  0%   { opacity: 0; background: rgba(244,248,252,0); }
  35%  { opacity: 1; background: rgba(244,248,252,.85); }
  100% { opacity: 0; background: rgba(244,248,252,0); }
}
#cortina .anillo {
  width: 62px; height: 62px;
  border: 4px solid var(--cyan-suave);
  border-top-color: var(--azul-claro);
  border-radius: 50%;
  animation: girar .8s linear infinite;
}

/* ==================================================================
   7-bis. GESTIÓN DE USUARIOS
================================================================== */
.rejilla-usuario {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px 16px;
  align-items: end;
}
.rejilla-usuario .campo { margin-bottom: 0; }
.campo-boton { display: flex; align-items: flex-end; }
#form-usuario.inactivo { opacity: .55; pointer-events: none; }

.marca-origen {
  display: inline-block;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  margin-right: 8px;
}
.marca-origen.ok    { background: #DCFCE7; color: #15803D; }
.marca-origen.aviso { background: #FEF3C7; color: #92400E; }
#estado-usuarios code {
  background: var(--fondo); border: 1px solid var(--borde);
  border-radius: 5px; padding: 1px 6px;
  font-size: 12px; font-family: 'Consolas', monospace;
}

.etiqueta.admin  { background: linear-gradient(120deg, #4C1D95, #8B5CF6); }
.etiqueta.asesor { background: linear-gradient(120deg, var(--azul), var(--azul-claro)); }
.etiqueta.local  { background: #94A3B8; }

.punto-ok, .punto-no {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-right: 5px;
}
.punto-ok { background: var(--ok); }
.punto-no { background: #CBD5E1; }
.fila-inactiva { opacity: .55; }

.btn.mini { padding: 6px 12px; font-size: 12px; }

/* ==================================================================
   8. MODAL DE CONFIRMACIÓN
================================================================== */
.capa-modal {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(16, 34, 62, .55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center; justify-content: center;
  padding: 24px;
}
.capa-modal.visible { display: flex; animation: aparecerCapa .25s ease-out; }
@keyframes aparecerCapa { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--blanco);
  border-radius: var(--r-lg);
  box-shadow: var(--sombra-3);
  padding: 36px 34px 28px;
  max-width: 520px; width: 100%;
  text-align: center;
  animation: subirModal .4s var(--transicion) both;
}
@keyframes subirModal {
  from { opacity: 0; transform: translateY(28px) scale(.95); }
  to   { opacity: 1; transform: none; }
}
.modal .visto {
  width: 62px; height: 62px; margin: 0 auto 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #15803D, #22C55E);
  color: #fff; display: grid; place-items: center;
  animation: brincoVisto .55s var(--transicion) both .1s;
  box-shadow: 0 8px 22px rgba(22,163,74,.35);
}
.modal .visto svg { width: 30px; height: 30px; }
@keyframes brincoVisto {
  from { transform: scale(0) rotate(-40deg); opacity: 0; }
  60%  { transform: scale(1.12) rotate(6deg); }
  to   { transform: none; opacity: 1; }
}
.modal h3 { font-size: 20px; color: var(--azul); margin-bottom: 8px; }
.modal p { color: var(--texto-2); font-size: 14px; line-height: 1.55; }
.ruta-archivo {
  margin: 16px 0 22px;
  padding: 11px 14px;
  background: var(--fondo);
  border: 1px solid var(--borde);
  border-radius: var(--r-sm);
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 11.5px; color: var(--texto-2);
  word-break: break-all; text-align: left;
}
.acciones-modal { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.acciones-modal .btn { min-width: 150px; }

/* Diálogo genérico (reemplaza prompt/confirm) */
.modal-dialogo { max-width: 460px; text-align: left; }
.modal-dialogo h3 { font-size: 18px; color: var(--azul); margin-bottom: 10px; text-align: left; }
.modal-dialogo p { color: var(--texto-2); font-size: 14px; line-height: 1.5; }
#dlg-campo { margin: 16px 0 4px; }
#dlg-input { width: 100%; }
.dlg-hint { font-size: 11.5px; color: var(--texto-2); margin-top: 6px; line-height: 1.45; }
.modal-dialogo .acciones-modal { justify-content: flex-end; margin-top: 20px; }
.btn-peligro { background: linear-gradient(120deg,#B91C1C,#EF4444) !important; box-shadow: 0 6px 18px rgba(220,38,38,.28) !important; }

/* ==================================================================
   8-bis. RESPONSIVE (que nada se salga de su lugar)
================================================================== */
html, body { max-width: 100%; overflow-x: hidden; }
img, canvas, svg { max-width: 100%; }

/* Tablas: scroll horizontal propio, nunca empujan la página */
#lista-usuarios, #contenido-historial { overflow-x: auto; -webkit-overflow-scrolling: touch; }
#lista-usuarios .tabla-historial,
#contenido-historial .tabla-historial { min-width: 680px; }

/* Barra superior */
@media (max-width: 860px) {
  .barra-sup .contenido { flex-wrap: wrap; padding: 10px 14px; gap: 8px 12px; }
  .barra-sup .nombre small { display: none; }
  .barra-sup .espacio { display: none; }
  .estado-lis { order: 6; font-size: 11px; }
  .chip-usuario .datos small { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 560px) {
  .barra-sup .logo { width: 36px; height: 36px; }
  .barra-sup .nombre strong { font-size: 12.5px; }
  #btn-usuarios, #btn-salir { padding: 8px 11px; font-size: 13px; }
  .chip-usuario { padding: 5px 6px; }
}

/* Contenido general */
@media (max-width: 640px) {
  .contenedor { padding: 22px 14px 48px; }
  .encabezado-seccion h2 { font-size: 21px; }
  .encabezado-seccion p { font-size: 14px; }
  .barra-acciones { flex-direction: column; }
  .barra-acciones .btn { width: 100%; }
  .rejilla-usuario { grid-template-columns: 1fr; }
  .tarjeta { padding: 20px 16px; }
}

/* Barra del documento y zona del documento */
@media (max-width: 900px) {
  .barra-doc { flex-wrap: wrap; gap: 8px; }
  .barra-doc .btn { flex: 1 1 auto; }
  .zona-doc { padding: 14px 10px 40px; }
}

/* Interior del documento en pantallas pequeñas (vertical y horizontal) */
@media (max-width: 600px) {
  .hoja { padding: 18px 14px; }

  /* Cabecera: logo + título juntos y el código abajo (ya no apretados) */
  .doc-encabezado { flex-wrap: wrap; gap: 10px 14px; }
  .doc-encabezado .logo { width: 54px; height: 54px; }
  .doc-encabezado .txt { flex: 1 1 62%; min-width: 0; }
  .doc-encabezado .txt h1 { font-size: 12.5pt; }
  .doc-encabezado .txt h2 { font-size: 11pt; }
  .doc-encabezado .codigo {
    flex: 1 1 100%; text-align: left;
    border-left: 0; border-top: 1px solid #DDD;
    padding-left: 0; padding-top: 7px;
  }
  .doc-titulo { font-size: 11pt; margin: 12px 0 12px; }

  /* Tabla de identificación: tarjetas apiladas clave/valor */
  .doc-table, .doc-table tbody, .doc-table tr,
  .doc-table th, .doc-table td { display: block; width: auto !important; }
  .doc-table tr { margin-bottom: 8px; border: 1px solid #C9D6E5; border-radius: 6px; overflow: hidden; }
  .doc-table th { background: #EEF5FB; border: 0; padding: 5px 9px; font-size: 8.6pt; }
  .doc-table td { border: 0; padding: 2px 9px 7px; }

  /* Firmas: una sola columna, lienzo cómodo para firmar con el dedo */
  .doc-firmas { grid-template-columns: 1fr; gap: 18px; margin-top: 20px; }
  .firma-lienzo { height: 112px; }

  /* Pie del documento apilado */
  .doc-pie { flex-direction: column; gap: 4px; }

  /* Modal de lectura a pantalla completa: aprovechar el ancho del teléfono */
  .doc-modal { padding: 8px; }
  .doc-modal-caja { max-height: 100%; border-radius: 10px; }
  .doc-modal-cab { padding: 11px 13px; font-size: 13px; }
  .doc-modal-cerrar span { display: none; }
}

/* ==================================================================
   9. IMPRESIÓN
================================================================== */
@media print {
  @page { size: A4 portrait; margin: 12mm 14mm; }

  body { background: #fff; }
  .fondo-ondas, .barra-sup, .barra-doc, #avisos, #cortina,
  .capa-modal, .no-imprimir { display: none !important; }
  .zona-doc { background: #fff; padding: 0; }
  .hoja {
    width: auto; min-height: auto;
    box-shadow: none; margin: 0; padding: 0;
    animation: none;
    font-size: 10.4pt;
  }
  .doc-firmas, .doc-table, .hoja h4 { page-break-inside: avoid; }
  .hoja h4 { page-break-after: avoid; }
  .doc-pie { position: relative; }
  a { text-decoration: none; color: inherit; }

  /* Los campos editables se imprimen como texto sobre una línea */
  .editable { background: transparent !important; box-shadow: none !important; }
  .editable:empty::before { content: ''; }
  .firma-lienzo { border: 0; border-bottom: 0; background: transparent; }
  .pista-firma, .borrar-firma { display: none !important; }
}

/* Accesibilidad: respeta la preferencia de menos movimiento */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
