:root {
  --auth-navy-900: #0f1b2d;
  --auth-navy-800: #16273f;
  --auth-navy-700: #1e3352;
  --auth-blue-500: #258cfb;
  --auth-blue-600: #1672d6;
  --auth-bg: #f4f6fa;
  --auth-text: #1b2433;
  --auth-text-muted: #5b6576;
  --auth-border: #dde3ec;
  --auth-danger: #c0392b;
  --auth-radius-card: 16px;
}

/* 1.3.0 Tema oscuro en las páginas de acceso (tokens de tema.css). El panel de marca conserva su degradado oscuro. */
[data-bs-theme="dark"] {
  --auth-bg: var(--c-page);
  --auth-text: var(--c-text);
  --auth-text-muted: var(--c-text-muted);
  --auth-border: var(--c-border-strong);
  --auth-danger: var(--c-danger-text);
}
[data-bs-theme="dark"] .auth-card h1, [data-bs-theme="dark"] .auth-mobile-brand .auth-brand-name { color: var(--c-text); }
/* El azul sólido de los botones se conserva (texto blanco); solo los enlaces y marcas de texto se aclaran. */
[data-bs-theme="dark"] .auth-link, [data-bs-theme="dark"] .auth-card a:not(.btn):not(.auth-submit):not(.auth-metodo), [data-bs-theme="dark"] .auth-help button,
[data-bs-theme="dark"] .password-toggle:hover, [data-bs-theme="dark"] .auth-mobile-brand .auth-brand-mark svg { color: var(--c-accent-text); }

html, body.auth-body {
  height: 100%;
}

body.auth-body {
  margin: 0;
  background: var(--auth-bg);
  color: var(--auth-text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .auth-shell {
    flex-direction: row;
  }
}

/* ---- Panel izquierdo / institucional ---- */
.auth-visual {
  display: none;
  position: relative;
  color: #fff;
  background:
    radial-gradient(1200px 600px at -10% -10%, rgba(37, 140, 251, 0.35), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(37, 140, 251, 0.25), transparent 55%),
    linear-gradient(160deg, var(--auth-navy-900), var(--auth-navy-700));
  padding: 3rem 2.5rem;
  overflow: hidden;
}

@media (min-width: 768px) {
  .auth-visual {
    display: flex;
    align-items: center;
    flex: 0 0 40%;
  }
}

@media (min-width: 992px) {
  .auth-visual {
    flex: 0 0 52%;
    padding: 4rem;
  }
}

.auth-visual-content {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.75rem;
}

.auth-brand-mark {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-brand-mark svg {
  width: 26px;
  height: 26px;
  color: #fff;
}

.auth-brand-name {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
}

.auth-tagline {
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 1rem;
}

.auth-message {
  color: rgba(255, 255, 255, 0.78);
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 2.25rem;
}

.auth-departments {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .85rem;
}

@media (max-width: 991.98px) {
  .auth-departments,
  .auth-message {
    display: none;
  }
}

.auth-dept {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  text-align: center;
  padding: .75rem .25rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.auth-dept svg {
  width: 20px;
  height: 20px;
  color: #cfe3ff;
}

.auth-dept span {
  font-size: .7rem;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.15;
}

/* ---- Panel derecho / formulario ---- */
.auth-form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1rem;
}

.auth-mobile-brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  justify-content: center;
  margin-bottom: 1.75rem;
}

.auth-mobile-brand .auth-brand-mark {
  width: 40px;
  height: 40px;
  background: rgba(37, 140, 251, 0.12);
}

.auth-mobile-brand .auth-brand-mark svg {
  color: var(--auth-blue-600);
}

.auth-mobile-brand .auth-brand-name {
  color: var(--auth-navy-900);
  font-size: 1.1rem;
}

@media (min-width: 768px) {
  .auth-mobile-brand {
    display: none;
  }
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--c-surface);
  border-radius: var(--auth-radius-card);
  box-shadow: 0 10px 40px rgba(15, 27, 45, 0.08), 0 2px 8px rgba(15, 27, 45, 0.06);
  padding: 2.25rem 2rem;
}

@media (max-width: 400px) {
  .auth-card {
    padding: 1.75rem 1.25rem;
  }
}

.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: .35rem;
  color: var(--auth-navy-900);
}

.auth-card-subtitle {
  color: var(--auth-text-muted);
  font-size: .9rem;
  margin-bottom: 1.5rem;
}

.auth-field {
  margin-bottom: 1.1rem;
}

.auth-field label {
  display: block;
  font-weight: 600;
  font-size: .85rem;
  margin-bottom: .4rem;
  color: var(--auth-text);
}

.auth-input-group {
  position: relative;
  display: flex;
  align-items: stretch;
  border: 1px solid var(--auth-border);
  border-radius: 10px;
  background: var(--c-surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.auth-input-group:focus-within {
  border-color: var(--auth-blue-500);
  box-shadow: 0 0 0 3px rgba(37, 140, 251, 0.18);
}

.auth-input-group.is-invalid {
  border-color: var(--auth-danger);
}

.auth-input-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  flex-shrink: 0;
  color: var(--auth-text-muted);
}

.auth-input-icon svg {
  width: 18px;
  height: 18px;
}

.auth-input-group input {
  border: none;
  outline: none;
  flex: 1;
  min-width: 0;
  padding: .7rem .25rem;
  font-size: .95rem;
  background: transparent;
  color: var(--auth-text);
}

/* Color de campo intencionalmente igual al de un input normal (no "deshabilitado"):
   fondo blanco, texto oscuro con buen contraste — evita el aspecto apagado señalado. */
.auth-input-group input::placeholder {
  color: var(--c-icon);
}

.password-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-height: 44px;
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--auth-text-muted);
  cursor: pointer;
  border-radius: 0 10px 10px 0;
}

/* Un solo control para mostrar la contraseña: Edge dibuja su propio botón nativo (::-ms-reveal) en todo
   input[type=password] con texto, que aparecía junto a .password-toggle ("dos ojos"). Se suprime SOLO donde
   existe el control propio; los demás campos de contraseña conservan el del navegador. */
.auth-input-group input::-ms-reveal,
.auth-input-group input::-ms-clear {
  display: none;
}

.password-toggle:hover {
  color: var(--auth-blue-600);
}

.password-toggle:focus-visible {
  outline: 2px solid var(--auth-blue-500);
  outline-offset: -2px;
}

.password-toggle svg {
  width: 18px;
  height: 18px;
}

.auth-field-error {
  display: block;
  color: var(--auth-danger);
  font-size: .8rem;
  margin-top: .4rem;
}

.auth-summary-error {
  display: flex;
  gap: .6rem;
  align-items: flex-start;
  background: var(--c-surface-3);
  border: 1px solid var(--c-danger-border);
  color: var(--auth-danger);
  border-radius: 10px;
  padding: .75rem .9rem;
  font-size: .875rem;
  margin-bottom: 1.25rem;
}

.auth-row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.35rem;
}

.auth-check {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-height: 44px;
  cursor: pointer;
}

.auth-check input {
  width: 1.1rem;
  height: 1.1rem;
  cursor: pointer;
}

.auth-check span {
  font-size: .875rem;
  color: var(--auth-text);
}

.auth-link {
  /* Es un <button> con aspecto de enlace: sin el fondo gris por defecto del navegador (#efefef), que bajaba el
     contraste del texto a 4,13:1 (WCAG 1.4.3, detectado por axe en 1.0.2). */
  background: none;
  border: 0;
  padding: 0;
  font-size: .85rem;
  color: var(--auth-blue-600);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.auth-link:hover,
.auth-link:focus-visible {
  text-decoration: underline;
}

.auth-submit {
  width: 100%;
  min-height: 46px;
  border: none;
  border-radius: 10px;
  background: var(--auth-blue-600);
  color: #fff;
  font-weight: 600;
  font-size: .95rem;
  padding: .7rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  transition: background-color .15s ease;
}

.auth-submit:hover:not(:disabled) {
  background: #125bb0;
}

.auth-submit:focus-visible {
  outline: 3px solid rgba(37, 140, 251, 0.5);
  outline-offset: 2px;
}

.auth-submit:disabled {
  opacity: .85;
  cursor: progress;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1.1rem 0;
  color: var(--auth-text-muted);
  font-size: .78rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--auth-border);
}

.auth-entra-btn {
  width: 100%;
  min-height: 46px;
  border: 1.5px solid var(--auth-border);
  border-radius: 10px;
  background: var(--c-surface);
  color: var(--c-text);
  font-weight: 600;
  font-size: .88rem;
  padding: .7rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease;
}

.auth-entra-btn:hover,
.auth-entra-btn:focus-visible {
  background: var(--c-surface-2);
  border-color: var(--c-border-strong);
  color: var(--c-text);
}

.auth-entra-btn:focus-visible {
  outline: 3px solid rgba(37, 140, 251, 0.5);
  outline-offset: 2px;
}

.auth-help {
  text-align: center;
  margin-top: 1.5rem;
  font-size: .85rem;
  color: var(--auth-text-muted);
}

.auth-help button {
  background: none;
  border: none;
  padding: 0;
  color: var(--auth-blue-600);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}

.auth-help button:hover,
.auth-help button:focus-visible {
  text-decoration: underline;
}

/* 1.1.1 — ayuda bajo una opción del formulario («Recordar este equipo»). */
.auth-field-hint { display: block; margin-top: .3rem; padding-left: 1.6rem; font-size: .8rem; line-height: 1.4; color: var(--c-text-muted); }

/* 1.1.1 — aviso de versión nueva de la PWA también en las páginas de inicio de sesión. */
.pwa-aviso { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 1060;
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; max-width: min(28rem, calc(100vw - 32px));
  padding: .75rem .9rem; background: var(--c-surface); border: 1px solid var(--c-border); border-left: 4px solid var(--c-accent); border-radius: 8px;
  box-shadow: 0 10px 28px rgba(15, 27, 45, .18); font-size: .9rem; color: var(--c-text); }
.pwa-aviso[hidden] { display: none; }
.pwa-aviso-texto { flex: 1 1 14rem; }
@media (max-width: 575.98px) { .pwa-aviso { left: 12px; right: 12px; max-width: none; } }

/* 1.3.3 — Selector «Cuenta institucional (Microsoft)» / «Cuenta local» (enlaces: funciona sin JavaScript). */
.auth-metodos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  margin-bottom: 1.25rem;
  border: 1px solid var(--auth-border);
  border-radius: 12px;
  background: var(--auth-bg);
}
.auth-metodo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: .45rem .5rem;
  border-radius: 8px;
  color: var(--auth-text);
  text-align: center;
  text-decoration: none;
  line-height: 1.2;
}
.auth-metodo:hover { background: var(--c-surface-2, #eef2f7); color: var(--auth-text); }
.auth-metodo:focus-visible { outline: 3px solid rgba(37, 140, 251, 0.5); outline-offset: 2px; }
.auth-metodo.is-activo {
  background: var(--c-surface, #fff);
  box-shadow: 0 1px 3px rgba(15, 27, 45, .14);
  font-weight: 600;
}
.auth-metodo-titulo { font-size: .92rem; }
.auth-metodo-detalle { font-size: .78rem; color: var(--auth-text-muted); font-weight: 400; }

.auth-microsoft-texto { color: var(--auth-text-muted); font-size: .9rem; margin-bottom: 1rem; }
a.auth-submit.auth-microsoft-btn,
a.auth-submit.auth-microsoft-btn:hover,
a.auth-submit.auth-microsoft-btn:focus-visible { color: #fff; text-decoration: none; }
.auth-microsoft-alterna { margin: 1rem 0 0; font-size: .85rem; color: var(--auth-text-muted); text-align: center; }
/* Enlace dentro de un texto: subrayado (WCAG 1.4.1, no solo el color). */
.auth-microsoft-alterna .auth-link { text-decoration: underline; text-underline-offset: 2px; }
