:root {
  --primario: #293375;
  --acento: #00AAF8;
  --suave: #84A3D8;
  --dorado: #B07A2E;
  --fondo: #F3F3F5;
  --superficie: #FFFFFF;
  --texto: #14172B;
  --texto-suave: #4A5070;
  --borde: #D3D8E8;
  --error: #A4161A;
  --sobre-suave: #14172B;
  --sobre-error: #FFFFFF;
  --btn-fondo: #293375;
  --btn-fondo-hover: #1f285b;
  --sobre-btn: #FFFFFF;
  --radio: 8px;
}
:root:not([data-theme="light"]) { color-scheme: light dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primario: #9FB6F0;
    --acento: #4CC3FF;
    --suave: #26335E;
    --dorado: #E0A94F;
    --fondo: #0F1226;
    --superficie: #181C3A;
    --texto: #EEF0FA;
    --texto-suave: #AEB5D6;
    --borde: #2C3360;
    --error: #FF8A8A;
    --sobre-suave: #EEF0FA;
    --sobre-error: #14172B;
    --btn-fondo: #6C7FE8;
    --btn-fondo-hover: #8190EE;
    --sobre-btn: #0F1226;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, "Segoe UI", sans-serif; background: var(--fondo); color: var(--texto); line-height: 1.5; }
a { color: var(--primario); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }

.barra { background: #293375; color: #fff; display: flex; align-items: center; gap: 1rem; padding: .5rem 1rem; flex-wrap: wrap; }
.barra img { height: 40px; width: auto; border-radius: 4px; }
.barra .marca { font-weight: 600; margin-right: auto; display: flex; align-items: center; gap: .75rem; }
.barra nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.barra a, .barra button { color: #fff; text-decoration: none; padding: .5rem .75rem; border-radius: var(--radio); background: none; border: 0; font: inherit; cursor: pointer; }
.barra a:hover, .barra button:hover, .barra a:focus-visible, .barra button:focus-visible { background: rgba(255,255,255,.18); outline: 2px solid var(--acento); }
.barra .rol { font-size: .85rem; opacity: .85; }
.barra form { margin: 0; }

main { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.tarjeta { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); padding: 1.25rem; }
.publico { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: var(--fondo); }
.publico .tarjeta { width: 100%; max-width: 420px; }
.publico img.logo { display: block; margin: 0 auto 1rem; height: 90px; max-width: 100%; border-radius: 6px; }

label { display: block; margin: .75rem 0 .25rem; font-weight: 600; }
input, select, textarea { width: 100%; padding: .65rem .75rem; border: 1px solid var(--texto-suave); border-radius: var(--radio); background: var(--superficie); color: var(--texto); font: inherit; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible { outline: 3px solid var(--acento); outline-offset: 1px; }
.btn { display: inline-block; margin-top: 1rem; padding: .65rem 1.1rem; border: 0; border-radius: var(--radio); background: var(--btn-fondo); color: var(--sobre-btn); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--btn-fondo-hover); }
.btn.secundario { background: transparent; color: var(--primario); border: 1px solid var(--primario); }
.btn.peligro { background: var(--error); color: var(--sobre-error); }
.alerta { background: color-mix(in srgb, var(--error) 12%, var(--superficie)); border: 1px solid var(--error); color: var(--texto); border-radius: var(--radio); padding: .6rem .8rem; }
.alerta ul { margin: 0; padding-left: 1.1rem; }
.validation-summary-valid { display: none; }
.exito { background: color-mix(in srgb, var(--acento) 14%, var(--superficie)); border: 1px solid var(--acento); color: var(--texto); border-radius: var(--radio); padding: .6rem .8rem; }
.campo-error { color: var(--error); font-size: .9rem; }
.clave-otp, .clave-temp { font-family: ui-monospace, Consolas, monospace; font-size: 1.1rem; letter-spacing: .08em; overflow-wrap: anywhere; }
.codigos { font-family: ui-monospace, Consolas, monospace; columns: 2; }

.tabla-envoltura { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--superficie); }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--borde); }
th { background: var(--suave); color: var(--sobre-suave); font-size: .9rem; }
tr:hover td { background: color-mix(in srgb, var(--suave) 18%, var(--superficie)); }
.etiqueta { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; border: 1px solid var(--texto-suave); color: var(--texto-suave); }
.etiqueta.inactivo { border-color: var(--error); color: var(--error); }
.etiqueta.aviso { border-color: var(--dorado); color: var(--texto); }
.filtros { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; margin-bottom: 1rem; }
.acciones { display: flex; gap: .4rem; flex-wrap: wrap; }
.acciones form { margin: 0; }
/* En tablas la celda sigue siendo celda (no flex): botones apilados, del mismo ancho y centrados */
td.acciones { display: table-cell; vertical-align: middle; min-width: 11.5rem; }
td.acciones form, td.acciones > .btn { display: block; margin: 0 0 .4rem; }
td.acciones form:last-child, td.acciones > .btn:last-child { margin-bottom: 0; }
td.acciones .btn { display: block; width: 100%; text-align: center; box-sizing: border-box; }
.salir { margin-top: 1rem; }
.rompible { overflow-wrap: anywhere; }
.acciones .btn { margin: 0; padding: .3rem .6rem; font-size: .85rem; }

@media (max-width: 600px) {
  .barra { padding: .5rem; }
  .codigos { columns: 1; }
}

/* Código QR del autenticador: fondo blanco propio para que se lea también en modo oscuro */
.qr { display: block; margin: 1rem auto; width: 224px; max-width: 100%; height: auto; background: #fff; border: 8px solid #fff; border-radius: var(--radio); image-rendering: pixelated; }


/* Ficha del personal: secciones, lista de datos y notas */
.seccion { margin-bottom: 1rem; }
.seccion h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
.datos { display: grid; grid-template-columns: minmax(8rem, max-content) 1fr; gap: .35rem 1rem; margin: 0; }
.datos dt { font-weight: 600; color: var(--texto-suave); }
.datos dd { margin: 0; overflow-wrap: anywhere; }
/* Foto de la ficha (etapa 2d) */
.foto-ficha { display: block; width: 160px; max-width: 100%; height: auto; margin-bottom: .75rem; border: 1px solid var(--borde); border-radius: var(--radio); background: var(--superficie); }
.celda-miniatura { width: 48px; padding-right: 0; }
.miniatura { display: block; width: 48px; height: 48px; object-fit: cover; border: 1px solid var(--borde); border-radius: var(--radio); background: color-mix(in srgb, var(--suave) 25%, var(--superficie)); }
.nota { color: var(--texto-suave); font-size: .9rem; margin: .25rem 0 0; }
textarea { min-height: 6rem; resize: vertical; }
@media (max-width: 600px) {
  .datos { grid-template-columns: 1fr; gap: 0; }
  .datos dd { margin-bottom: .5rem; }
}

/* Entorno de pruebas para el cliente: banner fijo en todas las páginas, con los tokens del tema */
.banner-pruebas { position: sticky; top: 0; z-index: 10; margin: 0; padding: .5rem 1rem; text-align: center; font-weight: 600; background: color-mix(in srgb, var(--dorado) 22%, var(--superficie)); color: var(--texto); border-bottom: 2px solid var(--dorado); }

/* Comentarios del entorno de pruebas: el texto conserva sus saltos de linea y se parte en pantallas estrechas */
.texto-comentario { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 14rem; }
