:root {
    --auth-primary: var(--primary, #6B153A);
    --auth-primary-dark: var(--primary-hover, #58102F);
    --auth-primary-active: var(--primary-active, #470C25);
    --auth-accent: var(--gold, #D4AF37);
    --auth-dark: var(--text-primary, #1D1D1F);
    --auth-dark-soft: #2A1520;
    --auth-text-muted: var(--text-muted, #6B7280);
    --auth-border: var(--border, #E5E7EB);
    --auth-surface: var(--surface, #FFFFFF);
    --auth-background: var(--background, #FAFAFA);
    --auth-radius: var(--radius-2xl, 1.5rem);
    --auth-input-radius: var(--radius-full, 9999px);
    --auth-shadow: var(--shadow-modal, 0 25px 50px -12px rgba(29, 29, 31, 0.18));
    --auth-focus: var(--shadow-focus, 0 0 0 3px rgba(107, 21, 58, 0.18));
}

*, *::before, *::after { box-sizing: border-box; }

html, body.auth-page {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font-ui, 'Inter', -apple-system, BlinkMacSystemFont, sans-serif);
    background: var(--auth-background);
    -webkit-font-smoothing: antialiased;
}

html[dir="rtl"] body.auth-page {
    font-family: 'Tajawal', 'Inter', sans-serif;
}

.auth-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 16px;
}

.auth-card {
    display: flex;
    width: 100%;
    max-width: 1100px;
    min-height: calc(100vh - 32px);
    min-height: calc(100dvh - 32px);
    background: var(--auth-surface);
    border-radius: var(--auth-radius);
    overflow: hidden;
    box-shadow: var(--auth-shadow);
    border: 1px solid var(--auth-border);
}

/* Brand panel */
.auth-brand {
    flex: 0 0 42%;
    background: linear-gradient(145deg, var(--auth-dark) 0%, var(--auth-dark-soft) 45%, var(--auth-primary) 100%);
    color: #fff;
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.auth-brand::before {
    content: '';
    position: absolute;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(212, 175, 55, 0.2) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.auth-brand::after {
    content: '';
    position: absolute;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.08);
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.auth-brand-tagline {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.5;
    max-width: 280px;
    position: relative;
    z-index: 1;
}

.auth-brand-headline {
    font-family: var(--font-brand, 'Playfair Display', Georgia, serif);
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 700;
    line-height: 1.15;
    margin: 0;
    position: relative;
    z-index: 1;
    letter-spacing: -0.02em;
}

.auth-brand-visual {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    padding: 24px 0;
}

.auth-brand-mockup {
    width: 220px;
    max-width: 80%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    padding: 20px;
    backdrop-filter: blur(8px);
}

.auth-brand-mockup-balance {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.auth-brand-mockup-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 16px;
}

.auth-brand-mockup-bars {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 48px;
}

.auth-brand-mockup-bars span {
    flex: 1;
    background: linear-gradient(180deg, var(--auth-accent) 0%, rgba(107, 21, 58, 0.5) 100%);
    border-radius: 4px 4px 0 0;
}

.auth-brand-mockup-bars span:nth-child(1) { height: 40%; }
.auth-brand-mockup-bars span:nth-child(2) { height: 70%; }
.auth-brand-mockup-bars span:nth-child(3) { height: 55%; }
.auth-brand-mockup-bars span:nth-child(4) { height: 90%; }
.auth-brand-mockup-bars span:nth-child(5) { height: 65%; }

/* Form panel */
.auth-form-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 32px 40px 24px;
    min-width: 0;
}

.auth-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    gap: 12px;
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--auth-dark);
}

.auth-logo img {
    height: 40px;
    width: auto;
    max-width: 180px;
    object-fit: contain;
}

.auth-logo-text {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--auth-dark);
}

.auth-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-link {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--auth-primary);
    text-decoration: none;
    transition: color 0.15s;
}

.auth-link:hover {
    color: var(--auth-primary-dark);
    text-decoration: none;
}

.auth-lang-toggle {
    font-size: 0.8rem;
    color: var(--auth-text-muted);
    text-decoration: none;
    padding: 6px 12px;
    border: 1px solid var(--auth-border);
    border-radius: 999px;
    transition: all 0.15s;
}

.auth-lang-toggle:hover {
    border-color: var(--auth-primary);
    color: var(--auth-primary);
    text-decoration: none;
}

.auth-form-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: 400px;
    width: 100%;
    margin: 0 auto;
}

.auth-form-title {
    font-family: var(--font-brand, 'Playfair Display', Georgia, serif);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--auth-dark);
    margin: 0 0 8px;
    letter-spacing: -0.02em;
}

.auth-form-subtitle {
    font-size: 0.9rem;
    color: var(--auth-text-muted);
    margin: 0 0 28px;
    line-height: 1.5;
}

.auth-field {
    margin-bottom: 20px;
}

.auth-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 8px;
}

.auth-input-wrap {
    position: relative;
}

.auth-input {
    width: 100%;
    padding: 14px 20px;
    font-size: 0.95rem;
    border: 1.5px solid var(--auth-border);
    border-radius: var(--auth-input-radius);
    background: #fff;
    color: var(--auth-dark);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.auth-input:focus {
    border-color: var(--auth-primary);
    box-shadow: var(--auth-focus);
}

.auth-input::placeholder {
    color: #94a3b8;
}

.auth-input.has-toggle {
    padding-inline-end: 48px;
}

.auth-toggle-password {
    position: absolute;
    top: 50%;
    inset-inline-end: 16px;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--auth-text-muted);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.auth-toggle-password:hover {
    color: var(--auth-primary);
}

.auth-forgot {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--auth-primary);
    text-decoration: none;
    margin-bottom: 24px;
}

.auth-forgot:hover {
    color: var(--auth-primary-dark);
    text-decoration: none;
}

.auth-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: var(--auth-primary);
    border: none;
    border-radius: var(--auth-input-radius);
    cursor: pointer;
    transition: transform 150ms ease-out, box-shadow 150ms ease-out, background 150ms ease-out, opacity 150ms ease-out;
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(29, 29, 31, 0.06));
}

.auth-btn:hover {
    background: var(--auth-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md, 0 4px 6px rgba(29, 29, 31, 0.07));
}

.auth-btn:active {
    background: var(--auth-primary-active);
    transform: translateY(0);
}

.auth-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.auth-btn svg {
    width: 18px;
    height: 18px;
}

.auth-alert {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.875rem;
    margin-bottom: 20px;
    line-height: 1.5;
}

.auth-alert-success {
    background: var(--success-light, #ecf8f1);
    color: var(--success, #16A34A);
    border: 1px solid rgba(22, 163, 74, 0.2);
}

.auth-alert-error {
    background: var(--danger-light, #fceeee);
    color: var(--danger, #DC2626);
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.auth-alert-warning {
    background: var(--warning-light, #fef7eb);
    color: var(--warning-hover, #d88b0a);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.auth-form-footer {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--auth-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--auth-text-muted);
}

.auth-signup-prompt {
    text-align: center;
    margin-top: 24px;
    font-size: 0.875rem;
    color: var(--auth-text-muted);
}

.auth-signup-prompt a {
    font-weight: 600;
    color: var(--auth-primary);
    text-decoration: none;
}

.auth-signup-prompt a:hover {
    text-decoration: underline;
}

.auth-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.auth-package-grid {
    display: grid;
    gap: 10px;
}

.auth-package-card {
    display: block;
    margin: 0;
    cursor: pointer;
}

.auth-package-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.auth-package-body {
    display: block;
    position: relative;
    padding: 14px 16px;
    border: 1.5px solid var(--auth-border);
    border-radius: 12px;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.auth-package-price {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--auth-primary);
    background: rgba(79, 70, 229, 0.08);
    border: 1px solid rgba(79, 70, 229, 0.18);
    border-radius: 999px;
    padding: 4px 10px;
    margin-bottom: 8px;
}

.auth-package-card input:checked + .auth-package-body {
    border-color: var(--auth-primary);
    box-shadow: var(--auth-focus);
    background: #f8fafc;
}

.auth-package-name {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--auth-dark);
    margin-bottom: 4px;
}

.auth-package-desc {
    display: block;
    font-size: 0.82rem;
    color: var(--auth-text-muted);
    line-height: 1.4;
    margin-bottom: 8px;
}

.auth-package-features {
    list-style: none;
    margin: 0 0 8px;
    padding: 0;
}

.auth-package-features li {
    position: relative;
    padding-inline-start: 18px;
    font-size: 0.78rem;
    color: #475569;
    line-height: 1.45;
    margin-bottom: 4px;
}

.auth-package-features li::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 0.45em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--auth-primary);
}

.auth-package-meta {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--auth-primary);
}

.auth-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--auth-text-muted);
    margin-bottom: 24px;
    line-height: 1.4;
}

.auth-checkbox input {
    margin-top: 3px;
    accent-color: var(--auth-primary);
}

.auth-success-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #f0fdf4;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    color: #22c55e;
    font-size: 1.75rem;
}

/* Mobile */
@media (max-width: 900px) {
    .auth-shell {
        padding: 0;
    }

    .auth-card {
        flex-direction: column;
        min-height: 100vh;
        min-height: 100dvh;
        border-radius: 0;
        max-width: none;
    }

    .auth-brand {
        flex: 0 0 auto;
        padding: 32px 24px 24px;
        min-height: auto;
    }

    .auth-brand-visual {
        display: none;
    }

    .auth-brand-headline {
        font-size: 1.5rem;
    }

    .auth-form-panel {
        padding: 24px 20px 20px;
        flex: 1;
    }

    .auth-form-body {
        max-width: none;
    }

    .auth-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .auth-form-header {
        flex-wrap: wrap;
    }

    .auth-header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .auth-form-title {
        font-size: 1.5rem;
    }
}

html[dir="rtl"] .auth-brand-headline,
html[dir="rtl"] .auth-form-title {
    letter-spacing: 0;
}

html[dir="rtl"] .auth-toggle-password {
    inset-inline-end: 16px;
}

@media (max-width: 900px) {
    html[dir="rtl"] .auth-card {
        flex-direction: column;
    }
}
