/* ═══════════════════════════════════════════════
   АРБУЗ — Design System
   ═══════════════════════════════════════════════ */

:root {
    /* Brand — синий (кнопки, фокус, чипы, строки форм) */
    /* Smoky navy accent (более “дорого”, без яркой синевы) */
    --brand:       #344A67;
    --brand-mid:   #415A7C;
    /* Почти белый с лёгким голубым подтоном */
    --brand-pale:  #F2F6FF;
    --brand-dark:  #283B55;

    /* Surfaces */
    --surface:     #FFFFFF;
    --surface-2:   #F6F8FF;

    /* Text */
    --tx:          #374151;
    --tx-2:        #475569;

    /* Borders */
    --border:      #E7E9EE;

    /* Radius */
    --r:           8px;
    --r-lg:        12px;

    /* Shadows */
    --sh-sm:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --sh-md:       0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);

    /* Transition */
    --t:           .15s ease;

    /* Semantic colours */
    --green:       #16A34A;
    --green-soft:  rgba(22,163,74,.08);
    --danger:      #DC2626;
    --success:     #16A34A;

    /* KPI palette — совпадают с цветами секций Детализации */
    --kpi-revenue: #22C55E;   /* Выручка → зелёный  */
    --kpi-cost:    #6E86B6;   /* Расходы WB → smoky blue  */
    --kpi-net:     #22C55E;   /* Прибыль → зелёный   */
    --kpi-roi:     #3B4D73;   /* Налоги → navy, отличим от WB */
    --kpi-qty:     #FACC15;   /* Опер. затраты → янтарный */

    /* Column accent colours */
    --pink:        #EC4899;
    --col-wb-clr:  #6E86B6;
    --col-rev-clr: #22C55E;
    --col-cost-clr:#F97316;
    --col-neg-clr: #EF4444;
    --col-opex-clr:#FACC15;
    --col-tax-clr: #3B4D73;

    /* Sidebar */
    --sb-bg:       #FFFFFF;
    --sb-hover:    #F4F7FF;
    --sb-active:   #EEF3FF;
    --sb-text:     #374151;
    --sb-text-dim: #475569;
    --sb-text-active: var(--brand);
    --sb-border:   #E2E8F0;

    /* Report panels */
    --rp-bg:        #FFFFFF;
    --rp-surface:   var(--surface-2);
    --rp-border:    var(--border);
    --rp-text:      #374151;
    --rp-text-dim:  #475569;
    --rp-header-bg: var(--surface-2);

    /* Fonts */
    /* System UI stack: ближе всего к шрифту WB (SF Pro на macOS/iOS) */
    --font:        ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";

    /* Typography — единая шкала (размер / межстрочный / трекинг) */
    --text-2xs:    10px;
    --text-xs:     11px;
    --text-2sm:    12px;
    --text-sm:     13px;
    --text-base:   14px;
    --text-md:     15px;
    --text-lg:     17px;
    --text-icon:   18px;
    --text-xl:     20px;
    --text-2xl:    22px;
    --text-3xl:    28px;
    --text-display: 32px;

    --lh-tight:    1.2;
    --lh-snug:     1.35;
    --lh-normal:   1.5;
    --lh-relaxed:  1.6;

    --fw-regular:  400;
    --fw-medium:   500;
    --fw-semibold: 600;
    --fw-bold:     700;

    --track-tight:      -0.02em;
    --track-snug:       -0.01em;
    --track-slight:     0.01em;
    --track-caps-tight: 0.05em;
    --track-caps:       0.06em;
    --track-caps-md:    0.07em;
    --track-caps-wide:  0.08em;
    --track-sidebar:    0.1em;
    --track-logo:       0.3em;
    --track-overline:   0.12em;
    --track-caps-xl:    0.14em;
    --track-logo-wide:  0.38em;

    /* Page */
    /* Белый фон с очень лёгким голубым оттенком */
    --page-bg:     #FAFBFF;
    --radius:      8px;
    --radius-lg:   12px;
    --transition:  0.2s ease;
    --accent:      var(--brand);
    --accent-hover:var(--brand-dark);
    --page-border: var(--border);
    --page-text:   #374151;
    --page-text-soft: #475569;
    --page-sidebar-bg: #FFFFFF;
    --text-soft:   #64748B;

    /* Сетка: шапка и .content должны совпадать по ширине колонок и полям, иначе «плывёт» вёрстка */
    --layout-pad-x: 20px;
    --sidebar-width: 260px;
    /* Вертикальный зазор между «верхним» и «нижним» рядом (KPI↔панель = плитки сайдбара) */
    --main-stack-gap: 32px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
input, button, select, textarea, optgroup { font-family: inherit; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--text-base);
    font-weight: var(--fw-medium);
    line-height: var(--lh-normal);
    background: var(--page-bg);
    color: var(--tx);
    -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════ */

.layout { min-height: 100vh; display: flex; flex-direction: column; }

/* Фон как на страницах регистрации / входа (auth-page); в кабинете — белый */
body.layout {
    background: var(--page-bg);
    position: relative;
}

body.layout.layout--authed {
    /* Как на странице регистрации: базовый фон + отдельный слой .auth-bg (сетка + орбы) */
    background: #faf8f6;
}

/* В кабинете используем тот же фон, что на регистрации */
.layout--authed .auth-bg { display: block; }

/* ── Topbar (плитка) ── */
.topbar {
    z-index: 20;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr) auto;
    align-items: center;
    gap: 0;
    margin: 16px var(--layout-pad-x) 12px var(--layout-pad-x);
    padding: 14px 20px 14px 16px;
    min-height: 64px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-md);
}

/* ── Logo ── */
.logo {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    text-decoration: none;
    padding: 0;
    flex-shrink: 0;
}
.logo:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; border-radius: var(--r); }

.logo-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.logo-text {
    font-family: inherit;
    font-size: var(--text-xl);
    font-weight: var(--fw-regular);
    letter-spacing: 0.11em;
    line-height: 1;
    color: #000000;
}

/* ── Topbar center — nav ── */
.topbar-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

/* ── Top navigation ── */
.topnav { display: flex; gap: 2px; flex-wrap: wrap; align-items: center; }

.topnav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--r);
    font-size: var(--text-xs);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    letter-spacing: var(--track-caps);
    color: var(--tx);
    text-decoration: none;
    transition: background var(--t), color var(--t), box-shadow var(--t);
}
.topnav-link:hover { background: var(--sb-hover); color: var(--tx); }
.topnav-link.active {
    background: var(--sb-active);
    color: var(--sb-text-active);
    box-shadow: inset 0 0 0 1px rgba(52, 74, 103, 0.18);
}
.topnav-link:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* ── Cabinet chips strip ── */
.accounts-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: var(--text-base);
    color: var(--tx-2);
}
.accounts-label {
    text-transform: uppercase;
    letter-spacing: var(--track-caps-wide);
    font-weight: var(--fw-semibold);
    font-size: var(--text-2xs);
    color: var(--tx-2);
}
.account-chip {
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: var(--text-base);
    font-weight: var(--fw-medium);
    color: var(--tx);
    cursor: pointer;
    transition: border-color var(--t), background var(--t);
}
.account-chip--active {
    border-color: var(--brand);
    background: var(--brand-pale);
    color: var(--brand);
}
.account-chip--add {
    border: 1.5px dashed var(--border);
    background: transparent;
    color: var(--tx-2);
    text-decoration: none;
    font-size: var(--text-2sm);
    font-weight: var(--fw-semibold);
    padding: 6px 14px;
}
.account-chip--add:hover {
    border-color: var(--brand);
    color: var(--brand);
}
.account-chip:hover:not(.account-chip--active) { border-color: #CBD5E1; }

/* ── Content grid ── */
.content {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    gap: 20px;
    flex: 1;
    padding: 0 var(--layout-pad-x) 20px;
    position: relative;
    z-index: 1;
}

/* ── Sidebar column (обёртка плиток) ── */
.sidebar-column {
    display: flex;
    flex-direction: column;
    gap: var(--main-stack-gap);
    margin: 24px 0 48px 0;
    align-self: start;
    grid-column: 1;
    grid-row: 1 / -1;
}

/* ── Плитка переключения кабинетов — по высоте как KPI-блоки (не детализация) ── */
.sidebar-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-md);
    padding: 16px 12px;
    transition: border-color var(--t), box-shadow var(--t);
}

.layout--authed .sidebar-tile:hover {
    border-color: #CBD5E1;
}
.sidebar-cabinet-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.sidebar-cabinet-form {
    flex: 1;
    min-width: 0;
}
/* Кастомный dropdown кабинетов с иконкой площадки */
.cabinet-dropdown {
    position: relative;
    width: 100%;
}
.cabinet-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 40px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: var(--surface);
    font-family: inherit;
    font-size: var(--text-2sm);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    letter-spacing: var(--track-caps-tight);
    color: var(--sb-text);
    cursor: pointer;
    text-align: left;
}
.cabinet-dropdown-trigger:hover { border-color: #CBD5E1; }
.cabinet-dropdown-badge {
    flex-shrink: 0;
    min-width: 32px;
    padding: 2px 6px;
    font-size: var(--text-2xs);
}
.cabinet-dropdown-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cabinet-dropdown-arrow {
    flex-shrink: 0;
    opacity: 0.6;
}
.cabinet-dropdown-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: var(--surface);
    box-shadow: var(--sh-md);
    z-index: 50;
    max-height: 200px;
    overflow-y: auto;
}
.cabinet-dropdown--open .cabinet-dropdown-list { display: block; }
.cabinet-dropdown-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: var(--r);
    font-size: var(--text-2sm);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    letter-spacing: var(--track-caps-tight);
    color: var(--sb-text);
    cursor: pointer;
    transition: background var(--t);
}
.cabinet-dropdown-option:hover { background: var(--sb-hover); }
.sidebar-cabinet-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    min-width: 40px;
    padding: 9px 12px;
    border: none;
    border-radius: var(--r);
    background: transparent;
    font-family: inherit;
    font-size: var(--text-2sm);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    letter-spacing: var(--track-caps-tight);
    color: var(--sb-text);
    text-decoration: none;
    transition: background var(--t), color var(--t);
}
.sidebar-cabinet-add-btn:hover {
    background: var(--sb-hover);
    color: var(--tx);
}
.sidebar-cabinet-add-btn--full {
    width: 100%;
    min-width: 0;
}

/* ── Sidebar (плитка навигации) — опущена ниже ── */
.sidebar {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-md);
    padding: 20px 12px;
}
.sidebar-title {
    font-size: var(--text-2xs);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    letter-spacing: var(--track-sidebar);
    color: var(--sb-text-dim);
    margin: 0 0 8px 4px;
    padding: 0;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }

.support-dropdown {
    margin-top: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0;
}
.sidebar-support {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 12px;
    border-radius: var(--r);
    font-size: var(--text-2sm);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    letter-spacing: var(--track-caps-tight);
    color: #64748B;
    text-decoration: none;
    transition: background var(--t), color var(--t);
    width: 100%;
    box-sizing: border-box;
}
.sidebar-support { cursor: pointer; border: none; background: transparent; font-family: inherit; text-align: left; }
.sidebar-support:hover,
.sidebar-support--active { background: var(--sb-hover); color: var(--tx); }
.sidebar-support .sidebar-icon { flex-shrink: 0; opacity: .6; }
.sidebar-support:hover .sidebar-icon,
.sidebar-support--active .sidebar-icon { opacity: 1; }
.support-dropdown__chevron {
    margin-left: auto;
    flex-shrink: 0;
    opacity: .5;
    transition: transform var(--t);
}
.support-dropdown--open .support-dropdown__chevron {
    transform: rotate(180deg);
}
.support-dropdown__list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding-top: 4px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.28s ease;
}
.support-dropdown--open .support-dropdown__list {
    max-height: 120px;
}
.support-dropdown__item {
    display: block;
    padding: 9px 12px;
    border-radius: var(--r);
    font-size: var(--text-2sm);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    letter-spacing: var(--track-caps-tight);
    color: var(--sb-text);
    text-decoration: none;
    transition: background var(--t), color var(--t);
}
.support-dropdown__item:hover {
    background: var(--sb-hover);
    color: var(--tx);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 12px;
    border-radius: var(--r);
    font-size: var(--text-2sm);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    letter-spacing: var(--track-caps-tight);
    color: var(--sb-text);
    text-decoration: none;
    transition: background var(--t), color var(--t);
}
.sidebar-link:hover { background: var(--sb-hover); color: var(--tx); }
.sidebar-link.active {
    background: var(--sb-active);
    color: var(--sb-text-active);
}
.sidebar-icon {
    flex-shrink: 0;
    opacity: .7;
}
.sidebar-link.active .sidebar-icon,
.sidebar-link:hover .sidebar-icon {
    opacity: 1;
}
.sidebar-link--muted {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 12px;
    border-radius: var(--r);
    font-size: var(--text-2sm);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    letter-spacing: var(--track-caps-tight);
    color: #64748B;
    cursor: default;
}

/* ── Main content ──
   Без горизонтального padding: иначе KPI/панели уже topbar по правому краю
   (у .content уже есть padding: 0 var(--layout-pad-x)). */
.main {
    padding: 24px 0;
    min-width: 0;
    grid-column: 2;
    grid-row: 1;
}

/* Футер: мелкие ссылки под основным контентом (колонка main) */
.site-footer {
    grid-column: 2;
    grid-row: 2;
    align-self: end;
    padding: 8px 0 4px;
}
.site-footer__inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 100%;
}
.site-footer__nav {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 4px;
    font-size: var(--text-xs);
    line-height: var(--lh-snug);
    font-weight: var(--fw-medium);
    color: var(--tx-2);
}
.site-footer__link {
    color: var(--tx-2);
    text-decoration: none;
    border-radius: var(--r);
    transition: color var(--t), background var(--t);
}
.site-footer__link:hover {
    color: var(--brand);
}
.site-footer__hint {
    font-weight: 500;
    color: var(--tx-2);
    opacity: 0.92;
}
.site-footer__sep {
    color: var(--border);
    user-select: none;
    font-weight: var(--fw-regular);
}
.site-footer__copy {
    margin: 0;
    font-size: var(--text-xs);
    line-height: var(--lh-snug);
    font-weight: var(--fw-medium);
    color: var(--tx-2);
    opacity: 0.88;
}

/* ── Page header ── */
.page-header { margin-bottom: 20px; }
.page-title {
    margin: 0 0 4px;
    font-size: var(--text-2xl);
    font-weight: var(--fw-bold);
    letter-spacing: var(--track-tight);
    line-height: var(--lh-tight);
    color: var(--tx);
}
.page-lead {
    margin: 0;
    font-size: var(--text-sm);
    line-height: var(--lh-snug);
    color: var(--tx-2);
}
.page-meta {
    margin: 0;
    font-size: var(--text-2sm);
    line-height: var(--lh-snug);
    color: var(--tx-2);
}

/* ═══════════════════════════════════════════════
   KPI CARDS
   ═══════════════════════════════════════════════ */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: var(--main-stack-gap);
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px 18px;
    box-shadow: var(--sh-sm);
    position: relative;
    overflow: hidden;
    transition: border-color var(--t), box-shadow var(--t);
}

.kpi-card:hover {
    border-color: #CBD5E1;
    box-shadow: var(--sh-md);
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}
.kpi-card--revenue::before { background: var(--kpi-revenue); }
.kpi-card--cost::before    { background: var(--kpi-cost); }
.kpi-card--net::before     { background: var(--kpi-net); }
.kpi-card--roi::before     { background: var(--kpi-roi); }
.kpi-card--qty::before     { background: var(--kpi-qty); }

.kpi-label {
    font-size: var(--text-2xs);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    letter-spacing: var(--track-caps-md);
    color: var(--tx-2);
    margin-bottom: 6px;
}
.kpi-sublabel {
    font-size: var(--text-xs);
    line-height: var(--lh-snug);
    color: var(--tx-2);
    margin-bottom: 6px;
}

.kpi-main { display: flex; align-items: baseline; gap: 6px; }

.kpi-value {
    font-size: var(--text-2xl);
    font-weight: var(--fw-bold);
    color: var(--tx);
    font-variant-numeric: tabular-nums;
    line-height: var(--lh-tight);
    letter-spacing: var(--track-tight);
}
.kpi-value-net { color: var(--kpi-net); }
.kpi-value-net.kpi-value-negative { color: var(--danger); }

.kpi-trend { font-size: var(--text-xs); font-weight: var(--fw-semibold); line-height: var(--lh-snug); }
.kpi-trend--up   { color: var(--kpi-revenue); }
.kpi-trend--down { color: var(--danger); }
/* Дельты KPI без красного — только итог чистой прибыли в блоке детализации подсвечивается */
.kpi-trend--neutral { color: var(--tx-2); }

/* ═══════════════════════════════════════════════
   REPORT PANELS (detail table, P&L, unit)
   ═══════════════════════════════════════════════ */

.panel-section {
    background: var(--rp-bg);
    border: 1px solid var(--rp-border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-sm);
    overflow: hidden;
    margin-bottom: 20px;
    position: relative;
    transition: border-color var(--t), box-shadow var(--t);
}

.layout--authed .panel-section:hover {
    border-color: #CBD5E1;
    box-shadow: var(--sh-md);
}
.panel-section::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}
.panel-section--green::before  { background: var(--kpi-revenue); }
.panel-section--blue::before   { background: var(--col-wb-clr); }
.panel-section--violet::before { background: var(--col-tax-clr); }
.panel-section--orange::before { background: var(--kpi-cost); }

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px 14px;
    flex-wrap: wrap;
}

.panel-heading {
    margin: 0;
    font-size: var(--text-md);
    font-weight: var(--fw-bold);
    color: var(--rp-text);
    letter-spacing: var(--track-tight);
    line-height: var(--lh-snug);
}

.panel-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Иконка скачать — та же высота, что у «Показать» в .panel-actions .btn */
.btn-export-xlsx {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 6px 8px;
    min-width: unset;
    height: auto;
    border-radius: var(--r);
    border: 1px solid var(--rp-border);
    background: var(--rp-surface);
    color: var(--rp-text);
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1;
}
.btn-export-xlsx:hover {
    background: var(--surface-2);
    border-color: var(--border);
}
.btn-export-xlsx svg {
    flex-shrink: 0;
    width: 13px;
    height: 13px;
    display: block;
}
.panel-actions .input-date {
    padding: 6px 10px;
    border-radius: var(--r);
    border: 1px solid var(--rp-border);
    background: var(--rp-surface);
    color: var(--rp-text);
    font-size: var(--text-sm);
    font-variant-numeric: tabular-nums;
}
.panel-actions .input-sep { color: var(--rp-text-dim); font-size: var(--text-sm); }
.panel-actions .btn {
    padding: 6px 14px;
    font-size: var(--text-2sm);
}

.panel-empty {
    padding: 16px 20px;
    color: var(--rp-text-dim);
    font-size: var(--text-sm);
    line-height: var(--lh-normal);
}

.panel-table-wrap { overflow-x: auto; }

.panel-table-wrap.report-loading {
    position: relative;
    /* Когда данных ещё нет, таблица может быть “тонкой” — чтобы оверлей/текст не обрезались */
    min-height: 140px;
}
.panel-table-wrap.report-loading .panel-table {
    filter: blur(4px);
    opacity: 0.6;
    pointer-events: none;
    user-select: none;
}
.report-loading__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    background: rgba(255, 255, 255, 0.35);
    z-index: 5;
    padding: 16px;
    box-sizing: border-box;
}
.report-loading__spinner {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 4px solid rgba(148, 163, 184, 0.55);
    border-top-color: var(--brand);
    animation: reportSpin 0.9s linear infinite;
    box-shadow: var(--sh-sm);
    background: transparent;
}
@keyframes reportSpin {
    to { transform: rotate(360deg); }
}

.report-loading__text {
    text-align: center;
    font-size: var(--text-2sm);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-snug);
    color: var(--tx-2);
    max-width: 420px;
    padding: 0 16px;
}

/* Главная: спиннер не по центру всей таблицы, а выше — около строки «Налогооблагаемая база»
   (шапка + секция ВЫРУЧКА + «Выручка» + середина следующей строки) */
.panel-table-wrap.panel-table-wrap--dashboard-loading {
    min-height: min(48vh, 400px);
}
.panel-table-wrap.panel-table-wrap--dashboard-loading .report-loading__overlay {
    justify-content: flex-start;
    padding-top: 6.5rem;
    padding-bottom: 1.5rem;
}

/* Глобальная полоска: фоновая загрузка по выбранным датам (под шапкой, на всех страницах) */
.period-load-bar {
    position: relative;
    z-index: 10;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 16px;
    font-size: var(--text-2sm);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-snug);
    color: #1f2937;
    background: linear-gradient(90deg, rgba(52, 74, 103, 0.10), rgba(255, 255, 255, 0.72));
    border-bottom: 1px solid rgba(52, 74, 103, 0.18);
    box-shadow: 0 2px 12px rgba(17, 24, 39, 0.06);
}
.period-load-bar[hidden] {
    display: none !important;
}
.period-load-bar__spinner {
    width: 16px;
    height: 16px;
    border-radius: 999px;
    border: 2px solid rgba(52, 74, 103, 0.20);
    border-top-color: var(--brand);
    animation: reportSpin 0.85s linear infinite;
    flex-shrink: 0;
}

/* Фоновая загрузка по датам: полноэкранный оверлей (не главная — без полоски и без оверлея) */
.period-load-overlay {
    position: fixed;
    inset: 0;
    z-index: 45;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(2px);
}
.period-load-overlay[hidden] {
    display: none !important;
}

.panel-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
    line-height: var(--lh-snug);
}

/* P&L и юнит: separate + 0 — иначе при sticky-шапке и collapse границы/цветная
   полоска border-top наезжают друг на друга при горизонтальном скролле. */
.panel-table.report-table {
    border-collapse: separate;
    border-spacing: 0;
}

/* Первая колонка (обычно "Дата") не должна переноситься по дефисам */
.report-table th:first-child,
.report-table td:first-child {
    white-space: nowrap;
    min-width: 96px;
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
}

/* P&L: колонка «Дата» закреплена слева при горизонтальном скролле */
.report-table--pnl th:first-child,
.report-table--pnl td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface);
    box-shadow: 3px 0 10px -4px rgba(15, 23, 42, 0.12);
}
.report-table--pnl thead th:first-child {
    z-index: 4;
    background: var(--rp-header-bg);
}
.report-table--pnl tbody tr.panel-row-total td:first-child {
    background: var(--surface);
}
.report-table--pnl tbody tr.panel-data-row:hover td:first-child {
    background: var(--surface-2);
}

/* Юнит-экономика: одна строка в текстовых колонках, без многоточий; таблица по содержимому + горизонтальный скролл.
   Горизонтально закреплён только «Артикул продавца» (3-я колонка, left: 0): три sticky-колонки с автошириной
   в чистом CSS дают неверные left и наложение; как в себестоимости — ключевой идентификатор строки слева. */
.report-table--unit {
    width: max-content;
    min-width: 100%;
    table-layout: auto;
}
.report-table--unit .panel-th-name,
.report-table--unit .panel-td-name {
    white-space: nowrap;
}
.report-table--unit thead th:nth-child(1),
.report-table--unit tbody td:nth-child(1) {
    box-sizing: border-box;
    min-width: 6.5rem;
}
.report-table--unit thead th:nth-child(2),
.report-table--unit tbody td:nth-child(2) {
    box-sizing: border-box;
    min-width: 8.5rem;
}
.report-table--unit thead th:nth-child(3),
.report-table--unit tbody td:nth-child(3) {
    position: sticky;
    left: 0;
    box-sizing: border-box;
    min-width: 10.5rem;
    max-width: none;
    overflow: visible;
    white-space: nowrap;
    background: var(--surface);
    box-shadow: 3px 0 10px -4px rgba(15, 23, 42, 0.12);
    z-index: 2;
}
.report-table--unit thead th:nth-child(3) {
    top: 0;
    z-index: 5;
    background: var(--rp-header-bg);
}
.report-table--unit tbody tr.panel-data-row:hover td:nth-child(3) {
    background: var(--surface-2);
}

.panel-th-name, .panel-td-name,
.panel-th-num,  .panel-td-num {
    padding: 12px 16px;
    border-bottom: 1px solid var(--rp-border);
}
.panel-th-num, .panel-td-num {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.panel-th-name, .panel-th-num {
    font-size: var(--text-xs);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    letter-spacing: var(--track-caps-wide);
    color: var(--rp-text-dim);
    background: var(--rp-header-bg);
    white-space: nowrap;
    position: sticky;
    top: 0;
}
.panel-td-name {
    color: var(--rp-text);
    font-weight: var(--fw-medium);
}
.panel-td-num  { color: var(--tx-2); }

/* Секционный разделитель */
.panel-section-title {
    font-size: var(--text-xs);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    letter-spacing: var(--track-caps-wide);
    padding: 10px 16px;
    color: var(--rp-text-dim);
    background: var(--rp-surface);
    line-height: var(--lh-snug);
}

/* Итоговые строки (Итого к оплате, Чистая прибыль) — без заливки */
.panel-row-total .panel-td-name,
.panel-row-total .panel-td-num,
.panel-row-total .panel-td-pct {
    font-weight: var(--fw-bold);
    color: var(--tx);
}

/* Подытог без зелёной заливки */
.panel-row-subtotal .panel-td-name,
.panel-row-subtotal .panel-td-num {
    font-weight: var(--fw-bold);
    color: var(--tx);
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

/* Чистая прибыль — текст чёрный, без зелёной подсветки */
.panel-num-net.positive { color: var(--tx); }
.panel-num-net.negative { color: var(--danger); }

/* Hover по строкам */
.panel-data-row:hover .panel-td-name,
.panel-data-row:hover .panel-td-num {
    background: var(--surface-2);
}

/* ── Column accent colours (border-top on th; name + num — для отчётов с colspan) ── */
.panel-th-num.col-revenue,
.panel-th-name.col-revenue   { border-top: 3px solid var(--col-rev-clr); }
.panel-th-num.col-cost,
.panel-th-name.col-cost      { border-top: 3px solid var(--col-cost-clr); }
.panel-th-num.col-negative,
.panel-th-name.col-negative  { border-top: 3px solid var(--col-neg-clr); }
.panel-th-num.col-wb,
.panel-th-name.col-wb        { border-top: 3px solid var(--col-wb-clr); }
.panel-th-num.col-wb-total,
.panel-th-name.col-wb-total  { border-top: 3px solid var(--col-wb-clr); }
.panel-th-num.col-pink,
.panel-th-name.col-pink      { border-top: 3px solid #EC4899; }
.panel-th-num.col-opex,
.panel-th-name.col-opex      { border-top: 3px solid var(--col-opex-clr); }
.panel-th-num.col-tax,
.panel-th-name.col-tax       { border-top: 3px solid var(--col-tax-clr); }
.panel-th-num.col-profit,
.panel-th-name.col-profit    { border-top: 3px solid var(--col-rev-clr); }
.panel-th-num.col-profit-bold { border-top: 3px solid var(--col-rev-clr); font-weight: 700; }
.panel-th-name.col-profit-bold { border-top: 3px solid var(--col-rev-clr); font-weight: 700; }

.panel-td-num.col-profit-bold { font-weight: 700; }
.panel-td-num.col-wb-total   { font-weight: 700; }
.panel-th-num.col-wb-total   { font-weight: 700; }
.panel-th-name.col-wb-total  { font-weight: 700; }

/* ABC-группа в юнит-отчёте */
.abc-chip {
    display: inline-block;
    min-width: 1.75em;
    text-align: center;
    padding: 3px 10px;
    border-radius: 6px;
    font-weight: var(--fw-bold);
    font-size: var(--text-2sm);
    letter-spacing: var(--track-caps);
}
.abc-chip--a {
    background: rgba(22, 163, 74, 0.2);
    color: #15803d;
}
.abc-chip--b {
    background: rgba(234, 179, 8, 0.35);
    color: #a16207;
}
.abc-chip--c {
    background: rgba(239, 68, 68, 0.2);
    color: #b91c1c;
}

/* Розовый акцент слева для Реклама / Удержания — та же толщина, что у секций (border, не gradient) */
.row-accent-pink .panel-td-name {
    border-left: 3px solid #EC4899 !important;
    padding-left: 13px !important;
    background: transparent !important;
}
/* Убираем разделитель только у первой розовой строки (Удержания) */
.row-accent-pink--first .panel-td-name,
.row-accent-pink--first .panel-td-num {
    border-bottom: 1px solid transparent !important;
}

/* ═══════════════════════════════════════════════
   DASHBOARD — section accent left border
   ═══════════════════════════════════════════════ */
.panel-section-row .panel-section-title { cursor: default; }

/* ═══════════════════════════════════════════════
   BUTTONS (general)
   ═══════════════════════════════════════════════ */
.btn {
    border-radius: var(--r);
    padding: 7px 16px;
    font-size: var(--text-sm);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-snug);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--tx);
    cursor: pointer;
    font-family: var(--font);
    transition: background var(--t), border-color var(--t), color var(--t);
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: #CBD5E1; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible,
.btn-outline:focus-visible,
.btn-primary:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.btn-outline {
    background: var(--surface-2);
    color: var(--tx);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 7px 16px;
    font-size: var(--text-sm);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-snug);
    cursor: pointer;
    font-family: var(--font);
    transition: background var(--t);
}
.btn-outline:hover:not(:disabled) { background: #E2E8F0; }

.btn-sm { padding: 4px 10px; font-size: var(--text-2sm); }
.btn-secondary { background: var(--surface-2); }

/* Иконка пользователя */
.btn-logout .user-icon {
    flex-shrink: 0;
    color: var(--tx-2);
}

/* Кнопка выхода — весь блок (аватар + email + иконка) */
.btn-outline.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--r);
    cursor: pointer;
    transition: background .15s, border-color .15s;
    letter-spacing: .01em;
}
.btn-outline.btn-logout:hover {
    background: var(--sb-hover);
    border-color: #CBD5E1;
}
.btn-logout svg {
    flex-shrink: 0;
    color: var(--tx-2);
}

/* ── Topbar user actions ── */
.user-menu { display: inline-flex; align-items: center; gap: 10px; }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: rgba(220,38,38,.06); }

.btn-auth-primary {
    background: #fff;
    border: 2px solid #166534;
    border-radius: 10px;
    color: #111827;
    cursor: pointer;
    font-family: var(--font);
    font-size: var(--text-2sm);
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: var(--track-caps-xl);
    line-height: var(--lh-snug);
    height: 48px;
    margin-top: 8px;
    width: 100%;
    transition: background var(--t), color var(--t), border-color var(--t), transform 0.12s ease;
}
.btn-auth-primary:hover {
    background: #f9fafb;
    color: #111827;
    border-color: #14532d;
}
.btn-auth-primary:active {
    transform: scale(0.99);
}

/* ═══════════════════════════════════════════════
   SETTINGS PAGES
   ═══════════════════════════════════════════════ */

.settings-page    { max-width: 640px; }
.settings-page--wide { max-width: 100%; }
.settings-page--wide .settings-card { max-width: 100%; }

.settings-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-sm);
    margin-bottom: 20px;
    overflow: hidden;
}

/* API-ключ: иконка справки и всплывающая инструкция */
.api-key-cell {
    position: relative;
}
.api-key-cell__wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}
.api-key-cell__wrap .form-input {
    flex: 1;
    min-width: 0;
}
.api-key-help {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--border);
    color: var(--tx-2);
    font-size: var(--text-sm);
    font-weight: var(--fw-bold);
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background var(--t), color var(--t);
}
.api-key-help:hover {
    background: var(--brand-pale);
    color: var(--brand);
}
.api-key-popover {
    display: none;
    position: fixed;
    z-index: 10000;
    min-width: 280px;
    max-width: 360px;
}
.api-key-popover--open {
    display: block;
}
.api-key-popover__inner {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    padding: 16px;
    position: relative;
}
.api-key-popover__close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--tx-2);
    font-size: var(--text-icon);
    line-height: 1;
    cursor: pointer;
    border-radius: 4px;
}
.api-key-popover__close:hover {
    background: var(--border);
    color: var(--tx);
}
.api-key-popover__title {
    margin: 0 24px 8px 0;
    font-size: var(--text-base);
    font-weight: var(--fw-bold);
    line-height: var(--lh-snug);
    color: var(--tx);
}
.api-key-popover__intro {
    margin: 0 0 8px;
    font-size: var(--text-2sm);
    color: var(--tx-2);
    line-height: var(--lh-snug);
}
.api-key-popover__note {
    margin: 0 0 10px;
    font-size: var(--text-2sm);
    color: var(--tx-2);
    line-height: var(--lh-normal);
}
.api-key-popover__list {
    margin: 0 0 10px;
    padding-left: 16px;
    font-size: var(--text-2sm);
    color: var(--tx-2);
    line-height: var(--lh-normal);
}
.api-key-popover__steps {
    margin: 0;
    padding-left: 16px;
    font-size: var(--text-2sm);
    color: var(--tx);
    line-height: var(--lh-relaxed);
}
.api-key-popover__steps a {
    color: var(--brand);
    text-decoration: none;
}
.api-key-popover__steps a:hover {
    text-decoration: underline;
}

/* Модальное подтверждение (центр экрана) */
.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}
.confirm-modal.confirm-modal--open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}
body.confirm-modal-active {
    overflow: hidden;
}
.confirm-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.48);
}
.confirm-modal__panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    padding: 22px 22px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--sh-md), 0 24px 48px rgba(15, 23, 42, 0.18);
}
.confirm-modal__message {
    margin: 0 0 20px;
    font-size: var(--text-base);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-normal);
    color: var(--tx);
}
.confirm-modal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}
.confirm-modal__actions .btn {
    min-width: 100px;
}

.settings-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    gap: 12px;
}

.settings-card-title {
    font-size: var(--text-sm);
    font-weight: var(--fw-bold);
    color: var(--tx);
    letter-spacing: var(--track-snug);
    line-height: var(--lh-snug);
}

.settings-card-body { padding: 20px; }

.settings-actions { display: flex; gap: 6px; }
.settings-actions-center { display: flex; justify-content: center; margin-top: 12px; }

.settings-alert {
    padding: 12px 16px;
    border-radius: var(--r);
    margin-bottom: 16px;
    font-size: var(--text-sm);
    line-height: var(--lh-normal);
}
.settings-alert--error {
    background: rgba(254,226,226,.5);
    border: 1px solid rgba(220,38,38,.3);
    color: #B91C1C;
    font-weight: var(--fw-semibold);
}
.settings-alert--success {
    background: var(--green-soft);
    border: 1px solid rgba(22,163,74,.35);
    color: var(--green);
    font-weight: var(--fw-semibold);
}

.settings-empty {
    color: var(--tx-2);
    font-size: var(--text-sm);
    line-height: var(--lh-normal);
    margin: 0;
    padding: 16px 20px;
}

/* ── Settings tables ── */
.settings-table-wrap { overflow-x: auto; }
.settings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
    line-height: var(--lh-snug);
}
.settings-table th,
.settings-table td {
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}
.settings-table th {
    font-size: var(--text-xs);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    letter-spacing: var(--track-caps-wide);
    color: var(--tx-2);
    background: var(--surface-2);
}
.settings-table th.settings-table-num,
.settings-table td.settings-table-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Cabinets table */
.cabinets-table-wrap { overflow-x: auto; }
.cabinets-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: var(--text-sm);
    line-height: var(--lh-snug);
}
.cabinets-table th,
.cabinets-table td {
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    line-height: 1.2;
    vertical-align: middle;
}
.cabinets-table th {
    font-size: var(--text-xs);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    letter-spacing: var(--track-caps-wide);
    color: var(--tx-2);
    background: var(--surface-2);
}
.cab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: var(--text-xs);
    font-weight: var(--fw-bold);
    line-height: var(--lh-snug);
    color: #fff;
}
/* WB — фиолетовый маркетплейс; не смешивать с синим брендом UI */
.cab-badge--wb     { background: #7C3AED; }
.cab-badge--yandex { background: #FACC15; color: #4A5568; }
.cab-badge--ozon   { background: #3B4D73; }

.cabinet-add-row td { text-align: left; }

/* Кнопка «Добавить» (пунктирная) */
.cab-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1.5px dashed var(--border);
    background: transparent;
    border-radius: 999px;
    padding: 5px 14px;
    font-size: var(--text-2sm);
    height: 32px;
    box-sizing: border-box;
    font-weight: var(--fw-semibold);
    line-height: var(--lh-snug);
    font-family: var(--font);
    color: var(--tx-2);
    cursor: pointer;
    transition: border-color var(--t), color var(--t);
    white-space: nowrap;
}
.cab-add-btn:hover { border-color: var(--brand); color: var(--brand); }

a.cab-add-btn {
    text-decoration: none;
    color: var(--tx-2);
}
a.cab-add-btn:hover { color: var(--brand); }

/* Кнопки иконки */
.settings-icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--r);
    padding: 6px 12px;
    font-size: var(--text-sm);
    font-family: var(--font);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-snug);
    cursor: pointer;
    color: var(--tx-2);
    transition: background var(--t), border-color var(--t);
    white-space: nowrap;
}
.settings-icon-btn:hover { background: var(--surface-2); border-color: #CBD5E1; }
.settings-icon-btn--link {
    text-decoration: none;
    color: inherit;
    box-sizing: border-box;
}
.settings-icon-btn--save { border-color: var(--green); color: var(--green); }
.settings-icon-btn--save:hover { background: var(--green-soft); }
.settings-icon-btn--danger {
    border-color: rgba(220, 38, 38, 0.45);
    color: var(--danger);
}
.settings-icon-btn--danger:hover {
    background: rgba(220, 38, 38, 0.08);
    border-color: var(--danger);
}

/* ── Form elements ── */
.form-label {
    display: block;
    font-size: var(--text-2sm);
    font-weight: var(--fw-semibold);
    color: var(--tx);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: var(--track-caps-tight);
    line-height: var(--lh-snug);
}
.form-input {
    width: 100%;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    font-size: var(--text-sm);
    line-height: var(--lh-snug);
    font-family: var(--font);
    color: var(--tx);
    background: var(--surface);
    transition: border-color var(--t);
}
.form-input:focus { outline: none; border-color: var(--brand); }
.form-input--number { max-width: 140px; }
.form-input--file   { max-width: 100%; padding: 8px; }

.form-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 16px;
}
.form-hint {
    font-size: var(--text-xs);
    line-height: var(--lh-snug);
    color: var(--tx-2);
    margin-top: 5px;
}
.form-inline { display: inline; }

/* Inline inputs in table cells */
.td-input {
    width: 100%;
    min-width: 0;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    font-size: var(--text-2sm);
    line-height: var(--lh-snug);
    font-family: var(--font);
    color: var(--tx);
    background: var(--surface);
    text-align: right;
}
.td-input:focus { outline: none; border-color: var(--brand); }

/* Cabinet add form in table — компактно, выровнено под колонками */
.cabinet-add-form td {
    padding: 8px 20px;
    background: var(--brand-pale);
    vertical-align: middle;
}
.cabinet-add-form td input.form-input,
.cabinet-add-form td select.form-input {
    margin: 0;
    padding: 5px 10px;
    font-size: var(--text-sm);
    width: 100%;
    min-width: 0;
    line-height: var(--lh-snug);
    height: 32px;
    box-sizing: border-box;
}
/* Не трогаем .cost-input — у них свой padding под суффикс */
.cabinet-add-form td.settings-table-num input.form-input:not(.cost-input) {
    min-width: 80px;
    padding-right: 12px;
}
.cabinet-add-form select.form-input {
    min-width: 120px;
}
.cabinet-add-form td.settings-table-num input {
    text-align: right;
}
.cabinet-add-form .cabinet-action-cell {
    padding: 8px 20px;
    text-align: right;
}

.cabinet-row .cabinet-action-cell,
.cabinet-add-form .cabinet-action-cell {
    text-align: center;
    vertical-align: middle;
}

/* Cabinet row — editable fields inline (как в строке добавления) */
.cabinet-row .form-input--inline {
    padding: 5px 10px;
    font-size: var(--text-sm);
    width: 100%;
    min-width: 80px;
    line-height: var(--lh-snug);
    height: 32px;
    box-sizing: border-box;
}
.cabinet-row td.settings-table-num .form-input--inline {
    text-align: right;
    padding-right: 12px;
}
.cabinet-row select.form-input--inline {
    min-width: 120px;
    padding-right: calc(20px + 0.5ch);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right calc(8px + 0.5ch) center;
}

/* Input с суффиксом % (ставка, НДС) */
.input-with-pct {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}
.input-with-pct input {
    text-align: right;
}
.input-pct-suffix {
    color: var(--tx-2);
    font-size: var(--text-sm);
    line-height: var(--lh-snug);
}

/* Операционные расходы: фиксированные ширины — строка с формой не сдвигает «Сумму» и не сжимает «Название» */
.settings-table--expenses {
    table-layout: fixed;
}
.settings-table--expenses col.exp-col-date { width: 11%; min-width: 108px; }
.settings-table--expenses col.exp-col-name { width: 34%; min-width: 220px; }
.settings-table--expenses col.exp-col-sum { width: 12%; min-width: 96px; }
.settings-table--expenses col.exp-col-vat { width: 9%; min-width: 92px; }
.settings-table--expenses col.exp-col-type { width: 14%; min-width: 118px; }
.settings-table--expenses col.exp-col-act { width: 20%; min-width: 132px; }
.settings-table--expenses.settings-table--expenses--5col col.exp-col-date { width: 12%; min-width: 108px; }
.settings-table--expenses.settings-table--expenses--5col col.exp-col-name { width: 40%; min-width: 240px; }
.settings-table--expenses.settings-table--expenses--5col col.exp-col-sum { width: 14%; min-width: 96px; }
.settings-table--expenses.settings-table--expenses--5col col.exp-col-type { width: 16%; min-width: 118px; }
.settings-table--expenses.settings-table--expenses--5col col.exp-col-act { width: 18%; min-width: 132px; }

/* Операционные расходы: колонка действий — ровная колонка справа */
.settings-table th.expense-actions-col {
    width: 1%;
    min-width: 132px;
    text-align: right;
    padding-right: 20px;
}
.settings-table td.expense-actions-cell {
    text-align: right;
    vertical-align: middle;
    padding: 10px 20px;
    white-space: nowrap;
}
.settings-table .expense-action-form {
    display: inline-block;
    margin: 0;
    vertical-align: middle;
}
.settings-table .expense-action-btn {
    min-width: 118px;
    justify-content: center;
    box-sizing: border-box;
}

/* ── Подписка: карточки тарифов ── */
.settings-page--subscription {
    max-width: 920px;
}

.settings-card--subscription .subscription-card-head {
    align-items: flex-start;
}

.subscription-card-head__text {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.subscription-lead {
    margin: 0;
    font-size: var(--text-sm);
    font-weight: var(--fw-medium);
    line-height: var(--lh-normal);
    color: var(--tx-2);
    max-width: 52ch;
}

.subscription-plans-body {
    padding-top: 22px;
    padding-bottom: 22px;
}

.subscription-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    align-items: stretch;
}

.plan-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 20px 18px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--sh-sm);
    transition: border-color var(--t), box-shadow var(--t), transform 0.2s ease;
}

.plan-card:hover {
    border-color: #CBD5E1;
    box-shadow: var(--sh-md);
    transform: translateY(-2px);
}

.plan-card--featured {
    border-color: rgba(47, 62, 94, 0.35);
    background: linear-gradient(165deg, var(--brand-pale) 0%, var(--surface) 44%, var(--surface) 100%);
    box-shadow: 0 4px 14px rgba(47, 62, 94, 0.10), var(--sh-sm);
    z-index: 1;
}

.plan-card--featured:hover {
    border-color: rgba(47, 62, 94, 0.55);
    box-shadow: 0 8px 22px rgba(47, 62, 94, 0.14), var(--sh-md);
}

.plan-card__ribbon {
    position: absolute;
    top: 14px;
    right: 14px;
    padding: 4px 10px;
    font-size: var(--text-2xs);
    font-weight: var(--fw-bold);
    letter-spacing: var(--track-caps-wide);
    line-height: var(--lh-snug);
    text-transform: uppercase;
    color: var(--brand-dark);
    background: #fff;
    border: 1px solid rgba(47, 62, 94, 0.28);
    border-radius: 999px;
    box-shadow: 0 1px 2px rgba(47, 62, 94, 0.10);
}

.plan-card__name {
    margin: 0 0 14px;
    padding-right: 96px;
    font-size: var(--text-lg);
    font-weight: var(--fw-bold);
    letter-spacing: var(--track-tight);
    line-height: var(--lh-snug);
    color: var(--tx);
}

.plan-card--featured .plan-card__name {
    padding-right: 108px;
}

.plan-card__price-block {
    margin-bottom: 18px;
}

.plan-card__price-row {
    display: flex;
    align-items: baseline;
    gap: 4px;
    flex-wrap: wrap;
}

.plan-card__price {
    font-size: var(--text-display);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: var(--lh-tight);
    color: #0f172a;
    font-variant-numeric: tabular-nums;
}

.plan-card__price-suffix {
    font-size: var(--text-md);
    font-weight: var(--fw-bold);
    line-height: var(--lh-snug);
    color: var(--tx-2);
}

.plan-card__period {
    margin: 6px 0 0;
    font-size: var(--text-sm);
    font-weight: var(--fw-medium);
    line-height: var(--lh-snug);
    color: var(--tx-2);
}

.plan-card__features {
    list-style: none;
    margin: 0 0 20px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.plan-card__feature {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: var(--text-base);
    color: var(--tx);
    line-height: var(--lh-snug);
}

.plan-card__feature-icon {
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--brand);
    opacity: 0.9;
}

.plan-card__cta {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: auto;
    min-height: 40px;
    box-sizing: border-box;
    text-align: center;
    text-decoration: none;
}

.plan-card__cta.btn {
    padding: 10px 16px;
}

.plan-card__cta--muted {
    font-size: var(--text-sm);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-snug);
    color: var(--tx-2);
    background: var(--surface-2);
    border: 1px dashed var(--border);
    border-radius: var(--r);
    cursor: default;
}

@media (max-width: 899px) {
    .subscription-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
    }

    .subscription-grid .plan-card:last-child {
        grid-column: 1 / -1;
        max-width: 420px;
        width: 100%;
        margin-left: auto;
        margin-right: auto;
    }
}

@media (max-width: 599px) {
    .subscription-grid {
        grid-template-columns: 1fr;
    }

    .subscription-grid .plan-card:last-child {
        grid-column: auto;
        max-width: none;
        width: auto;
        margin-left: 0;
        margin-right: 0;
    }

    .plan-card__name {
        padding-right: 0;
    }

    .plan-card--featured .plan-card__name {
        padding-right: 0;
        padding-top: 22px;
    }

    .plan-card__ribbon {
        top: 12px;
        right: 12px;
    }
}

.expense-vat-chip{
    display:inline-block;
    margin-left:6px;
    padding:2px 6px;
    border-radius:999px;
    font-size: var(--text-2sm);
    line-height: var(--lh-tight);
    background: rgba(47, 62, 94, 0.10);
    border: 1px solid rgba(47, 62, 94, 0.24);
    color: #27334b;
    vertical-align: middle;
}

/* Info alert (вместо “синего” инлайна) */
.settings-alert--info {
    background: rgba(47, 62, 94, 0.08);
    border: 1px solid rgba(47, 62, 94, 0.22);
    color: #27334b;
    font-weight: var(--fw-semibold);
}

/* Expense add form in table */
.expense-add-form-row td {
    padding: 10px 20px 10px 12px;
    background: var(--brand-pale);
    vertical-align: middle;
}
.expense-add-form-row td.settings-table-num {
    padding: 10px 10px 10px 20px;
}
.expense-add-form-row .expense-add-input {
    padding: 6px 10px;
    font-size: var(--text-sm);
    line-height: var(--lh-snug);
    width: 100%;
}
.expense-add-form-row td.settings-table-num .expense-add-input {
    text-align: right;
}
.expense-add-form-row .expense-add-save-cell {
    padding: 10px 20px;
}
.expense-add-form-row select.expense-add-input {
    min-width: 133px;
    padding-left: 10px;
    padding-right: 28px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}
.settings-table--expenses .expense-add-form-row select.expense-add-input {
    min-width: 0;
    width: 100%;
    max-width: 100%;
}
.settings-table--expenses .expense-add-form-row .expense-add-input--vat {
    max-width: none;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    padding-left: 8px;
    text-align: right;
}
.settings-table--expenses .expense-add-form-row .cost-input-inner .expense-add-input--vat.cost-input {
    padding-right: 2.25em;
}

/* ═══════════════════════════════════════════════
   SYSTEM EXPENSE ROW
   ═══════════════════════════════════════════════ */
.expense-row-system td {
    background: transparent;
    color: var(--tx-2);
}
.expense-row-system td:nth-child(2) {
    background: transparent;
}
.expense-row-system td:first-child {
    padding-left: 13px;
}
.expense-system-badge {
    display: inline-block;
    background: #EDE9FE;
    color: #5B21B6;
    font-weight: var(--fw-semibold);
    font-size: var(--text-sm);
    line-height: var(--lh-snug);
    border-radius: 999px;
    padding: 2px 8px;
    vertical-align: middle;
    white-space: nowrap;
}
.expense-row-system--disabled td {
    opacity: 0.55;
}
.expense-row-system--disabled .expense-system-badge {
    background: var(--surface-2);
    color: var(--tx-2);
}

/* ═══════════════════════════════════════════════
   CAB ADD SAVE BUTTON (legacy)
   ═══════════════════════════════════════════════ */
.cab-add-save-btn {
    white-space: nowrap;
    border-radius: var(--r);
    padding: 7px 16px;
    font-size: var(--text-2sm);
    font-family: var(--font);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-snug);
    border: 1px solid var(--brand);
    background: var(--brand);
    color: #fff;
    cursor: pointer;
    transition: background var(--t);
}
.cab-add-save-btn:hover { background: var(--brand-dark); }

/* ── Danger text button ── */
.btn-danger-text, .cab-link {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-family: var(--font);
    font-size: var(--text-sm);
    line-height: var(--lh-normal);
    padding: 0;
}
.btn-danger-text:hover, .cab-link:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════
   AUTH — фон и орбы 1:1 как на сервере (variant 2)
   ═══════════════════════════════════════════════ */
body.auth-page {
    background: #faf8f6;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    position: relative;
    font-family: var(--font);
}

.auth-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}
.auth-dot-grid {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, rgba(0, 0, 0, 0.07) 1px, transparent 1px);
    background-size: 28px 28px;
}
.auth-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
}
.auth-orb-1 {
    width: 320px;
    height: 320px;
    /* Sky blue */
    background: rgba(14, 165, 233, 0.16);
    top: -60px;
    right: -60px;
}
.auth-orb-2 {
    width: 280px;
    height: 280px;
    /* Soft blue (убираем зелёный подтон) */
    background: rgba(59, 130, 246, 0.12);
    bottom: -40px;
    left: -40px;
}
.auth-orb-3 {
    width: 200px;
    height: 200px;
    /* Было слишком лилово — делаем мягкий синий */
    /* Deeper blue */
    background: rgba(37, 99, 235, 0.10);
    top: 50%;
    left: 30%;
    transform: translateY(-50%);
}

.auth-wrap {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.auth-logo-wrap {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}
.auth-logo-wrap .logo-text {
    font-size: var(--text-2xl);
    font-weight: var(--fw-regular);
    letter-spacing: 0.11em;
}

.auth-card {
    width: 100%;
    background: #fff;
    border-radius: 16px;
    padding: 40px 36px 36px;
    border: 1px solid #e8ecf4;
    box-shadow:
        0 4px 6px rgba(15, 23, 42, 0.04),
        0 20px 50px rgba(15, 23, 42, 0.08);
    position: relative;
    z-index: 10;
}
.auth-title {
    font-size: var(--text-xl);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--track-tight);
    color: #111827;
    margin: 0 0 28px;
    line-height: var(--lh-tight);
}
.auth-form { display: flex; flex-direction: column; gap: 20px; }
.auth-field { display: flex; flex-direction: column; gap: 8px; }
.auth-label {
    font-size: var(--text-2xs);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--track-overline);
    line-height: var(--lh-snug);
    color: #64748b;
    text-transform: uppercase;
}
.auth-input {
    background: #edf2fa;
    border: 1px solid #d1d9e6;
    border-radius: 10px;
    color: #111827;
    font-family: var(--font);
    font-size: var(--text-base);
    line-height: var(--lh-normal);
    height: 48px;
    padding: 0 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
    box-sizing: border-box;
}
.auth-input::placeholder { color: #94a3b8; }
.auth-input:focus {
    outline: none;
    border-color: #94a3b8;
    box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.25);
}

.auth-password-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.auth-input-with-toggle { padding-right: 48px; }
.auth-password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #64748b;
    border-radius: 8px;
    line-height: 0;
    transition: color 0.15s, background 0.15s;
}
.auth-password-toggle:hover {
    color: #475569;
    background: rgba(255, 255, 255, 0.7);
}
.auth-eye-icon { display: block; }

.auth-card .settings-alert {
    margin: -8px 0 16px;
    border-radius: 10px;
    font-size: var(--text-sm);
    line-height: var(--lh-normal);
}

.auth-switch {
    margin: 24px 0 0;
    text-align: center;
    font-size: var(--text-sm);
    color: #64748b;
    line-height: var(--lh-normal);
}
.auth-link {
    color: #16a34a;
    text-decoration: none;
    font-weight: var(--fw-semibold);
}
.auth-link:hover {
    color: #15803d;
    text-decoration: underline;
}

/* ═══════════════════════════════════════════════
   USER MENU
   ═══════════════════════════════════════════════ */
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-email {
    font-size: var(--text-2sm);
    line-height: var(--lh-snug);
    color: var(--tx-2);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: var(--fw-medium);
}

/* ═══════════════════════════════════════════════
   ALERTS
   ═══════════════════════════════════════════════ */
.alert {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: var(--r);
    border: 1px solid rgba(248,113,113,.4);
    background: rgba(254,226,226,.4);
    color: #B91C1C;
    font-size: var(--text-sm);
    line-height: var(--lh-normal);
}

/* ═══════════════════════════════════════════════
   MISSING / ALIAS CLASSES
   ═══════════════════════════════════════════════ */

/* Global .btn-primary */
.btn-primary {
    background: var(--brand);
    color: #fff;
    border: 1px solid var(--brand);
    border-radius: var(--r);
    padding: 7px 16px;
    font-size: var(--text-sm);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-snug);
    font-family: var(--font);
    cursor: pointer;
    transition: background var(--t), border-color var(--t);
}
.btn-primary:hover:not(:disabled) {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
}

/* settings-card-header = alias for settings-card-head */
.settings-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    gap: 12px;
}

/* settings-icon-btn--primary = alias for --save */
.settings-icon-btn--primary {
    border-color: var(--brand);
    color: var(--brand);
}
.settings-icon-btn--primary:hover { background: var(--brand-pale); }

/* Cost input in costs table */
.settings-table--costs th.settings-table-num {
    padding-right: 28px;
}
.cost-input-inner {
    position: relative;
    display: block;
}
.cost-input-inner .cost-input {
    display: block;
    width: 100%;
    /* Место под суффикс ₽ / % (absolute right: 8px), иначе цифры наезжают */
    padding-right: 2.25em;
    box-sizing: border-box;
}
.cost-input-inner .cost-currency-suffix,
.cost-input-inner .cost-percent-suffix {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--tx-2);
    font-size: var(--text-2sm);
    line-height: var(--lh-snug);
    pointer-events: none;
    user-select: none;
}
.cabinet-row .cost-input-inner,
.cabinet-add-form .cost-input-inner {
    width: 100%;
    max-width: 160px;
}
.cabinet-row td.settings-table-num .cost-input-inner .form-input--inline.cost-input,
.cabinet-add-form td.settings-table-num .cost-input-inner input.form-input.cost-input {
    padding-right: 2.25em;
    min-width: 80px;
}
.settings-table td.settings-table-num .cost-input {
    text-align: right;
}

/* Себестоимость — две отдельные карточки-вкладки + карточка с таблицей */
.costs-page {
    align-self: start;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    /* Блок начинается на одной линии с сайдбаром */
    --costs-work-offset: 0px;
}
.costs-page .settings-card {
    margin-bottom: 0;
}
.costs-page .costs-work-card {
    margin-top: var(--costs-work-offset);
    border: 1px solid var(--border);
    background: var(--surface);
    /* Скругления как у всех карточек */
    overflow: hidden;
    transition: border-color var(--t), box-shadow var(--t);
}
.layout--authed .costs-page .costs-work-card:hover {
    border-color: #CBD5E1;
    box-shadow: var(--sh-md);
}
.costs-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px 14px;
    flex-wrap: wrap;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.costs-heading {
    margin: 0;
    font-size: var(--text-md);
    font-weight: var(--fw-bold);
    color: var(--tx);
    letter-spacing: var(--track-tight);
    line-height: var(--lh-snug);
}
.costs-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.costs-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    white-space: nowrap;
}
.costs-action-btn svg {
    flex-shrink: 0;
}
.costs-panel {
    padding: 0 0 16px;
}
.costs-panel--hidden {
    display: none !important;
}
.costs-placeholder {
    padding: 48px 24px;
    text-align: center;
}
.costs-placeholder__text {
    margin: 0;
    font-size: var(--text-base);
    line-height: var(--lh-normal);
    color: var(--tx-2);
}
/* Горизонтальный скролл только здесь (вся таблица), не внутри отдельных ячеек */
.costs-table-wrap {
    padding: 0;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

/* separate + border-spacing: 0 — иначе position:sticky у ячеек ведёт себя непредсказуемо */
.settings-table--costs-mp {
    width: max-content;
    min-width: 100%;
    table-layout: auto;
    border-collapse: separate;
    border-spacing: 0;
}

.settings-table--costs-mp th,
.settings-table--costs-mp td {
    padding: 8px 12px;
    vertical-align: middle;
    box-sizing: border-box;
}

/* Текстовые колонки — влево, одинаковая типографика */
.settings-table--costs-mp .costs-mp-col-brand,
.settings-table--costs-mp .costs-mp-col-subject,
.settings-table--costs-mp .costs-mp-col-sku {
    text-align: left;
}
.settings-table--costs-mp thead .costs-mp-col-brand,
.settings-table--costs-mp thead .costs-mp-col-subject,
.settings-table--costs-mp thead .costs-mp-col-sku {
    white-space: nowrap;
    line-height: 1.25;
}

.settings-table--costs-mp .costs-mp-col-brand {
    min-width: 6.5rem;
}
.settings-table--costs-mp .costs-mp-col-subject {
    min-width: 8.5rem;
}

/* Закреплённый при горизонтальном скролле «Артикул продавца» */
.settings-table--costs-mp .costs-mp-col-sku {
    min-width: 10.5rem;
    position: sticky;
    left: 0;
    z-index: 2;
    background-color: var(--surface);
    background-clip: padding-box;
    box-shadow: 4px 0 14px -6px rgba(15, 23, 42, 0.22);
}
.settings-table--costs-mp thead .costs-mp-col-sku {
    z-index: 4;
    background-color: var(--surface-2);
}

/* Денежные колонки — ширина и выравнивание шапки/ячеек */
.settings-table--costs-mp .costs-mp-col-money {
    min-width: 7.25rem;
    text-align: right;
    white-space: nowrap;
}
.settings-table--costs-mp thead th.costs-mp-col-money {
    padding-right: 14px;
}

.settings-table--costs-mp .costs-mp-col-qty {
    vertical-align: middle;
    min-width: 5.5rem;
    text-align: right;
}
.settings-table--costs-mp thead th.costs-mp-col-qty {
    text-align: right;
}
.settings-table--costs-mp td.costs-mp-col-qty .costs-mp-qty {
    width: 100%;
    max-width: 6.5rem;
    margin-left: auto;
    display: block;
    text-align: right;
}
.settings-table--costs-mp .costs-mp-col-actions {
    vertical-align: middle;
    text-align: center;
    width: 1%;
    min-width: 5.5rem;
    padding-left: 6px;
    padding-right: 10px;
    white-space: nowrap;
}
.settings-table--costs-mp thead th.costs-mp-col-actions {
    background-color: var(--surface-2);
}
.settings-table--costs-mp .costs-mp-actions-row {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.settings-table--costs-mp .costs-mp-delete-btn,
.settings-table--costs-mp .costs-mp-duplicate-btn {
    flex-shrink: 0;
    padding: 6px;
    min-width: 34px;
    justify-content: center;
}
.settings-table--costs-mp .costs-mp-delete-btn svg,
.settings-table--costs-mp .costs-mp-duplicate-btn svg {
    flex-shrink: 0;
}

.settings-table--costs-mp .costs-mp-full {
    display: inline-block;
    min-width: 3ch;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.settings-table--costs-mp .costs-mp-full-suffix {
    position: static;
    display: inline;
    margin-left: 2px;
    color: var(--tx-2);
    font-size: var(--text-2sm);
    line-height: var(--lh-snug);
}
.settings-table--costs-mp td .costs-mp-input {
    width: 100%;
    min-width: 3.25rem;
}
.settings-table--costs-mp .costs-mp-text-cell {
    max-width: none;
    vertical-align: middle;
    white-space: nowrap;
}
.settings-table--costs-mp .costs-mp-text {
    font-size: var(--text-2sm);
    line-height: var(--lh-snug);
    color: var(--tx);
    white-space: nowrap;
}
/* form-input--cabinet */
.form-input--cabinet {
    max-width: 100%;
    padding: 6px 8px;
    font-size: var(--text-2sm);
    line-height: var(--lh-snug);
}
.cabinet-add-form select.form-input--cabinet {
    padding-right: calc(20px + 0.5ch);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right calc(8px + 0.5ch) center;
}

/* settings-form, settings-message */
.settings-form > .btn { margin-top: 16px; }
.settings-message {
    margin: 0 0 12px;
    color: var(--tx);
    font-size: var(--text-sm);
    line-height: var(--lh-normal);
}

/* standalone input-date */
.input-date {
    padding: 6px 10px;
    border-radius: var(--r);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--tx);
    font-size: var(--text-sm);
    line-height: var(--lh-snug);
    font-variant-numeric: tabular-nums;
    font-family: var(--font);
}
.input-date:focus { outline: none; border-color: var(--brand); }

/* panel section row — no border */
.panel-section-row td { border-bottom: none; }

/* panel-title compatibility */
.panel-title {
    font-size: var(--text-xs);
    line-height: var(--lh-snug);
    text-transform: uppercase;
    letter-spacing: var(--track-caps-wide);
    color: var(--tx-2);
}

/* topbar Войти button */
.topbar-right .btn-outline {
    background: var(--surface-2);
    color: var(--tx);
    border: 1px solid #CBD5E1;
    border-radius: var(--r);
    padding: 7px 16px;
    font-size: var(--text-sm);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-snug);
    cursor: pointer;
    font-family: var(--font);
    transition: background var(--t), border-color var(--t);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.topbar-right .btn-outline:hover {
    background: #E2E8F0;
    border-color: #94A3B8;
}

/* Topbar logout: рамка + подсветка */
.topbar-right .btn-outline.btn-logout {
    background: transparent;
    border: 1px solid var(--border);
}
.topbar-right .btn-outline.btn-logout:hover {
    background: var(--sb-hover);
    border-color: #CBD5E1;
}

/* Accounts strip account-chip active */
.account-chip:hover { cursor: pointer; }

/* form-row */
.form-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; margin-bottom: 16px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group .form-input { min-width: 0; }

/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .content { grid-template-columns: minmax(0, 1fr); }
    .sidebar-column { display: none; }
    .main { grid-column: 1; grid-row: 1; }
    .site-footer { grid-column: 1; grid-row: 2; }
    .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .topbar { margin: 12px var(--layout-pad-x) 12px; padding: 12px 16px; grid-template-columns: auto 1fr auto; }
}
@media (max-width: 768px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .topbar { margin: 8px var(--layout-pad-x) 12px; padding: 12px 14px; grid-template-columns: 1fr; grid-template-rows: auto auto auto; gap: 12px; }
    .topbar-center { justify-content: flex-start; }
    .topbar-right { justify-content: flex-start; }
    .kpi-grid { grid-template-columns: minmax(0, 1fr); }
}
