:root {
    --bg-1: #003a54;
    --bg-2: #005377;
    --bg-glow: #0a7aa8;
    --accent: #0095e8;
    --accent-hover: #0580c8;
    --ink: #14213d;
    --ink-soft: #5b6478;
    --line: #dde4ec;
    --field: #f4f7fa;
    --danger: #d92d20;
    --ok: #15803d;
    --radius: 14px;
    --radius-sm: 10px;
}

* {
    box-sizing: border-box;
}

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: Poppins, system-ui, -apple-system, "Segoe UI", Helvetica, sans-serif;
    color: var(--ink);
    background-color: var(--bg-2);
    background-image:
        radial-gradient(900px 500px at 15% -10%, var(--bg-glow) 0%, transparent 60%),
        radial-gradient(700px 500px at 100% 110%, rgba(0, 149, 232, .35) 0%, transparent 60%),
        linear-gradient(160deg, var(--bg-2) 0%, var(--bg-1) 100%);
    background-attachment: fixed;

    display: flex;
    flex-direction: column;
}

/* ---------- Layout ---------- */

main {
    flex: 1 0 auto;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    padding: 24px 16px;
}

#auth_wrapper {
    flex: 1 1 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

#auth_image {
    display: none;
}

#auth_logo {
    margin: 0 0 28px;
}
#auth_logo img {
    display: block;
    max-height: 48px;
}

/* ---------- Tarjeta ---------- */

#auth_card {
    width: 100%;
    max-width: 440px;
    padding: 40px 36px 32px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow:
        0 1px 2px rgba(0, 20, 40, .08),
        0 24px 60px -12px rgba(0, 20, 40, .45);
    animation: auth-enter .5s cubic-bezier(.2, .7, .2, 1) both;
}

#auth_card form {
    overflow-x: hidden;   /* necesario para el truco submit/loader */
    /* margen interno para que el focus ring no se recorte */
    margin: 0 -6px;
    padding: 0 6px;
}

#auth_card #auth_card_title {
    color: var(--ink);
    text-align: left;
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: -.02em;
    line-height: 1.2;
    margin-bottom: 1.75rem;
}

#auth_card .auth_form_row {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
}

#auth_card .auth_form_row label {
    color: var(--ink);
    font-weight: 500;
    font-size: .875rem;
    margin-bottom: .45rem;
}

#auth_card .auth_form_row input {
    width: 100%;
    appearance: none;
    outline: none;
    border: 1.5px solid transparent;
    background-color: var(--field);
    color: var(--ink);
    padding: .85rem 1rem;
    font: inherit;
    font-size: 1rem;           /* >=16px evita el zoom en iOS */
    border-radius: var(--radius-sm);
    transition: border-color .2s ease, background-color .2s ease, box-shadow .2s ease;
}

#auth_card .auth_form_row input:hover {
    border-color: var(--line);
}

#auth_card .auth_form_row input:focus {
    background-color: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(0, 149, 232, .15);
}

#auth_card #auth_password_remember {
    margin-left: auto;
    margin-top: 8px;
    font-size: .85rem;
    color: var(--accent);
    cursor: pointer;
    border-radius: 4px;
    transition: color .2s ease;
}
#auth_card #auth_password_remember:hover {
    color: var(--accent-hover);
    text-decoration: underline;
    text-underline-offset: 3px;
}
#auth_card #auth_password_remember:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

#auth_card #auth_message {
    margin: 4px 0 14px;
    min-height: 40px;
    color: var(--danger);
    text-align: center;
    font-size: .8rem;
    line-height: 1.4;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Botón + loader (se mantiene el mecanismo de 200% de ancho) */
#auth_card #auth_submit_loader {
    width: 200%;
    display: flex;
    align-items: center;
    margin-bottom: 6px;
}
#auth_card #auth_submit_loader #auth_submit {
    flex-basis: 50%;
    padding: 13px 24px;
    color: #fff;
    border: none;
    background-color: var(--accent);
    font-size: 1rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    outline: none;
    text-align: center;
    user-select: none;
    box-shadow: 0 6px 16px -6px rgba(0, 149, 232, .7);
    transition: background-color .2s ease, box-shadow .2s ease, transform .1s ease;
}
#auth_card #auth_submit_loader #auth_submit:hover {
    background-color: var(--accent-hover);
    box-shadow: 0 8px 20px -6px rgba(0, 149, 232, .8);
}
#auth_card #auth_submit_loader #auth_submit:active {
    transform: translateY(1px);
}
#auth_card #auth_submit_loader #auth_loader {
    flex-basis: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
#auth_card #auth_submit_loader #auth_loader .loader {
    margin: 0 auto;
    font-size: 6px;
}

/* ---------- "Desarrollado por" y footer ---------- */

#auth_developedby {
    margin-top: 48px;
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    row-gap: 6px;
}
#auth_developedby span {
    color: rgba(255, 255, 255, .7);
    font-size: .7rem;
}
#auth_developedby img {
    max-height: 32px;
}

footer {
    flex-shrink: 0;
    padding: 1rem 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .18);
    border-top: 1px solid rgba(255, 255, 255, .08);
}
footer #footer_copyright {
    font-size: .8rem;
    color: rgba(255, 255, 255, .7);
}
footer #footer_copyright a {
    color: inherit;
    text-decoration: none;
    transition: color .2s ease;
}
footer #footer_copyright a:hover {
    color: #fff;
}

/* ---------- Recuperar contraseña (popup) ---------- */

#auth_recovery_overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 20, 35, .6);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#auth_recovery_overlay.active {
    display: flex;
}

#auth_recovery_popup {
    position: relative;
    width: 100%;
    max-width: 420px;
    padding: 32px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 24px 60px -12px rgba(0, 20, 40, .5);
    font-family: inherit;
    animation: auth-enter .25s ease both;
}

#auth_recovery_popup h2 {
    margin: 0 36px 10px 0;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -.01em;
    color: var(--ink);
}

#auth_recovery_popup p {
    margin: 0 0 20px;
    font-size: .9rem;
    line-height: 1.6;
    color: var(--ink-soft);
}

#auth_recovery_popup .auth_form_row {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
}
#auth_recovery_popup .auth_form_row label {
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: .45rem;
    color: var(--ink);
}
#auth_recovery_popup .auth_form_row input {
    width: 100%;
    appearance: none;
    outline: none;
    border: 1.5px solid transparent;
    background: var(--field);
    color: var(--ink);
    padding: .85rem 1rem;
    font: inherit;
    font-size: 1rem;
    border-radius: var(--radius-sm);
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
#auth_recovery_popup .auth_form_row input:focus {
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(0, 149, 232, .15);
}

#auth_recovery_close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: none;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    color: var(--ink-soft);
    transition: background-color .2s ease, color .2s ease;
}
#auth_recovery_close:hover {
    background: var(--field);
    color: var(--ink);
}

#auth_recovery_submit {
    width: 100%;
    padding: 13px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .2s ease;
}
#auth_recovery_submit:hover {
    background: var(--accent-hover);
}
#auth_recovery_submit:disabled {
    opacity: .6;
    cursor: wait;
}

#auth_recovery_message {
    margin: 8px 0 14px;
    min-height: 1.2em;
    font-size: .85rem;
}
#auth_recovery_message.error   { color: var(--danger); }
#auth_recovery_message.success { color: var(--ok); }

/* Foco visible para teclado en botones */
#auth_recovery_close:focus-visible,
#auth_recovery_submit:focus-visible,
#auth_submit:focus-visible {
    outline: 3px solid rgba(0, 149, 232, .45);
    outline-offset: 2px;
}

/* ---------- Animación de entrada (una sola) ---------- */

@keyframes auth-enter {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
}

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

/* ---------- Responsive ---------- */

@media (max-width: 600px) {
    main { padding: 16px 12px; }
    #auth_card { padding: 28px 22px 24px; }
    #auth_card #auth_card_title { font-size: 1.4rem; margin-bottom: 1.4rem; }
    #auth_developedby { margin-top: 32px; }
    #auth_recovery_popup { padding: 26px 22px; }
}

@media (max-height: 560px) {
    #auth_developedby { margin-top: 24px; }
}