/* Глобальные стили приложения. Перенесены 1:1 из <style> в base.html
   (этап 3): десктоп-вид не меняется. Адаптивная секция для телефона —
   в конце файла, строго внутри @media (max-width:720px), поэтому на
   широком экране ни одно из этих правил не активно.

   Палитра централизована в :root ниже (UI-01). Тёмная тема — через
   @media (prefers-color-scheme: dark), переопределяющий те же переменные.
   Не добавляй новые хардкод-цвета — только переменные. */

/* Inter — самохост, без Google Fonts CDN (приватность, офлайн, кэш SW).
   Вариативный файл покрывает веса 100–900, кириллица включена. Имя
   семейства именно InterVariable: в официальном inter.css вариативное и
   статические начертания названы по-разному, чтобы не конфликтовать. */
@font-face {
    font-family: InterVariable;
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("fonts/InterVariable.2bf3d951bf9d.woff2") format("woff2");
}

:root {
    /* нативные виджеты (скроллбары, date-picker, выпадашки select)
       следуют теме — без этого в тёмном режиме они остаются светлыми */
    color-scheme: light;

    /* акцент */
    --accent:        #2563EB;
    --accent-hover:  #1D4ED8;
    --accent-soft:   #EFF4FF;   /* фон активного пункта меню, итог-строки */

    /* поверхности */
    --page-bg:       #F4F6F9;   /* подложка страницы под карточки/таблицы */
    --surface:       #FFFFFF;   /* карточки, ячейки таблиц, выпадашки */
    --surface-alt:   #F8FAFC;   /* zebra, шапки таблиц, вторичные панели */

    /* текст */
    --text:          #101828;
    --text-muted:    #667085;
    --text-faint:    #98A2B3;

    /* границы */
    --border:        #E3E8EF;   /* основная разделительная */
    --border-strong: #D0D7E2;   /* акцентная (итоги, скролл-зоны) */

    /* поля ввода (UI: заметные поля, вариант «Б») */
    --input-bg:           #FFFFFF;
    --input-border:       #BCC6D3;
    --input-border-hover: #97A3B6;
    --input-inset:        inset 0 1px 2px rgba(16,24,40,.08);
    --form-bg:            #EEF2F7;   /* подложка форм с полями ввода */
    /* таблицы: зебра и вертикальные разделители (TX_TABLE_1) */
    --row-alt:  #FAFBFD;
    --col-line: #EEF1F5;

    /* семантика отклонений (сведены из разнобоя plan_fact/home) */
    --pos:           #067647;   /* «лучше плана» — расход меньше/доход больше */
    --neg:           #B42318;   /* «хуже плана» */

    /* статусные блоки */
    --warn-bg:       #FFFAEB;
    --warn-border:   #F79009;
    --warn-text:     #7A2E0E;
    --warn:          #B54708;   /* текстовый янтарный (≠ --warn-border) */
    --danger-bg:     #FEF3F2;
    --danger-border: #F04438;
    --danger-text:   #912018;

    /* статус «успех» (баннеры .form-ok и т.п.) */
    --ok-bg:         #ECFDF3;
    --ok-border:     #12B76A;
    --ok-text:       #054F31;

    /* кнопка экспорта Excel */
    --excel:         #1e7e34;
    --excel-hover:   #155f22;

    /* фон полос прогресса (бюджет, цели) */
    --track:         #EAEEF3;

    /* сайдбар — тёмная панель независимо от темы страницы */
    --nav-bg:        #16304D;
    --nav-text:      #A9BCD3;
    --nav-text-hi:   #FFFFFF;
    --nav-hover:     #1B3C60;
    --nav-active:    #1E4470;
    --nav-section:   #6E88A6;

    /* размеры оболочки — переменными, чтобы свёрнутый режим не разъезжался.
       От темы не зависят, как и радиусы. */
    --side-w:        236px;
    --side-w-min:    60px;

    /* радиусы/тени — чтобы не плодить разнобой 3px/4px/10px.
       Радиусы и размеры оболочки от темы не зависят и живут только здесь;
       в тёмных блоках переопределяются лишь цвета и тени. */
    --radius:        8px;
    --radius-lg:     10px;
    --radius-sm:     6px;       /* мелкие контролы: кнопки, чипы, поля */
    --shadow-card:   0 1px 2px rgba(16,24,40,.05);
    --shadow-pop:    0 8px 20px rgba(16,24,40,.10);
}

/* ── Тёмная палитра (UI-04B): один и тот же список значений активируется
   двумя путями —
   1) системная тёмная (media-запрос) — НО только когда пользователь не
      выбрал тему вручную (нет data-theme="light"/"dark" на <html>);
   2) ручной выбор html[data-theme="dark"] — переопределяет ОС всегда.
   ⚠ Два блока ниже ОБЯЗАНЫ совпадать по значениям: правишь один — правь
   и второй. (Дублирование осознанное: один блок внутри @media, второй —
   вне, объединить нельзя.) Светлая ручная тема ничего не переопределяет —
   :root уже светлый, а media-блок её не трогает через :not([data-theme]). ── */
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]):not([data-theme="dark"]) {
        color-scheme: dark;

        --accent:        #60A5FA;
        --accent-hover:  #93C5FD;
        --accent-soft:   #1B2C44;

        --page-bg:       #0F141A;
        --surface:       #171E26;
        --surface-alt:   #1C242E;

        --text:          #E6EAF0;
        --text-muted:    #98A2B3;
        --text-faint:    #6B7A8C;

        --border:        #263140;
        --border-strong: #33404F;
        --input-bg:           #171E26;
        --input-border:       #3A4757;
        --input-border-hover: #4B5A6E;
        --input-inset:        none;
        --form-bg:            #1C242E;
        --row-alt:  #1A212A;
        --col-line: #1F2833;

        --pos:           #3DD68C;
        --neg:           #F97066;

        --warn-bg:       #3B2A10;
        --warn-border:   #8A6D1F;
        --warn-text:     #F5D98B;
        --warn:          #F5A623;
        --danger-bg:     #40201C;
        --danger-border: #A3514D;
        --danger-text:   #F3B4AE;

        --ok-bg:         #10321F;
        --ok-border:     #2E7D51;
        --ok-text:       #A7E8C4;

        --excel:         #2ea043;
        --excel-hover:   #3fb950;

        --track:         #263140;

        --nav-bg:        #121920;
        --nav-text:      #8FA3B8;
        --nav-text-hi:   #FFFFFF;
        --nav-hover:     #1C242E;
        --nav-active:    #23303F;
        --nav-section:   #5C6E80;

        --shadow-card:   0 1px 4px rgba(0,0,0,.4);
        --shadow-pop:    0 4px 14px rgba(0,0,0,.5);
    }
}

/* Ручной выбор «Тёмная» — те же значения, что в media-блоке выше. */
html[data-theme="dark"] {
    color-scheme: dark;

    --accent:        #60A5FA;
    --accent-hover:  #93C5FD;
    --accent-soft:   #1B2C44;

    --page-bg:       #0F141A;
    --surface:       #171E26;
    --surface-alt:   #1C242E;

    --text:          #E6EAF0;
    --text-muted:    #98A2B3;
    --text-faint:    #6B7A8C;

    --border:        #263140;
    --border-strong: #33404F;
    --input-bg:           #171E26;
    --input-border:       #3A4757;
    --input-border-hover: #4B5A6E;
    --input-inset:        none;
    --form-bg:            #1C242E;
    --row-alt:  #1A212A;
    --col-line: #1F2833;

    --pos:           #3DD68C;
    --neg:           #F97066;

    --warn-bg:       #3B2A10;
    --warn-border:   #8A6D1F;
    --warn-text:     #F5D98B;
    --warn:          #F5A623;
    --danger-bg:     #40201C;
    --danger-border: #A3514D;
    --danger-text:   #F3B4AE;

    --ok-bg:         #10321F;
    --ok-border:     #2E7D51;
    --ok-text:       #A7E8C4;

    --excel:         #2ea043;
    --excel-hover:   #3fb950;

    --track:         #263140;

    --nav-bg:        #121920;
    --nav-text:      #8FA3B8;
    --nav-text-hi:   #FFFFFF;
    --nav-hover:     #1C242E;
    --nav-active:    #23303F;
    --nav-section:   #5C6E80;

    --shadow-card:   0 1px 4px rgba(0,0,0,.4);
    --shadow-pop:    0 4px 14px rgba(0,0,0,.5);
}

body {
    /* Inter вторым — подхватится, если установлен в системе, не дожидаясь
       загрузки woff2 */
    font-family: InterVariable, Inter, -apple-system, BlinkMacSystemFont,
                 "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    /* Колоночная геометрия (была max-width: 1180px + центрирование)
       переехала в .app-main: страница теперь во всю ширину (UI-07). */
    margin: 0;
    color: var(--text);
    background: var(--page-bg);
}
h1 { margin-top: 0; }

/* ── оболочка: сайдбар + контент (UI-07) ───────────── */
/* ⚠ minmax(0, 1fr), а НЕ 1fr: у grid-колонки min-width по умолчанию auto,
   и широкая таблица (план-факт за год) растянула бы колонку контента,
   выдавив сайдбар за экран. */
.app {
    display: grid;
    grid-template-columns: var(--side-w) minmax(0, 1fr);
    min-height: 100vh;
}
html.nav-collapsed .app { grid-template-columns: var(--side-w-min) minmax(0, 1fr); }
/* Ширину грида НЕ анимируем: на каждой странице это читается как тормоз. */

.app-body { min-width: 0; }
.app-main { padding: 20px 24px 40px; }

/* ── сайдбар ── */
.side {
    background: var(--nav-bg);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}
.side-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 18px;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
}
.side-brand:hover { text-decoration: none; }
/* Знак-логотип: градиент — намеренное исключение из палитры (фирменная
   метка, как зелёный Excel), белый текст на нём — тоже. */
.side-mark {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 7px;
    background: linear-gradient(135deg, #2F6DB5, #1A4E8A);
    display: grid;
    place-items: center;
    font-weight: 600;
    font-size: 14px;
}
.side-brand-text { display: flex; flex-direction: column; }
.side-brand-name { font-weight: 600; font-size: 15px; letter-spacing: .01em; }
.side-brand-sub { font-size: 12px; color: var(--nav-section); letter-spacing: .06em; }

.nav-section {
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--nav-section);
    padding: 16px 18px 6px;
    white-space: nowrap;
}

/* пункт и кнопка группы выглядят одинаково */
.nav-link,
.nav-group-btn {
    display: flex;
    align-items: center;
    gap: 11px;
    box-sizing: border-box;
    width: calc(100% - 16px);
    padding: 8px 18px;
    margin: 1px 8px;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--nav-text);
    font: inherit;
    font-size: 14.5px;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background .12s, color .12s;
}
.nav-link:hover,
.nav-group-btn:hover { background: var(--nav-hover); color: var(--nav-text-hi); text-decoration: none; }
.nav-link.active,
.nav-group-btn.active-group { background: var(--nav-active); color: var(--nav-text-hi); font-weight: 500; }
.nav-link svg,
.nav-group-btn svg { flex: 0 0 17px; width: 17px; height: 17px; opacity: .85; }
.nav-link.active svg,
.nav-group-btn.active-group svg { opacity: 1; }
/* подпись забирает свободное место — бейдж и «галка» уходят вправо */
.side .nav-label { margin-right: auto; overflow: hidden; text-overflow: ellipsis; }
.nav-caret { font-size: 11px; opacity: .7; transition: transform .12s; }
.nav-group.open .nav-caret { transform: rotate(180deg); }

/* подменю группы: открыто сервером на активной странице, дальше — по клику */
.nav-sub { display: none; padding: 2px 0 4px; }
.nav-group.open .nav-sub { display: block; }
.nav-sublink {
    display: block;
    padding: 6px 14px 6px 46px;
    margin: 1px 8px;
    border-radius: var(--radius-sm);
    color: var(--nav-text);
    font-size: 13.5px;
    text-decoration: none;
}
.nav-sublink:hover { background: var(--nav-hover); color: var(--nav-text-hi); text-decoration: none; }
.nav-sublink.active { background: var(--nav-active); color: var(--nav-text-hi); font-weight: 500; }

.nav-divider { height: 1px; background: rgba(255,255,255,.08); margin: 14px 18px 4px; }

/* подвал сайдбара — прижат книзу */
.side-foot { margin-top: auto; padding: 8px 8px 16px; }
.side-user {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 10px;
    color: var(--nav-text);
    font-size: 14px;
    white-space: nowrap;
}
.side-av {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 50%;
    background: var(--nav-active);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 600;
}
.side-logout-form { display: flex; }

/* кнопка «Выход» — иконкой в подвале сайдбара */
.nav-logout {
    background: none;
    border: none;
    padding: 0 2px;
    color: var(--nav-text);
    cursor: pointer;
    font: inherit;
    text-decoration: none;
}
.nav-logout:hover { color: var(--nav-text-hi); }

/* ── свёрнутый режим: только иконки.
   Внутри min-width:901px намеренно: ниже брейкпоинта сайдбар выезжает
   ящиком во всю ширину (UI-08), и свёрнутое состояние там не значит
   ничего — иначе в ящике оказались бы одни иконки. ── */
@media (min-width: 901px) {
    html.nav-collapsed .nav-label,
    html.nav-collapsed .nav-caret,
    html.nav-collapsed .nav-section,
    html.nav-collapsed .side-brand-text,
    html.nav-collapsed .nav-sub { display: none; }
    html.nav-collapsed .nav-link,
    html.nav-collapsed .nav-group-btn {
        position: relative;
        justify-content: center;
        padding: 9px 0;
    }
    html.nav-collapsed .side-brand { justify-content: center; padding: 18px 0; }
    html.nav-collapsed .side-user { justify-content: center; padding: 8px 0; }
    html.nav-collapsed .nav-divider { margin: 14px 12px 4px; }
    /* бейдж-счётчик уезжает в угол иконки */
    html.nav-collapsed .side .nav-badge {
        position: absolute;
        top: 2px;
        right: 6px;
        min-width: 0;
        padding: 1px 4px;
        font-size: 11px;
        transform: translate(2px, -2px);
    }
}

/* ── верхняя строка контента ──
   НЕ sticky (UI-09). Прибитый топбар перекрывал бы sticky-шапки отчётов:
   они прибиты к top:0 собственными <style> в шаблонах (balances,
   balance_as_of, plan_fact, plan_fact_year, cashflow …), и при прокрутке
   уезжали под него. Липкая шапка таблицы ценнее липкой кнопки: к экрану
   прибит сайдбар, а в топбаре пока только сворачивание.
   Возвращать sticky — на этапе табличного слоя, когда шапки сведутся
   в общий класс: тогда же появится --topbar-h и шапки сдвинутся на неё
   синхронно. Порознь эти две правки делать нельзя. ── */
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: background .12s, border-color .12s;
}
.btn-icon:hover { background: var(--surface-alt); border-color: var(--text-faint); }
/* бургер и подложка живут только на узком экране (UI-08) */
.nav-burger { display: none; }
.side-overlay { display: none; position: fixed; inset: 0; z-index: 50; background: rgba(16,24,40,.45); }

/* ── узкий экран: сайдбар уезжает за край и открывается бургером ──
   Брейкпоинт 900 (а не 720): с сайдбаром в 236px контенту тесно
   заметно раньше, чем начинается «телефонная» секция ниже. ── */
@media (max-width: 900px) {
    .app,
    html.nav-collapsed .app { grid-template-columns: minmax(0, 1fr); }
    .side {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 60;
        width: var(--side-w);
        transform: translateX(-100%);
        transition: transform .18s;
    }
    html.nav-open .side { transform: none; }
    html.nav-open .side-overlay { display: block; }
    .nav-burger { display: inline-flex; }
    #side-toggle { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .side { transition: none; }
}

/* ── карточки и сетки (UI-12) ─────────────────────────
   Переехали из локального <style> главной: нужны и на «Графиках», и
   дальше на отчётах. Значения — из прототипа «Обзор 2.0». ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}
.card-head { display: flex; align-items: baseline; gap: 8px; padding: 16px 16px 12px; }
.card-title { font-size: 15px; font-weight: 600; margin: 0; }
.card-note { font-size: 13.5px; color: var(--text-muted); }
.card-link { margin-left: auto; font-size: 14px; }
.card-body { padding: 0 16px 16px; }
.card-foot { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 14px; }

/* minmax(0, 1fr) — как у колонки контента: иначе широкая таблица внутри
   ячейки растянет колонку и сломает сетку. */
.grid-kpi { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1280px) {
    .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3,
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
    .grid-kpi { grid-template-columns: minmax(0, 1fr); }
}

/* ── полоса доли / исполнения (общий компонент): главная, «Капитал»,
   карточка поездки. Переехала из локальных <style> home.html и
   trip_detail.html — «Капитал» своих правил не имел, и полоски там
   были невидимы. overflow не hidden: риска темпа выступает за края. ── */
.bar { position: relative; height: 8px; border-radius: 4px; background: var(--track); }
.bar-fill { height: 100%; border-radius: 4px; }
.bar-ok   { background: var(--pos); }
.bar-warn { background: var(--warn); }
.bar-over { background: var(--neg); }
.bar-acc  { background: var(--accent); min-width: 2px; }
.bar-tick {
    position: absolute; top: -4px; bottom: -4px; width: 2px;
    background: var(--text); opacity: .55; border-radius: 1px;
}
.bar-caption { display: flex; gap: 8px; margin-top: 5px; font-size: 13px; color: var(--text-muted); }
.bar-caption .pace { margin-left: auto; font-weight: 500; white-space: nowrap; }

/* ── графики: карточки и переключатель метрики.
   Переехали из локального <style> страницы «Графики», когда раздел
   разнесли на отдельные страницы: копий в шаблонах не заводить. ── */
.charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.chart-card { min-height: 0; }
.chart-wrap { position: relative; height: 320px; }
/* Карточка динамики капитала идёт отдельным блоком на всю ширину. */
.nw-card { margin-bottom: 18px; }

/* Шапка трендового графика: заголовок + сегмент-переключатель. */
.chart-head { flex-wrap: wrap; }
.chart-head .seg { margin-left: auto; }
.chart-sub { font-size: 0.85em; margin: 2px 0 10px; }

/* Сегмент-контрол «Расходы | Доходы». */
.seg {
    display: inline-flex;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    overflow: hidden;
}
.seg-btn {
    border: none;
    background: var(--surface);
    color: var(--accent);
    padding: 5px 14px;
    font-size: 0.85em;
    cursor: pointer;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--border-strong); }
.seg-btn:hover { background: var(--accent-soft); }
.seg-btn.is-active { background: var(--accent); color: #fff; font-weight: 600; }

@media (max-width: 700px) {
    .chart-wrap { height: 260px; }
}

/* ── таблицы ──────────────────────────────────────── */
table { border-collapse: collapse; width: 100%; margin-top: 8px; }
th, td { padding: 7px 10px; font-size: 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--surface-alt); font-weight: 600; }
/* моноширинные цифры: все ячейки таблиц + утилита .num для плиток/KPI */
th, td, .num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}
.amount { text-align: right; }
tr.subtotal td {
    font-weight: 600;
    background: var(--surface-alt);
    border-top: 1px solid var(--border);
}
tr.grand td {
    font-weight: 700;
    background: var(--accent-soft);
    border-top: 2px solid var(--border-strong);
    border-bottom: 2px solid var(--border-strong);
    font-size: 1.05em;
}
/* Подсветка строки под курсором. Специфичность (0,1,2): отчёты со своей
   зеброй (0,2,3+) её перебивают — там подсветка добирается собственным
   правилом после зебры, в локальном <style> шаблона. */
tbody tr:hover > td { background: var(--surface-alt); }

/* Обёртка-карточка для таблицы: рамка со скруглением вместо покраски
   самой таблицы.
   ⚠ overflow здесь НЕ задаём (ни hidden ради углов, ни auto): панель
   стала бы скролл-контейнером, и sticky-шапка внутри начала бы липнуть
   к ней, а не к окну — ровно та поломка, которую чинил UI-15. Углы
   скругляем на угловых ячейках шапки. */
.table-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.table-panel > table { margin-top: 0; }
.table-panel thead th:first-child { border-top-left-radius: var(--radius-lg); }
.table-panel thead th:last-child  { border-top-right-radius: var(--radius-lg); }

/* Ширины числовых колонок: без них на широком мониторе колонка с суммой
   растягивается и число уезжает от своего заголовка. Ставятся на <th>. */
.w-num-s { width: 90px; }
.w-num-m { width: 120px; }
.w-num-l { width: 150px; }

.muted { color: var(--text-muted); }
.warning { color: var(--warn); }
form.report-form {
    display: flex;
    gap: 18px;
    align-items: center;
    padding: 14px 16px;
    background: var(--form-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 18px;
}
form.report-form label { font-weight: 600; }
form.report-form input[type="date"] { padding: 4px 6px; }
form.report-form button {
    padding: 6px 16px;
    cursor: pointer;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 14px;
}
form.report-form button:hover { background: var(--accent-hover); }
/* Вторичная сабмит-кнопка «Сохранить и закрыть вкладку» — единый
   вид во всех формах правки (вид под вторичную кнопку). */
button.btn-save-close {
    padding: 6px 14px;
    background: var(--surface);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 3px;
    font-size: 0.95em;
    cursor: pointer;
    margin-left: 8px;
}
button.btn-save-close:hover { background: var(--accent-soft); }

/* ── поля ввода: единый вид во всех формах. Явный фон/текст/рамка —
   критично для тёмной темы, иначе остаются системные светлые поля
   с тёмным текстом (инверсия). color-scheme в :root довершает
   нативные части (стрелка select, date-picker). ── */
input[type="text"], input[type="number"], input[type="date"],
input[type="search"], input[type="password"], input[type="email"],
input[type="url"], input[type="tel"], select, textarea {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    box-shadow: var(--input-inset);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }

/* Hover/focus полей. Специфичность :is()+псевдоклассы намеренно выше
   локальных правил шаблонов (form.entry-form input[...] = 0,2,2),
   иначе hover не был бы виден в журнале. .input-error исключён из hover,
   чтобы не гасить красную рамку ошибки. */
:is(input[type="text"], input[type="number"], input[type="date"],
    input[type="search"], input[type="password"], input[type="email"],
    input[type="url"], input[type="tel"], select, textarea):hover:not(:focus):not(:disabled):not(.input-error) {
    border-color: var(--input-border-hover);
}
:is(input[type="text"], input[type="number"], input[type="date"],
    input[type="search"], input[type="password"], input[type="email"],
    input[type="url"], input[type="tel"], select, textarea):focus {
    border-color: var(--accent);
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* ── обёртка широких таблиц для горизонтального скролла. Нужна и на
   десктопе (UI-07): после снятия max-width у body широкий отчёт распирал
   бы страницу целиком. Обёртку навешивает app.js на все <table>. ── */
.table-scroll { width: 100%; overflow-x: auto; }

/* ── бейдж-счётчик в шапке: «На разбор N», «Процедуры N».
   Жёлтый — инбокс разбора, синий — непарные переводы. ── */
.nav-badge {
    display: inline-block;
    min-width: 1.4em;
    padding: 1px 5px;
    border-radius: 9px;
    background: var(--warn-border);
    color: #fff;
    font-size: 0.78em;
    font-weight: 700;
    text-align: center;
    line-height: 1.4;
    vertical-align: text-top;
}
.nav-badge-blue { background: var(--accent); }

/* ── хлебные крошки на экранах-деталях (формы справочников,
   правка операции, переоценка актива) ── */
nav.breadcrumbs {
    color: var(--text-muted);
    font-size: 0.92em;
    margin: -6px 0 14px;
}
nav.breadcrumbs a { color: var(--accent); text-decoration: none; }
nav.breadcrumbs a:hover { text-decoration: underline; }
nav.breadcrumbs .sep { margin: 0 6px; color: var(--text-faint); }

/* ── бейдж сплита (A4б): пометка «сплит» у строк, где статья/аналитика
   взяты из сплита операции (список операций, карточка КД, аудиты). ── */
.split-badge {
    display: inline-block;
    padding: 0 6px;
    border-radius: 9px;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--border-strong);
    font-size: 0.78em;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    vertical-align: text-top;
}

/* ── чип тега (A4а): цветная плашка с названием. Цвет фона приходит
   инлайном из Tag.color; текст белый с лёгкой тенью для читаемости на
   любом фоне. Фон ниже — лишь дефолт, когда у тега цвет не задан. ── */
.tag-chip {
    display: inline-block;
    padding: 1px 8px;
    margin: 1px 3px 1px 0;
    border-radius: 10px;
    background: #6c8cbf;
    color: #fff;
    font-size: 0.82em;
    line-height: 1.5;
    white-space: nowrap;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
}

/* ── список чекбоксов выбора тегов (формы ввода/правки операции).
   CheckboxSelectMultiple рендерит <ul> или <div> — стилизуем оба. ── */
.tag-checks ul, .field-row-tags ul,
.tag-checks > div, .field-row-tags > div {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
}
.tag-checks li, .field-row-tags li,
.tag-checks > div > div, .field-row-tags > div > div { margin: 0; }
.tag-checks label, .field-row-tags label {
    font-weight: 400;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* ── строка-тулбар над отчётной таблицей (для тумблера и т.п.) ── */
.report-toolbar { margin: 10px 0 4px; display: flex; align-items: center; gap: 8px; }

/* ── тумблер «Суммы | %» над таблицами отчётов. Активный режим — синий.
   Значения-пары: .v-amt / .v-pct, видимость переключает app.js через
   inline style (конвенция проекта: не через CSS-класс). ── */
.amt-pct-switch {
    display: inline-flex;
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    overflow: hidden;
}
.amt-pct-switch button {
    padding: 5px 12px;
    border: none;
    background: var(--accent-soft);
    cursor: pointer;
    font-size: 0.9em;
}
.amt-pct-switch button + button { border-left: 1px solid var(--border-strong); }
.amt-pct-switch button.on {
    background: var(--accent);
    color: #fff;
    cursor: default;
}

/* ── раскладка «строка × период» (отчёты «По тегам» и «По регулярным
   платежам»): первая колонка — имя среза, дальше узкие числовые, итоговая
   отбита рамкой, как «Год» в ДДС. Общая на оба отчёта — своей копии в
   шаблонах не заводить. ── */
table.tp-grid td.hname,
table.tp-grid th.amount,
table.tp-grid td.amount { white-space: nowrap; }
table.tp-grid .tp-total-col {
    border-left: 2px solid var(--border-strong);
    font-weight: 600;
}
table.tp-grid td.neg { color: var(--neg); }
table.tp-grid thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface-alt);
    box-shadow: inset 0 -1px 0 var(--border);
}

/* Подпись перед сегмент-переключателем в тулбаре («Группировка:»).
   Второй и далее — с отступом слева, чтобы группы не слипались. */
.report-toolbar .switch-label { font-size: 0.9em; }
.report-toolbar .group-switch + .switch-label { margin-left: 10px; }

/* ── сегмент-переключатель группировки («Остатки»: владелец | банк |
   валюта | без группировки) и сортировки (по названию | по остатку).
   Та же стилистика, что у «Суммы | %», но состояние живёт в GET-параметре,
   поэтому сегменты — ссылки, а не кнопки (URL остаётся закладываемым). ── */
.group-switch {
    display: inline-flex;
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    overflow: hidden;
}
.group-switch a {
    padding: 5px 12px;
    background: var(--accent-soft);
    color: var(--text);
    text-decoration: none;
    font-size: 0.9em;
}
.group-switch a + a { border-left: 1px solid var(--border-strong); }
.group-switch a.on {
    background: var(--accent);
    color: #fff;
    cursor: default;
}

/* ── ссылки-значения в ячейках отчётов (ДДС, план-факт):
   клик ведёт на список «Операции» с готовым фильтром статья+период.
   Цвет наследуется (минус остаётся красным), пунктир — намёк на клик. ── */
a.cell-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted var(--border-strong);
}
a.cell-link:hover {
    color: var(--accent);
    border-bottom: 1px solid var(--accent);
}

/* ── Мастер бюджета (bw-*): вертикальный степпер из карточек-шагов.
   Три состояния: done (сводка + чип «Готово»), current (акцентная рамка,
   содержимое раскрыто), pending (приглушено; у шага 4 пунктир + «Скоро»).
   Палитра — только существующие семантические переменные (--ok-*,
   --warn-*, --accent*), поэтому тёмная тема работает без новых значений.
   Фоны кружков/чипов непрозрачные (никакого transparent). ── */
.bw-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px 24px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.bw-head h1 { margin: 0; }
.bw-sub { margin: 4px 0 0; color: var(--text-muted); font-size: 13px; }
.bw-year { display: flex; align-items: center; gap: 12px; }
.bw-year label { font-weight: 600; }
.bw-year select { padding: 4px 6px; }

.bw-msg {
    border-radius: 4px;
    padding: 10px 16px;
    margin-bottom: 12px;
}
.bw-msg--ok {
    background: var(--ok-bg);
    border: 1px solid var(--ok-border);
    color: var(--ok-text);
}
.bw-msg--err {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger-text);
}

.bw-step {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 10px;
    box-shadow: var(--shadow-card);
}
.bw-step--current { border: 2px solid var(--accent); }
.bw-step--pending { background: var(--surface-alt); box-shadow: none; }
.bw-step--pending h2,
.bw-step--pending .bw-summary { color: var(--text-muted); }

.bw-step-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.bw-step-title { flex: 1 1 auto; min-width: 220px; }
.bw-step-title h2 { margin: 0; font-size: 16px; }
.bw-summary { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.bw-circle {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}
.bw-circle--done {
    background: var(--ok-bg);
    color: var(--ok-text);
    border: 1px solid var(--ok-border);
}
.bw-circle--current {
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent);
}
.bw-circle--pending {
    background: var(--surface);
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
}

.bw-badge,
.bw-chip {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
}
.bw-badge {
    background: var(--ok-bg);
    color: var(--ok-text);
    border: 1px solid var(--ok-border);
}
.bw-chip--ok {
    background: var(--ok-bg);
    color: var(--ok-text);
    border: 1px solid var(--ok-border);
}
.bw-chip--warn {
    background: var(--warn-bg);
    color: var(--warn-text);
    border: 1px solid var(--warn-border);
}

/* отступ содержимого под кружок (28px + зазор 12px) */
.bw-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0 0 40px;
}
.bw-note { font-size: 12px; color: var(--text-muted); margin: 6px 0 0 40px; }
.bw-note--flush { margin-left: 0; }
.bw-step-body { margin: 12px 0 0 40px; }

.bw-form-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.bw-step button {
    padding: 6px 16px;
    cursor: pointer;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 14px;
}
.bw-step button:hover { background: var(--accent-hover); }
.bw-btn-link {
    padding: 5px 14px;
    background: var(--surface);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 3px;
    font-size: 14px;
    text-decoration: none;
    white-space: nowrap;
}
.bw-btn-link:hover { background: var(--accent-soft); }

.bw-tiles {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.bw-tile {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 8px 14px;
    background: var(--surface);
    cursor: pointer;
}
.bw-tile--disabled {
    color: var(--text-muted);
    background: var(--surface-alt);
    border-color: var(--border);
    cursor: not-allowed;
}

/* ── Превью загрузки бюджета (продолжение bw-*): карточка файла,
   метрики, тонированные панели, чипы ячеек, панель действий.
   Палитра — те же существующие семантические переменные (--ok-*,
   --warn-*, --danger-*, --accent*), поэтому тёмная тема работает без
   новых значений; фоны непрозрачные. ── */
.bw-crumb { margin: 0 0 6px; font-size: 13px; }

.bw-file-card,
.bw-metric,
.bw-panel,
.bw-actionbar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-card);
}

.bw-file-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
}
.bw-file-badge {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}
.bw-file-main { flex: 1 1 auto; min-width: 0; }
.bw-file-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bw-file-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.bw-chip--accent {
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent);
}
.bw-chip--muted {
    background: var(--surface-alt);
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
}

.bw-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
    margin: 14px 0;
}
.bw-metric { padding: 10px 12px; }
.bw-metric-label { font-size: 12px; color: var(--text-muted); }
.bw-metric-value {
    font-size: 22px;
    font-weight: 500;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);   /* ноль — без окраски (см. _bw_metrics) */
}
.bw-metric--ok .bw-metric-value { color: var(--ok-text); }
.bw-metric--accent .bw-metric-value { color: var(--accent); }
.bw-metric--warn .bw-metric-value { color: var(--warn-text); }
.bw-metric--danger .bw-metric-value { color: var(--danger-text); }
.bw-metric--danger { border-color: var(--danger-border); }

.bw-panel {
    margin: 14px 0;
    overflow: hidden;   /* чтобы таблица внутри не резала скругление */
}
.bw-panel-head {
    padding: 10px 14px;
    font-weight: 600;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
}
.bw-panel table { margin: 0; }
.bw-panel > table:last-child tr:last-child td { border-bottom: none; }
.bw-panel--danger { border-color: var(--danger-border); }
.bw-panel--danger .bw-panel-head {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-bottom-color: var(--danger-border);
}
.bw-panel--warn { border-color: var(--warn-border); }
.bw-panel--warn .bw-panel-head {
    background: var(--warn-bg);
    color: var(--warn-text);
    border-bottom-color: var(--warn-border);
}
.bw-confirm { display: block; padding: 12px 14px; }
.bw-blocked-note { font-size: 12px; color: var(--warn-text); margin-top: 2px; }
.bw-val {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .95em;
    background: var(--surface-alt);
    border-radius: 3px;
    padding: 1px 5px;
}

.bw-cell-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.bw-cell-chip {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    background: var(--surface-alt);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.bw-cell-chip s { opacity: .6; }
.bw-cell-chip--new {
    background: var(--ok-bg);
    color: var(--ok-text);
    border-color: var(--ok-border);
}
.bw-cell-chip--upd {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}
.bw-cell-chip--warn {
    background: var(--warn-bg);
    color: var(--warn-text);
    border-color: var(--warn-border);
}

.bw-actionbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 14px;
    margin: 14px 0;
}
/* вторичная кнопка по умолчанию; залитая — только primary */
.bw-actionbar button {
    padding: 6px 16px;
    font-size: 14px;
    border-radius: 3px;
    cursor: pointer;
    background: var(--surface);
    color: var(--accent);
    border: 1px solid var(--accent);
}
.bw-actionbar button:hover { background: var(--accent-soft); }
.bw-actionbar .bw-btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.bw-actionbar .bw-btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}
.bw-actionbar .bw-btn-primary:disabled,
.bw-step button:disabled {
    background: var(--surface-alt);
    color: var(--text-faint);
    border: 1px solid var(--border);
    cursor: not-allowed;
}
.bw-actionbar-note {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
}

/* ════════════════════════════════════════════════════
   Списки справочников (UI-17)
   ────────────────────────────────────────────────────
   Раньше этот набор жил в двух местах: половина списков
   включала core/_ref_list_styles.html, половина держала
   собственную копию тех же правил в локальном <style>.
   Копии успели разойтись (у «Бюджетов» не было даже фона
   таблицы). Теперь набор один и лежит здесь.
   ════════════════════════════════════════════════════ */

/* ── шапка экрана: заголовок и главное действие в одну строку ── */
.page-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin: 0 0 6px;
}
.page-head h1 { margin: 0; }
/* группа действий уходит вправо; на «Статьях» и «Активах» их два
   (выгрузка в Excel + добавление), поэтому inline-flex с зазором */
.page-head .page-action {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 12px;
}
/* пояснение под заголовком: 90ch — иначе на широком мониторе строка
   растягивается на весь экран и читается тяжело */
.page-note {
    color: var(--text-muted);
    font-size: 13.5px;
    margin: 0 0 14px;
    max-width: 90ch;
}

/* ── действия по строке таблицы: одна ячейка справа, содержимое
   проявляется при наведении на строку.
   ⚠ opacity, а НЕ display/visibility: ячейка должна занимать своё
   место всегда, иначе строка дёргается по ширине при наведении.
   :focus-within обязателен — без него ссылки недостижимы с клавиатуры,
   @media (hover: none) — для тача, где наведения не бывает. ── */
.row-actions { width: 1%; white-space: nowrap; text-align: right; }
.row-act {
    display: inline-block;
    font-size: 13.5px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: none;
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.row-act + .row-act { margin-left: 2px; }
.row-act:hover { background: var(--accent-soft); text-decoration: none; }
.row-act-danger { color: var(--neg); }
.row-act-danger:hover { background: var(--danger-bg); }
.row-actions .row-act { opacity: 0; transition: opacity .12s; }
tbody tr:hover .row-act,
tbody tr:focus-within .row-act { opacity: 1; }
@media (hover: none) {
    .row-actions .row-act { opacity: 1; }
}

/* ── чип состояния. Правило: пусто, когда состояние обычное, чип —
   когда особое («Архив», «Неактивен»). Частокол прочерков «—» глазу
   не помогает, исключение должно быть заметно. ── */
.chip {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
    background: var(--surface-alt);
    color: var(--text-muted);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.chip-warn {
    background: var(--warn-bg);
    color: var(--warn-text);
    border-color: var(--warn-border);
}
/* положительное состояние («активна» у идущей поездки) */
.chip-ok {
    background: var(--ok-bg);
    color: var(--ok-text);
    border-color: var(--ok-border);
}

/* ── фильтр-форма списка (внутри общей form.report-form) ── */
.filter-field label { font-weight: 600; }
.filter-field input[type="text"],
.filter-field select {
    padding: 5px 8px;
    font-size: .95em;
    border: 1px solid var(--input-border);
    border-radius: 3px;
}
.filter-check { align-self: flex-end; }
.filter-check label { font-weight: 400; }
.filter-actions { align-self: flex-end; display: flex; align-items: center; gap: 12px; }
.cd-check { font-weight: 400; font-size: .95em; display: inline-flex; align-items: center; gap: 5px; }
.ref-reset { color: var(--accent); text-decoration: none; font-size: .95em; }
.ref-reset:hover { text-decoration: underline; }

/* ── кнопка «+ Добавить» и её старая строка-тулбар.
   .ref-toolbar остаётся для списков, ещё не переведённых на .page-head. ── */
.ref-toolbar { display: flex; gap: 18px; align-items: center; margin: 16px 0; }
.ref-add {
    display: inline-block;
    padding: 7px 16px;
    background: var(--accent);
    color: #fff;
    border-radius: 3px;
    text-decoration: none;
    font-size: .95em;
    white-space: nowrap;
}
.ref-add:hover { background: var(--accent-hover); text-decoration: none; }
/* «Выгрузить в Excel» — зелёный цвет Excel, намеренный хардкод-токен */
.ref-export {
    display: inline-block;
    padding: 7px 16px;
    background: var(--excel);
    color: #fff;
    border-radius: 3px;
    text-decoration: none;
    font-size: .95em;
    white-space: nowrap;
}
.ref-export:hover { background: var(--excel-hover); text-decoration: none; }

/* ── сама таблица списка. Фон нужен спискам, которые ещё не обёрнуты
   в .table-panel; внутри панели он снимается, иначе прямоугольник
   таблицы закрасил бы скруглённые углы панели. ── */
table.ref-list { background: var(--surface); }
.table-panel > table { background: none; }
table.ref-list th.num, table.ref-list td.num { text-align: right; white-space: nowrap; }
/* название записи — ссылка на правку (основной путь, как имя счёта
   в «Остатках»); кнопка «Изменить» остаётся дублирующей */
table.ref-list td .ref-name { color: var(--text); text-decoration: none; }
table.ref-list td .ref-name:hover { color: var(--accent); text-decoration: underline; }
/* строка «выведена из оборота»: у каждого справочника свой термин
   (архив / неактивен / закрыт / выбыл), вид один */
table.ref-list tr.inactive td,
table.ref-list tr.archived td,
table.ref-list tr.closed td,
table.ref-list tr.disposed td {
    color: var(--text-faint);
    background: var(--surface-alt);
    font-style: italic;
}

/* ── старый вид действий строкой (ещё живёт в непереведённых списках) ── */
.ref-edit {
    display: inline-block; padding: 4px 12px; background: var(--accent); color: #fff;
    border-radius: 3px; text-decoration: none; font-size: .9em; white-space: nowrap;
}
.ref-edit:hover { background: var(--accent-hover); text-decoration: none; }
.ref-delete {
    display: inline-block; padding: 4px 12px; background: var(--surface); color: var(--neg);
    border: 1px solid var(--neg); border-radius: 3px; text-decoration: none;
    font-size: .9em; white-space: nowrap;
}
.ref-delete:hover { background: var(--danger-bg); text-decoration: none; }

/* ── подтверждение удаления: отдельный шаг, POST с CSRF внутри ── */
.ref-confirm-delete {
    background: var(--warn-bg);
    border: 1px solid var(--warn-border);
    border-radius: 4px;
    padding: 14px 18px;
    margin: 0 0 16px;
    max-width: 560px;
}
.ref-confirm-delete p { margin: 0 0 12px; }
.ref-confirm-delete form { display: flex; align-items: center; gap: 12px; }
.btn-danger {
    padding: 7px 16px; background: var(--neg); color: #fff; border: none;
    border-radius: 3px; font-size: .95em; cursor: pointer;
}
.btn-danger:hover { filter: brightness(0.9); }
.btn-cancel { color: var(--accent); text-decoration: none; font-size: .95em; }
.btn-cancel:hover { text-decoration: underline; }

/* ── сообщения об итоге операции над справочником ── */
.form-ok {
    background: var(--ok-bg); border: 1px solid var(--ok-border); border-radius: 4px;
    padding: 10px 16px; margin-bottom: 16px; color: var(--ok-text);
}
.form-error {
    background: var(--danger-bg); border: 1px solid var(--danger-border); border-radius: 4px;
    padding: 10px 16px; margin-bottom: 16px; color: var(--danger-text);
}

/* ════════════════════════════════════════════════════
   Чеки (A10): карточка чека и селект привязки товара.
   Общий слой инбокса разбора и реестра чеков — до
   TASK_RECEIPT_REGISTRY жил инлайном в inbox_receipts.html
   (значения перенесены как были).
   ════════════════════════════════════════════════════ */
.receipt-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 6px; margin: 0 0 18px; padding: 14px 16px;
    box-shadow: var(--shadow-card);
}
.receipt-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 14px; margin-bottom: 10px; }
.receipt-merchant { font-size: 1.1em; font-weight: 700; }
.receipt-meta { color: var(--text-muted); }
.receipt-tag {
    display: inline-block; padding: 1px 8px; font-size: .82em; background: var(--accent-soft);
    color: var(--accent); border-radius: 9px; margin-left: 4px;
}
.receipt-unbalanced { color: var(--warn-text); background: var(--warn-bg);
    border: 1px solid var(--warn-border); border-radius: 4px; padding: 1px 8px; font-size: .85em; }
table.receipt-items { width: 100%; border-collapse: collapse; background: var(--surface); }
table.receipt-items th, table.receipt-items td {
    padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle;
}
table.receipt-items th { font-size: .85em; color: var(--text-muted); font-weight: 600; }
table.receipt-items .num { text-align: right; white-space: nowrap; }
table.receipt-items tr.aux-line td { color: var(--text-muted); font-size: .92em; }
.product-pick { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.product-pick select {
    padding: 4px 6px; border: 1px solid var(--input-border); border-radius: 3px;
    background: var(--surface); min-width: 200px;
}
.product-create {
    font-size: .85em; color: var(--accent); white-space: nowrap; cursor: pointer;
    background: none; border: none; padding: 0; text-decoration: none; font: inherit;
}
.product-create:hover { text-decoration: underline; }
.product-suggest {
    font-size: .78em; color: var(--ok-text); background: var(--ok-bg);
    border: 1px solid var(--ok-border); border-radius: 9px; padding: 0 7px;
}
.receipt-actions { margin-top: 4px; }
.btn-save-bind {
    padding: 8px 18px; background: var(--excel); color: #fff; border: none;
    border-radius: 3px; font-size: .95em; cursor: pointer;
}
.btn-save-bind:hover { background: var(--excel-hover); }

/* Пагинация реестра — тот же вид, что у «Операций» (там свой локальный
   дубль в transactions.html; значения совпадают построчно). */
.tx-pager {
    margin-top: 12px;
    display: flex;
    gap: 14px;
    align-items: baseline;
}
.tx-pager a { text-decoration: none; color: var(--accent); }
.tx-pager a:hover { text-decoration: underline; }
.tx-pager .disabled { color: var(--text-faint); }
.tx-pager .tx-pager-cur { font-weight: 600; }

/* Поля формсета позиций на карточке чека: числовые уже, налог совсем
   короткий — иначе таблица не влезает. */
.receipt-items input.ri-num { max-width: 110px; text-align: right; }
.receipt-items input.ri-tax { max-width: 56px; }
.receipt-items td.ri-flag { text-align: center; white-space: nowrap; }
.receipt-items tr.formset-error td { border-bottom: none; }
.receipt-items .row-error { color: var(--danger-text); font-size: .88em; padding-top: 0; }

/* ════════════════════════════════════════════════════
   Адаптив (только узкий экран). Десктоп ≥721px не затронут.
   ════════════════════════════════════════════════════ */
@media (max-width: 720px) {
    /* поля страницы уже, чем на десктопе (геометрия переехала из body
       в .app-main вместе с сайдбаром, UI-07) */
    .app-main { padding: 14px 12px 28px; }
    .topbar { padding: 8px 12px; }

    /* фильтр-формы отчётов — в столбик */
    form.report-form {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    form.report-form button { width: 100%; padding: 10px 16px; }

    /* широкие отчётные таблицы: сам overflow-x теперь десктопный,
       здесь остаётся инерционный скролл и минимальная ширина таблицы */
    .table-scroll { -webkit-overflow-scrolling: touch; }
    .table-scroll > table { min-width: 560px; }

    /* мастер бюджета: содержимое шагов без отступа под кружок,
       шапка и формы — в столбик */
    .bw-head { align-items: flex-start; }
    .bw-step-body,
    .bw-chips,
    .bw-note { margin-left: 0; }
    .bw-form-row { align-items: stretch; flex-direction: column; }

    /* панель действий превью — кнопки в столбик на всю ширину */
    .bw-actionbar { align-items: stretch; }
    .bw-actionbar button { width: 100%; }
    .bw-actionbar-note { margin-left: 0; }
}

/* ── главная: сторож курсов (core.rate_health) ── */
.dash-alert {
    background: var(--warn-bg);
    border: 1px solid var(--warn-border);
    border-radius: 4px;
    padding: 10px 14px;
    margin: 0 0 16px;
}
.dash-alert ul { margin: 4px 0 6px; padding-left: 20px; }
.dash-alert ul:last-child { margin-bottom: 0; }

/* ── свой выпадающий поиск для input[data-picker] (app.js, раздел 6) ──
   Ширина, позиция и max-height — из JS, по полю ввода. z-index выше
   sticky-шапок и сайдбара. */
.picker-pop {
    position: absolute;
    z-index: 100;
    box-sizing: border-box;
    overflow-y: auto;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    box-shadow: var(--shadow-pop);
    font-size: 14px;
}
.picker-opt {
    padding: 6px 10px;
    cursor: pointer;
    overflow-wrap: anywhere;
}
.picker-opt.is-active { background: var(--accent-soft); }
.picker-opt mark {
    background: transparent;
    color: inherit;
    font-weight: 700;
    text-decoration: underline;
}
.picker-more {
    padding: 6px 10px;
    color: var(--text-muted);
    font-size: 13px;
}
