:root {
  --fondo: #f4f7fb;
  --superficie: #ffffff;
  --tinta: #0f1b3d;
  --tenue: #5b6782;
  --linea: #d9e1ec;
  --campo: #f7f9fc;
  --marino: #213a86;
  --marino-hondo: #0f1f52;
  --turquesa: #2a9d8f;
  --acento: #2a9d8f;
  --primario: linear-gradient(135deg, #213a86, #2c56b8);
  --anillo: rgba(42, 157, 143, .25);
  --exito: #1f9d6f;
  --error: #c62828;
  --sombra: 0 1px 2px rgba(15, 27, 61, .04), 0 12px 32px -12px rgba(15, 27, 61, .18);
  --marca: linear-gradient(160deg, #213a86 0%, #0f1f52 70%);
  --halo: radial-gradient(60% 40% at 100% 0%, rgba(42, 157, 143, .10), transparent 70%), radial-gradient(50% 40% at 0% 100%, rgba(33, 58, 134, .10), transparent 70%);
  --logo-fondo: transparent;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --fondo: #000000;
  --superficie: #0a0a0b;
  --tinta: #f3f5f9;
  --tenue: #a3a9b6;
  --linea: #26262b;
  --campo: #121214;
  --acento: #4fd1bf;
  --primario: linear-gradient(135deg, #1f8a7d, #2d5bc4);
  --anillo: rgba(79, 209, 191, .28);
  --exito: #4fd1a1;
  --error: #ff7b78;
  --sombra: 0 0 0 1px rgba(255, 255, 255, .02), 0 24px 48px -20px rgba(0, 0, 0, .9);
  --marca: radial-gradient(70% 60% at 20% 10%, rgba(33, 58, 134, .55), transparent 70%), radial-gradient(60% 50% at 90% 90%, rgba(42, 157, 143, .25), transparent 70%), #000000;
  --halo: radial-gradient(50% 35% at 100% 0%, rgba(79, 209, 191, .07), transparent 70%);
  --logo-fondo: #f3f5f9;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  min-height: 100dvh;
  background: var(--fondo);
  color: var(--tinta);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
}

h1, h2, p { margin: 0; }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.escena { display: grid; min-height: 100dvh; }

.marca { display: none; }

.panel-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: clamp(8px, 2vh, 20px);
  min-height: 100dvh;
  padding: clamp(10px, 2vh, 24px) 16px max(clamp(10px, 2vh, 20px), env(safe-area-inset-bottom));
  background: var(--halo);
}

.barra {
  width: 100%;
  max-width: 400px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sello { font-weight: 700; font-size: 13px; letter-spacing: .22em; }

.tema {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--linea);
  background: var(--superficie);
  color: var(--tenue);
  cursor: pointer;
  transition: color .2s ease, transform .3s ease;
}

.tema:hover { color: var(--tinta); transform: rotate(-15deg); }
.tema:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--anillo); }
.tema svg { grid-area: 1 / 1; transition: opacity .25s ease, transform .35s ease; }
.tema-luna { opacity: 0; transform: scale(.6) rotate(-40deg); }
:root[data-theme="dark"] .tema-sol { opacity: 0; transform: scale(.6) rotate(40deg); }
:root[data-theme="dark"] .tema-luna { opacity: 1; transform: none; }

.tarjeta {
  width: 100%;
  max-width: 400px;
  padding: clamp(18px, 3.6vh, 34px) clamp(18px, 5vw, 30px);
  background: var(--superficie);
  border: 1px solid var(--linea);
  border-radius: 20px;
  box-shadow: var(--sombra);
  text-align: center;
  animation: entra .6s cubic-bezier(.2, .8, .2, 1) both;
  transition: background-color .3s ease, border-color .3s ease;
}

.logo {
  width: clamp(52px, 9vh, 80px);
  height: clamp(52px, 9vh, 80px);
  margin: 0 auto clamp(8px, 1.6vh, 14px);
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--logo-fondo);
}

.logo img { width: 78%; height: auto; }

.tarjeta h1 { font-size: clamp(20px, 3.2vh, 24px); font-weight: 700; letter-spacing: -.01em; }

.sub { margin-top: 2px; color: var(--tenue); font-size: 14px; }

.form { display: grid; gap: clamp(10px, 1.8vh, 14px); margin-top: clamp(14px, 2.6vh, 22px); text-align: left; }

.campo { display: grid; gap: 6px; }

.etiqueta { font-size: 13px; font-weight: 600; color: var(--tinta); opacity: .85; }

.caja { position: relative; display: block; }

.caja input {
  width: 100%;
  height: clamp(44px, 6.2vh, 50px);
  padding: 0 14px 0 42px;
  font: inherit;
  font-size: 16px;
  color: var(--tinta);
  background: var(--campo);
  border: 1px solid var(--linea);
  border-radius: 12px;
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}

.caja input[name="clave"] { padding-right: 48px; }
.caja input::placeholder { color: var(--tenue); opacity: .9; }
.caja input:focus { outline: none; border-color: var(--acento); box-shadow: 0 0 0 4px var(--anillo); }
.caja input[aria-invalid="true"] { border-color: var(--error); }

.flecha {
  position: absolute;
  top: 50%;
  left: 14px;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  color: var(--tenue);
  pointer-events: none;
  transition: color .2s ease, transform .2s ease;
}

.caja:focus-within .flecha { color: var(--acento); }
.caja:focus-within:has(input:placeholder-shown) .flecha { animation: empuja 1.1s ease-in-out infinite; }
.caja input:not(:placeholder-shown) { background: var(--superficie); }

.ver {
  position: absolute;
  top: 50%;
  right: 4px;
  width: 40px;
  height: 40px;
  margin-top: -20px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--tenue);
  cursor: pointer;
}

.ver:hover, .ver[aria-pressed="true"] { color: var(--acento); }
.ver:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--anillo); }

.boton {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: clamp(44px, 6.2vh, 50px);
  padding: 0 18px;
  font: inherit;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .15s ease, filter .2s ease, opacity .2s ease;
}

.boton:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--anillo); }

.primario {
  margin-top: 4px;
  border: 0;
  color: #fff;
  background: var(--primario);
  box-shadow: 0 10px 24px -12px rgba(33, 58, 134, .8);
}

.primario:hover { transform: translateY(-1px); filter: brightness(1.08); }
.primario:active { transform: none; }

.giro {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: gira .7s linear infinite;
}

.cargando { pointer-events: none; opacity: .85; }
.cargando .giro { display: block; }

.separador {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: clamp(10px, 2vh, 18px) 0;
  color: var(--tenue);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .14em;
}

.separador::before, .separador::after { content: ""; flex: 1; height: 1px; background: var(--linea); }

.google { border: 1px solid var(--linea); background: var(--superficie); color: var(--tinta); }
.google svg { stroke: none; }
.google:disabled { cursor: not-allowed; opacity: .55; }

.pronto {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--anillo);
}

.pie { font-size: 12px; color: var(--tenue); text-align: center; }

.sobretitulo { font-size: 12px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; }

.aviso {
  width: min(360px, calc(100% - 32px));
  padding: 28px 24px 22px;
  border: 1px solid var(--linea);
  border-radius: 22px;
  background: var(--superficie);
  color: var(--tinta);
  box-shadow: var(--sombra);
  text-align: center;
}

.aviso[open] { animation: aparece .35s cubic-bezier(.2, 1.2, .3, 1) both; }
.aviso::backdrop { background: rgba(0, 0, 0, .5); backdrop-filter: blur(4px); }
.aviso h2 { margin-top: 14px; font-size: 19px; font-weight: 700; }
.aviso p { margin-top: 6px; color: var(--tenue); font-size: 14px; }
.aviso form { margin: 20px 0 0; }

.aviso-icono {
  --tono: var(--exito);
  width: 72px;
  height: 72px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--tono);
  background: color-mix(in srgb, var(--tono) 14%, transparent);
}

.aviso-icono svg { width: 52px; height: 52px; stroke-width: 3.2; }
.aviso-icono circle { stroke-dasharray: 151; stroke-dashoffset: 151; animation: traza .5s .1s ease-out forwards; }
.aviso-icono path { stroke-dasharray: 48; stroke-dashoffset: 48; animation: traza .35s .5s ease-out forwards; }
.icono-error { display: none; }
.aviso.error .aviso-icono { --tono: var(--error); animation: vibra .4s .6s ease; }
.aviso.error .icono-exito { display: none; }
.aviso.error .icono-error { display: block; }

@media (max-height: 640px) {
  .sub, .pie { display: none; }
}

@media (max-height: 520px) {
  .logo, .separador, .google { display: none; }
  .barra { position: absolute; top: 8px; right: 16px; width: auto; }
  .sello { display: none; }
  .panel-form { justify-content: center; }
}

@media (min-width: 900px) {
  .escena { grid-template-columns: 1.1fr 1fr; }

  .marca {
    position: relative;
    display: flex;
    align-items: flex-end;
    padding: clamp(32px, 7vh, 64px);
    overflow: hidden;
    color: #fff;
    background: var(--marca);
  }

  .marca-texto { position: relative; max-width: 440px; animation: entra .8s .1s cubic-bezier(.2, .8, .2, 1) both; }
  .marca-texto .sobretitulo { color: #7fd6c9; }
  .marca-texto h2 { margin-top: 14px; font-size: clamp(28px, 4.6vh, 38px); line-height: 1.15; letter-spacing: -.02em; }
  .marca-texto p:last-child { margin-top: 14px; color: rgba(255, 255, 255, .72); font-size: 16px; }

  .forma { position: absolute; display: block; animation: flota 12s ease-in-out infinite; }

  .f1 {
    top: 9%;
    left: 8%;
    width: 30%;
    aspect-ratio: 1.1;
    background: linear-gradient(160deg, rgba(42, 157, 143, .55), rgba(42, 157, 143, .12));
    clip-path: polygon(0 22%, 100% 0, 100% 100%, 0 100%);
  }

  .f2 {
    top: 4%;
    left: 34%;
    width: 32%;
    aspect-ratio: 1;
    border-radius: 50%;
    border: clamp(20px, 3vw, 36px) solid rgba(255, 255, 255, .10);
    border-top-color: transparent;
    animation-delay: -4s;
  }

  .f3 {
    top: 7%;
    right: -6%;
    width: 40%;
    aspect-ratio: 1.08;
    background: linear-gradient(200deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, .03));
    clip-path: polygon(0 0, 80% 0, 100% 100%, 8% 100%);
    animation-delay: -8s;
  }

  .panel-form { padding-left: 32px; padding-right: 32px; }
}

@keyframes entra { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes aparece { from { opacity: 0; transform: translateY(10px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes traza { to { stroke-dashoffset: 0; } }
@keyframes flota { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
@keyframes empuja { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(4px); } }
@keyframes gira { to { transform: rotate(360deg); } }
@keyframes vibra { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .aviso-icono circle, .aviso-icono path { stroke-dashoffset: 0; }
}
