* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #e0f2fe 0%, #f0f9ff 40%, #dbeafe 100%);
    /* Solo se recorta en horizontal: en pantallas bajas el formulario debe poder desplazarse */
    overflow-x: hidden;
}

/* Bolitas decorativas de fondo (fijas, no agrandan la página) */
body::before,
body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.5;
    z-index: 0;
    pointer-events: none;
}

body::before {
    width: 320px;
    height: 320px;
    background: #93c5fd;
    top: -80px;
    left: -80px;
}

body::after {
    width: 280px;
    height: 280px;
    background: #60a5fa;
    bottom: -60px;
    right: -40px;
}

.container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    margin: auto; /* centra sin cortar arriba cuando es más alto que la pantalla */
    padding: 2.4rem 2rem;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 20px 50px rgba(37, 99, 235, 0.12),
                0 8px 20px rgba(0, 0, 0, 0.06);
    animation: fadeIn 0.5s ease;
}

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

.logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 1.2rem;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
}

.logo svg {
    width: 28px;
    height: 28px;
    fill: white;
}

h1 {
    margin-bottom: 0.4rem;
    color: #1e293b;
    text-align: center;
    font-size: 1.55rem;
    font-weight: 700;
}

.subtitle {
    margin-bottom: 1.5rem;
    color: #64748b;
    text-align: center;
    font-size: 0.9rem;
    line-height: 1.4;
    overflow-wrap: anywhere; /* correos largos en el paso 2 */
}

.subtitle strong {
    color: #334155;
}

.form-group {
    margin-bottom: 1.15rem;
}

label {
    display: block;
    margin-bottom: 0.35rem;
    color: #334155;
    font-weight: 600;
    font-size: 0.9rem;
}

input[type="email"],
input[type="password"],
input[type="text"] {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem; /* 16px: evita que iPhone haga zoom al escribir */
    background: #f8fafc;
    color: #1e293b;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input::placeholder {
    color: #94a3b8;
}

input:focus {
    border-color: #2563eb;
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

/* Código de 6 dígitos */
.code-input {
    text-align: center;
    font-size: 1.4rem !important;
    font-weight: 700;
    letter-spacing: 0.5em;
    font-variant-numeric: tabular-nums;
}

.code-input::placeholder {
    letter-spacing: 0.5em;
}

/* Campo de contraseña con botón Ver/Ocultar */
.password-field {
    position: relative;
}

.password-field input {
    padding-right: 5rem;
}

.toggle-password {
    position: absolute;
    top: 50%;
    right: 0.5rem;
    transform: translateY(-50%);
    padding: 0.35rem 0.6rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #2563eb;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

.toggle-password:hover {
    background: #eff6ff;
}

/* Botón principal */
.btn-primary {
    width: 100%;
    margin-top: 0.6rem;
    padding: 0.9rem;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #ffffff;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(37, 99, 235, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: wait;
    box-shadow: none;
}

/* Botones con aspecto de enlace */
.link-button {
    padding: 0;
    border: none;
    background: none;
    color: #2563eb;
    font: inherit;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s;
}

.link-button:hover:not(:disabled) {
    color: #1d4ed8;
    text-decoration: underline;
}

.link-button:disabled {
    color: #94a3b8;
    cursor: default;
}

/* Foco visible al navegar con teclado */
button:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.45);
    outline-offset: 2px;
}

.message {
    display: none;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
}

.message.error {
    display: block;
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #b91c1c;
}

.message.success {
    display: block;
    border: 1px solid #bbf7d0;
    background: #f0fdf4;
    color: #15803d;
}

.strength-warning {
    display: none;
    margin-top: 0.4rem;
    font-size: 0.82rem;
    font-weight: 600;
}

.strength-warning.visible {
    display: block;
}

.strength-warning.weak {
    color: #b91c1c;
}

.strength-warning.medium {
    color: #b45309;
}

.strength-warning.strong {
    color: #15803d;
}

.hidden {
    display: none !important;
}

.footer-note {
    margin-top: 1.6rem;
    text-align: center;
    font-size: 0.8rem;
    color: #64748b;
}

/* ===== Olvidé mi contraseña ===== */
.forgot-link {
    display: block;
    margin: 1.1rem auto 0;
    font-size: 0.92rem;
}

/* ===== Reenviar código ===== */
.resend {
    margin-top: 1.2rem;
    text-align: center;
    color: #64748b;
    font-size: 0.86rem;
    line-height: 1.5;
}

.resend .link-button {
    font-size: inherit;
}

/* ===== Volver / Salir ===== */
.back-link {
    display: inline-block;
    margin-bottom: 1.2rem;
    color: #64748b;
    font-size: 0.88rem;
}

.back-link:hover:not(:disabled) {
    color: #2563eb;
}

.logout-link {
    display: block;
    margin: 1.2rem 0 0;
    text-align: center;
}

/* ===== Pasos ===== */
.steps {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.4rem;
    list-style: none;
}

.step {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #64748b;
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Verde oscuro: el blanco sobre #22c55e no se lee (2.3:1); sobre #15803d da 5:1 */
.step.active,
.step.done {
    background: #15803d;
    color: #fff;
}

.step-line {
    width: 48px;
    height: 3px;
    background: #e2e8f0;
}

.step-line.done {
    background: #15803d;
}

/* ===== Pantallas chicas ===== */
@media (max-width: 420px) {
    body {
        padding: 12px;
    }

    .container {
        padding: 1.8rem 1.25rem;
        border-radius: 16px;
    }
}

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