body.auth-page {
    margin: 0;
    padding: 1.5rem 1rem;
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: var(--bg-gradient);
    color: var(--text);
}

/* main card */
.auth-main {
    width: min(1100px, 100%);
    padding: 1.6rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.72);

    display: grid;
    grid-template-columns: 1.25fr 0.95fr;
    grid-template-rows: auto 1fr;
    /* row 1 for back button */
    gap: 1.6rem;
    align-items: start;
}

/* back button in normal flow (no overlap) */
.back-btn {
    grid-column: 1 / -1;
    justify-self: end;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0.55rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.75);
    color: var(--text);
    text-decoration: none;
    font-weight: var(--font-weight-bold);

    transition:
        transform var(--td-fast) ease,
        border-color var(--td-fast) ease,
        background var(--td-fast) ease;
}

.back-btn:hover {
    border-color: rgba(49, 145, 219, 0.35);
    transform: translateY(-1px);
}

.back-btn:active {
    transform: translateY(0);
}

/* banner image */
.auth-visual {
    grid-row: 2;
    grid-column: 1;

    width: 100%;
    height: 100%;
    min-height: 520px;
    object-fit: cover;
    object-position: left;
    border-radius: 16px;
    border: 1px solid rgba(230, 231, 241, 0.8);
}

/* forms column card */
.auth-forms {
    grid-row: 2;
    grid-column: 2;

    width: 100%;
    max-width: 420px;
    margin: auto;
    padding: 1.25rem;
    border-radius: 16px;
    border: 1px solid rgba(230, 231, 241, 0.85);
    background: rgba(255, 255, 255, 0.70);
}

/* tabs (pill) */
.auth-tabs {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
    margin: 0 0 1.1rem;
    padding: 0.35rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.65);
}

.auth-tab {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--secondary-text);
    font-weight: var(--font-weight-bold);
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
    cursor: pointer;
    transition:
        background var(--td-fast) ease,
        color var(--td-fast) ease,
        transform var(--td-fast) ease;
}

.auth-tab:hover {
    background: rgba(49, 145, 219, 0.08);
    color: var(--text);
}

.auth-tab:active {
    transform: translateY(1px);
}

.auth-tab.active {
    background: rgba(49, 145, 219, 0.12);
    color: var(--primary);
    border: 1px solid rgba(49, 145, 219, 0.22);
}

/* form layout */
.auth-form {
    display: none;
}

.auth-form.active {
    display: flex;
    flex-flow: column nowrap;
}

/* fields */
.input-field {
    width: 100%;
    display: grid;
    gap: 0.45rem;
    margin-block-end: 0.95rem;
}

.input-name {
    margin: 0;
    display: flex;
    justify-content: space-between;
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-sm);
    color: var(--secondary-text);
}

.input-name .required {
    color: var(--negative);
}

/* inputs */
input {
    width: 100%;
    height: 46px;
    outline: none;
    border: 1px solid var(--border);
    padding: 0.65rem 0.9rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.85);
    color: var(--text);
    transition:
        border-color var(--td-fast) ease,
        background var(--td-fast) ease;
}

input::placeholder {
    color: rgba(78, 92, 119, 0.65);
}

input:focus {
    border-color: rgba(49, 145, 219, 0.55);
}

/* phone row from component */
.phone-input {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 0.6rem;
    align-items: center;
}

.country-code-input {
    height: 46px;
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.85);
    outline: none;
    cursor: pointer;
    transition: border-color var(--td-fast) ease;
}

.country-code-input:focus {
    border-color: rgba(49, 145, 219, 0.55);
}

/* submit */
.submit-btn {
    height: 46px;
    border: 1px solid rgba(49, 145, 219, 0.35);
    border-radius: 12px;
    padding: 0 1rem;
    font-weight: var(--font-weight-bold);
    letter-spacing: 0.01em;
    color: var(--white);
    background: linear-gradient(180deg,
            rgba(49, 145, 219, 0.95),
            rgba(49, 145, 219, 0.82));
    transition:
        transform var(--td-fast) ease,
        filter var(--td-fast) ease;
}

.submit-btn:hover {
    cursor: pointer;
    filter: brightness(1.03);
    transform: translateY(-1px);
}

.submit-btn:active {
    transform: translateY(0);
}

/* accessibility focus */
.auth-tab:focus-visible,
input:focus-visible,
.country-code-input:focus-visible,
.submit-btn:focus-visible,
.back-btn:focus-visible {
    outline: 3px solid rgba(49, 145, 219, 0.35);
    outline-offset: 2px;
}

/* responsive: order must be back button then image then form */
@media only screen and (max-width: 960px) {
    body {
        padding: 1rem;
        place-items: start center;
    }

    .auth-main {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        padding: 1.1rem;
        gap: 1rem;
    }

    .back-btn {
        grid-column: 1;
        grid-row: 1;
        justify-self: end;
        width: fit-content;
        margin: 0;
    }

    .auth-visual {
        grid-column: 1;
        grid-row: 2;
        min-height: 240px;
    }

    .auth-forms {
        grid-column: 1;
        grid-row: 3;
        max-width: 520px;
        margin: 0 auto;
    }

    .phone-input {
        grid-template-columns: 1fr;
    }
}

/* ===== Modal shell ===== */
.auth-modal.hidden {
    display: none;
}

.auth-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
}

.auth-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
}

.auth-modal__panel {
    position: relative;
    z-index: 1;
    width: min(1100px, 95vw);
    margin: 4vh auto;
}

.auth-modal__close {
    position: absolute;
    top: 10px;
    right: 14px;
    z-index: 5;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    font-size: var(--font-size-lg);
    line-height: 1;
}

/* error box inside modal */
.auth-errors {
    border: 1px solid rgba(255, 0, 0, 0.25);
    background: rgba(255, 0, 0, 0.06);
    color: #b10000;
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: var(--font-size-sm);
}

.auth-errors.hidden {
    display: none;
}

/* General hidden utility class */
.hidden {
    display: none !important;
}

.auth-modal.hidden {
    display: none;
}

.auth-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
}

.auth-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
}

.auth-modal__panel {
    position: relative;
    z-index: 1;
    width: min(520px, 95vw);
    margin: 8vh auto;
}

.auth-modal__close {
    position: absolute;
    top: 10px;
    right: 14px;
    z-index: 5;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    font-size: var(--font-size-lg);
    line-height: 1;
    transition: background var(--td-fast) ease;
}

.auth-modal__close:hover {
    background: rgba(255, 255, 255, 0.95);
}

.auth-modal__content {
    width: 100%;
    padding: 1.6rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.92);
}

/* Modal forms styling */
.auth-modal .auth-forms {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 1.25rem;
    border-radius: 16px;
    border: 1px solid rgba(230, 231, 241, 0.85);
    background: rgba(255, 255, 255, 0.70);
}

/* error box */
.auth-errors {
    border: 1px solid rgba(255, 0, 0, 0.25);
    background: rgba(255, 0, 0, 0.06);
    color: #b10000;
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: var(--font-size-sm);
}

.auth-errors.hidden {
    display: none;
}

/* Back button in modal */
.auth-modal .back-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.75);
    color: var(--text);
    text-decoration: none;
    font-weight: var(--font-weight-bold);
    cursor: pointer;
    transition:
        transform var(--td-fast) ease,
        border-color var(--td-fast) ease,
        background var(--td-fast) ease;
}

.auth-modal .back-btn:hover {
    border-color: rgba(49, 145, 219, 0.35);
    transform: translateY(-1px);
}

.auth-modal .back-btn:active {
    transform: translateY(0);
}
