:root {
    color-scheme: dark;
    --background: #000;
    --surface: #0a0a0a;
    --hover: #151515;
    --border: #252525;
    --text: #fff;
    --muted: #a1a1a1;
    --disabled: #666;
}

*, *::before, *::after { box-sizing: border-box; }
html { min-width: 320px; background: var(--background); }
body {
    min-width: 320px;
    min-height: 100dvh;
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    overflow-x: hidden;
}
button, input { font: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.login-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    min-height: 100dvh;
    background: var(--background);
}
.form-section {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 72px clamp(28px, 4vw, 76px) 72px calc(72px + clamp(28px, 4vw, 76px));
}
.login-card { width: min(100%, 390px); }
.brand-section {
    position: relative;
    box-sizing: border-box;
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    min-height: calc(100dvh - 16px);
    margin: 8px;
    border: 10px solid #000000;
    border-radius: 16px;
    overflow: hidden;
}
.brand-photo {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.login-header { margin-bottom: 32px; }
.login-logo-frame {
    width: 105px;
    height: 49px;
    margin-bottom: 25px;
    overflow: hidden;
}
.login-logo {
    display: block;
    width: 105px;
    height: 105px;
    transform: translateY(-30px);
    filter: brightness(0) invert(1);
}
.login-header h1,
.login-header h2 {
    margin: 0 0 8px;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -.035em;
    line-height: 1.25;
}
.login-header p {
    max-width: 360px;
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

/* The same four controls remain in the DOM and retain their existing IDs. */
.social-grid {
    position: fixed;
    z-index: 10;
    top: 0;
    bottom: 0;
    left: 0;
    width: 72px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border-right: 1px solid #202020;
    background: #000;
}
.btn-social-top {
    position: relative;
    display: grid;
    place-items: center;
    flex: none;
    width: 44px;
    height: 44px;
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: transparent;
    font-size: 0;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 180ms ease, opacity 180ms ease;
}
.btn-social-top > img,
.btn-social-top > i { display: none; }
.btn-social-top::before {
    content: '';
    display: block;
    width: 21px;
    height: 21px;
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
}
#btn-google::before,
#btn-modal-google::before { background-image: url('/assets/google-g.png'); }
#btn-microsoft::before,
#btn-modal-microsoft::before { background-image: url('/assets/microsoft.svg'); }
#btn-apple::before,
#btn-modal-apple::before {
    content: '\f179';
    width: auto;
    height: auto;
    background: none;
    color: #fff;
    font-family: 'Font Awesome 6 Brands';
    font-size: 22px;
    font-weight: 400;
    line-height: 1;
}
#btn-correo-tradicional::before {
    background-image: url('/assets/mail.svg');
    filter: invert(1);
}
.btn-social-top:hover,
.btn-social-top:focus-visible { background: var(--hover); }
.btn-social-top.is-active { background: #1a1a1a; }
.btn-social-top:active { background: #222; }
.btn-social-top:disabled { opacity: .55; cursor: wait; }
.btn-social-top[aria-busy='true']::after {
    content: '';
    position: absolute;
    right: 4px;
    bottom: 4px;
    width: 7px;
    height: 7px;
    border: 1px solid #fff;
    border-left-color: transparent;
    border-radius: 50%;
    animation: social-loading 700ms linear infinite;
}
@keyframes social-loading { to { transform: rotate(360deg); } }
.btn-social-top[data-tooltip]::marker { content: none; }
.btn-social-top[data-tooltip]:not([aria-busy='true']):hover::after,
.btn-social-top[data-tooltip]:not([aria-busy='true']):focus-visible::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 50%;
    left: calc(100% + 12px);
    transform: translateY(-50%);
    z-index: 20;
    width: max-content;
    max-width: 190px;
    padding: 8px 10px;
    border: 1px solid #303030;
    border-radius: 7px;
    background: #171717;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    box-shadow: 0 6px 20px rgb(0 0 0 / 25%);
    pointer-events: none;
}

.divider { display: none; }
.input-group { position: relative; margin-bottom: 18px; }
.input-group label {
    display: block;
    margin-bottom: 8px;
    color: #e7e7e7;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.35;
}
.input-group input[type='text'],
.input-group input[type='email'],
.input-group input[type='password'] {
    display: block;
    width: 100%;
    height: 48px;
    padding: 0 0 1px;
    border: 0;
    border-bottom: 1px solid #333;
    border-radius: 0;
    outline: none;
    box-shadow: none;
    background: transparent;
    color: #fff;
    font-size: 14px;
    transition: border-color 180ms ease;
}
.input-group input::placeholder { color: #777; opacity: 1; }
.input-group input:not(:disabled):hover { border-bottom-color: #555; }
.input-group input:focus { border-bottom: 1.5px solid #fff; background: transparent; }
.input-group input:is([aria-invalid='true'], :user-invalid) { border-bottom-color: #dd7b7b; }
.input-group input:disabled { color: var(--disabled); background: transparent; }
.input-group:has(.toggle-password) input { padding-right: 48px; }
.toggle-password {
    position: absolute;
    right: 0;
    bottom: 0;
    display: grid;
    place-items: center;
    width: 44px;
    height: 48px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 15px;
    cursor: pointer;
    transition: color 180ms ease;
}
.toggle-password:hover { color: #fff; }
.toggle-password:focus-visible,
.btn-social-top:focus-visible,
.btn-login:focus-visible,
.btn-close-modal:focus-visible,
.back-top:focus-visible,
.btn-back:focus-visible,
.login-terms a:focus-visible,
#desarrollado-orbi:focus-visible {
    outline: 2px solid #d0d0d0;
    outline-offset: 3px;
}
.options { margin: 0 0 24px; }
.options label {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 30px;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
}
#checkbox-remember { width: 16px; height: 16px; margin: 0; accent-color: #fff; cursor: pointer; }
.btn-login {
    display: grid;
    place-items: center;
    width: 100%;
    min-height: 48px;
    padding: 11px 16px;
    border: 0;
    border-radius: 10px;
    background: #fff;
    color: #000;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 180ms ease, opacity 180ms ease;
}
.btn-login:hover { background: #eaeaea; }
.btn-login:active { background: #dcdcdc; }
.btn-login:disabled { color: #444; opacity: .65; cursor: wait; }
.login-status {
    margin: 14px 0 0;
    padding: 10px 12px;
    border: 1px solid #673737;
    border-radius: 8px;
    background: #180d0d;
    color: #ffc1c1;
    font-size: 12px;
    line-height: 1.5;
}
.login-status[data-type='info'] { border-color: #3a3a3a; background: #101010; color: #d0d0d0; }
.login-terms {
    margin: 27px 0 0;
    color: #888;
    font-size: 11px;
    line-height: 1.6;
    text-align: center;
}
.login-terms a { color: #d2d2d2; text-underline-offset: 3px; }
.login-terms a:hover { color: #fff; }
#desarrollado-orbi {
    position: fixed;
    z-index: 5;
    left: calc(72px + 22px);
    bottom: 22px;
    color: #777;
    font-size: 11px;
    text-decoration: none;
}
#desarrollado-orbi:hover { color: #fff; }

/* First access modal keeps its existing controls and IDs. */
.modal-overlay {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
    background: rgb(0 0 0 / 85%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-card {
    position: relative;
    width: min(100%, 440px);
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    margin: auto;
    padding: 34px;
    border: 1px solid #292929;
    border-radius: 16px;
    background: var(--surface);
    color: #fff;
    text-align: center;
}
.modal-card h3 { margin: 0 0 9px; font-size: 20px; font-weight: 600; }
.modal-card p { margin: 0 0 22px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.modal-card .login-status { margin: 14px 0 0; color: #ffc1c1; font-size: 12px; }
.modal-card .login-status[data-type='info'] { color: #d0d0d0; }
.btn-close-modal {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-size: 24px;
    cursor: pointer;
}
.btn-close-modal:hover { background: var(--hover); color: #fff; }
#modal-vinculacion .social-grid {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    border: 0;
    background: transparent;
}
#modal-vinculacion .btn-social-top {
    display: flex;
    width: auto;
    min-width: 105px;
    height: 44px;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: #fff;
    font-size: 12px;
}
#modal-vinculacion .btn-social-top > img,
#modal-vinculacion .btn-social-top > i { display: none; }
#modal-vinculacion .btn-social-top::before { display: block; flex: none; width: 18px; height: 18px; font-size: 18px; }
#modal-vinculacion .divider { display: block; margin: 18px 0; color: var(--muted); font-size: 12px; }
#modal-vinculacion .btn-login { margin-top: 8px; }
.modal-fields { text-align: left; }

.email-page .back-top,
.email-page .btn-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
    text-decoration: none;
    transition: color 180ms ease;
}
.email-page .back-top { margin-bottom: 28px; }
.email-page .btn-back { justify-content: center; width: 100%; margin-top: 20px; }
.email-page .back-top:hover,
.email-page .btn-back:hover { color: #fff; }
.email-page .login-form .input-group:last-of-type { margin-bottom: 24px; }
.email-page #desarrollado-orbi { left: 22px; }

@media (max-width: 1100px) {
    .login-container { grid-template-columns: minmax(0, 57%) minmax(0, 43%); }
    .form-section { padding-right: 30px; padding-left: 102px; }
    .brand-photo { object-position: 58% center; }
}
@media (max-width: 850px) {
    .login-container { grid-template-columns: minmax(0, 1fr); }
    .brand-section { display: none; }
    .form-section {
        width: 100%;
        min-height: 100dvh;
        padding: calc(32px + env(safe-area-inset-top)) 28px calc(66px + env(safe-area-inset-bottom));
    }
    .login-card { width: min(100%, 420px); }
    .social-grid {
        position: static;
        width: 100%;
        height: auto;
        flex-direction: row;
        justify-content: center;
        gap: 14px;
        margin: -4px 0 28px;
        border: 0;
    }
    .btn-social-top[data-tooltip]:not([aria-busy='true']):hover::after,
    .btn-social-top[data-tooltip]:not([aria-busy='true']):focus-visible::after {
        top: calc(100% + 7px);
        left: 50%;
        transform: translateX(-50%);
    }
    #desarrollado-orbi { left: 28px; bottom: calc(18px + env(safe-area-inset-bottom)); }
    .email-page .form-section { padding-bottom: calc(54px + env(safe-area-inset-bottom)); }
}
@media (min-width: 601px) and (max-width: 850px) and (max-height: 700px) {
    .form-section { align-items: flex-start; padding-top: calc(20px + env(safe-area-inset-top)); }
    .login-logo-frame { margin-bottom: 12px; }
    .login-header { margin-bottom: 20px; }
    .social-grid { margin-bottom: 18px; }
    .login-terms { margin-top: 18px; }
    #desarrollado-orbi { position: static; display: block; width: fit-content; margin: 0 0 18px 20px; }
}
/* Smartphone composition: the code form leads; other methods follow it. */
@media (max-width: 600px) {
    html { scroll-padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
    body {
        display: flex;
        flex-direction: column;
        justify-content: center;
        min-height: 100svh;
    }
    .login-container { order: 1; min-height: 0; }
    .form-section,
    .email-page .form-section {
        align-items: flex-start;
        min-height: 0;
        padding: calc(18px + env(safe-area-inset-top)) 24px 0;
    }
    .login-card {
        display: flex;
        flex-direction: column;
        width: min(100%, 390px);
    }
    .login-header { order: 1; margin-bottom: 30px; }
    .login-logo-frame { width: 100px; height: 44px; margin-bottom: 20px; }
    .login-logo { width: 100px; height: 100px; transform: translateY(-31px); }
    .login-header h1,
    .login-header h2 { margin-bottom: 8px; font-size: 23px; }
    .login-header p { font-size: 14px; }
    .login-form { order: 2; }

    .login-card > .social-grid {
        order: 3;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        align-items: stretch;
        justify-content: stretch;
        gap: 8px;
        width: 100%;
        margin: 24px 0 0;
        border: 0;
    }
    .login-card > .social-grid::before {
        content: 'O continúa con';
        grid-column: 1 / -1;
        color: #777;
        font-size: 12px;
        line-height: 16px;
        text-align: center;
    }
    .login-card > .social-grid > .btn-social-top {
        width: 100%;
        height: 44px;
        border: 1px solid #252525;
        border-radius: 9px;
        background: #000;
        transition: background-color 180ms ease, border-color 180ms ease, opacity 180ms ease;
    }
    .login-card > .social-grid > .btn-social-top::before { width: 19px; height: 19px; }
    .login-card > .social-grid > #btn-apple::before { width: auto; height: auto; font-size: 20px; }
    .login-card > .social-grid > .btn-social-top:hover,
    .login-card > .social-grid > .btn-social-top:focus-visible { border-color: #454545; }
    .login-card > .social-grid > .btn-social-top:active { background: #222; }
    .login-card > .social-grid > .btn-social-top[data-tooltip]::after { content: none; }
    .login-card > .social-grid > .btn-social-top[aria-busy='true']::after { content: ''; }

    .input-group { margin-bottom: 18px; }
    .input-group label { margin-bottom: 7px; font-size: 13px; font-weight: 500; }
    .input-group input[type='text'],
    .input-group input[type='email'],
    .input-group input[type='password'] { height: 48px; font-size: 16px; }
    .toggle-password { height: 48px; }
    .options { margin: 2px 0 18px; }
    .btn-login { min-height: 48px; height: 48px; border-radius: 9px; }
    .login-terms { order: 4; margin-top: 18px; }
    #desarrollado-orbi {
        position: static;
        order: 2;
        display: block;
        width: fit-content;
        margin: 24px auto calc(18px + env(safe-area-inset-bottom));
        text-align: center;
    }
}
@media (max-width: 600px) and (max-height: 700px) {
    body { justify-content: flex-start; }
}
@media (hover: none) {
    .btn-social-top[data-tooltip]:hover::after { content: none; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
