:root {
    --brand-blue: #21358f;
    --brand-blue-dark: #101f5d;
    --brand-blue-ink: #0c1744;
    --brand-lime: #b2c73a;
    --brand-lime-dark: #8da21f;
    --brand-lime-soft: #f4f8db;
    --color-bg: #f5f7fb;
    --color-surface: #ffffff;
    --color-ink: #172033;
    --color-muted: #667085;
    --color-border: #d9e2ec;
    --color-primary: var(--brand-blue);
    --color-primary-dark: var(--brand-blue-dark);
    --color-primary-soft: #eef1ff;
    --color-danger: #b42318;
    --color-danger-soft: #fff1f0;
    --color-success: #067647;
    --shadow-card: 0 24px 70px rgba(16, 31, 93, 0.18);
    --radius-sm: 8px;
    --radius-md: 14px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--brand-blue-ink);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--color-ink);
    font-family: "Plus Jakarta Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

body.dialog-open {
    overflow: hidden;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.auth-page {
    min-height: 100vh;
    padding: 16px;
    display: grid;
    place-items: center;
    background:
        linear-gradient(90deg, rgba(7, 13, 37, 0.78) 0%, rgba(16, 31, 93, 0.46) 46%, rgba(255, 255, 255, 0.18) 100%),
        url("../img/fondo%20web%20efacturagas.png") center / cover no-repeat;
}

.auth-shell {
    width: min(1040px, 100%);
    min-height: min(620px, calc(100vh - 32px));
    display: grid;
    grid-template-columns: minmax(300px, 0.84fr) minmax(360px, 1fr);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.26);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 24px 80px rgba(7, 13, 37, 0.34);
}

.auth-brand {
    position: relative;
    padding: 34px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 22px;
    color: #ffffff;
    background:
        linear-gradient(180deg, rgba(7, 13, 37, 0.78), rgba(16, 31, 93, 0.9)),
        url("../img/fondo%20web%20efacturagas.png") 17% center / cover no-repeat;
}

.brand-logo img {
    width: 230px;
    max-width: 100%;
    height: auto;
    display: block;
}

.brand-copy {
    max-width: 470px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--color-primary);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.auth-brand .eyebrow {
    color: var(--brand-lime);
}

.brand-copy h1 {
    margin: 0;
    font-size: clamp(1.7rem, 3.2vw, 2.7rem);
    line-height: 1.08;
    letter-spacing: 0;
}

.brand-copy p {
    margin: 12px 0 0;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.93rem;
}

.brand-panel {
    display: grid;
    gap: 12px;
}

.brand-panel div {
    padding: 12px;
    border: 1px solid rgba(178, 199, 58, 0.28);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.08);
}

.brand-panel strong,
.brand-panel span {
    display: block;
}

.brand-panel span {
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.76);
    font-size: 0.83rem;
}

.auth-card {
    padding: clamp(24px, 4vw, 44px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: rgba(255, 255, 255, 0.96);
}

.auth-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.auth-card-header h2 {
    margin: 0;
    font-size: clamp(1.45rem, 2.5vw, 2rem);
    line-height: 1.1;
}

.secondary-link,
.text-button {
    border: 0;
    padding: 0;
    color: var(--brand-blue);
    background: transparent;
    font-weight: 700;
    text-decoration: none;
}

.secondary-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.auth-tabs {
    --tab-gap: 4px;
    position: relative;
    margin-bottom: 14px;
    padding: 4px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--tab-gap);
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: rgba(247, 250, 252, 0.88);
}

.auth-tabs::before {
    content: "";
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc((100% - 16px) / 3);
    border-radius: 10px;
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-blue-dark));
    box-shadow: 0 10px 20px rgba(33, 53, 143, 0.25);
    transform: translateX(0);
    transition: transform 220ms ease, box-shadow 220ms ease;
    will-change: transform;
}

.auth-tabs.active-1::before {
    transform: translateX(calc(100% + var(--tab-gap)));
}

.auth-tabs.active-2::before {
    transform: translateX(calc(200% + 8px));
}

.auth-tab {
    position: relative;
    z-index: 1;
    min-height: 44px;
    border: 0;
    border-radius: 10px;
    color: var(--color-muted);
    background: transparent;
    font-weight: 800;
    transition: color 180ms ease, transform 180ms ease;
}

.auth-tab.is-active {
    color: #ffffff;
    background: transparent;
    box-shadow: none;
    transform: translateY(-1px);
}

.v2-dialog[hidden] {
    display: none;
}

.v2-dialog {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 18px;
}

.v2-dialog__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 13, 37, 0.58);
    backdrop-filter: blur(4px);
}

.v2-dialog__panel {
    position: relative;
    width: min(420px, 100%);
    padding: 26px;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 24px 80px rgba(7, 13, 37, 0.34);
    text-align: center;
    animation: dialog-enter 180ms ease;
}

.v2-dialog__icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    color: #ffffff;
    background: var(--brand-blue);
}

.v2-dialog__icon::before {
    content: "i";
    font-size: 1.4rem;
    font-weight: 900;
}

.v2-dialog.is-success .v2-dialog__icon {
    color: var(--brand-blue-dark);
    background: var(--brand-lime-soft);
}

.v2-dialog.is-success .v2-dialog__icon::before {
    content: "";
    width: 18px;
    height: 10px;
    border-left: 3px solid var(--brand-lime-dark);
    border-bottom: 3px solid var(--brand-lime-dark);
    transform: rotate(-45deg) translate(1px, -1px);
}

.v2-dialog.is-error .v2-dialog__icon {
    background: var(--color-danger);
}

.v2-dialog.is-error .v2-dialog__icon::before {
    content: "!";
}

.v2-dialog__panel h2 {
    margin: 0;
    color: var(--brand-blue-ink);
    font-size: 1.22rem;
    line-height: 1.2;
}

.v2-dialog__panel p {
    margin: 10px 0 0;
    color: var(--color-muted);
    font-size: 0.94rem;
}

.v2-dialog__details {
    margin: 14px 0 0;
    padding: 12px 14px;
    border-radius: 10px;
    color: #7a271a;
    background: var(--color-danger-soft);
    text-align: left;
    font-size: 0.86rem;
}

.v2-dialog__details:empty {
    display: none;
}

.v2-dialog__button {
    width: 100%;
    min-height: 44px;
    margin-top: 18px;
    border: 0;
    border-radius: var(--radius-sm);
    color: #ffffff;
    background: var(--brand-blue);
    font-weight: 900;
}

.auth-panel {
    display: none;
}

.auth-panel.is-active {
    display: grid;
    gap: 8px;
    animation: panel-enter 180ms ease;
}

.field {
    display: grid;
    gap: 4px;
}

.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

label {
    color: #344054;
    font-size: 0.84rem;
    font-weight: 800;
}

.input-field {
    position: relative;
}

.field-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    width: 18px;
    height: 18px;
    color: #667085;
    pointer-events: none;
    transform: translateY(-50%);
}

.field-icon svg,
.password-toggle svg {
    width: 100%;
    height: 100%;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

input {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 10px 14px 10px 42px;
    color: var(--color-ink);
    background: #ffffff;
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

input:focus {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 4px rgba(178, 199, 58, 0.26);
}

.input-field:focus-within .field-icon {
    color: var(--brand-blue);
}

input.has-error {
    border-color: var(--color-danger);
    background: #fffafa;
}

.password-field input {
    padding-right: 54px;
}

.password-toggle {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 32px;
    min-height: 32px;
    border: 0;
    border-radius: 7px;
    padding: 8px;
    color: var(--brand-blue-dark);
    background: var(--brand-lime-soft);
}

.password-toggle:hover,
.password-toggle:focus {
    color: var(--brand-blue);
    background: #eef1ff;
}

.password-toggle .icon-eye-off {
    display: none;
}

.password-toggle.is-visible .icon-eye {
    display: none;
}

.password-toggle.is-visible .icon-eye-off {
    display: block;
}

.field-hint,
.field-error {
    margin: 0;
    font-size: 0.76rem;
    line-height: 1.35;
}

.field-hint {
    color: var(--color-muted);
}

.field-error {
    color: var(--color-danger);
    font-weight: 700;
}

.field-error:empty {
    display: none;
}

.primary-button {
    width: 100%;
    min-height: 44px;
    margin-top: 2px;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: var(--brand-blue);
    font-weight: 900;
    transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
    box-shadow: 0 14px 28px rgba(33, 53, 143, 0.22);
}

.primary-button:hover {
    background: var(--brand-blue-dark);
}

.primary-button:active {
    transform: translateY(1px);
}

.primary-button[disabled] {
    cursor: wait;
    opacity: 0.65;
    transform: none;
}

@media (max-width: 860px) {
    .auth-page {
        padding: 0;
        place-items: stretch;
    }

    .auth-shell {
        min-height: 100vh;
        grid-template-columns: 1fr;
        border: 0;
        border-radius: 0;
    }

    .auth-brand {
        min-height: 230px;
        padding: 24px;
    }

    .brand-copy h1 {
        font-size: 1.65rem;
    }

    .brand-panel {
        display: none;
    }
}

@media (max-width: 520px) {
    .auth-card {
        padding: 22px 18px 28px;
    }

    .auth-card-header {
        align-items: stretch;
        flex-direction: column;
        margin-bottom: 20px;
    }

    .label-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }
}

@media (max-height: 760px) and (min-width: 861px) {
    .auth-page {
        padding: 10px;
    }

    .auth-shell {
        min-height: calc(100vh - 20px);
    }

    .auth-brand {
        padding: 26px;
    }

    .brand-logo img {
        width: 200px;
    }

    .brand-copy h1 {
        font-size: 2rem;
    }

    .brand-panel {
        gap: 8px;
    }

    .brand-panel div {
        padding: 10px;
    }

    .auth-card {
        padding: 24px 34px;
    }

    .auth-card-header {
        margin-bottom: 12px;
    }
}

@media (max-height: 660px) and (min-width: 861px) {
    .brand-panel {
        display: none;
    }
}

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

@keyframes panel-enter {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes dialog-enter {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
