:root {
  /* Paleta institucional compartida con SICAI. */
  --fondo: #f6f2f3;
  --superficie: #ffffff;
  --campo-fondo: #f7f3f4;
  --texto: #1a1216;
  --texto-suave: #6b5b62;
  --borde: #dccfd4;
  --marca: #691b32;
  --marca-hover: #4a1223;
  --marca-profunda: #1f0610;
  --marca-tenue: rgba(105, 27, 50, 0.1);
  --dorado: #bc955c;
  --sobre-marca: #ffffff;
  --sobre-marca-suave: #e6c894;
  --error: #b42318;
  --error-fondo: #fef2f2;
  --error-borde: #fecaca;
  --foco: #691b32;
  --foco-sobre-marca: #e6c894;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font-family: "Manrope", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, p { margin: 0; }

:focus-visible {
  outline: 3px solid var(--foco);
  outline-offset: 2px;
}

/* Login */
.login {
  display: flex;
  min-height: 100vh;
}

.login-marca {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  flex: 1.1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 48px;
  border-radius: 0 48px 48px 0;
  background: linear-gradient(150deg, var(--marca-profunda) 0%, var(--marca-hover) 40%, var(--marca) 100%);
  color: var(--sobre-marca);
}

.anillo {
  position: absolute;
  z-index: -1;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  pointer-events: none;
}

.anillo-1 { top: -180px; left: -160px; width: 520px; height: 520px; }
.anillo-2 { right: -100px; bottom: -140px; width: 380px; height: 380px; border-color: rgba(188, 149, 92, 0.18); }
.anillo-3 { right: 90px; bottom: 70px; width: 180px; height: 180px; }

.login-identidad {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  animation: aparecer 0.8s ease both;
}

.login-marca h1 {
  font-size: clamp(64px, 9vw, 128px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}

.login-divisor {
  width: 72px;
  height: 3px;
  margin: 24px 0 20px;
  border-radius: 999px;
  background: var(--dorado);
}

.login-nombre {
  max-width: 30ch;
  color: var(--sobre-marca-suave);
  font-size: clamp(17px, 1.6vw, 22px);
  font-weight: 600;
  line-height: 1.35;
}

.login-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background:
    radial-gradient(circle at 100% 0%, rgba(105, 27, 50, 0.07) 0%, transparent 40%),
    radial-gradient(circle at 0% 100%, rgba(188, 149, 92, 0.08) 0%, transparent 40%),
    var(--fondo);
}

.tarjeta {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 430px;
  border: 1px solid rgba(105, 27, 50, 0.06);
  border-radius: 24px;
  background: var(--superficie);
  box-shadow: 0 1px 2px rgba(26, 18, 22, 0.04), 0 24px 60px -20px rgba(74, 18, 35, 0.22);
  animation: subir 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.tarjeta::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--marca-hover), var(--marca), var(--dorado));
}

.formulario { padding: 48px 40px 40px; }

.formulario-encabezado {
  margin-bottom: 28px;
  text-align: center;
}

.formulario-encabezado h2 {
  margin-bottom: 6px;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.formulario-encabezado p {
  color: var(--texto-suave);
  font-size: 0.88rem;
  font-weight: 500;
}

.campo {
  position: relative;
  margin-bottom: 16px;
}

.campo input {
  width: 100%;
  height: 58px;
  padding: 24px 46px 8px 48px;
  border: 1.5px solid var(--borde);
  border-radius: 14px;
  background: var(--campo-fondo);
  color: var(--texto);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.campo input::placeholder { color: transparent; }
.campo input:not(:placeholder-shown) { background: var(--superficie); }

.campo input:focus,
.campo input:focus-visible {
  border-color: var(--marca);
  outline: none;
  background: var(--superficie);
  box-shadow: 0 0 0 4px var(--marca-tenue);
}

.campo-etiqueta {
  position: absolute;
  top: 18px;
  left: 48px;
  color: var(--texto-suave);
  font-size: 0.92rem;
  font-weight: 500;
  pointer-events: none;
  transform-origin: left top;
  transition: transform 0.16s ease, top 0.16s ease, color 0.16s ease;
}

.campo input:focus ~ .campo-etiqueta,
.campo input:not(:placeholder-shown) ~ .campo-etiqueta {
  top: 9px;
  font-weight: 700;
  transform: scale(0.74);
}

.campo input:-webkit-autofill ~ .campo-etiqueta {
  top: 9px;
  font-weight: 700;
  transform: scale(0.74);
}

.campo input:focus ~ .campo-etiqueta,
.campo input:focus ~ .campo-icono { color: var(--marca); }

.campo-icono,
.boton-ojo svg,
.boton-flecha {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.campo-icono {
  position: absolute;
  top: 19px;
  left: 16px;
  width: 20px;
  height: 20px;
  color: var(--texto-suave);
  pointer-events: none;
  transition: color 0.2s;
}

.boton-ojo {
  position: absolute;
  top: 11px;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--texto-suave);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.boton-ojo svg { width: 20px; height: 20px; }
.boton-ojo:hover { background: var(--marca-tenue); color: var(--marca); }

.boton-primario {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 54px;
  margin-top: 8px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--marca) 0%, var(--marca-hover) 100%);
  box-shadow: 0 14px 28px -10px rgba(105, 27, 50, 0.6);
  color: var(--sobre-marca);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.boton-primario:hover:not(:disabled) {
  box-shadow: 0 18px 34px -10px rgba(105, 27, 50, 0.7);
  transform: translateY(-1px);
}

.boton-primario:active:not(:disabled) { transform: translateY(0); }
.boton-primario:disabled { opacity: 0.7; cursor: progress; }

.boton-flecha {
  width: 18px;
  height: 18px;
  transition: transform 0.2s ease;
}

.boton-primario:hover:not(:disabled) .boton-flecha { transform: translateX(4px); }

.boton-giro {
  display: none;
  width: 17px;
  height: 17px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: var(--sobre-marca);
  border-radius: 50%;
  animation: girar 0.7s linear infinite;
}

.cargando .boton-flecha { display: none; }
.cargando .boton-giro { display: block; }

.mensaje-error {
  margin-bottom: 16px;
  padding: 10px 14px;
  border: 1px solid var(--error-borde);
  border-radius: 12px;
  background: var(--error-fondo);
  color: var(--error);
  font-size: 0.84rem;
  animation: sacudir 0.35s ease;
}

@keyframes subir {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes aparecer {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes sacudir {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

@keyframes girar { to { transform: rotate(360deg); } }

@media (max-width: 992px) {
  .login { flex-direction: column; }

  .login-marca {
    flex: none;
    padding: 32px 24px;
    border-radius: 0 0 36px 36px;
  }

  .login-divisor { margin: 16px 0 12px; }
  .login-panel { flex: 1; padding: 32px 16px 40px; }
}

@media (max-width: 480px) {
  .formulario { padding: 40px 22px 28px; }
  .formulario-encabezado h2 { font-size: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
