/* Unitum Visual Brand — споделени токени и auth shell */
:root {
    --font: 'Geologica', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --unitum-black: #000000;
    --unitum-blue: #365baa;
    --unitum-blue-hover: #2c4a8f;
    --unitum-neutral-100: #edeff7;
    --unitum-neutral-200: #e7e8ee;
    --unitum-neutral-300: #d6dbef;
    --unitum-text-secondary: #676d70;
    --bg: var(--unitum-neutral-100);
    --bg-subtle: #f7f8fc;
    --surface: #ffffff;
    --border: var(--unitum-neutral-200);
    --border-strong: var(--unitum-neutral-300);
    --text: var(--unitum-black);
    --text-secondary: var(--unitum-text-secondary);
    --text-muted: #8a9093;
    --primary: var(--unitum-blue);
    --primary-hover: var(--unitum-blue-hover);
    --primary-fg: #ffffff;
    --header-bg: var(--unitum-black);
    --header-text: #ffffff;
    --header-border: var(--unitum-blue);
    --danger: #c62828;
    --danger-bg: #ffebee;
    --ok: #2e7d32;
    --ok-bg: #e8f5e9;
    --radius: 10px;
    --radius-lg: 14px;
    --unitum-radius-card: 14px 14px 14px 6px;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(54, 91, 170, 0.08);
    /* Алиаси за съществуващи dashboard стилове */
    --primary-color: var(--unitum-blue);
    --primary-dark: var(--unitum-blue-hover);
    --bg-color: var(--unitum-neutral-100);
    --border-color: var(--unitum-neutral-200);
    --text-primary: var(--unitum-black);
    --text-secondary-alias: var(--unitum-text-secondary);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    line-height: 1.5;
    font-size: 15px;
}

body.auth-body {
    background: var(--unitum-neutral-100);
    min-height: 100vh;
    min-height: 100dvh;
}

body.auth-body main {
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ——— Auth split shell ——— */
.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
}

.auth-shell__brand {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(1.75rem, 4vw, 3rem);
    background-color: #141c21;
    color: #eceff1;
    overflow: hidden;
    isolation: isolate;
}

.auth-shell__brand::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -2;
    background-image: var(--auth-brand-bg);
    background-size: cover;
    background-position: center 55%;
    background-repeat: no-repeat;
    transform: scale(1.04);
    filter: saturate(0.75) contrast(1.08);
}

.auth-shell__brand::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        linear-gradient(112deg, rgba(12, 18, 22, 0.94) 0%, rgba(18, 28, 34, 0.82) 42%, rgba(24, 36, 44, 0.62) 72%, rgba(30, 42, 50, 0.48) 100%),
        linear-gradient(180deg, rgba(8, 12, 15, 0.55) 0%, transparent 28%, transparent 72%, rgba(8, 12, 15, 0.72) 100%),
        radial-gradient(ellipse 120% 80% at 0% 100%, rgba(54, 91, 170, 0.32) 0%, transparent 58%);
}

/* Счетоводен портал — фонова снимка (успех / устойчивост) */
.auth-shell__brand--accountant {
    background-color: #141c21;
}

.auth-shell__brand--accountant::before {
    background-image: var(--auth-brand-bg);
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    transform: scale(1.02);
    filter: saturate(0.7) contrast(1.05) brightness(0.92);
}

.auth-shell__brand--accountant::after {
    background:
        linear-gradient(112deg, rgba(10, 16, 28, 0.92) 0%, rgba(16, 24, 38, 0.84) 40%, rgba(22, 32, 48, 0.72) 68%, rgba(28, 40, 58, 0.58) 100%),
        linear-gradient(180deg, rgba(6, 10, 18, 0.55) 0%, transparent 28%, transparent 68%, rgba(6, 10, 18, 0.75) 100%),
        radial-gradient(ellipse 100% 70% at 100% 0%, rgba(54, 91, 170, 0.28) 0%, transparent 55%),
        radial-gradient(ellipse 80% 60% at 0% 100%, rgba(54, 91, 170, 0.22) 0%, transparent 50%);
}

.auth-shell__brand--accountant .auth-shell__brand-inner::before,
.auth-shell__brand--accountant .auth-shell__brand-inner::after {
    content: none;
}

.auth-shell__brand-inner {
    position: relative;
    z-index: 1;
    max-width: 28rem;
    isolation: isolate;
}

.auth-shell__logo {
    display: inline-flex;
    align-items: center;
    gap: 0.85rem;
    text-decoration: none;
    color: #fff;
    margin-bottom: 2.5rem;
}

.auth-shell__logo:hover { text-decoration: none; color: #fff; }

.auth-shell__logo-mark {
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius);
    background: linear-gradient(145deg, #365baa 0%, #2c4a8f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
    overflow: hidden;
}

.auth-shell__logo-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 0.35rem;
}

.auth-shell__logo-mark svg {
    width: 1.65rem;
    height: 1.65rem;
    color: #fff;
}

.auth-shell__logo-text {
    font-weight: 600;
    font-size: 1.0625rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    line-height: 1.2;
}

.auth-shell__logo-text small {
    display: block;
    font-size: 0.75rem;
    font-weight: 300;
    text-transform: none;
    letter-spacing: 0.01em;
    opacity: 0.88;
    margin-top: 0.2rem;
}

.auth-shell__headline {
    margin: 0 0 0.85rem;
    font-size: clamp(1.75rem, 3.2vw, 2.25rem);
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -0.02em;
    color: #fff;
    text-shadow: 0 2px 18px rgba(0, 0, 0, 0.35);
}

.auth-shell__lead {
    margin: 0 0 2rem;
    font-size: 1rem;
    font-weight: 300;
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.9);
    max-width: 26rem;
    text-shadow: 0 1px 12px rgba(0, 0, 0, 0.35);
}

.auth-shell__features {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.75rem;
}

.auth-shell__feature {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.875rem;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.92);
    line-height: 1.5;
    padding: 0.75rem 0.85rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.auth-shell__feature-icon {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.16);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #d6dbef;
}

.auth-shell__feature-icon svg {
    width: 1rem;
    height: 1rem;
}

.auth-shell__feature strong {
    display: block;
    color: #fff;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.15rem;
}

.auth-shell__footer {
    position: relative;
    z-index: 1;
    font-size: 0.75rem;
    color: rgba(176, 190, 197, 0.9);
    padding-top: 2rem;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
}

.auth-shell__form-side {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1.5rem, 4vw, 3rem);
    padding-top: max(clamp(1.5rem, 4vw, 3rem), env(safe-area-inset-top, 0px));
    padding-bottom: max(clamp(1.5rem, 4vw, 3rem), env(safe-area-inset-bottom, 0px));
    background: var(--unitum-neutral-100);
    position: relative;
}

.auth-form-column {
    width: 100%;
    max-width: 26rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
}

.auth-card {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--unitum-neutral-200);
    border-radius: var(--radius-lg);
    padding: clamp(1.5rem, 3vw, 2rem);
    box-shadow: var(--shadow-md);
}

.auth-card__eyebrow {
    margin: 0 0 0.35rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--unitum-blue);
}

.auth-card__title {
    margin: 0 0 0.5rem;
    font-size: 1.625rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--unitum-black);
    line-height: 1.2;
}

.auth-card__subtitle {
    margin: 0 0 1.75rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--unitum-text-secondary);
    line-height: 1.55;
}

.auth-field { margin-bottom: 1.15rem; }

.auth-field label,
.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.auth-field__control { position: relative; }

.auth-field__icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.125rem;
    height: 1.125rem;
    color: var(--text-muted);
    pointer-events: none;
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    min-height: 44px;
    border: 1px solid var(--unitum-neutral-200);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 400;
    color: var(--text);
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-field .form-control { padding-left: 2.65rem; }

.form-control:focus {
    outline: none;
    border-color: var(--unitum-blue);
    box-shadow: 0 0 0 3px rgba(54, 91, 170, 0.14);
}

.form-control.error,
.form-control.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.12);
}

.auth-field--password .form-control {
    padding-left: 0.85rem;
    padding-right: 2.75rem;
}

.auth-field--password .form-control::-ms-reveal,
.auth-field--password .form-control::-ms-clear,
.auth-field--password .form-control::-webkit-credentials-auto-fill-button,
.auth-field--password .form-control::-webkit-password-reveal-button {
    display: none;
}

.auth-field__toggle {
    position: absolute;
    right: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2rem;
    height: 2rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.auth-field__toggle svg,
.auth-field__toggle-icon {
    width: 1rem;
    height: 1rem;
    display: block;
}

.auth-field__toggle:hover {
    color: var(--text-secondary);
    background: var(--bg-subtle);
}

.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.75rem 0.9rem;
    margin-bottom: 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.45;
    background: var(--danger-bg);
    color: #b71c1c;
    border: 1px solid #ffcdd2;
}

.auth-alert svg {
    flex-shrink: 0;
    width: 1.125rem;
    height: 1.125rem;
    margin-top: 0.1rem;
}

.auth-alert--success {
    background: var(--ok-bg);
    color: #1b5e20;
    border-color: #a5d6a7;
}

.error-message {
    color: var(--danger);
    font-size: 0.8125rem;
    margin-top: 0.35rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary,
.auth-submit {
    width: 100%;
    min-height: 46px;
    margin-top: 0.35rem;
    padding: 0.65rem 1rem;
    font-size: 0.9375rem;
    background: var(--unitum-blue);
    color: #fff;
    box-shadow: 0 2px 10px rgba(54, 91, 170, 0.28);
}

.btn-primary:hover,
.auth-submit:hover:not(:disabled) {
    background: var(--unitum-blue-hover);
}

.btn-primary:disabled,
.auth-submit:disabled {
    opacity: 0.72;
    cursor: wait;
}

.auth-submit__spinner {
    display: none;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: unitum-spin 0.65s linear infinite;
}

.auth-submit.is-loading .auth-submit__spinner { display: block; }

@keyframes unitum-spin { to { transform: rotate(360deg); } }

.auth-powered-by { margin: 0; text-align: center; }

.auth-powered-by__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.4rem 0.5rem;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    opacity: 0.68;
    transition: opacity 0.2s ease, color 0.2s ease;
}

.auth-powered-by__link:hover {
    opacity: 1;
    color: var(--text-secondary);
    text-decoration: none;
}

.auth-powered-by__logo {
    display: block;
    height: 1.125rem;
    width: auto;
    max-width: 4.5rem;
    object-fit: contain;
}

.auth-card__help {
    margin: 1.35rem 0 0;
    padding-top: 1.25rem;
    border-top: 1px solid var(--unitum-neutral-200);
    font-size: 0.8125rem;
    font-weight: 300;
    color: var(--unitum-text-secondary);
    text-align: center;
    line-height: 1.5;
}

.auth-card__back {
    margin: 1.15rem 0 0;
    text-align: center;
    font-size: 0.8125rem;
    font-weight: 500;
}

.auth-card__back a {
    color: var(--unitum-blue);
    text-decoration: none;
}

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

#portal-toast {
    position: fixed;
    top: max(1.25rem, env(safe-area-inset-top, 0px));
    right: max(1.25rem, env(safe-area-inset-right, 0px));
    max-width: min(22rem, calc(100vw - 2.5rem));
    padding: 0.85rem 1.25rem;
    border-radius: var(--unitum-radius-lg, 12px);
    color: #fff;
    font-weight: 500;
    font-size: 0.9375rem;
    line-height: 1.45;
    box-shadow: var(--unitum-shadow-md, 0 10px 25px rgba(15, 23, 42, 0.12));
    z-index: 25000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
    word-break: break-word;
}

#portal-toast.is-visible {
    opacity: 1;
    pointer-events: auto;
}

/* ——— Dashboard portal header (Unitum) ——— */
body.portal-dashboard {
    background: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font);
}

.portal-dashboard .header {
    background: var(--header-bg);
    color: var(--header-text);
    border-bottom: 3px solid var(--header-border);
    box-shadow: var(--shadow-md);
}

.portal-dashboard .header .logo {
    filter: brightness(0) invert(1);
    max-height: 36px;
}

.portal-dashboard .header-nav a {
    color: rgba(255, 255, 255, 0.88);
    font-weight: 500;
}

.portal-dashboard .header-nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.portal-dashboard .header-nav a[aria-current="page"] {
    color: #fff;
    background: rgba(54, 91, 170, 0.45);
}

.portal-dashboard .portal-nav-toggle {
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.portal-dashboard .header-logout-btn {
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    box-shadow: none;
}

.portal-dashboard .header-logout-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
}

.portal-dashboard .main {
    background: var(--bg-color);
}

/* Lux toolbar върху тъмен хедър */
.portal-dashboard .header .portal-lux-toolbar .topbar-icon-btn {
    color: rgba(255, 255, 255, 0.88);
}

.portal-dashboard .header .portal-lux-toolbar .topbar-icon-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.portal-dashboard .header .portal-lux-toolbar .topbar-icon-badge {
    border-color: var(--header-bg, #000);
}

/* Unitum типография в съдържанието */
.portal-dashboard .main h1 {
    font-size: clamp(1.35rem, 3vw, 1.5625rem);
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.portal-dashboard .main h2 {
    font-size: clamp(1.5rem, 3.5vw, 2.125rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.portal-dashboard .main h3 {
    font-size: clamp(1.2rem, 2.5vw, 1.5625rem);
    font-weight: 600;
    line-height: 1.25;
}

.portal-dashboard .main p,
.portal-dashboard .main .portal-empty-panel__text {
    font-weight: 300;
}

@media (max-width: 599px) {
    .portal-crm-shortcuts {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scrollbar-width: thin;
        gap: 0.4rem;
        padding-bottom: 0.75rem;
    }

    .portal-crm-shortcuts__btn {
        flex-shrink: 0;
        min-height: 44px;
    }

    .portal-table-wrap table {
        min-width: 36rem;
    }

    table.portal-inv-table {
        min-width: 58rem;
    }
}

@media (max-width: 380px) {
    .header .logo {
        max-width: min(160px, 42vw);
    }
}

@media (max-width: 900px) {
    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-shell__brand {
        min-height: 16rem;
        padding: 1.5rem;
    }

    .auth-shell__headline {
        font-size: 1.5rem;
    }

    .auth-shell__features {
        display: none;
    }
}
