.bm-auth {
    --bm-primary: var(--primary-color, var(--bs-primary));
    --bm-primary-contrast: #fff;
    --bm-accent: var(--secondary-color, var(--bm-primary));
    --bm-accent-contrast: #fff;
    --bm-link: var(--bm-accent);
    --bm-surface: var(--bs-body-bg, #fff);
    --bm-text: var(--bs-body-color, #212529);
    --bm-muted: var(--bs-secondary-color, #6c757d);
    --bm-border: var(--bs-border-color, #dee2e6);
    --bm-radius: .75rem;
    --bm-input-h: 3.25rem;
    --bm-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
    --bm-primary-hover: color-mix(in srgb, var(--bm-primary) 86%, #000);
    --bm-primary-soft: color-mix(in srgb, var(--bm-primary) 10%, transparent);
    --bm-ring: color-mix(in srgb, var(--bm-primary) 22%, transparent);

    font-family: inherit;
    color: var(--bm-text);
    width: 100%;
    max-width: 440px;
    margin-inline: auto;
}

.bm-auth__box { background: var(--bm-surface); border-radius: var(--bm-radius); }
.bm-auth[data-variant="card"] .bm-auth__box { border: 1px solid var(--bm-border); box-shadow: var(--bm-shadow); overflow: hidden; }
.bm-auth__header {
    background: var(--bm-accent); color: var(--bm-accent-contrast);
    padding: .9rem 1.5rem; font-size: 1.125rem; font-weight: 500;
    display: flex; align-items: center; gap: .6rem;
}
.bm-auth[data-variant="plain"] { margin-top: 1.25rem; }
.bm-auth[data-variant="plain"] .bm-auth__header { display: none; }
.bm-auth__body { padding: 1.5rem; }
.bm-auth[data-variant="plain"] .bm-auth__body { padding: 0; }
.bm-auth #loginMessage .alert { border-radius: calc(var(--bm-radius) - .25rem); font-size: .875rem; }

.bm-auth .bm-steps { display: flex; align-items: center; gap: .5rem; margin-bottom: 1.25rem; font-size: .75rem; color: var(--bm-muted); }
.bm-auth .bm-steps__item { display: flex; align-items: center; gap: .4rem; font-weight: 500; white-space: nowrap; }
.bm-auth .bm-steps__dot {
    width: 1.375rem; height: 1.375rem; border-radius: 50%;
    display: grid; place-items: center; font-size: .7rem; font-weight: 600;
    border: 1.5px solid var(--bm-border); background: var(--bm-surface); transition: all .25s;
}
.bm-auth .bm-steps__line { flex: 1; min-width: .75rem; height: 2px; border-radius: 2px; background: var(--bm-border); position: relative; overflow: hidden; }
.bm-auth .bm-steps__line::after { content: ""; position: absolute; inset: 0; width: 0; background: var(--bm-primary); transition: width .35s ease; }
.bm-auth .bm-steps__line.is-done::after { width: 100%; }
.bm-auth .bm-steps__item.is-active { color: var(--bm-text); }
.bm-auth .bm-steps__item.is-active .bm-steps__dot { border-color: var(--bm-primary); color: var(--bm-primary); background: var(--bm-primary-soft); }
.bm-auth .bm-steps__item.is-done .bm-steps__dot { border-color: var(--bm-primary); background: var(--bm-primary); color: var(--bm-primary-contrast); }

.bm-auth__title { font-size: 1.375rem; font-weight: 700; letter-spacing: -.01em; margin: 0 0 .25rem; color: var(--bm-text); }
.bm-auth__subtitle { color: var(--bm-muted); font-size: .9375rem; margin: 0 0 1.25rem; overflow-wrap: anywhere; }

.bm-auth .bm-field { position: relative; margin-bottom: 1rem; }
.bm-auth .bm-field .form-control {
    height: var(--bm-input-h); min-height: var(--bm-input-h);
    border-radius: calc(var(--bm-radius) - .25rem); border-color: var(--bm-border);
    padding-left: 2.75rem; font-size: 1rem;
}
.bm-auth .bm-field.form-floating > label { padding-left: 2.75rem; color: var(--bm-muted); }
.bm-auth .bm-field.form-floating > .form-control:focus ~ label,
.bm-auth .bm-field.form-floating > .form-control:not(:placeholder-shown) ~ label { transform: scale(.82) translateY(-.6rem) translateX(.55rem); }
.bm-auth .bm-field .form-control:focus { border-color: var(--bm-primary); box-shadow: 0 0 0 .25rem var(--bm-ring); }
.bm-auth .bm-field__icon { position: absolute; left: 1rem; top: calc(var(--bm-input-h) / 2); transform: translateY(-50%); color: var(--bm-muted); z-index: 5; pointer-events: none; transition: color .2s; }
.bm-auth .bm-field:focus-within .bm-field__icon { color: var(--bm-primary); }
.bm-auth .bm-field__action {
    position: absolute; right: .4rem; top: calc(var(--bm-input-h) / 2); transform: translateY(-50%); z-index: 5;
    width: 2.5rem; height: 2.5rem; border: 0; border-radius: .5rem; background: transparent; color: var(--bm-muted);
}
.bm-auth .bm-field__action:hover { color: var(--bm-primary); background: var(--bm-primary-soft); }
.bm-auth .bm-field .form-control.has-action { padding-right: 3rem; }
.bm-auth .bm-field .form-control.has-action.is-invalid,
.bm-auth .bm-field .form-control.has-action.is-valid { background-image: none; padding-right: 3rem; }
.bm-auth .bm-caps { display: none; font-size: .8125rem; margin: -.5rem 0 .75rem; color: var(--bs-warning-text-emphasis, #997404); }
.bm-auth .bm-caps.is-on { display: flex; align-items: center; gap: .4rem; }

.bm-auth .bm-btn-primary {
    --bs-btn-bg: var(--bm-primary); --bs-btn-border-color: var(--bm-primary); --bs-btn-color: var(--bm-primary-contrast);
    --bs-btn-hover-bg: var(--bm-primary-hover); --bs-btn-hover-border-color: var(--bm-primary-hover); --bs-btn-hover-color: var(--bm-primary-contrast);
    --bs-btn-active-bg: var(--bm-primary-hover); --bs-btn-active-border-color: var(--bm-primary-hover); --bs-btn-active-color: var(--bm-primary-contrast);
    --bs-btn-disabled-bg: var(--bm-primary); --bs-btn-disabled-border-color: var(--bm-primary); --bs-btn-disabled-color: var(--bm-primary-contrast);
    --bs-btn-focus-box-shadow: 0 0 0 .25rem var(--bm-ring);
    width: 100%; height: var(--bm-input-h); border-radius: calc(var(--bm-radius) - .25rem); font-weight: 600;
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
}
.bm-auth .bm-btn-primary.is-loading .bm-btn-icon { display: none; }

.bm-auth .bm-btn-ghost {
    width: 100%; height: 2.75rem; margin-top: .5rem; border: 0; background: transparent; text-decoration: none;
    border-radius: calc(var(--bm-radius) - .25rem); color: var(--bm-muted); font-weight: 500; font-size: .9375rem;
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
}
.bm-auth .bm-btn-ghost:hover { color: var(--bm-text); background: var(--bs-tertiary-bg, #f8f9fa); }
.bm-auth .bm-btn-ghost:focus-visible { box-shadow: 0 0 0 .25rem var(--bm-ring); outline: 0; }

.bm-auth .bm-btn-oauth {
    width: 100%; height: 3rem; border-radius: calc(var(--bm-radius) - .25rem);
    border: 1px solid var(--bm-border); background: var(--bm-surface); color: var(--bm-text); font-weight: 500;
    display: inline-flex; align-items: center; justify-content: center; gap: .6rem;
}
.bm-auth .bm-btn-oauth { text-decoration: none; }
.bm-auth .bm-btn-oauth img { width: 18px; height: 18px; object-fit: contain; }
.bm-auth .bm-btn-oauth:hover { background: var(--bs-tertiary-bg, #f8f9fa); color: var(--bm-text); }
.bm-auth .bm-btn-oauth:focus-visible { box-shadow: 0 0 0 .25rem var(--bm-ring); outline: 0; }

.bm-auth .bm-divider { display: flex; align-items: center; gap: .75rem; margin: 1.25rem 0 1rem; color: var(--bm-muted); font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; }
.bm-auth .bm-divider::before, .bm-auth .bm-divider::after { content: ""; flex: 1; height: 1px; background: var(--bm-border); }
.bm-auth .bm-auth__oauth { display: grid; gap: .5rem; }
/* Oculta el bloque OAuth de form.phtml cuando el card ya lo muestra. */
body:has(.bm-auth [data-bm-oauth]) [data-bm-oauth-legacy] { display: none !important; }

.bm-auth .bm-register {
    margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--bm-border);
    text-align: center; font-size: .9375rem; color: var(--bm-muted);
}
.bm-auth .bm-register__links { display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem 1rem; margin-top: .25rem; }
.bm-auth .bm-link { color: var(--bm-link); font-weight: 600; text-decoration: none; }
.bm-auth .bm-link:hover { text-decoration: underline; color: var(--bm-link); }

.bm-auth .bm-options { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; align-items: center; margin: -.25rem 0 1.25rem; font-size: .875rem; }
.bm-auth .form-check-input:checked { background-color: var(--bm-primary); border-color: var(--bm-primary); }
.bm-auth .form-check-input:focus { border-color: var(--bm-primary); box-shadow: 0 0 0 .25rem var(--bm-ring); }

.bm-auth .bm-legal { margin-top: 1rem; text-align: center; font-size: .75rem; color: var(--bm-muted); line-height: 1.5; }
.bm-auth .bm-legal .bm-recaptcha { margin-top: 0 !important; max-width: none; }
.bm-auth .bm-legal a { color: inherit !important; text-decoration: underline; text-underline-offset: 2px; }

.bm-auth .bm-identity {
    display: flex; align-items: center; gap: .75rem; padding: .4rem .4rem .4rem .45rem;
    border: 1px solid var(--bm-border); border-radius: 999px; margin-bottom: 1.25rem;
}
.bm-auth .bm-identity__avatar { flex: 0 0 2.125rem; height: 2.125rem; border-radius: 50%; display: grid; place-items: center; background: var(--bm-primary-soft); color: var(--bm-primary); font-weight: 700; font-size: .8rem; }
.bm-auth .bm-identity__email { flex: 1; min-width: 0; font-size: .9375rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bm-auth .bm-identity__email small { display: block; font-size: .75rem; font-weight: 400; color: var(--bm-muted); overflow: hidden; text-overflow: ellipsis; }
.bm-auth .bm-identity__change { border: 0; background: transparent; color: var(--bm-link); font-weight: 600; font-size: .8125rem; padding: .35rem .75rem; border-radius: 999px; white-space: nowrap; }
.bm-auth .bm-identity__change:hover { background: var(--bm-primary-soft); }

.bm-auth .login-step-agencies { display: flex; flex-direction: column; gap: .5rem; margin: 0 0 1.25rem; }
.bm-auth .login-step-agency {
    position: relative; display: flex; align-items: center; gap: .75rem; min-width: 0; margin: 0;
    padding: .7rem .85rem; border: 1px solid var(--bm-border); border-radius: calc(var(--bm-radius) - .25rem);
    background: var(--bm-surface); color: var(--bm-text); font-size: .9375rem; font-weight: 500; cursor: pointer;
    transition: border-color .2s, background .2s;
}
.bm-auth .login-step-agency:hover { border-color: color-mix(in srgb, var(--bm-primary) 45%, var(--bm-border)); }
.bm-auth .login-step-agency.is-selected,
.bm-auth .login-step-agency:has(input:checked) { border-color: var(--bm-primary); background: var(--bm-primary-soft); }
.bm-auth .login-step-agency:focus-within { outline: 0; box-shadow: 0 0 0 .25rem var(--bm-ring); }
.bm-auth .login-step-agency input[type="radio"] { position: absolute; opacity: 0; }
.bm-auth .login-step-agency-logo {
    display: grid; place-items: center; flex: 0 0 2.125rem; height: 2.125rem; border-radius: .5rem;
    background: var(--bm-primary-soft); color: var(--bm-primary); font-size: .8rem; font-weight: 700;
}
.bm-auth .login-step-agency.is-selected .login-step-agency-logo,
.bm-auth .login-step-agency:has(input:checked) .login-step-agency-logo { background: var(--bm-primary); color: var(--bm-primary-contrast); }
.bm-auth .login-step-agency-who { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.bm-auth .login-step-agency-who small { display: block; font-size: .8125rem; font-weight: 400; color: var(--bm-muted); }

.bm-auth .bm-step-anim { animation: bmIn .3s cubic-bezier(.2, .8, .2, 1); }
.bm-auth[data-dir="back"] .bm-step-anim { animation-name: bmBack; }
@keyframes bmIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes bmBack { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .bm-auth .bm-step-anim { animation: none; } }
