:root {
  --site-font-base: sans-serif;
  --site-font-heading: sans-serif;
  --site-color-text: #fff;
  --site-color-border: rgba(255, 255, 255, 0.28);
  --site-color-secondary-text: rgba(255, 255, 255, 0.72);
  --site-bar-opacity: 0.82;
  --site-bar-blur: 12px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body.auth-page {
  --auth-transparency-rgb: 0, 0, 0;
  margin: 0;
  min-height: 100dvh;
  color: var(--site-color-text);
  background: var(--site-color-background);
  font-family: var(--site-font-base);
}

.auth-background {
  position: fixed;
  z-index: -2;
  inset: 0;
}

.auth-background::after {
  position: absolute;
  content: "";
  inset: 0;
  background: rgba(var(--auth-transparency-rgb), 0.38);
}

.auth-background img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.auth-shell {
  height: 100dvh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.auth-main {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1.25rem, 4vw, 3rem);
  overflow: hidden;
}

.auth-card {
  width: min(100%, 28.75rem);
  height: min(39.5rem, calc(100dvh - 9rem));
  min-height: 32rem;
  color: var(--site-color-background);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 1.25rem 3rem rgba(var(--site-color-background-rgb), 0.38);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.auth-card-inner {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(1.4rem, 4vw, 2rem) clamp(1rem, 4vw, 1.5rem);
  overflow: hidden;
  text-align: left;
}

.auth-registration-card {
  width: min(100%, 52rem);
  height: 100%;
  max-height: 46rem;
  min-height: 0;
}
.auth-registration-card .auth-card-inner {
  justify-content: flex-start;
  overflow-y: auto;
}
.auth-registration-card .auth-flow-header { margin-bottom: 1rem; }
.auth-registration-card .auth-flow-header p:last-child {
  max-width: 42rem;
  margin: .45rem auto 0;
  color: #5d6e82;
  font-size: .82rem;
  line-height: 1.4;
}
.auth-registration-card .standard-form-field:has(.g-recaptcha) {
  grid-column: 1 / -1;
}
.auth-registration-card .standard-form-field:has([name="cargo"]) {
  grid-column: 1 / -1;
}
.auth-registration-card .standard-form-field:has([name="username"]) {
  grid-column: 1 / -1;
}
.auth-registration-card .g-recaptcha { min-height: 4.9rem; }
.auth-registration-card .standard-form-actions {
  grid-column: 1 / -1;
  align-items: center;
  margin-top: .2rem;
}
.auth-registration-card .standard-form-actions .button {
  min-width: 9.5rem;
  min-height: 2.35rem;
  padding: .55rem .9rem;
  font-size: .82rem;
}

.auth-card-header { margin-bottom: 1.5rem; text-align: center; }
.auth-flow {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.85rem;
}
.auth-flow:has(> .auth-flow-form), .auth-flow:has(> .auth-flow-content) { height: 100%; min-height: 0; justify-content: flex-start; }
.auth-account-flow:has(> .auth-flow-content) { display: flex; align-items: stretch; justify-content: center; }

.auth-flow-header {
  margin: 0 0 0.35rem;
  text-align: center;
}

.auth-flow-header .auth-card-logo {
  display: none;
}
.auth-flow-header:not(.auth-login-header)::before {
  display: block;
  margin: 0 0 .35rem;
  color: var(--site-color-primary);
  content: "Acceso al sistema";
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-align: center;
  text-transform: uppercase;
}
.auth-flow-header h1 {
  color: var(--site-color-background);
  font-size: clamp(1.6rem, 4vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.05;
  text-align: center;
}
.auth-login-header h1 {
  color: var(--site-color-background);
  font-size: clamp(1.6rem, 4vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.05;
}
.auth-login-eyebrow {
  display: block;
  margin: 0 0 .35rem;
  color: var(--site-color-primary);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.auth-login-header { margin-bottom: .65rem; }
.auth-account-flow .auth-flow-header { width: 100%; text-align: center; }
.auth-account-flow .auth-flow-header h1 {
  margin-inline: auto;
  padding: 0;
  color: var(--site-color-background);
  font-size: clamp(1.6rem, 4vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.05;
  text-align: center;
}
.auth-flow-notice { width: 100%; margin: 0 0 0.35rem; }
.auth-login-error { width: 100%; margin-bottom: 0.15rem; }
.auth-flow > form { width: 100%; margin: 0; }
.auth-flow-form { min-height: 0; display: grid; flex: 1; grid-template-rows: minmax(0, 1fr) auto; gap: 1rem; }
.auth-flow-content { min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: .85rem; }
.auth-flow > .auth-flow-content { min-height: 0; align-self: stretch; }
.auth-account-flow:has(> .auth-flow-content) > .auth-flow-content { flex: 0 0 auto; }
.auth-account-flow:has(> .auth-flow-content) > .auth-flow-actions { padding-top: 0; border-top: 0; }
.auth-flow-actions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .65rem; padding-top: .85rem; border-top: 1px solid color-mix(in srgb, var(--site-color-primary) 16%, var(--border)); }
.auth-flow-actions .site-button { width: auto; min-width: 9.5rem; flex: 0 1 auto; }
.auth-flow-actions .site-button-primary { order: 2; }
.auth-flow-actions:has(> :nth-child(2)) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.auth-flow-actions:has(> :nth-child(2)) .site-button { width: 100%; min-width: 0; padding-inline: .7rem; font-size: .82rem; white-space: nowrap; }
.auth-flow-actions--backup:has(> :nth-child(2)) { grid-template-columns: minmax(0, .9fr) minmax(0, 1.25fr); }
.auth-card-logo {
  width: auto;
  height: 5.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  color: var(--site-color-primary);
}

.auth-card-logo .brand-lockup { gap: .9rem; padding: 0; }
.auth-card-logo .brand-logo-frame {
  width: 6.25rem;
  height: 4.5rem;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.auth-card-logo .brand-logo-frame img { padding: .15rem; }
.auth-card-logo .brand-lockup-separator { height: 2.8rem; color: var(--site-color-primary); opacity: .35; }

.auth-eyebrow {
  margin: 0 0 0.35rem;
  color: var(--site-color-accent);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.auth-card h1 {
  margin: 0;
  color: var(--site-color-background);
  font-family: var(--site-font-heading);
  font-size: clamp(1.55rem, 5vw, 1.95rem);
  font-weight: 400;
  line-height: 1.12;
}

.auth-card-header p:last-child { margin: 0.55rem 0 0; color: var(--site-color-secondary); font-size: 0.9rem; line-height: 1.45; }

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

.auth-setup-layout {
  gap: 0.7rem;
}

.auth-actions { display: flex; align-items: center; justify-content: center; flex-direction: row; flex-wrap: wrap; gap: 0.65rem; margin-top: 1.35rem; }
.auth-actions .site-button { width: auto; min-width: 9.5rem; flex: 0 1 auto; }
.auth-actions-stacked { flex-direction: column; }
.auth-actions-stacked .site-button { width: 100%; }
.auth-card .site-button-outline-primary {
  color: var(--site-color-primary);
  border-color: var(--site-color-primary);
}
.auth-link { display: block; margin-top: 0.9rem; color: var(--site-color-secondary); font-size: 0.82rem; text-align: center; text-decoration: none; }
.auth-link:hover { color: var(--site-color-accent); }
.auth-recovery-link { margin: 0.1rem 0 0.7rem; }
.auth-login-notice { margin: 0 0 .45rem !important; }
.auth-backup-form { margin-top: 0.75rem; text-align: center; }
.auth-text-button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0;
  color: var(--site-color-accent);
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}
.auth-text-button:hover { color: var(--site-color-secondary); transform: translateY(-1px); }
.auth-text-button:focus-visible { outline: 2px solid var(--site-color-accent); outline-offset: 0.25rem; }
.auth-alternatives { display: grid; gap: 0.55rem; margin-top: 1rem; }
.auth-form-message { position: static; margin-bottom: 1rem; box-shadow: none; }
.auth-card .system-notice { margin: 0 0 0.35rem; }
.auth-blocked-help { margin: 0; color: #5d6e82; font-size: .82rem; line-height: 1.45; text-align: center; }
.auth-denied-flow { gap: .7rem; }
.auth-denied-flow .auth-flow-content { justify-content: flex-start; gap: .65rem; overflow-y: auto; scrollbar-gutter: stable; }
.auth-permission-detail { padding: .7rem .75rem; border: 1px solid color-mix(in srgb, var(--site-color-primary) 20%, var(--border)); border-left: .22rem solid var(--site-color-primary); border-radius: .55rem; background: color-mix(in srgb, var(--site-color-primary) 4%, #fff); }
.auth-permission-detail > header { display: flex; align-items: center; gap: .55rem; }
.auth-permission-detail > header .bi { width: 1rem; height: 1rem; flex: 0 0 auto; color: var(--site-color-primary); fill: currentColor; }
.auth-permission-detail > header div { display: grid; gap: .05rem; }
.auth-permission-detail > header small { color: var(--site-color-primary); font-size: .62rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.auth-permission-detail > header strong { font-size: .82rem; }
.auth-permission-detail dl { margin: .5rem 0 0; }
.auth-permission-detail dl > div { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); gap: .5rem; padding: .38rem 0; border-bottom: 1px solid color-mix(in srgb, var(--site-color-primary) 12%, var(--border)); }
.auth-permission-detail dt { color: #5d6e82; font-size: .61rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.auth-permission-detail dd { margin: 0; font-size: .72rem; font-weight: 600; overflow-wrap: anywhere; }
.auth-permission-detail code { color: var(--site-color-primary); font: inherit; }
.auth-permission-detail > p { margin: .5rem 0 0; color: #5d6e82; font-size: .7rem; line-height: 1.35; }
.auth-denied-actions > form { display: contents; }
.auth-denied-actions .site-button .bi { width: 1rem; height: 1rem; fill: currentColor; }

.auth-card input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0 0.45rem 0 0;
  vertical-align: -0.15rem;
  accent-color: var(--site-color-primary);
  cursor: pointer;
}

.auth-card input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--site-color-accent);
  outline-offset: 2px;
  box-shadow: none;
}

.auth-qr { margin: 0; text-align: center; }
.auth-qr img { width: min(100%, 9.5rem); height: auto; padding: 0.35rem; background: #fff; }
.auth-secret-key {
  display: block;
  max-width: 100%;
  min-height: 2.35rem;
  margin: 0.55rem auto 0;
  padding: 0.6rem 0.75rem;
  overflow-wrap: anywhere;
  color: var(--site-color-background);
  background: #ececec;
  font-size: 0.76rem;
  line-height: 1.4;
  letter-spacing: .04em;
}
.backup-token-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.45rem; margin: 0; padding: 0; list-style: none; }
.backup-token-list li { padding: 0.55rem; border: 1px solid #d5dee7; border-radius: .45rem; text-align: center; background: #eef2f6; }
.backup-token-list code { color: var(--site-color-background); font-size: .82rem; }
.auth-backup-flow > form { margin: 0; }

.auth-security-layout { gap: 0.75rem; }

.auth-security-options {
  display: grid;
  gap: 0.65rem;
}

.auth-security-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.3rem 0.7rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid color-mix(in srgb, var(--site-color-primary) 18%, #dbe3eb);
  border-radius: 0.7rem;
  background: color-mix(in srgb, var(--site-color-primary) 5%, #fff);
}

.auth-security-option-icon {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  grid-row: 1;
  color: var(--site-color-primary);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0.25rem 0.65rem rgba(var(--site-color-background-rgb), 0.12);
}

.auth-security-option-icon .button-icon { width: 1rem; height: 1rem; }
.auth-security-option-copy { min-width: 0; }
.auth-security-option-copy h2 {
  margin: 0;
  color: var(--site-color-background);
  font-size: 0.92rem;
  line-height: 1.25;
}
.auth-security-option-copy p {
  margin: 0.15rem 0 0;
  color: #5d6e82;
  font-size: 0.76rem;
  line-height: 1.4;
}
.auth-security-option > .site-button {
  grid-column: 1 / -1;
  width: 100%;
  margin-top: 0.25rem;
}

.auth-security-option--danger {
  border-color: color-mix(in srgb, var(--message-danger-color) 24%, #e4e8ed);
  background: color-mix(in srgb, var(--message-danger-background) 42%, #fff);
}
.auth-security-option--danger .auth-security-option-icon { color: var(--message-danger-color); }

.auth-danger-action {
  color: #fff;
  border-color: var(--message-danger-color);
  background: var(--message-danger-color);
}
.auth-danger-action:hover { color: #fff; }

@media (max-width: 600px) {
  body.auth-page { overflow-y: auto; }
  .auth-shell {
    height: auto;
    min-height: 100svh;
  }
  .auth-main {
    min-height: min-content;
    align-items: flex-start;
    padding: 1rem;
    overflow: visible;
  }
  .auth-card {
    height: calc(100dvh - 8.5rem);
    height: calc(100svh - 8.5rem);
    min-height: 0;
  }
  .auth-card-inner { min-height: 0; padding: 1.25rem 0.85rem; }
  .auth-actions { align-items: stretch; flex-direction: row; }
  .auth-actions .site-button { width: auto; min-width: min(9.5rem, 100%); flex: 1 1 9.5rem; }
  .auth-flow-actions .site-button { width: auto; min-width: min(9.5rem, 100%); flex: 1 1 9.5rem; }
  .auth-flow-actions:has(> :nth-child(2)) .site-button { width: 100%; min-width: 0; gap: .3rem; padding-inline: .4rem; font-size: .74rem; }
  .backup-token-list { grid-template-columns: 1fr; }
}

@media (max-height: 720px) {
  .auth-card-inner:has(.auth-login-layout) { justify-content: flex-start; overflow-y: auto; }
}

/* Estados breves sin captura: la tarjeta se ajusta al contenido. */
.auth-card:has(.auth-account-flow > .auth-flow-content) { height: auto; min-height: 0; }
.auth-card:has(.auth-account-flow > .auth-flow-content) .auth-card-inner { height: auto; min-height: 0; padding-block: 1.75rem; }
.auth-card:has(.auth-account-flow > .auth-flow-content) .auth-account-flow { height: auto; min-height: 0; }

/* Todo el flujo 2FA crece con su contenido y sólo desplaza si rebasa el viewport. */
.auth-card:has(.auth-two-factor-flow) {
  height: auto;
  min-height: 0;
  max-height: calc(100dvh - 9rem);
}
.auth-card:has(.auth-two-factor-flow) .auth-card-inner {
  height: auto;
  min-height: 0;
  max-height: inherit;
  padding-block: 1.75rem;
  overflow-y: auto;
}
.auth-card:has(.auth-two-factor-flow) .auth-two-factor-flow {
  height: auto;
  min-height: 0;
}
