:root {
    --brand-gold: #c59d5f;
    --brand-gold-dark: #a8844f;
    --brand-navy: #1a3a5c;
    --brand-slate: #64748b;
    --surface: #ffffff;
    --border: #e5e7eb;
    --danger: #dc2626;
    --shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: "Vazirmatn", Tahoma, sans-serif;
    color: var(--brand-navy);
}

.auth-page {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
}

@media (max-width: 860px) {
    html,
    body {
        height: 100%;
        overflow: hidden;
    }

    .auth-page {
        height: 100svh;
        height: 100dvh;
        overflow: hidden;
    }
}

.auth-background {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: linear-gradient(
        -45deg,
        #f8fafc,
        #dce8f5,
        #faf0d4,
        #e8edf5,
        #f5e0b8,
        #d4e2f0,
        #faf6ee,
        #eef2f7
    );
    background-size: 600% 600%;
    animation: auth-bg-gradient 11s ease-in-out infinite;
}

.auth-background::before,
.auth-background::after {
    content: "";
    position: absolute;
    inset: -35%;
    pointer-events: none;
    will-change: transform;
}

.auth-background::before {
    background:
        radial-gradient(circle at 25% 25%, rgba(197, 157, 95, 0.48), transparent 46%),
        radial-gradient(circle at 75% 35%, rgba(232, 200, 114, 0.36), transparent 42%),
        radial-gradient(circle at 55% 85%, rgba(26, 58, 92, 0.22), transparent 44%);
    animation: auth-bg-drift-a 13s ease-in-out infinite;
}

.auth-background::after {
    background:
        radial-gradient(circle at 80% 20%, rgba(26, 58, 92, 0.3), transparent 48%),
        radial-gradient(circle at 15% 70%, rgba(197, 157, 95, 0.34), transparent 44%),
        radial-gradient(circle at 60% 50%, rgba(148, 163, 184, 0.24), transparent 50%);
    animation: auth-bg-drift-b 16s ease-in-out infinite;
}

.auth-background__grid {
    position: absolute;
    inset: 0;
    opacity: 0.24;
    background-image:
        linear-gradient(rgba(148, 163, 184, 0.16) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.16) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(circle at center, black, transparent 78%);
    pointer-events: none;
    animation: auth-bg-grid-shift 18s linear infinite;
}

@keyframes auth-bg-gradient {
    0% {
        background-position: 0% 50%;
    }

    33% {
        background-position: 100% 0%;
    }

    66% {
        background-position: 0% 100%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes auth-bg-drift-a {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
    }

    25% {
        transform: translate(12%, -10%) scale(1.14) rotate(8deg);
    }

    50% {
        transform: translate(-8%, 14%) scale(0.92) rotate(-6deg);
    }

    75% {
        transform: translate(10%, 8%) scale(1.1) rotate(10deg);
    }

    100% {
        transform: translate(0, 0) scale(1) rotate(0deg);
    }
}

@keyframes auth-bg-drift-b {
    0% {
        transform: translate(0, 0) scale(1.08) rotate(0deg);
    }

    25% {
        transform: translate(-14%, 8%) scale(0.9) rotate(-10deg);
    }

    50% {
        transform: translate(10%, -12%) scale(1.16) rotate(8deg);
    }

    75% {
        transform: translate(-6%, -8%) scale(1.04) rotate(-12deg);
    }

    100% {
        transform: translate(0, 0) scale(1.08) rotate(0deg);
    }
}

@keyframes auth-bg-grid-shift {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    100% {
        transform: translate(24px, 24px) rotate(1.5deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-background {
        animation: none;
        background-size: 100% 100%;
    }

    .auth-background::before,
    .auth-background::after,
    .auth-background__grid {
        animation: none;
    }
}

.auth-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(920px, 100%);
    min-height: 520px;
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    background: var(--surface);
    border-radius: 18px;
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.7);
}

.login-card__form {
    padding: 42px 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 18px;
}

.login-card__header {
    text-align: center;
}

.login-card__company {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.8;
}

.login-card__year {
    margin: 8px 0 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--brand-slate);
}

.login-card__avatar-wrap {
    display: flex;
    justify-content: center;
    margin: 8px 0 4px;
}

.login-card__avatar {
    width: 130px;
    height: 160px;
    border-radius: 65px / 80px;
    object-fit: cover;
    object-position: center top;
    display: block;
    flex: 0 0 auto;
    border: 3px solid #fff;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
    background: #f1f5f9;
}

.login-form {
    display: grid;
    gap: 16px;
}

.field__label.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.user-select {
    position: relative;
}

.user-select__input,
.field__input {
    width: 100%;
    border: none;
    border-bottom: 1px solid #cbd5e1;
    background: transparent;
    padding: 12px 36px 12px 4px;
    font: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.user-select__input:focus,
.field__input:focus {
    border-color: var(--brand-gold);
    box-shadow: 0 1px 0 0 var(--brand-gold);
}

.user-select__input.is-invalid,
.field__input.is-invalid {
    border-color: var(--danger);
}

.user-select__icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--brand-slate);
    pointer-events: none;
}

.field__error {
    margin: 6px 0 0;
    color: var(--danger);
    font-size: 0.875rem;
}

.login-form__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 8px;
}

.btn {
    border: 0;
    border-radius: 4px;
    padding: 12px 16px;
    font: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.2s ease, opacity 0.2s ease;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn--primary {
    background: linear-gradient(180deg, #e8c872 0%, var(--brand-gold) 100%);
    color: var(--brand-navy);
    font-weight: 700;
}

.btn--primary:hover:not(:disabled) {
    transform: translateY(-1px);
    background: linear-gradient(180deg, #f0d48a 0%, #d4ad72 100%);
}

.btn--ghost {
    background: #fff;
    border: 1px solid #d1d5db;
    color: #475569;
}

.login-card__brand {
    display: grid;
    grid-template-rows: 1fr auto;
    background: #fff;
}

.login-card__brand-top {
    padding: 32px 28px 20px;
    text-align: center;
    border-right: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafbfc;
}

.brand-logo__image {
    width: min(80%, 280px);
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.login-card__brand-bottom {
    background: linear-gradient(180deg, #e8c872 0%, var(--brand-gold) 100%);
    padding: 22px 24px;
    text-align: center;
    color: var(--brand-navy);
}

.login-card__brand-bottom p {
    margin: 0 0 6px;
    font-weight: 600;
}

.brand-bottom__url {
    margin-top: 10px !important;
    font-size: 0.85rem;
    opacity: 0.85;
}

.dashboard-page {
    min-height: 100vh;
    background: #f8fafc;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 20px 28px;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.dashboard-header h1 {
    margin: 0 0 4px;
    font-size: 1.25rem;
}

.dashboard-header p {
    margin: 0;
    color: var(--brand-slate);
}

.dashboard-main {
    padding: 28px;
}

.dashboard-placeholder {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

@media (max-width: 860px) {
    .auth-shell {
        height: 100%;
        min-height: 0;
        padding: 8px;
        padding-top: max(8px, env(safe-area-inset-top));
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        display: flex;
        align-items: stretch;
        place-items: stretch;
    }

    .login-card {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        width: 100%;
        height: 100%;
        max-height: 100%;
        min-height: 0;
        border-radius: 12px;
        box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
    }

    .login-card__brand {
        display: contents;
    }

    .login-card__brand-top {
        order: 1;
        border-right: 0;
        border-bottom: 1px solid #f1f5f9;
        padding: 8px 16px 10px;
        flex-shrink: 0;
    }

    .brand-logo__image {
        width: auto;
        max-width: min(78%, 260px);
        max-height: clamp(92px, 15svh, 132px);
        object-fit: contain;
    }

    .login-card__form {
        order: 2;
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        padding: 6px 18px 0;
        gap: 10px;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
    }

    .login-card__header {
        flex-shrink: 0;
    }

    .login-card__company {
        font-size: clamp(1rem, 4.5vw, 1.22rem);
        line-height: 1.55;
        font-weight: 700;
    }

    .login-card__avatar-wrap {
        margin: 0;
        flex-shrink: 0;
    }

    .login-card__avatar {
        width: clamp(88px, 23vw, 112px);
        height: auto;
        aspect-ratio: 130 / 160;
        border-radius: 50% / 46%;
        border: 2px solid #fff;
        box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
    }

    .login-form {
        gap: 10px;
        flex-shrink: 0;
        margin-top: 0;
        padding: 14px 14px 12px;
        background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
    }

    .user-select__input,
    .field__input {
        padding: 10px 32px 10px 8px;
        font-size: 16px;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        border-bottom: 1px solid #e2e8f0;
        box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    }

    .user-select__input:focus,
    .field__input:focus {
        border-color: var(--brand-gold);
        box-shadow: 0 0 0 3px rgba(197, 157, 95, 0.18);
    }

    .user-select__icon {
        left: 12px;
    }

    .login-form__actions {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-top: 2px;
    }

    .btn {
        min-height: 42px;
        padding: 10px 12px;
        font-size: 0.9rem;
        border-radius: 8px;
    }

    .btn--ghost {
        background: #fff;
    }

    .login-card__brand-bottom {
        order: 3;
        flex-shrink: 0;
        margin-top: auto;
        padding: 12px 14px max(14px, env(safe-area-inset-bottom));
        border-radius: 0 0 12px 12px;
    }

    .login-card__brand-bottom p {
        margin: 0 0 2px;
        font-size: clamp(0.68rem, 2.8vw, 0.82rem);
        line-height: 1.35;
    }

    .brand-bottom__url {
        margin-top: 2px !important;
        font-size: clamp(0.62rem, 2.5vw, 0.75rem) !important;
    }
}

@media (max-width: 860px) and (max-height: 740px) {
    .login-card__brand-top {
        padding: 6px 12px 8px;
    }

    .brand-logo__image {
        max-width: min(74%, 230px);
        max-height: clamp(78px, 12svh, 100px);
    }

    .login-card__form {
        padding: 4px 14px 0;
        gap: 8px;
    }

    .login-card__avatar {
        width: clamp(76px, 21vw, 96px);
    }

    .login-card__company {
        font-size: clamp(0.92rem, 4vw, 1.08rem);
        line-height: 1.45;
    }

    .login-form {
        gap: 8px;
        padding: 12px 12px 10px;
    }

    .user-select__input,
    .field__input {
        padding: 8px 28px 8px 8px;
    }

    .btn {
        min-height: 38px;
        font-size: 0.85rem;
    }

    .login-card__brand-bottom {
        margin-top: auto;
        padding: 10px 12px max(10px, env(safe-area-inset-bottom));
    }

    .login-card__brand-bottom p {
        font-size: 0.65rem;
        margin-bottom: 1px;
    }
}

@media (max-width: 480px) {
    .auth-shell {
        padding: 6px;
    }

    .login-card {
        border-radius: 10px;
    }

    .login-card__brand-bottom {
        border-radius: 0 0 10px 10px;
    }
}

@media (max-width: 360px) {
    .btn {
        min-height: 36px;
        padding: 6px 8px;
        font-size: 0.8rem;
    }
}

/* PWA — standalone app mode */
@media (display-mode: standalone) {
    .auth-shell {
        padding-top: max(12px, env(safe-area-inset-top));
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .dashboard-header {
        padding-top: max(20px, env(safe-area-inset-top));
    }

    .pwa-install-banner {
        display: none !important;
    }
}

.pwa-install-banner {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
}

.pwa-install-banner[hidden] {
    display: none !important;
}

.pwa-install-banner__content {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.pwa-install-banner__icon {
    flex-shrink: 0;
    border-radius: 12px;
}

.pwa-install-banner__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.82rem;
    color: var(--brand-slate);
    line-height: 1.45;
}

.pwa-install-banner__text strong {
    color: var(--brand-navy);
    font-size: 0.92rem;
}

.pwa-install-banner__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.pwa-install-banner__install {
    border: 0;
    border-radius: 8px;
    padding: 8px 14px;
    background: linear-gradient(180deg, #e8c872 0%, var(--brand-gold) 100%);
    color: var(--brand-navy);
    font: inherit;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
}

.pwa-install-banner__dismiss {
    border: 0;
    background: transparent;
    color: var(--brand-slate);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
}

.offline-page .auth-shell {
    min-height: 100dvh;
}

.offline-card {
    width: min(420px, 100%);
    margin: 0 auto;
    padding: 32px 24px;
    text-align: center;
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.offline-card img {
    margin-bottom: 16px;
}

.offline-card h1 {
    margin: 0 0 8px;
    font-size: 1.15rem;
}

.offline-card p {
    margin: 0 0 20px;
    color: var(--brand-slate);
    line-height: 1.7;
}
