:root {
    --color-primary-dark: #0E2954;
    --color-primary-light: #1A5F7A;
    --color-accent: #57C5B6;
    --color-text: #333333;
    --color-muted: #7A8794;
    --color-success: #2ECC71;
    --color-error: #E74C3C;
    --color-border: #E3E8EE;
    --color-field: #FAFBFC;
}

/* =========================================================
   BASE
========================================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: "Roboto", sans-serif;
    color: var(--color-text);
    background: var(--color-primary-dark);
}

button,
input {
    font: inherit;
}

/* =========================================================
   LAYOUT
========================================================= */
.auth-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    min-height: 100vh;
}

/* =========================================================
   PANEL IZQUIERDO / MARCA
========================================================= */
.panel-brand {
    position: relative;
    overflow: hidden;
    padding: 38px 50px 40px;
    color: #fff;
    display: flex;
    flex-direction: column;
    background: var(--color-primary-dark);
}

.panel-brand .bg-photo {
    position: absolute;
    inset: -3%;

    background-image: url("/imagenes/login-bg.webp");
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;

    animation: ken-burns 30s ease-in-out infinite alternate;
}

@keyframes ken-burns {
    from {
        transform: scale(1) translate(0, 0);
    }
    to {
        transform: scale(1.12) translate(-1.5%, -1.5%);
    }
}

.panel-brand .bg-veil {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(
            180deg,
            rgba(14, 41, 84, .58) 0%,
            rgba(14, 41, 84, .82) 52%,
            rgba(14, 41, 84, .97) 100%
        ),
        radial-gradient(
            circle at 70% 30%,
            rgba(87, 197, 182, .20),
            transparent 62%
        );
}

.panel-brand > *:not(.bg-photo):not(.bg-veil):not(.fx) {
    position: relative;
    z-index: 3;
}

/* =========================================================
   PARTÍCULAS
========================================================= */
.fx {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.fx i {
    position: absolute;
    bottom: -40px;
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .5);
    animation: subir linear infinite;
}

@keyframes subir {
    0% {
        transform: translateY(0) scale(1);
        opacity: 0;
    }
    10% {
        opacity: .7;
    }
    90% {
        opacity: .4;
    }
    100% {
        transform: translateY(-105vh) scale(.4);
        opacity: 0;
    }
}

/* =========================================================
   CABECERA CERTUAP
========================================================= */
.brand-top {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    align-self: flex-start;

    min-height: 72px;
    padding: 8px 10px;

    /* TOTALMENTE TRANSPARENTE */
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;

    border-radius: 0;

    text-decoration: none;
    color: inherit;

    transition: opacity .2s ease;
}

.brand-top:hover {
    background: transparent !important;
    color: inherit;
    opacity: .9;
}

.brand-top:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 3px;
}

/*
   IMPORTANTE:
   Antes existían dos .brand-mark img.
   La segunda regla de 32x32 anulaba el tamaño grande.
*/
.brand-mark {
    width: 58px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 58px;
    overflow: visible;
}

.brand-mark img {
    width: 54px;
    height: 54px;
    max-width: none;
    object-fit: contain;
    display: block;
}

.brand-name {
    font-size: 1.16rem;
    font-weight: 700;
    letter-spacing: .035em;
    line-height: 1.15;
}

.brand-name small {
    display: block;
    margin-top: 5px;
    font-size: .72rem;
    font-weight: 400;
    letter-spacing: .01em;
    color: rgba(255, 255, 255, .74);
}

/* =========================================================
   CONTENIDO CENTRAL ROTATIVO
========================================================= */
.brand-core {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px 0 28px;
    transform: translateY(-8px);
}

.hero-icon {
    position: relative;
    width: 132px;
    height: 132px;
    margin-bottom: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-icon::before,
.hero-icon::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid rgba(87, 197, 182, .45);
    animation: pulso 3.6s ease-out infinite;
}

.hero-icon::after {
    animation-delay: 1.8s;
}

@keyframes pulso {
    0% {
        transform: scale(.85);
        opacity: .8;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.hero-icon .disco {
    width: 118px;
    height: 118px;
    border-radius: 50%;
    background: rgba(87, 197, 182, .14);
    border: 1px solid rgba(87, 197, 182, .40);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 50px;
    color: var(--color-accent);
    box-shadow:
        0 12px 40px rgba(0, 0, 0, .28),
        inset 0 0 25px rgba(87, 197, 182, .06);
}

.hero-icon .disco i {
    animation: icono-in .5s cubic-bezier(.2, .8, .3, 1);
}

@keyframes icono-in {
    from {
        opacity: 0;
        transform: scale(.6) rotate(-12deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
}

.brand-badge {
    display: inline-block;
    padding: 7px 15px;
    margin-bottom: 16px;
    border-radius: 30px;
    background: var(--color-accent);
    color: #04342C;
    font-size: .70rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    box-shadow: 0 6px 18px rgba(87, 197, 182, .18);
}

.brand-title {
    max-width: 470px;
    margin: 0 0 10px;
    font-size: clamp(1.65rem, 2.2vw, 2rem);
    font-weight: 700;
    line-height: 1.22;
    text-shadow: 0 2px 14px rgba(0, 0, 0, .35);
}

.brand-sub {
    max-width: 430px;
    margin: 0 0 18px;
    color: rgba(255, 255, 255, .80);
    font-size: .95rem;
    line-height: 1.6;
}

.brand-cta {
    display: inline-flex;
    align-items: center;
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 600;
    font-size: .90rem;
    transition: color .2s ease, transform .2s ease;
}

.brand-cta:hover {
    color: #fff;
    transform: translateX(2px);
}

.brand-dots {
    display: flex;
    gap: 7px;
    justify-content: center;
    margin-top: 26px;
}

.brand-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .30);
    cursor: pointer;
    transition: all .3s ease;
}

.brand-dots span.on {
    width: 26px;
    border-radius: 4px;
    background: var(--color-accent);
}

/* =========================================================
   ESTADÍSTICAS
========================================================= */
.brand-stats {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, .14);
}

.brand-stats > div {
    position: relative;
    flex: 1;
    min-width: 0;
    text-align: center;
}

.brand-stats > div + div::before {
    content: "";
    position: absolute;
    left: -5px;
    top: 10%;
    width: 1px;
    height: 80%;
    background: rgba(255, 255, 255, .08);
}

.brand-stats strong {
    display: block;
    margin-bottom: 4px;
    color: #fff;
    font-size: 1.32rem;
    font-weight: 700;
    line-height: 1.2;
}

.brand-stats span {
    color: rgba(255, 255, 255, .66);
    font-size: .74rem;
    letter-spacing: .02em;
    line-height: 1.35;
}

.brand-stats .mobile-label {
    display: none;
}

/* =========================================================
   PANEL DERECHO / FORMULARIO
========================================================= */
.panel-form {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 32px;
    background: #fff;
}

.auth-container {
    width: 100%;
    max-width: 420px;
}

/* Logo principal encima de "Iniciar sesión" */
.logo {
    width: 104px;
    height: 104px;
    object-fit: contain;
    display: block;
    margin: 0 auto 16px;
}

.auth-title {
    margin: 0 0 6px;
    color: var(--color-primary-dark);
    font-size: 1.65rem;
    font-weight: 700;
    text-align: center;
}

.auth-subtitle {
    margin: 0 0 25px;
    color: #728196;
    font-size: .92rem;
    text-align: center;
}

.form-container {
    display: flex;
    flex-direction: column;
    animation: fade-in .4s ease-out;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================================
   CAMPOS
========================================================= */
.input-group {
    position: relative;
}

.form-control {
    width: 100%;
    min-height: 52px;
    padding: 14px 18px 14px 44px;
    border: 1.5px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-field);
    color: var(--color-text);
    font-size: .98rem;
    transition:
        border-color .2s ease,
        background-color .2s ease,
        box-shadow .2s ease;
}

.form-control::placeholder {
    color: #7F8B99;
    opacity: 1;
}

.form-control:hover {
    border-color: #D4DCE5;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary-light);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(26, 95, 122, .10);
}

.input-group-icon {
    position: absolute;
    z-index: 5;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #9AA7B4;
    font-size: .95rem;
    pointer-events: none;
}

/* Mostrar / ocultar contraseña */
.has-toggle .form-control {
    padding-right: 48px;
}

.toggle-pass {
    position: absolute;
    z-index: 6;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #9AA7B4;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .2s ease, background-color .2s ease;
}

.toggle-pass:hover {
    color: var(--color-primary-light);
    background: #F1F5F9;
}

.toggle-pass:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 1px;
}

/* =========================================================
   BOTONES
========================================================= */
.btn-auth {
    width: 100%;
    min-height: 50px;
    margin-top: 6px;
    padding: 14px 24px;
    border: 0;
    border-radius: 10px;
    background: var(--color-primary-dark);
    color: #fff;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    transition:
        background-color .2s ease,
        transform .15s ease,
        box-shadow .2s ease;
}

.btn-auth:hover {
    background: #143A72;
    box-shadow: 0 8px 20px rgba(14, 41, 84, .15);
}

.btn-auth:active {
    transform: scale(.99);
}

.btn-auth:disabled {
    opacity: .68;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-auth.secondary {
    background: var(--color-accent);
    color: #04342C;
}

.btn-auth.secondary:hover {
    background: #45B69C;
}

.btn-auth.tertiary {
    border: 1.5px solid var(--color-border);
    background: #fff;
    color: var(--color-text);
}

.btn-auth.tertiary:hover {
    background: #F4F7F9;
}

.btn-auth:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

/* =========================================================
   ENLACES / DIVISORES / MENSAJES
========================================================= */
.auth-link {
    margin: 16px 0 0;
    font-size: .90rem;
    text-align: center;
}

.auth-link a {
    color: var(--color-primary-light);
    font-weight: 500;
    text-decoration: none;
}

.auth-link a:hover {
    text-decoration: underline;
}

.divider {
    display: flex;
    align-items: center;
    margin: 18px 0;
    color: #9AA7B4;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    border-bottom: 1px solid var(--color-border);
}

.divider-text {
    padding: 0 12px;
    font-size: .82rem;
}

.message {
    padding: 14px;
    margin-bottom: 18px;
    border-radius: 10px;
    font-size: .90rem;
    animation: fade-in .4s ease;
}

.success-message {
    border-left: 4px solid var(--color-success);
    background: rgba(46, 204, 113, .12);
    color: #1E8449;
}

.error-message {
    border-left: 4px solid var(--color-error);
    background: rgba(231, 76, 60, .12);
    color: #A93226;
}

/* =========================================================
   VALIDACIÓN DE REFERIDOS
========================================================= */
.form-control.valid {
    border-color: #28A745 !important;
    background-color: rgba(40, 167, 69, .06);
}

.form-control.invalid {
    border-color: #DC3545 !important;
    background-color: rgba(220, 53, 69, .06);
}

.codigo-status {
    position: absolute;
    z-index: 6;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: .76rem;
    font-weight: 700;
}

.codigo-status.valido {
    color: #28A745;
}

.codigo-status.invalido {
    color: #DC3545;
}

.referido-info {
    margin-bottom: 20px;
    padding: 16px;
    border-radius: 12px;
    background: var(--color-accent);
    color: #04342C;
    text-align: center;
}

.referido-info h5 {
    margin: 6px 0;
    font-size: 1rem;
    font-weight: 700;
}

.referido-code {
    display: inline-block;
    margin: 6px 0;
    padding: 7px 16px;
    border: 2px dashed rgba(4, 52, 44, .35);
    border-radius: 20px;
    background: rgba(255, 255, 255, .45);
    font-weight: 700;
}

/* =========================================================
   RECUPERACIÓN DE CONTRASEÑA
========================================================= */
.reset-step {
    display: none;
    animation: fade-in .4s ease-out;
}

.reset-step.active {
    display: block;
}

.code-inputs {
    display: flex;
    justify-content: center;
    gap: 9px;
    margin: 20px 0;
}

.code-inputs input {
    width: 46px;
    height: 54px;
    padding: 0;
    border: 1.5px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-field);
    color: var(--color-primary-dark);
    font-size: 22px;
    font-weight: 700;
    text-align: center;
}

.code-inputs input:focus {
    outline: none;
    border-color: var(--color-primary-light);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(26, 95, 122, .12);
}

.code-inputs input.filled {
    border-color: var(--color-accent);
    background: rgba(87, 197, 182, .08);
}

.reset-info {
    margin-bottom: 20px;
    padding: 12px 15px;
    border-left: 4px solid var(--color-primary-light);
    border-radius: 8px;
    background: #F4F7F9;
    color: #555;
    font-size: .88rem;
}

.timer-text {
    margin-top: 10px;
    color: #8794A4;
    font-size: .82rem;
    text-align: center;
}

.timer-text span {
    color: var(--color-primary-light);
    font-weight: 700;
}

/* =========================================================
   FOOTER
========================================================= */
.auth-footer {
    margin-top: 26px;
    color: #8B98AA;
    font-size: .82rem;
    text-align: center;
}

.auth-footer p {
    margin: 0;
}

/* =========================================================
   TABLET / MÓVIL
========================================================= */
@media (max-width: 991px) {
    body {
        background-image:
            linear-gradient(
                180deg,
                rgba(14, 41, 84, .74) 0%,
                rgba(14, 41, 84, .89) 60%,
                rgba(14, 41, 84, .97) 100%
            ),
            url("/imagenes/login-bg-mobile.webp");

        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
    }

    .auth-split {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
    }

    .panel-form {
        order: 1;
        padding: 30px 18px 20px;
        background: transparent;
    }

    .panel-brand {
        order: 2;
        display: block;
        padding: 0 22px 34px;
        background: transparent;
        text-align: center;
    }

    .panel-brand .bg-photo,
    .panel-brand .bg-veil,
    .brand-top,
    .hero-icon {
        display: none;
    }

    .brand-core {
        display: block;
        padding: 0;
        transform: none;
    }

    .fx {
        position: fixed;
        z-index: 0;
    }

    .auth-container {
        position: relative;
        z-index: 3;
        max-width: 460px;
        padding: 28px 22px;
        border: 1px solid rgba(255, 255, 255, .25);
        border-radius: 20px;
        background: rgba(255, 255, 255, .97);
        box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
    }

    .logo {
        width: 90px;
        height: 90px;
    }

    .brand-title {
        font-size: 1.3rem;
    }

    .brand-sub {
        margin-left: auto;
        margin-right: auto;
    }

    .brand-stats {
        margin-top: 24px;
    }

    .brand-stats strong {
        font-size: 1.1rem;
    }

    .brand-stats span {
        font-size: .68rem;
    }
}

/* =========================================================
   TELÉFONOS PEQUEÑOS
========================================================= */
@media (max-width: 480px) {
    .panel-form {
        padding: 18px 12px 14px;
    }

    .auth-container {
        padding: 24px 18px;
        border-radius: 18px;
    }

    .logo {
        width: 78px;
        height: 78px;
        margin-bottom: 12px;
    }

    .auth-title {
        font-size: 1.42rem;
    }

    .auth-subtitle {
        margin-bottom: 22px;
        font-size: .88rem;
    }

    .form-control {
        min-height: 50px;
        font-size: .94rem;
    }

    .code-inputs {
        gap: 6px;
    }

    .code-inputs input {
        width: 40px;
        height: 50px;
        font-size: 20px;
    }

    .brand-stats {
        gap: 6px;
    }

    .brand-stats > div + div::before {
        display: none;
    }

    .brand-stats strong {
        font-size: 1rem;
    }

    .brand-stats span {
        font-size: .65rem;
        line-height: 1.25;
    }

    .brand-stats .desktop-label {
        display: none;
    }

    .brand-stats .mobile-label {
        display: inline;
    }
}

/* =========================================================
   ACCESIBILIDAD
========================================================= */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}