        :root {
            color-scheme: light;
            --payflow-workspace-bg: #f3f6fa;
            --payflow-line-soft: #e1e7ef;
            --payflow-line: #d2dae5;
            --payflow-line-strong: #b9c5d3;
            --payflow-control-border: #7c8a9c;
            --payflow-focus: #2563eb;
            --payflow-surface-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 10px 28px -20px rgba(15, 23, 42, 0.34);
            --payflow-control-inset: inset 0 1px 2px rgba(15, 23, 42, 0.045);
        }
        [v-cloak] { display: none; }
        html { -webkit-text-size-adjust: 100%; }
        body { overscroll-behavior-y: none; touch-action: manipulation; background: var(--payflow-workspace-bg); }
        input[type="number"] { text-align: right; }
        input[type="number"]::-webkit-outer-spin-button,
        input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
        input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
        input[type="date"], input, select, textarea { min-width: 0; max-width: 100%; }
        .auth-recovery-link { display: inline-flex; align-items: center; min-height: 24px; max-width: 100%; padding: 2px 0; border: 0; border-radius: 2px; background: transparent; box-shadow: none; color: #1d4ed8; font-size: 14px; line-height: 20px; font-weight: 400; text-align: left; text-decoration: underline; text-underline-offset: 3px; }
        .auth-recovery-link:hover:not(:disabled) { color: #1e40af; }
        .auth-recovery-link:focus-visible { outline: 2px solid #2563eb; outline-offset: 3px; }
        .auth-recovery-link:disabled { color: #6b7280; cursor: wait; }
        @media (pointer: coarse) { .auth-recovery-link { min-height: 44px; } }
        .acc-plan-table { font-size: 90%; }
        .acc-plan-table th { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
        .acc-plan-table td { padding-top: 0.36rem !important; padding-bottom: 0.36rem !important; }

        /* Visual separation per invoice — each invoice gets its own <tbody>. */
        .inv-tbody { transition: background-color 120ms ease; }
        .inv-tbody:not(:last-child) { border-bottom: 2px solid #d1d5db; }
        .inv-tbody:hover > tr > td { background-color: rgb(239 246 255 / 0.7); }
        .inv-tbody.is-overdue:hover > tr > td { background-color: rgb(254 226 226 / 0.7); }
        .inv-tbody.is-closed:hover > tr > td { background-color: rgb(243 244 246 / 0.9); }
        .inv-prio-cell {
            position: relative;
            padding-left: 0.875rem !important;
        }
        .inv-prio-cell::before {
            content: "";
            position: absolute;
            left: 0; top: 0; bottom: 0;
            width: 4px;
            background-color: transparent;
        }
        .inv-prio-low::before    { background-color: #86efac; }
        .inv-prio-medium::before { background-color: #fcd34d; }
        .inv-prio-high::before   { background-color: #f87171; }
        .inv-overdue::before     { background-color: #ef4444 !important; width: 5px; }
        .inv-closed::before      { background-color: #9ca3af !important; width: 4px; }

        /* Список заявок помещается в ширину рабочей области без прокрутки вбок. Ширина считается по самому списку
           (контейнерные запросы), а не по окну: меню слева бывает развёрнуто и свёрнуто. Уже 960 px — карточки.
           Шире — таблица; необязательные столбцы появляются по мере места, а пока места нет — их значения
           стоят строкой под «Кому платим» (.inv-fold). Столбец «Действия» — 192 px кнопок, как просила Татьяна 05.10. */
        .invoice-list { container-type: inline-size; container-name: invoice-list; }
        .invoice-table-scroll { display: none; }
        @container invoice-list (min-width: 60rem) {
            .invoice-table-scroll { display: block; }
            .invoice-cards { display: none; }
        }
        .invoice-table { table-layout: fixed; width: 100%; }
        .invoice-table th, .invoice-table td { vertical-align: top; overflow-wrap: anywhere; }
        .invoice-table .inv-w-check { width: 2.5rem; }
        .invoice-table .inv-w-id { width: 6rem; }
        .invoice-table .inv-w-amount { width: 9rem; }
        .invoice-table .inv-w-deadline { width: 8rem; }
        .invoice-table .inv-w-status { width: 9rem; }
        .invoice-table .inv-w-actions { width: 13.5rem; }
        .invoice-table .inv-w-created { width: 6.5rem; }
        .invoice-table .inv-w-requester,
        .invoice-table .inv-w-category,
        .invoice-table .inv-w-direction { width: 9.5rem; }
        .invoice-table .inv-w-department,
        .invoice-table .inv-w-legal { width: 7.5rem; }
        .invoice-table .inv-opt { display: none; }
        @container invoice-list (min-width: 70rem) { .invoice-table .inv-opt-requester { display: table-cell; } .invoice-table .inv-fold-requester { display: none; } }
        @container invoice-list (min-width: 79.375rem) { .invoice-table .inv-opt-category { display: table-cell; } .invoice-table .inv-fold-category { display: none; } }
        @container invoice-list (min-width: 86.875rem) { .invoice-table .inv-opt-department { display: table-cell; } .invoice-table .inv-fold-department { display: none; } }
        @container invoice-list (min-width: 94.375rem) { .invoice-table .inv-opt-legal { display: table-cell; } .invoice-table .inv-fold-legal { display: none; } }
        @container invoice-list (min-width: 100.9375rem) { .invoice-table .inv-opt-created { display: table-cell; } .invoice-table .inv-fold-created { display: none; } }
        @container invoice-list (min-width: 110.3125rem) { .invoice-table .inv-opt-direction { display: table-cell; } .invoice-table .inv-fold-direction { display: none; } }
        /* На широком экране «Кому платим» не забирает весь запас ширины: получателю — 20 % строки, остальное поровну
           юрлицу, статье, сроку и статусу (там переносы и даты оплаты). Порог — когда у каждого из четырёх остаётся не
           меньше его обычной ширины: со всеми столбцами — от 2000 px, без галочек и «Инициатора» — от 1600 px.
           Пороги — в rem, как и ширины столбцов: при мелком шрифте браузера («Мелкий», 12 px) всё сжимается вместе. */
        @container invoice-list (min-width: 125rem) {
            .invoice-table .inv-w-party { width: 20%; }
            .invoice-table .inv-w-legal, .invoice-table .inv-w-category, .invoice-table .inv-w-deadline, .invoice-table .inv-w-status { width: auto; }
        }
        @container invoice-list (min-width: 100rem) {
            .invoice-table.inv-lean .inv-w-party { width: 20%; }
            .invoice-table.inv-lean .inv-w-legal, .invoice-table.inv-lean .inv-w-category, .invoice-table.inv-lean .inv-w-deadline, .invoice-table.inv-lean .inv-w-status { width: auto; }
        }
        .inv-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; }
        .inv-meta-item { display: inline-flex; align-items: flex-start; gap: 4px; min-width: 0; }
        .inv-meta-item svg { margin-top: 1px; color: #6b7280; }
        .inv-check { width: 1.125rem; height: 1.125rem; cursor: pointer; }
        .inv-id-link { padding: 2px 3px; margin: -2px -3px; }
        .inv-date-chip { height: 1.75rem; padding: 0 0.6rem; border-radius: 0.375rem; border: 1px solid #bfdbfe; background: #fff; font-size: 12px; color: #1d4ed8; }
        .inv-date-chip:hover { background: #eff6ff; }
        .inv-bulk-bar { box-shadow: 0 -10px 24px -22px rgba(15, 23, 42, 0.6); }
        /* Таблицы справочников и дашборда — без прокрутки вбок: ячейки переносят текст, а на узкой ширине таблица
           становится карточками (подпись столбца — из data-label). Ширину смотрим по самой таблице, а не по окну. */
        .payflow-fit-table { container-type: inline-size; }
        .payflow-fit-table > table { width: 100%; }
        .payflow-fit-table > table td, .payflow-fit-table > table th { overflow-wrap: break-word; }
        @container (max-width: 44.9375rem) {
            .payflow-fit-table > table > thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
            .payflow-fit-table > table > tbody > tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; row-gap: 6px; padding: 10px 12px; }
            .payflow-fit-table > table > tbody > tr > td { display: block; padding: 0 !important; text-align: left !important; }
            .payflow-fit-table > table > tbody > tr > td[data-label]:not([data-label=""])::before { content: attr(data-label); display: block; margin-bottom: 1px; font-size: 11px; font-weight: 500; color: #4b5563; }
            .payflow-fit-table > table > tbody > tr > td[colspan], .payflow-fit-table > table > tbody > tr > td[data-label=""] { grid-column: 1 / -1; }
        }
        .dash-chart { container-type: inline-size; }
        @container (max-width: 44.9375rem) {
            .dash-chart .dash-bar-value { display: none; }
            .dash-chart .dash-day-label { visibility: hidden; }
            .dash-chart .dash-day-major .dash-day-label { visibility: visible; }
        }
        /* С разрешённым масштабированием iPhone увеличивает страницу при фокусе на поле мельче 16 px: на телефоне поля — 16 px. */
        @media (max-width: 767px) {
            input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea { font-size: 16px; }
        }
        /* Sticky table header subtle shadow to indicate there's more below. */
        thead.sticky { box-shadow: 0 1px 0 rgba(15, 23, 42, 0.08), 0 5px 12px -10px rgba(15, 23, 42, 0.35); }

        /* Toast slide-in from bottom-right. */
        .toast-enter { animation: toast-in 180ms ease-out; }
        @keyframes toast-in {
            from { transform: translateY(8px); opacity: 0; }
            to { transform: translateY(0); opacity: 1; }
        }

        /* Shared right-side work panels: one motion language and viewport-safe widths. */
        .payflow-side-panel-enter-active {
            transition: opacity 260ms ease-out;
        }
        .payflow-side-panel-leave-active {
            transition: opacity 220ms ease-in;
        }
        .payflow-side-panel-enter-from,
        .payflow-side-panel-leave-to {
            opacity: 0;
        }
        .payflow-side-panel__surface {
            width: 100%;
            max-width: none;
            transform: translate3d(0, 0, 0);
            will-change: transform;
        }
        .payflow-side-panel-enter-active .payflow-side-panel__surface {
            transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
        }
        .payflow-side-panel-leave-active .payflow-side-panel__surface {
            transition: transform 220ms cubic-bezier(0.4, 0, 1, 1);
        }
        .payflow-side-panel-enter-from .payflow-side-panel__surface,
        .payflow-side-panel-leave-to .payflow-side-panel__surface {
            transform: translate3d(100%, 0, 0);
        }
        @media (min-width: 640px) {
            .payflow-side-panel__surface--budget {
                width: min(42rem, calc(100vw - 3rem));
            }
            .payflow-side-panel__surface--invoice {
                width: min(59rem, calc(100vw - 3rem));
            }
            .payflow-side-panel__surface--bank {
                width: min(40rem, calc(100vw - 3rem));
            }
            /* «Настройка ДДС»: было 56rem — на 40 % шире, на узком экране — до края с полоской фона. */
            .payflow-side-panel__surface--dds {
                width: min(78rem, calc(100vw - 3rem));
            }
        }
        @media (min-width: 1280px) {
            .payflow-side-panel__surface--invoice {
                width: min(67rem, calc(100vw - 4rem));
            }
        }
        /* «Сверить»: счёт слева от карточки заявки. На узком экране — поверх карточки, на широком карточка сужается. */
        .payflow-invoice-viewer {
            position: fixed;
            inset: 0;
            z-index: 2;
            display: flex;
            flex-direction: column;
            background: #f1f5f9;
        }
        @media (min-width: 1024px) {
            .payflow-invoice-viewer {
                position: relative;
                inset: auto;
                z-index: 1;
                flex: 1 1 0%;
                min-width: 0;
                border-right: 1px solid #d1d5db;
            }
            .payflow-side-panel__surface--invoice.payflow-invoice-drawer--with-viewer {
                width: min(36rem, 45vw);
            }
            /* Рядом со счётом карточка узкая: отдел, статья и направления — в одну колонку, без прокрутки вбок. */
            .payflow-invoice-drawer--with-viewer [data-drawer-category-grid] {
                width: 100%;
                grid-template-columns: minmax(0, 1fr);
            }
        }
        @media (prefers-reduced-motion: reduce) {
            .payflow-side-panel-enter-active,
            .payflow-side-panel-leave-active,
            .payflow-side-panel-enter-active .payflow-side-panel__surface,
            .payflow-side-panel-leave-active .payflow-side-panel__surface {
                transition-duration: 1ms !important;
            }
            .payflow-side-panel-enter-from .payflow-side-panel__surface,
            .payflow-side-panel-leave-to .payflow-side-panel__surface {
                transform: none;
            }
        }

        /* Bullet-proof fixed-height layout: body=viewport, header & footer fixed, only <main> scrolls. */
        /* Прокручивается только рабочая область (ТЗ «05.11»: в бюджете иногда видны только верхние строки). Подписи для
           экранного диктора (sr-only) и другие абсолютно позиционированные элементы без своей опоры отсчитывались от
           всего окна и растягивали его прокрутку: колесо в конце таблицы или прокрутка к строке сдвигали всю страницу —
           рабочая область уезжала вверх, внизу оставалось пустое место. Теперь их опора — #app, и он их обрезает: окну
           прокручивать нечего. Обрезает через clip, а не hidden: блок с hidden программа ещё может прокрутить
           (scrollIntoView), и уезжал бы уже он — без возврата колесом; hidden — для браузеров без clip (Safari до 16). */
        html, body { height: 100%; margin: 0; }
        #app { position: relative; height: 100%; overflow: hidden; overflow: clip; }
        body:not(.app-visible) #app { visibility: hidden; opacity: 0; }
        body.app-visible { background: var(--payflow-workspace-bg); }
        body.app-visible #app { visibility: visible; opacity: 1; transition: opacity 120ms ease; }
        .app-shell {
            height: 100%;
            box-sizing: border-box;
            padding-top: 3.5rem;    /* reserve space for fixed header (h-14 = 56px) */
            padding-bottom: 3.25rem; /* reserve space for fixed product footer */
        }
        .budget-workspace { color: #17212f; min-width: 0; }
        .budget-document > header { container: budget-document-header / inline-size; padding: 10px 12px; }
        .budget-document > div { padding: 10px 12px; }
        .budget-document .budget-metrics { margin-top: 8px; }
        .budget-document .budget-metrics > div { padding: 8px 10px; }
        .budget-document .budget-reconciliation { margin-top: 3px; }
        .budget-line-filters { padding: 0 0 4px; }
        .budget-toolbar button[title] { display: inline-flex; align-items: center; gap: 6px; }
        .budget-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 8px 0 12px; border-bottom: 1px solid #aab8ca; }
        .budget-toolbar-main { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
        .budget-toolbar .budget-month-input { flex: 0 1 11rem; width: 11rem; min-width: 0; }
        .budget-filter-summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 38px; padding: 6px 12px; border: 1px solid #aab8ca; border-radius: 6px; background: #fff; color: #243448; font-size: 14px; font-weight: 500; cursor: pointer; list-style: none; }
        .budget-filter-summary::-webkit-details-marker { display: none; }
        .budget-filter-menu { position: absolute; top: 100%; left: 0; z-index: 60; margin-top: 6px; width: 280px; max-width: calc(100vw - 32px); max-height: 360px; overflow-x: hidden; overflow-y: auto; border: 1px solid #aab8ca; border-radius: 6px; padding: 12px; background: #fff; box-shadow: 0 8px 24px #14223826; }
        .budget-filter-menu--create { left: auto; right: 0; }
        /* Закрытое меню не участвует в раскладке: иначе Chrome держит его невидимый блок внутри свёрнутого <details>. */
        details:not([open]) > .budget-filter-menu { display: none; }
        /* Сводка бюджета: 4 плитки в ряд или 2 (по ширине шапки документа), суммы не переносятся посреди числа. */
        .budget-metrics { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1px; margin-top: 12px; border-block: 1px solid #c2ccda; background: #c2ccda; }
        .budget-metrics > div { min-width: 0; padding: 10px 12px; background: #fff; }
        .budget-metrics p { overflow-wrap: normal; }
        .budget-metrics p.tabular-nums { white-space: nowrap; }
        .budget-metrics > .budget-metric--balance { background: #e9f7ef; box-shadow: inset 0 3px #237652; }
        .budget-correction-totals { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1px; border-bottom: 1px solid #dbeafe; background: #dbeafe; }
        .budget-correction-totals > div { min-width: 0; padding: 8px 12px; background: #fff; }
        .budget-correction-totals .tabular-nums { white-space: nowrap; }
        @container budget-document-header (min-width: 600px) {
            .budget-metrics, .budget-correction-totals { grid-template-columns: repeat(4,minmax(0,1fr)); }
        }
        .budget-line-filter-row { display: flex; flex-wrap: wrap; gap: 8px; }
        .budget-line-filter-row > * { flex: 1 1 9.5rem; min-width: 0; }
        .budget-line-filter-row > input[type=search] { flex: 1.4 1 10rem; }
        .budget-line-filter-row > button { flex: 0 0 auto; }
        .budget-metadata { display: flex; flex-wrap: wrap; gap: 6px 16px; padding-top: 8px; font-size: 12px; color: #4b5c70; }
        .budget-reconciliation { margin-top: 8px; font-size: 13px; color: #324459; }
        .budget-reconciliation > summary { cursor: pointer; min-height: 28px; font-weight: 500; }
        .budget-reconciliation__content { padding: 8px 0; line-height: 1.6; }
        .budget-scope { margin-top: 8px; max-width: 800px; }
        .budget-scope > div { display: flex; justify-content: space-between; gap: 16px; padding: 4px 0; border-bottom: 1px solid #d4dde8; }
        .budget-scope dd { flex-shrink: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
        .budget-filter-summary { border-color: #7c8a9c; }
        .budget-mode-control { display: inline-flex; flex-wrap: wrap; gap: 2px; border: 1px solid #7c8a9c; border-radius: 6px; padding: 2px; background: #f1f4f8; }
        .budget-mode-control button { min-height: 32px; padding: 5px 10px; border-radius: 4px; font-size: 13px; font-weight: 600; color: #43536a; }
        .budget-mode-control button[aria-pressed=true] { background: #1d4ed8; color: #fff; }
        .budget-mode-control button[data-mode=invoiced][aria-pressed=true] { background: #9a4312; }
        .budget-mode-control button[data-mode=paid][aria-pressed=true] { background: #156143; }
        .budget-mode-control button:focus-visible, .budget-filter-summary:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 2px; }
        /* График «по дням» (сводный и отдела): неделя или месяц по неделям, таблица на всю ширину окна без
           прокрутки вбок. Ширину столбцов с суммами задаёт budgetGridLayout; если суммы не помещаются — список. */
        .budget-grid { min-width: 0; }
        /* Скругление рамки без окна прокрутки: overflow: clip не мешает закреплённой шапке таблицы. */
        .budget-grid-shell { overflow: clip; }
        .budget-grid-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; border-bottom: 1px solid #c2ccda; background: #f8fafc; }
        .budget-scale-control { display: inline-flex; gap: 2px; border: 1px solid #7c8a9c; border-radius: 6px; padding: 2px; background: #f1f4f8; }
        .budget-scale-control button { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 10px; border-radius: 4px; font-size: 13px; font-weight: 600; color: #43536a; }
        .budget-scale-control button[aria-pressed=true] { background: #1d4ed8; color: #fff; }
        .budget-week-nav { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
        .budget-week-step { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid #aab8ca; border-radius: 6px; background: #fff; color: #243448; }
        .budget-week-step:disabled { color: #8a97a8; background: #f1f4f8; cursor: default; }
        .budget-week-label { min-width: 7.5rem; padding: 0 4px; font-size: 14px; font-weight: 600; color: #17212f; text-align: center; font-variant-numeric: tabular-nums; }
        .budget-week-today { min-height: 32px; padding: 4px 10px; border: 1px solid #aab8ca; border-radius: 6px; background: #fff; font-size: 13px; font-weight: 500; color: #1d4ed8; }
        .budget-week-today:disabled { color: #4b5c70; background: #f1f4f8; cursor: default; }
        .budget-grid-unit { margin-left: auto; font-size: 12px; color: #4b5c70; }
        .budget-grid-toolbar button:focus-visible, .budget-grid-table button:focus-visible, .budget-agenda button:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 1px; }
        .budget-grid-table { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; font-size: 13px; color: #17212f; }
        .budget-grid-table :is(th,td) { border-right: 1px solid #c5d0df; border-bottom: 1px solid #c5d0df; }
        .budget-grid-table :is(th,td):last-child { border-right: 0; }
        /* Шапка с днями остаётся на виду, пока прокручивают страницу: длинный сводный график читается целиком. */
        .budget-grid-table thead th { position: sticky; top: -1rem; z-index: 2; padding: 6px 4px; background: #f1f5f9; font-size: 12px; font-weight: 600; color: #334155; text-align: center; vertical-align: bottom; }
        .budget-grid-table thead .budget-grid-corner { padding-left: 12px; text-align: left; }
        .budget-grid-head-label { display: block; white-space: nowrap; font-variant-numeric: tabular-nums; }
        .budget-payment-note { display: block; margin-top: 2px; font-size: 11px; font-weight: 500; text-transform: none; }
        [data-budget-calendar-cell-panel] h5 { overflow-wrap: anywhere; }
        .budget-grid-table thead [data-weekend=true] { background: #e3e9f0; color: #3f4f63; }
        .budget-grid-table thead [data-payment-day=true] { background: #dcefe5; color: #195c40; box-shadow: inset 0 3px #357b5c; }
        .budget-grid-table thead [data-today=true] { box-shadow: inset 0 3px #b42336; color: #922336; }
        .budget-grid-table tbody [data-weekend=true], .budget-grid-table tfoot [data-weekend=true] { background: #f1f4f8; }
        .budget-grid-table tbody [data-payment-day=true], .budget-grid-table tfoot [data-payment-day=true] { background: #f0f9f5; }
        .budget-grid-week-button { display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 32px; border-radius: 4px; font-weight: 600; color: #1d4ed8; text-decoration: underline; text-underline-offset: 3px; font-variant-numeric: tabular-nums; white-space: nowrap; }
        .budget-grid-week-button:hover { background: #dde8f2; }
        .budget-grid-total-head { background: #e9eef5 !important; }
        .budget-grid-label { padding: 6px 10px; text-align: left; font-weight: 600; vertical-align: middle; overflow-wrap: anywhere; background: #fff; }
        .budget-grid-label-inner { display: flex; align-items: center; gap: 6px; min-width: 0; }
        .budget-grid-label-title { display: block; font-size: 13px; line-height: 1.3; }
        .budget-grid-direction { display: block; font-size: 12px; font-weight: 500; color: #475569; }
        .budget-grid-sublabel { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin-top: 2px; font-size: 12px; font-weight: 400; line-height: 1.3; color: #475569; }
        .budget-grid-hidden { display: inline-flex; align-items: center; gap: 2px; color: #92400e; }
        .budget-grid-handle { display: grid; place-items: center; flex-shrink: 0; width: 24px; height: 32px; border-radius: 4px; color: #475569; }
        .budget-grid-handle:not(:disabled):hover { background: #fff; color: #17212f; }
        .budget-grid-handle:disabled { opacity: .35; cursor: default; }
        .budget-grid-cell { height: 42px; padding: 2px; text-align: right; vertical-align: middle; }
        .budget-grid-cell--drop { box-shadow: inset 0 0 0 2px #1d4ed8; }
        .budget-grid-amount { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; width: 100%; min-height: 32px; padding: 3px 4px; border-width: 1px 1px 1px 3px; border-style: solid; border-radius: 3px; font-size: 12px; font-weight: 600; line-height: 1.25; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
        .budget-grid-count { font-size: 11px; font-weight: 400; }
        .budget-grid-group-row > :is(th,td) { background: #e9eef5; box-shadow: inset 0 2px #64748b; }
        .budget-grid-group-amount, .budget-grid-footer-amount { display: block; padding: 4px 4px; border-radius: 3px; background: #334155; color: #fff; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
        .budget-grid-row--section > :is(th,td) { box-shadow: inset 0 2px #94a3b8; }
        .budget-grid-total { padding: 2px 8px; text-align: right; vertical-align: middle; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; background: #f6f8fb; }
        .budget-grid-table tfoot :is(th,td) { background: #eef2f7; border-bottom: 0; box-shadow: inset 0 2px #94a3b8; }
        .budget-grid-table tfoot .budget-grid-total { background: #e2e8f0; }
        /* Итоги — кнопки: открывают документы, из которых сложились (ТЗ «29.10»). */
        button.budget-grid-group-amount, button.budget-grid-footer-amount { width: 100%; border: 0; text-align: right; cursor: pointer; }
        button.budget-grid-group-amount:hover, button.budget-grid-footer-amount:hover { background: #1e293b; }
        .budget-grid-total-link { display: block; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: right; cursor: pointer; }
        .budget-grid-total-link.inline { display: inline; width: auto; }
        .budget-grid-total-link:hover { color: #1d4ed8; text-decoration: underline; text-underline-offset: 3px; }
        :is(.budget-grid-total-link, button.budget-grid-group-amount, button.budget-grid-footer-amount):focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; border-radius: 3px; }
        .budget-agenda-section { padding: 8px 12px; border-top: 1px solid #c2ccda; }
        .budget-agenda-section:first-child { border-top: 0; }
        .budget-agenda-section[data-payment-day=true] { background: #f0f9f5; box-shadow: inset 3px 0 #357b5c; }
        .budget-agenda-section[data-weekend=true] { background: #f4f6f9; }
        .budget-agenda-section[data-today=true] { box-shadow: inset 3px 0 #b42336; }
        .budget-agenda-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 12px; min-height: 28px; }
        .budget-agenda-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-size: 14px; font-weight: 600; color: #17212f; }
        .budget-agenda-week { min-height: 32px; font-weight: 600; color: #1d4ed8; text-decoration: underline; text-underline-offset: 3px; }
        .budget-agenda-note { font-size: 12px; font-weight: 500; color: #195c40; }
        .budget-agenda-section[data-weekend=true] .budget-agenda-note { color: #475569; }
        .budget-agenda-today { font-size: 12px; font-weight: 600; color: #922336; }
        .budget-agenda-total { font-size: 13px; color: #334155; font-variant-numeric: tabular-nums; white-space: nowrap; }
        .budget-agenda-empty { font-size: 12px; color: #4b5c70; }
        .budget-agenda-list { display: grid; gap: 4px; margin-top: 6px; }
        .budget-agenda-item { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; min-height: 36px; }
        .budget-agenda-item[data-kind=group] { min-height: 28px; padding-top: 4px; border-top: 1px solid #d5dde8; font-weight: 600; }
        .budget-agenda-label { min-width: 0; font-size: 13px; line-height: 1.3; overflow-wrap: anywhere; }
        .budget-agenda-group-total { flex-shrink: 0; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
        .budget-agenda-amount { flex-shrink: 0; width: auto; min-width: 6.5rem; }
        .budget-agenda-summary { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 16px; padding: 8px 12px; border-top: 2px solid #94a3b8; background: #eef2f7; font-size: 13px; font-variant-numeric: tabular-nums; }
        .budget-workspace [data-budget-period-list-filters] { border-bottom: 1px solid #c2ccda; padding-bottom: 8px; }
        /* Раскрывающиеся блоки бюджета: шеврон Lucide вместо стандартного треугольника, поворот при открытии. */
        .budget-disclosure-summary { list-style: none; }
        .budget-disclosure-summary::-webkit-details-marker { display: none; }
        .budget-disclosure-icon { transition: transform .15s; }
        details[open] > .budget-disclosure-summary .budget-disclosure-icon { transform: rotate(90deg); }
        .budget-disclosure-summary:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 2px; border-radius: 4px; }
        /* «Строки»: реестр расходов помещается в окно. Вторая строка расхода — статья и направления; в узком окне
           заявки, оплачено и остаток — столбиком в одной ячейке, ещё уже — карточки. Ширину решает окно, а не экран. */
        .budget-lines { container: budget-lines / inline-size; }
        .budget-lines-desktop { display: none; }
        .budget-lines-cards { display: grid; gap: 6px; }
        @container budget-lines (min-width: 600px) {
            .budget-lines-desktop { display: block; }
            .budget-lines-cards { display: none; }
        }
        .budget-lines-table { --lines-exec: minmax(6rem,10rem); overflow: clip; border: 1px solid #d1d9e3; border-radius: 12px; background: #fff; }
        .budget-lines-table[data-execution-columns="1"] { --lines-exec: 19rem; }
        .budget-lines-row { display: grid; grid-template-columns: 2rem 3.5rem minmax(0,1fr) 6.5rem var(--lines-exec) 1.5rem; align-items: center; column-gap: 8px; min-height: 48px; padding: 6px 10px; border-bottom: 1px solid #e5eaf1; font-size: 12px; color: #17212f; cursor: pointer; }
        .budget-lines-table[data-selectable="0"] .budget-lines-row { grid-template-columns: 3.5rem minmax(0,1fr) 6.5rem var(--lines-exec) 1.5rem; }
        .budget-lines-row:last-child { border-bottom: 0; }
        .budget-lines-row:hover { background: #f5f8ff; }
        .budget-lines-row.is-active { background: #eaf1ff; }
        .budget-lines-head { position: sticky; top: -1rem; z-index: 2; min-height: 40px; background: #f6f8fb; font-weight: 600; color: #3f4f63; cursor: default; }
        .budget-lines-head:hover { background: #f6f8fb; }
        .budget-lines-sorts { display: flex; flex-wrap: wrap; column-gap: 12px; }
        .budget-lines-sort { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; text-align: left; font-weight: 600; }
        .budget-lines-sort:hover { color: #17212f; }
        .budget-lines-sort--end { justify-content: flex-end; width: 100%; text-align: right; }
        .budget-lines-sort:focus-visible, .budget-lines-title:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 2px; }
        .budget-lines-check { display: grid; place-items: center; width: 32px; height: 36px; cursor: pointer; }
        .budget-lines-date { font-weight: 500; color: #34445b; font-variant-numeric: tabular-nums; white-space: nowrap; }
        .budget-lines-more { margin-left: 4px; color: #1d4ed8; font-size: 12px; }
        .budget-lines-main { min-width: 0; }
        .budget-lines-title { display: inline-flex; align-items: flex-start; gap: 4px; max-width: 100%; min-height: 24px; text-align: left; font-size: 13px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
        .budget-lines-title:hover { color: #1d4ed8; text-decoration: underline; }
        .budget-lines-meta { display: block; margin-top: 1px; font-size: 12px; line-height: 1.35; color: #4b5c70; overflow-wrap: anywhere; }
        .budget-lines-amount { text-align: right; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
        .budget-lines-exec { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; text-align: right; font-variant-numeric: tabular-nums; }
        .budget-lines-exec > * { display: flex; justify-content: flex-end; gap: 6px; white-space: nowrap; }
        .budget-lines-exec-label { display: none; }
        .budget-lines-state { font-weight: 500; overflow-wrap: anywhere; }
        .budget-lines-chevron { display: grid; place-items: center; color: #4b5c70; }
        /* Группа и итог «Строк» (Таня, 23.11): название — на месте даты и расхода, суммы — под своими столбцами.
           Итог прилипает к нижнему краю области прокрутки, bottom гасит её отступ, как top у шапки. */
        .budget-lines-group, .budget-lines-foot { min-height: 40px; font-weight: 600; cursor: default; }
        .budget-lines-group, .budget-lines-group:hover { background: #f1f4f9; }
        .budget-lines-foot { position: sticky; bottom: -1rem; z-index: 2; border-top: 1px solid #c9d4e3; }
        .budget-lines-foot, .budget-lines-foot:hover { background: #eaf0f8; }
        .budget-lines-group-title { grid-column: span 2; min-width: 0; font-size: 13px; color: #17212f; overflow-wrap: anywhere; }
        .budget-lines-group-count { font-weight: 400; color: #4b5c70; }
        .budget-lines-empty, .budget-lines-empty:hover { background: #fff; cursor: default; }
        [data-budget-lines-controls] button:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 1px; }
        .budget-lines-empty-text { grid-column: 1 / -1; color: #4b5c70; }
        @container budget-lines (max-width: 759px) {
            .budget-lines-table[data-execution-columns="1"] { --lines-exec: 9.5rem; }
            .budget-lines-exec { grid-template-columns: minmax(0,1fr); gap: 1px; }
            .budget-lines-exec > * { justify-content: space-between; }
            .budget-lines-head .budget-lines-exec > * { justify-content: flex-end; }
            .budget-lines-exec-label { display: inline; font-weight: 400; color: #4b5c70; }
        }
        @media (min-width: 768px) { .budget-lines-head { top: -1.5rem; } .budget-lines-foot { bottom: -1.5rem; } }
        /* «Хвосты»: таблица на ширину окна; в узком окне статья — строкой, суммы — парами «подпись — сумма». */
        .budget-tails { container: budget-tails / inline-size; margin-top: 8px; }
        .budget-tails-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; color: #17212f; }
        .budget-tails-col-name { width: 34%; }
        .budget-tails-table thead th { padding: 6px 8px; border-bottom: 1px solid #c2ccda; font-weight: 600; color: #3f4f63; text-align: right; }
        .budget-tails-table thead th:first-child { text-align: left; }
        .budget-tails-table :is(tbody,tfoot) :is(th,td) { padding: 4px 8px; border-bottom: 1px solid #e5eaf1; text-align: right; white-space: nowrap; }
        .budget-tails-table :is(tbody,tfoot) th { text-align: left; font-weight: 600; white-space: normal; overflow-wrap: anywhere; }
        .budget-tails-row { cursor: pointer; }
        .budget-tails-row:hover > * { background: #f8fafc; }
        .budget-tails-toggle { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; text-align: left; font-weight: 600; }
        .budget-tails-toggle:hover { color: #1d4ed8; }
        .budget-tails-toggle:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 2px; }
        .budget-tails-chevron { flex-shrink: 0; transition: transform .15s; }
        .budget-tails-toggle[aria-expanded=true] .budget-tails-chevron { transform: rotate(90deg); }
        .budget-tails-count { display: block; padding-left: 20px; font-size: 11px; font-weight: 400; color: #4b5c70; }
        .budget-tails-line > * { background: #f8fafc; color: #34445b; }
        .budget-tails-table .budget-tails-line th { padding-left: 28px; font-weight: 400; }
        .budget-tails-table tfoot :is(th,td) { border-top: 1px solid #94a3b8; border-bottom: 0; font-weight: 600; }
        .budget-tails-label { display: none; }
        @container budget-tails (max-width: 539px) {
            .budget-tails-table, .budget-tails-table :is(tbody,tfoot,tr,th,td) { display: block; }
            .budget-tails-table :is(thead,colgroup) { display: none; }
            .budget-tails-table tr { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 2px 16px; padding: 6px 0; border-bottom: 1px solid #d5dde8; }
            .budget-tails-table :is(tbody,tfoot) :is(th,td) { padding: 0; border: 0; }
            .budget-tails-table tr > th { grid-column: 1 / -1; }
            .budget-tails-table tr > td { display: flex; justify-content: space-between; gap: 8px; }
            .budget-tails-table .budget-tails-line { padding-left: 16px; }
            .budget-tails-table .budget-tails-line th { padding-left: 0; }
            .budget-tails-label { display: inline; font-weight: 400; color: #4b5c70; }
        }
        /* Отступ .app-main (p-4 md:p-6): шапка прилипает к верхнему краю области прокрутки, а не на отступ ниже. */
        @media (min-width: 768px) { .budget-grid-table thead th { top: -1.5rem; } }
        @media (max-width: 767px) {
            .budget-metrics .text-lg { font-size: 16px; }
            .budget-filter-menu--create { left: 0; right: auto; }
            .budget-grid-unit { margin-left: 0; }
        }
        /* Телефон: «Обновить» — значком, выпадающие меню — на ширину экрана, а не за его край. */
        @media (max-width: 639px) {
            .budget-toolbar .budget-month-input { flex-basis: 9.5rem; }
            .budget-refresh-button { padding-inline: 12px; }
            .budget-refresh-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
            .budget-filter-menu, .budget-filter-menu--create { position: fixed; top: auto; left: 16px; right: 16px; width: auto; max-width: none; }
        }
        /* «Месяц»: семь столбцов по ширине окна. Узкое окно (меньше 640 px) — день с отметками, события — в панели дня:
           в столбце уже 90 px сумма события не помещается и обрезалась бы соседним днём. */
        .budget-month { container: budget-month / inline-size; border: 1px solid #aab8ca; border-radius: 6px; overflow: hidden; background: #fff; }
        .budget-month-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px; padding: 10px 12px; border-bottom: 1px solid #aab8ca; }
        .budget-month-heading h3 { font-size: 16px; font-weight: 600; }
        .budget-month-totals { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; font-variant-numeric: tabular-nums; }
        .budget-month-totals > span { display: inline-flex; gap: 5px; align-items: center; }
        .budget-month-totals i, .budget-month-mobile-marks i { width: 7px; height: 7px; border-radius: 2px; }
        .budget-month-weekdays, .budget-month-week { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); }
        .budget-month-weekdays > span { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; background: #f1f4f8; font-size: 13px; font-weight: 600; border-right: 1px solid #bdc9d9; }
        .budget-month-weekdays small { font-size: 12px; font-weight: 400; }
        .budget-month [data-payment-day=true] { background: #f0f9f5; }
        .budget-month-weekdays [data-payment-day=true] { background: #dcefe5; color: #195c40; box-shadow: inset 0 3px #357b5c; }
        .budget-month [data-weekend=true] { background: #ecf0f5; }
        .budget-month [data-outside=true] { background: #f6f7f9; color: #566478; }
        .budget-month-day { min-width: 0; min-height: 156px; padding: 5px; border-top: 1px solid #bdc9d9; border-right: 1px solid #bdc9d9; }
        .budget-month-week > :last-child, .budget-month-weekdays > :last-child { border-right: 0; }
        .budget-month-day-trigger { display: flex; width: 100%; min-height: 28px; align-items: center; justify-content: space-between; gap: 4px; margin-bottom: 3px; color: #334155; font-size: 12px; }
        .budget-month-day-trigger:disabled { cursor: default; opacity: 1; }
        .budget-month-day-trigger:not(:disabled):hover { background: #dde8f2; border-radius: 4px; }
        .budget-month-date { display: grid; place-items: center; width: 26px; height: 26px; font-size: 14px; font-weight: 600; border-radius: 50%; }
        .budget-month-date[data-today=true] { background: #ad2336; color: #fff; }
        .budget-month-count { color: #475569; font-size: 12px; }
        .budget-month-mobile-marks { display: none; }
        .budget-month-events { display: grid; grid-template-columns: minmax(0,1fr); gap: 4px; }
        .budget-month-events > article { min-width: 0; }
        .budget-month-event { display: block; width: 100%; min-width: 0; height: 48px; padding: 4px 6px; border-width: 1px 1px 1px 3px; border-style: solid; border-radius: 4px; text-align: left; }
        .budget-month-event-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; line-height: 18px; }
        .budget-month-event--selectable .budget-month-event-title { padding-right: 22px; }
        .budget-month-event-bottom { display: flex; align-items: center; justify-content: space-between; gap: 6px; line-height: 18px; }
        .budget-month-event-bottom > span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
        .budget-month-event-bottom strong { flex-shrink: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
        .budget-month-selection { position: absolute; right: 2px; top: 1px; display: grid; place-items: center; width: 26px; height: 26px; cursor: pointer; }
        .budget-month-selection input { width: 16px; height: 16px; }
        .budget-month-more { min-height: 26px; padding: 2px 5px; text-align: left; color: #334155; font-size: 12px; font-weight: 600; }
        .budget-month-more:hover { background: #dde8f2; }
        .budget-month button:focus-visible { outline: 2px solid #1d4ed8; outline-offset: -2px; }
        @container budget-month (max-width: 639px) {
            .budget-month-heading { padding: 10px 8px; }
            .budget-month-totals { display: grid; gap: 4px; }
            .budget-month-weekdays small, .budget-month-count-label, .budget-month-events { display: none; }
            .budget-month-day { padding: 2px; min-height: 76px; }
            .budget-month-day-trigger { flex-direction: column; justify-content: flex-start; gap: 2px; min-height: 70px; margin: 0; }
            .budget-month-mobile-marks { display: flex; justify-content: center; gap: 3px; height: 7px; }
        }
        @media (max-width: 767px) {
            [data-budget-month-day-panel] .grid-cols-3 { grid-template-columns: 1fr; }
            [data-budget-month-day-panel] .grid-cols-3 > div { display: flex; justify-content: space-between; gap: 8px; }
        }
        .app-main {
            height: 100%;
            overflow-y: auto;
            box-sizing: border-box;
            background: var(--payflow-workspace-bg);
        }
        .app-footer {
            position: fixed;
            left: 0; right: 0; bottom: 0;
            min-height: 3.25rem;
            z-index: 20;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #fff;
            border-top: 1px solid var(--payflow-line);
            box-shadow: 0 -8px 24px -24px rgba(15, 23, 42, 0.72);
            transition: left 200ms ease;
        }
        @media (min-width: 768px) {
            .app-footer--with-sidebar { left: 16rem; }
            .app-footer--with-sidebar-collapsed { left: 4rem; }
        }
        .app-footer a { display: inline-flex; align-items: center; min-height: 24px; }
        /* На телефоне подвал с версией не держит место у работы: версия видна на компьютере.
           Правило стоит после основных .app-shell и .app-footer, иначе они его перебивают. */
        @media (max-width: 767px) {
            .app-footer { display: none; }
            .app-shell { padding-bottom: 0; }
        }

        /* Keep focus opaque: translucent rings disappear on pale surfaces. */
        body :is(input, select, textarea, button, a, [tabindex]):focus-visible {
            outline: 2px solid var(--payflow-focus);
            outline-offset: 2px;
        }
        body :is(input, textarea)::placeholder {
            color: #4b5563;
            opacity: 1;
        }
        /* Shared cabinet depth: stronger structure without elevating every nested block. */
        body.app-visible .border-gray-100,
        body.app-visible .border-slate-100 {
            border-color: var(--payflow-line-soft);
        }
        body.app-visible .border-gray-200,
        body.app-visible .border-slate-200 {
            border-color: var(--payflow-line);
        }
        body.app-visible .border-gray-300,
        body.app-visible .border-slate-300 {
            border-color: var(--payflow-line-strong);
        }
        /* Form boundaries are stronger than decorative row/surface dividers; a field with an error keeps its red frame. */
        body.app-visible :is(input, select, textarea, button[aria-haspopup], button[aria-expanded]):is(.border-gray-200, .border-gray-300, .border-slate-200, .border-slate-300):not(:disabled):not(:focus):not([aria-invalid=true]) {
            border-color: var(--payflow-control-border);
        }
        body.app-visible :is(input, select, textarea):focus:not(:disabled) {
            border-color: var(--payflow-focus);
        }
        body.app-visible .divide-gray-100 > :not([hidden]) ~ :not([hidden]),
        body.app-visible .divide-slate-100 > :not([hidden]) ~ :not([hidden]) {
            border-color: var(--payflow-line-soft);
        }
        body.app-visible .divide-gray-200 > :not([hidden]) ~ :not([hidden]),
        body.app-visible .divide-slate-200 > :not([hidden]) ~ :not([hidden]) {
            border-color: var(--payflow-line);
        }
        body.app-visible .app-main :is(section, article, aside, div).shadow-sm:not([class*="shadow-sky"]):not([class*="shadow-emerald"]):not([class*="shadow-rose"]):not([class*="shadow-amber"]):not([class*="shadow-blue"]) {
            --tw-shadow: var(--payflow-surface-shadow);
        }
        body.app-visible .app-main input.bg-white:not([type="checkbox"]):not([type="radio"]):not(:focus),
        body.app-visible .app-main select.bg-white:not(:focus),
        body.app-visible .app-main textarea.bg-white:not(:focus) {
            box-shadow: var(--payflow-control-inset);
        }
        body.app-visible .payflow-topbar {
            border-color: var(--payflow-line);
            box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04), 0 8px 22px -22px rgba(15, 23, 42, 0.7);
        }
        body.app-visible .payflow-sidebar {
            border-color: var(--payflow-line);
            box-shadow: 8px 0 24px -24px rgba(15, 23, 42, 0.78);
        }
        body.app-visible .payflow-work-surface {
            border-color: var(--payflow-line);
            box-shadow: var(--payflow-surface-shadow);
        }
        .payflow-card {
            border: 1px solid var(--payflow-line);
            border-radius: 1rem;
            background: #ffffff;
            box-shadow: var(--payflow-surface-shadow);
        }
        .payflow-soft-card {
            border: 1px solid var(--payflow-line);
            border-radius: 1rem;
            background: rgba(248, 250, 252, 0.86);
        }
        .payflow-chip {
            display: inline-flex;
            align-items: center;
            gap: 0.35rem;
            min-height: 1.75rem;
            border-radius: 999px;
            border: 1px solid #dbeafe;
            background: #eff6ff;
            padding: 0 0.625rem;
            color: #1d4ed8;
            font-size: 0.75rem;
            font-weight: 600;
        }
        @media (max-width: 640px) {
            input, select, textarea { font-size: 16px !important; }
        }
        body.payflow-inbox-open {
            overflow: hidden;
        }
        .inbox-panel {
            overscroll-behavior: contain;
        }
        .inbox-scroll {
            -webkit-overflow-scrolling: touch;
            overscroll-behavior: contain;
            touch-action: pan-y;
        }
        @media (min-width: 768px) {
            body.payflow-inbox-open {
                overflow: auto;
            }
        }
        .pull-refresh-indicator {
            top: 3.35rem;
            pointer-events: none;
            display: flex;
            justify-content: center;
            opacity: calc(0.35 + (var(--ptr-progress, 0) * 0.65));
            transition: transform 160ms ease, opacity 160ms ease;
            will-change: transform, opacity;
        }
        .pull-refresh-pill {
            display: inline-flex;
            align-items: center;
            gap: 0.55rem;
            min-height: 2.25rem;
            max-width: calc(100vw - 2rem);
            border: 1px solid rgba(203, 213, 225, 0.9);
            border-radius: 999px;
            background: rgba(255, 255, 255, 0.96);
            box-shadow: 0 16px 42px rgba(15, 23, 42, 0.14);
            padding: 0.45rem 0.75rem;
            color: #111827;
            font-size: 0.875rem;
            font-weight: 600;
            backdrop-filter: blur(18px);
        }
        /* «Потяните, чтобы обновить» — значок Lucide loader-circle: поворачивается вслед за жестом, крутится при обновлении. */
        .pull-refresh-icon {
            color: #2563eb;
            transform: rotate(calc(var(--ptr-progress, 0) * 240deg));
            transition: transform 120ms ease;
            flex: 0 0 auto;
        }
        .pull-refresh-pill.is-refreshing .pull-refresh-icon {
            animation: pwa-spin 780ms linear infinite;
        }
        .wiki-content .wiki-link {
            color: #2563eb;
            font-weight: 600;
            text-decoration: underline;
            text-decoration-thickness: 1px;
            text-underline-offset: 3px;
        }
        .wiki-content .wiki-link:hover {
            color: #1d4ed8;
        }
        .wiki-content .wiki-inline-code {
            border: 1px solid #e5e7eb;
            border-radius: 0.375rem;
            background: #f8fafc;
            padding: 0.075rem 0.3rem;
            color: #0f172a;
            font-size: 0.92em;
        }
        @keyframes pwa-spin { to { transform: rotate(360deg); } }
        @keyframes pwa-line {
            0% { transform: translateX(-120%); }
            100% { transform: translateX(260%); }
        }
        @keyframes page-load-line {
            0% { background-position: 220% 0; }
            100% { background-position: -220% 0; }
        }

.invoice-budget-remainder {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    padding: 5px 8px;
    border-left: 3px solid #059669;
    background: #ecfdf5;
    color: #065f46;
    font-size: 12px;
    line-height: 20px;
}
.invoice-budget-remainder strong {
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.invoice-budget-remainder.is-overdrawn {
    border-color: #d97706;
    background: #fffbeb;
    color: #92400e;
}
.invoice-direction-menu {
    max-height: min(72vh, 640px);
    overflow-y: auto;
    overscroll-behavior: contain;
}
.payflow-icon {
    display: inline-block;
    flex-shrink: 0;
    vertical-align: -0.125em;
}

/* Invoice entry shares the existing data handlers; only this work surface is restyled. */
.invoice-create-layout { width: 100%; --invoice-workspace-height: calc(100dvh - 10rem); }
.invoice-entry { min-width: 0; min-height: var(--invoice-workspace-height, calc(100dvh - 10rem)); display: flex; flex-direction: column; border: 1px solid #bcc8d6; border-radius: 8px; background: #fff; color: #17212f; }
.invoice-entry-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 20px; border-bottom: 1px solid #bcc8d6; }
.invoice-entry h2 { font-size: 16px; font-weight: 700; }
.invoice-entry h3 { font-size: 14px; font-weight: 700; }
.invoice-kind-label { font-size: 13px; color: #526174; }
.invoice-entry-body { padding: 16px 20px 24px; }
.invoice-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px 16px; }
.invoice-field { min-width: 0; scroll-margin-block: 90px; }
.invoice-field-wide { grid-column: 1 / -1; }
.invoice-field-label { display: block; margin-bottom: 6px; font-size: 12px; line-height: 16px; font-weight: 600; color: #3c4c62; }
.invoice-entry :is(input:not([type=checkbox]):not([type=file]),select,textarea) { max-width: 100%; min-width: 0; border-color: #7f8fa2; border-radius: 6px; font-size: 14px; color: #17212f; background: #fff; }
.invoice-entry :is(input,select)::placeholder { color: #526174; }
.invoice-entry :is(input:not([type=checkbox]):not([type=file]),select,textarea)[aria-invalid=true] { border-color: #b42318; box-shadow: 0 0 0 1px #b42318; background: #fff9f8; }
.invoice-entry button[aria-invalid=true] { border-color: #b42318; box-shadow: 0 0 0 1px #b42318; }
.invoice-entry input[type=checkbox] { width: 16px; height: 16px; flex-shrink: 0; accent-color: #1d4ed8; }
.invoice-entry :is(input[type=number], input[inputmode=decimal]) { font-variant-numeric: tabular-nums; }
.invoice-entry #invoice-amount { font-size: 18px; font-weight: 650; text-align: right; }
.invoice-entry textarea { display: block; min-height: 64px; resize: vertical; }
.invoice-field-error { margin-top: 5px; font-size: 12px; line-height: 18px; color: #a5261b; overflow-wrap: anywhere; }
.invoice-field-hint { margin-top: 4px; font-size: 12px; line-height: 18px; color: #526174; }
.invoice-entry button:disabled { cursor: wait; opacity: .6; }
.invoice-secondary, .invoice-ai-action { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; border: 1px solid #8797aa; border-radius: 6px; padding: 5px 10px; background: #fff; color: #34445b; font-size: 12px; font-weight: 600; }
.invoice-secondary:hover { background: #edf2f7; }
.invoice-ai-action { border-color: #268565; color: #166044; background: #f0faf4; }
.invoice-entry :is(button,summary):focus-visible, .invoice-budget-picker-shell :is(button,summary):focus-visible { outline: 2px solid #1d4ed8; outline-offset: 3px; }
.invoice-source { padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px solid #ccd5e1; }
.invoice-source-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.invoice-scenarios-wrap { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.invoice-scenarios { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; width: 100%; }
.invoice-scenario-card { position: relative; display: flex; align-items: stretch; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; transition: border-color .15s, background-color .15s, box-shadow .15s; }
.invoice-scenario-card:hover { border-color: #94a3b8; background: #f8fafc; }
.invoice-scenario-card.is-active { border-color: #1d4ed8; background: #eff6ff; box-shadow: 0 0 0 1px #1d4ed8; }
.invoice-scenario { display: flex; flex: 1 1 auto; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; padding: 10px 30px 10px 12px; border-radius: 9px; color: #1e293b; text-align: left; }
.invoice-scenario-head { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; line-height: 18px; color: #0f172a; }
.invoice-scenario-card.is-active .invoice-scenario-head { color: #1d4ed8; }
.invoice-scenario-hint { display: block; font-size: 11px; line-height: 15px; font-weight: 400; color: #475569; }
.invoice-scenario-card.is-active .invoice-scenario-hint { color: #1e3a8a; }
.invoice-scenario-help { position: absolute; top: 7px; right: 7px; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 999px; color: #475569; background: transparent; }
.invoice-scenario-help:hover { background: #e2e8f0; color: #0f172a; }
.invoice-scenario-card.is-active .invoice-scenario-help { color: #1d4ed8; }
.invoice-scenario-popover { position: absolute; z-index: 50; left: 0; right: 0; top: calc(100% + 6px); padding: 8px 10px; border: 1px solid #94a3b8; border-radius: 8px; background: #0f172a; color: #f8fafc; font-size: 12px; line-height: 17px; box-shadow: 0 8px 24px rgba(15, 23, 42, .22); }
.invoice-scenarios-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.invoice-amount-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.invoice-amount-head .invoice-field-label { margin-bottom: 0; }
.invoice-currency-switcher { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid #cbd5e1; border-radius: 7px; background: #f8fafc; }
.invoice-currency-pill { min-width: 28px; height: 24px; padding: 0 7px; border-radius: 5px; font-size: 11px; font-weight: 600; color: #334155; }
.invoice-currency-pill:hover { background: #e2e8f0; }
.invoice-currency-pill.is-active { background: #1d4ed8; color: #fff; }
.invoice-crypto-requisites { padding: 12px; border: 1px solid #bfdbfe; border-radius: 8px; background: #f8fbff; }
.invoice-crypto-badge { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; padding: 1px 7px; border-radius: 999px; background: #dcfce7; color: #166534; font-size: 11px; font-weight: 600; }
.invoice-receipt-optin { display: flex; flex-direction: column; gap: 8px; }
.invoice-direction-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.invoice-direction-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 11px; border: 1px solid #94a3b8; border-radius: 999px; background: #fff; color: #334155; font-size: 12px; font-weight: 500; transition: border-color .12s, background-color .12s, color .12s; }
.invoice-direction-chip:hover { background: #f1f5f9; }
.invoice-direction-chip.is-selected { border-color: #1d4ed8; background: #eff6ff; color: #1d4ed8; font-weight: 600; }
.invoice-direction-single-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; font-size: 12px; color: #475569; }
.invoice-reset { margin-left: auto; order: 1; }
.invoice-file-name { margin-top: 7px; font-size: 12px; color: #526174; overflow-wrap: anywhere; }
.invoice-attachments { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; min-width: 0; }
.invoice-attachment-trigger { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; min-width: 0; max-width: 100%; padding: 4px 6px; border-radius: 4px; color: #1d4ed8; background: transparent; font-size: 13px; text-align: left; }
.invoice-attachment-trigger span { overflow-wrap: anywhere; min-width: 0; }
.invoice-attachment-trigger svg { flex: 0 0 16px; }
.invoice-attachment-trigger:hover { background: #eff6ff; }
.invoice-attachment-trigger:focus-visible, .invoice-attachment-tools :focus-visible, .invoice-attachment-expand:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.invoice-attachment-peek { position: fixed; z-index: 100; padding: 8px; overflow: hidden; border: 1px solid #aebcd0; border-radius: 8px; background: #fff; box-shadow: 0 8px 30px #15243c33; }
.invoice-attachment-peek-body { width: 100%; height: 100%; overflow: hidden; background: #f1f3f5; }
.invoice-attachment-peek-body iframe { width: 100%; height: 100%; border: 0; pointer-events: none; }
.invoice-attachment-peek-body img { display: block; width: 100%; height: 100%; object-fit: contain; }
.invoice-attachment-expand { position: absolute; inset: 0; width: 100%; height: 100%; cursor: zoom-in; background: transparent; border-radius: 6px; }
.invoice-attachment-expand svg { position: absolute; right: 16px; bottom: 16px; box-sizing: content-box; padding: 8px; background: white; border: 1px solid #aebcd0; border-radius: 4px; color: #1d4ed8; }
.invoice-attachment-dialog { padding: 0; margin: auto; width: min(1120px, calc(100vw - 32px)); height: calc(100dvh - 32px); max-width: none; max-height: none; border: 1px solid #aebcd0; border-radius: 8px; color: #182334; background: #fff; overflow: hidden; }
.invoice-attachment-dialog[open] { display: flex; flex-direction: column; }
.invoice-attachment-dialog::backdrop { background: #11182799; }
.invoice-attachment-toolbar { display: flex; align-items: center; gap: 12px; padding: 10px 12px; flex: 0 0 auto; min-width: 0; border-bottom: 1px solid #cbd5e1; background: #fff; }
.invoice-attachment-title { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.invoice-attachment-toolbar select { flex: 1; min-width: 0; height: 36px; border: 1px solid #aebcd0; border-radius: 4px; padding: 0 8px; background: white; font-size: 14px; }
.invoice-attachment-tools { display: flex; align-items: center; flex-shrink: 0; gap: 4px; }
.invoice-attachment-tools button, .invoice-attachment-tools a { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 1px solid #cbd5e1; border-radius: 4px; background: white; color: #334155; }
.invoice-attachment-tools .invoice-attachment-zoom { width: 58px; font-size: 12px; font-variant-numeric: tabular-nums; }
.invoice-attachment-tools button:hover, .invoice-attachment-tools a:hover { background: #f1f5f9; }
.invoice-attachment-tools button:disabled { opacity: .4; cursor: default; }
.invoice-attachment-content { flex: 1; min-height: 0; min-width: 0; overflow: hidden; background: #e9edf1; }
.invoice-attachment-content > iframe { display: block; width: 100%; height: 100%; border: 0; background: white; }
.invoice-attachment-image { height: 100%; overflow: auto; padding: 16px; }
.invoice-attachment-image img { display: block; height: auto; margin: 0 auto; background: white; }
.invoice-attachment-fallback { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; text-align: center; font-size: 14px; overflow-wrap: anywhere; color: #475569; }
.invoice-attachment-fallback > svg { width: 32px; height: 32px; flex-shrink: 0; }
.invoice-attachment-fallback a { color: #1d4ed8; text-decoration: underline; max-width: 100%; }
@media (max-width: 639px) {
  .invoice-attachment-dialog { width: calc(100vw - 16px); height: calc(100dvh - 16px); }
  .invoice-attachment-toolbar { flex-wrap: wrap; gap: 8px; padding: 8px; }
  .invoice-attachment-title, .invoice-attachment-toolbar select { flex-basis: 100%; }
  .invoice-attachment-tools { width: 100%; justify-content: flex-end; }
  .invoice-attachment-tools button, .invoice-attachment-tools a { width: 40px; height: 40px; }
  .invoice-attachment-image { padding: 8px; }
}
.invoice-ai-results { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid #ccd5e1; }
.invoice-counterparty-options { position: absolute; z-index: 45; top: calc(100% + 4px); left: 0; right: 0; max-height: 240px; overflow: auto; border: 1px solid #7f8fa2; border-radius: 6px; background: #fff; box-shadow: 0 6px 20px #15223926; }
.invoice-counterparty-options button { display: block; width: 100%; padding: 9px 12px; text-align: left; font-size: 13px; border-bottom: 1px solid #d8e0ea; overflow-wrap: anywhere; }
.invoice-counterparty-options button:hover, .invoice-counterparty-options button:focus { background: #edf4ff; }
.invoice-counterparty-options span { display: block; margin-top: 3px; font-size: 12px; color: #526174; }
.invoice-date-shortcuts { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; }
.invoice-date-shortcuts button, .invoice-text-action { color: #1d4ed8; font-size: 12px; line-height: 24px; text-decoration: underline; text-underline-offset: 3px; }
.invoice-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 24px; margin-top: 16px; font-size: 13px; cursor: pointer; }
.invoice-foreign-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; margin-top: 4px; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px; background: #f8fafc; }
.invoice-employee-fields { margin-bottom: 14px; }
.invoice-readonly { padding: 10px 0; color: #526174; font-size: 14px; }
.invoice-form-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid #bcc8d6; }
.invoice-form-section > h3 { margin-bottom: 12px; }
.invoice-section-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.invoice-budget-binding { margin-top: 12px; }
.invoice-budget-binding p, .invoice-budget-binding span { overflow-wrap: anywhere; }
.invoice-budget-binding .flex { min-width: 0; }
.invoice-budget-binding select { width: 100%; }
.invoice-direction-list { margin-top: 10px; }
.invoice-direction-option { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid #d8e0ea; }
.invoice-direction-option:last-child { border-bottom: 0; }
.invoice-direction-option input[type=checkbox] { margin-left: 1px; }
.invoice-direction-option .break-words { font-size: 13px; }
.invoice-direction-amount { display: flex; align-items: center; justify-content: flex-end; gap: 5px; color: #526174; font-size: 12px; }
.invoice-direction-amount > span:first-child { display: none; }
.invoice-route-preview { margin-top: 20px; padding: 12px 14px; border: 1px solid #cbd5e1; border-radius: 8px; background: #f8fafc; }
.invoice-route-preview-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-bottom: 8px; }
.invoice-route-preview-title { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: #334155; }
.invoice-route-preview-flow { font-size: 11px; font-weight: 600; color: #1d4ed8; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 999px; padding: 2px 8px; }
.invoice-route-preview-muted { font-size: 12px; line-height: 18px; color: #526174; }
.invoice-route-preview-error { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; color: #a5261b; }
.invoice-route-steps { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; list-style: none; margin: 0; padding: 0; }
.invoice-route-step { display: inline-flex; align-items: center; gap: 8px; flex: 1 1 150px; min-width: 0; padding: 7px 10px; border: 1px solid #d5e0ec; border-radius: 6px; background: #fff; }
.invoice-route-step.is-skipped { background: #f1f5f9; border-style: dashed; opacity: .78; }
.invoice-route-step-num { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 999px; background: #eff6ff; color: #1d4ed8; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.invoice-route-step.is-skipped .invoice-route-step-num { background: #e2e8f0; color: #64748b; }
.invoice-route-step-body { min-width: 0; flex: 1; }
.invoice-route-step-label { display: block; font-size: 11px; line-height: 14px; color: #526174; }
.invoice-route-step-assignee { display: block; font-size: 12px; line-height: 16px; font-weight: 600; color: #0f172a; overflow-wrap: anywhere; }
.invoice-route-step.is-skipped .invoice-route-step-assignee { color: #64748b; font-weight: 500; }
.invoice-route-step-arrow { color: #94a3b8; flex-shrink: 0; }
.invoice-route-self-note { margin-top: 8px; padding: 6px 10px; border-radius: 6px; border: 1px solid #fde68a; background: #fffbeb; font-size: 12px; color: #92400e; }
.invoice-submit-bar { position: sticky; bottom: -24px; z-index: 30; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: auto; padding: 12px 20px; border-top: 1px solid #8797aa; border-radius: 0 0 8px 8px; background: #fff; box-shadow: 0 -3px 12px #15223912; }
.invoice-submit-total { margin-right: auto; min-width: 100px; font-variant-numeric: tabular-nums; }
.invoice-submit-total span { display: block; font-size: 11px; color: #526174; }
.invoice-submit-total strong { display: block; font-size: 17px; line-height: 24px; }
.invoice-completion { display: inline-flex; align-items: center; gap: 5px; min-height: 24px; font-size: 12px; color: #526174; }
button.invoice-completion { text-decoration: underline; text-underline-offset: 3px; }
.invoice-completion.is-ready { color: #166044; }
.invoice-completion.has-errors { color: #a5261b; }
.invoice-submit-button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; white-space: nowrap; }
.invoice-budget-picker-shell { display: none; min-width: 0; }
.invoice-budget-panel { color: #17212f; }
.invoice-budget-row { padding: 12px 14px; border-bottom: 1px solid #b9c7d7; background: #fff; }
.invoice-budget-row.is-selected { background: #eef4ff; box-shadow: inset 3px 0 #1d4ed8; }
.invoice-budget-row.is-recommended:not(.is-selected) { background: #f5faf7; }
.invoice-budget-row-title { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.invoice-budget-row h3 { font-size: 14px; line-height: 20px; font-weight: 650; overflow-wrap: anywhere; }
.invoice-budget-row-state { display: inline-flex; gap: 4px; font-size: 11px; color: #1d4ed8; }
.invoice-budget-row-category { font-size: 12px; color: #526174; margin-top: 3px; overflow-wrap: anywhere; }
.invoice-budget-row-main { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.4fr); align-items: center; gap: 6px; margin-top: 8px; }
.invoice-budget-row time { font-size: 12px; font-variant-numeric: tabular-nums; color: #34445b; }
.invoice-budget-row .invoice-budget-remainder { width: 100%; min-width: 0; padding: 2px 6px; justify-content: space-between; }
.invoice-budget-row .invoice-budget-remainder strong { min-width: 0; overflow-wrap: anywhere; text-align: right; margin-left: auto; }
.invoice-budget-row-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 8px; margin-top: 7px; }
.invoice-budget-row-actions details { flex: 1 0 auto; min-width: 0; }
.cash-flow-operation-table {
    table-layout: fixed;
    width: 100%;
    min-width: 0;
}
.cash-flow-toolbar { container-type: inline-size; }
/* При печати окно прокрутки не нужно: печатается весь список, а не первый экран. */
@media print {
    .invoice-table-scroll, .budget-calendar-scroll { max-height: none !important; overflow: visible !important; }
}
.payflow-work-surface.cash-calendar-workspace { height: calc(100dvh - 7.5rem); }
/* Size the embedded calendar from the app's remaining space, including notices and footer. */
.app-main:has(.cash-calendar-workspace) { display: flex; flex-direction: column; }
.app-main:has(.cash-calendar-workspace) > .app-update-notice { flex-shrink: 0; }
.app-main:has(.cash-calendar-workspace) > .space-y-6 { display: flex; flex: 1; min-height: 0; flex-direction: column; }
.app-main:has(.cash-calendar-workspace) > .space-y-6 > section { flex-shrink: 0; }
.app-main:has(.cash-calendar-workspace) > .space-y-6 > .space-y-4 { display: flex; flex: 1; min-height: 52rem; flex-direction: column; }
.app-main .payflow-work-surface.cash-calendar-workspace { flex: 1; height: auto; min-height: 0; }
@media (max-width: 1023px) {
    .app-main:has(.cash-calendar-workspace) > .space-y-6 > .space-y-4 { min-height: 640px; }
}
.cash-flow-calendar { display: flex; flex-direction: column; container-type: inline-size; }
.cash-calendar-toolbar { display: grid; grid-template-columns: 172px minmax(160px, 1fr) minmax(160px, 1fr) minmax(150px, auto) auto; align-items: end; gap: 12px; flex-shrink: 0; padding: 12px 16px; border-bottom: 1px solid #cbd5e1; }
.cash-calendar-field { display: flex; min-width: 0; flex-direction: column; gap: 5px; }
.cash-calendar-field > span { color: #526174; font-size: 12px; font-weight: 600; }
.cash-calendar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cash-calendar-refresh { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.cash-calendar-refresh:hover:not(:disabled) { background: #1e40af; }
/* Сетка по дням (календарь платежей, ДДС): «Неделя» — дни недели и итоги, «Месяц» — недели. Ширина — по окну,
   прокрутки вбок нет; вертикально прокручивается окно сетки, шапка и остаток на конец остаются на виду. */
.cash-grid-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; flex-shrink: 0; padding: 8px 16px; border-bottom: 1px solid #cbd5e1; }
.cash-grid-bar .cash-calendar-legend { padding: 0; border-bottom: 0; }
.cash-grid-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-width: 0; }
.cash-grid-mode { display: inline-flex; height: 36px; padding: 2px; border: 1px solid var(--payflow-control-border); border-radius: 6px; background: #fff; }
.cash-grid-mode button { display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; border-radius: 4px; color: #34445b; font-size: 12px; font-weight: 600; }
.cash-grid-mode button:hover { background: #f3f6fa; }
.cash-grid-mode button[aria-pressed=true] { color: #fff; background: #34445b; }
.cash-grid-weeks { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.cash-grid-arrow { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--payflow-control-border); border-radius: 6px; background: #fff; color: #34445b; }
.cash-grid-arrow:hover:not(:disabled) { background: #f3f6fa; }
.cash-grid-arrow:disabled { opacity: .5; cursor: default; }
.cash-grid-week-label { min-width: 8.5rem; text-align: center; color: #111827; font-size: 13px; font-weight: 600; }
.cash-calendar-scroll { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: auto; scroll-padding: 48px 0 56px; }
/* «По дням» — весь месяц по дням, как до rc217 (Татьяна 08.10, Владимир: «давай как раньше»): сетка шириной по
   содержимому прокручивается вбок только внутри своего окна, страница — нет; статьи слева и итог месяца справа
   закреплены, неделя начинается с черты. На узком экране — список по дням, как в других режимах. */
.cash-calendar-scroll[data-scroll-x] { overflow-x: auto; overscroll-behavior-x: contain; scroll-padding: 48px 176px 56px 240px; }
.cash-flow-calendar-table[data-grid-mode=days] { width: max-content; min-width: 100%; table-layout: auto; }
.cash-flow-calendar-table[data-grid-mode=days] thead th:not(:first-child), .cash-flow-calendar-table[data-grid-mode=days] td:not([colspan]) { min-width: 7.5rem; white-space: nowrap; }
.cash-flow-calendar-table[data-grid-mode=days] .cash-calendar-article { position: sticky; left: 0; z-index: 3; width: 15rem; min-width: 15rem; max-width: 15rem; white-space: normal; }
.cash-flow-calendar-table[data-grid-mode=days] .cash-calendar-total { position: sticky; right: 0; z-index: 2; }
.cash-flow-calendar-table[data-grid-mode=days] thead .cash-calendar-article, .cash-flow-calendar-table[data-grid-mode=days] thead .cash-calendar-total { z-index: 8; }
.cash-flow-calendar-table[data-grid-mode=days] tfoot .cash-calendar-article, .cash-flow-calendar-table[data-grid-mode=days] tfoot .cash-calendar-total { z-index: 7; }
.cash-flow-calendar-table[data-grid-mode=days] [data-week-start=true] { border-left: 1px solid #aab8ca; }
.cash-flow-calendar-table { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; color: #263244; font-size: 13px; font-variant-numeric: tabular-nums; }
.cash-flow-calendar-table col.cash-day-grid-label { width: 15rem; }
.cash-flow-calendar-table th, .cash-flow-calendar-table td { border-right: 1px solid #d9e1ea; border-bottom: 1px solid #d9e1ea; padding: 6px 8px; }
.cash-flow-calendar-table th { font-weight: 600; }
.cash-flow-calendar-table thead th:not(:first-child), .cash-flow-calendar-table td { text-align: right; }
.cash-flow-calendar-table .cash-calendar-article { background: #fff; overflow-wrap: anywhere; text-align: left; border-right-color: #aab8ca; }
.cash-flow-calendar-table .cash-calendar-total { background: #f6f8fb; border-left: 1px solid #aab8ca; }
.cash-flow-calendar-table thead th { position: sticky; top: 0; z-index: 6; height: 44px; background: #f1f5f9; text-align: center; white-space: nowrap; box-shadow: inset 0 -1px #aab8ca; }
.cash-flow-calendar-table thead .cash-calendar-article { z-index: 8; text-align: left; white-space: normal; }
.cash-flow-calendar-table thead .cash-calendar-total { background: #e8edf3; }
.cash-grid-date { color: #526174; font-weight: 500; }
.cash-flow-calendar-table [data-weekend=true] { background: #f6f8fb; }
.cash-flow-calendar-table thead [data-today=true] { background: #edf4ff; box-shadow: inset 0 3px #2563eb, inset 0 -1px #aab8ca; }
.cash-grid-week-button { display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 32px; border-radius: 4px; color: #1d4ed8; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.cash-grid-week-button:hover { background: #e6efff; }
.cash-calendar-opening > * { height: 36px; background: #f8fafc; }
.cash-calendar-opening .cash-calendar-article, .cash-calendar-opening .cash-calendar-total { background: #f8fafc; }
.cash-calendar-group > * { height: 34px; background: #eef2f6; }
.cash-calendar-group .cash-calendar-article { background: #eef2f6; }
.cash-calendar-group button { display: flex; width: 100%; min-height: 24px; align-items: center; gap: 6px; text-align: left; }
.cash-calendar-group .cash-calendar-article small { margin-left: auto; font-size: 11px; font-weight: 400; color: #526174; }
.cash-calendar-data-row .cash-calendar-article { padding-left: 28px; font-weight: 500; }
.cash-calendar-data-row:hover > *, .cash-calendar-data-row:focus-within > * { background: #edf4ff; }
.cash-flow-calendar-table td.cash-calendar-day { padding: 0; vertical-align: top; }
.cash-flow-calendar-table .cash-calendar-group td.cash-calendar-day { padding: 6px 8px; vertical-align: middle; }
.cash-calendar-cell { display: flex; width: 100%; min-height: 44px; flex-direction: column; justify-content: center; gap: 4px; padding: 6px 8px; color: inherit; text-align: right; }
/* Подпись — над суммой: соседние значения не слипаются, «₽» — один раз в шапке. */
.cash-calendar-value { display: flex; flex-direction: column; align-items: flex-end; line-height: 16px; }
.cash-calendar-value > span { font-weight: 600; white-space: nowrap; }
.cash-calendar-value small { color: #526174; font-size: 11px; font-weight: 400; line-height: 14px; }
.cash-calendar-fact > span { color: #14634b; }
.cash-calendar-plan > span { color: #c2410c; }
.cash-calendar-budget > span { color: #1d4ed8; }
.cash-calendar-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding: 6px 16px; border-bottom: 1px solid #cbd5e1; font-size: 12px; color: #334155; }
.cash-calendar-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.cash-calendar-legend-item > i { width: 10px; height: 10px; border-radius: 2px; background: #14634b; }
.cash-calendar-legend-item.cash-calendar-plan > i { background: #c2410c; }
.cash-calendar-legend-item.cash-calendar-budget > i { background: #1d4ed8; }
.cash-flow-calendar-table tfoot th, .cash-flow-calendar-table tfoot td { position: sticky; bottom: 0; z-index: 5; height: 54px; background: #e7f2ed; color: #174c3d; box-shadow: inset 0 2px #43816c; }
.cash-flow-calendar-table tfoot td strong { white-space: nowrap; }
.cash-flow-calendar-table tfoot small { display: block; font-size: 11px; color: #345e50; font-weight: 400; }
.cash-flow-calendar-table tfoot [data-negative=true] { background: #fff1f2; color: #9f1239; box-shadow: inset 0 2px #be123c; }
.cash-flow-calendar-table tfoot [data-negative=true] small { color: #9f1239; }
.cash-calendar-cell:focus-visible, .cash-calendar-group button:focus-visible, .cash-grid-week-button:focus-visible { position: relative; outline: 2px solid #2563eb; outline-offset: -3px; border-radius: 2px; }
.cash-flow-load-error { margin: 16px; padding: 16px; border: 1px solid #fecdd3; border-radius: 8px; background: #fff1f2; color: #9f1239; font-size: 14px; }
.cash-flow-inline-error { margin: 0; padding: 8px 16px; border-bottom: 1px solid #fecdd3; background: #fff1f2; color: #9f1239; font-size: 13px; }
/* Формы вкладок счетов и загрузок: поля переносятся по ширине, без столбцов шире окна. */
.cash-flow-form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr)); align-items: end; gap: 12px; }
.cash-flow-form-grid .col-span-full { grid-column: 1 / -1; }
.cash-flow-field-wide { min-width: min(100%, 14rem); }
.cash-import-form { grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); }
/* Таблицы счетов и загрузок: по ширине окна; уже 860 px — каждая строка карточкой с подписями полей. */
.cash-stack-host { container-type: inline-size; }
.cash-stack-table { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; color: #1f2937; font-size: 13px; line-height: 18px; }
.cash-stack-table thead th { position: sticky; top: 0; z-index: 2; padding: 8px 12px; background: #f1f5f9; color: #334155; font-size: 12px; font-weight: 600; text-align: left; box-shadow: inset 0 -1px #cbd5e1; }
.cash-stack-table thead th.text-right { text-align: right; }
.cash-stack-table td { padding: 8px 12px; border-bottom: 1px solid #e2e8f0; vertical-align: top; overflow-wrap: anywhere; }
.cash-stack-table tfoot td { background: #1e293b; color: #fff; font-weight: 600; }
.cash-stack-muted > td { background: #f9fafb; color: #4b5563; }
.cash-stack-label { display: none; }
.cash-stack-table td.cash-stack-actions > * { margin: 0 0 6px 6px; }
.cash-stack-actions { text-align: right; }
.cash-stack-table col.cash-acc-col-balance { width: 176px; }
.cash-stack-table col.cash-acc-col-updated { width: 160px; }
.cash-stack-table col.cash-acc-col-check { width: 240px; }
.cash-stack-table col.cash-acc-col-actions { width: 208px; }
.cash-stack-table col.cash-imp-col-date { width: 176px; }
.cash-stack-table col.cash-imp-col-period { width: 120px; }
.cash-stack-table col.cash-imp-col-rows { width: 128px; }
.cash-stack-table col.cash-imp-col-status { width: 160px; }
.cash-stack-table col.cash-imp-col-actions { width: 208px; }
/* Широкое окно: название счёта не забирает весь запас — ему 36 %, остаток поровну остатку, выписке и сверке. */
@container (min-width: 1500px) {
    .cash-stack-table:has(col.cash-acc-col-balance) col.cash-acc-col-account { width: 36%; }
    .cash-stack-table col.cash-acc-col-balance, .cash-stack-table col.cash-acc-col-updated, .cash-stack-table col.cash-acc-col-check { width: auto; }
}
.cash-import-status { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.cash-import-status[data-status=uploaded] { color: #047857; }
.cash-import-status[data-status=cancelled] { color: #4b5563; }
.cash-import-status[data-status=failed] { color: #b91c1c; }
.cash-import-cancel { color: #be123c; }
@container (max-width: 860px) {
    .cash-stack-table, .cash-stack-table tbody, .cash-stack-table tfoot, .cash-stack-table tr, .cash-stack-table td { display: block; width: auto; }
    .cash-stack-table thead { display: none; }
    .cash-stack-table tr { margin: 8px 12px; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
    .cash-stack-table td { display: grid; grid-template-columns: minmax(6rem, 30%) minmax(0, 1fr); gap: 2px 12px; padding: 6px 12px; border-bottom: 1px solid #f1f5f9; text-align: left; }
    .cash-stack-table td:first-child { display: block; background: #f8fafc; }
    .cash-stack-table td.text-right { text-align: left; }
    .cash-stack-table td > :not(.cash-stack-label) { grid-column: 2; }
    .cash-stack-label { display: block; grid-column: 1; grid-row: 1 / span 6; color: #4b5563; font-size: 12px; font-weight: 600; }
    .cash-stack-table td.cash-stack-actions { display: flex; flex-wrap: wrap; gap: 6px; }
    .cash-stack-table td.cash-stack-actions > * { margin: 0; }
    .cash-stack-table tfoot tr { background: #1e293b; }
    .cash-stack-table tfoot td.cash-stack-empty { display: none; }
}
/* Узкое окно: сетка списком — по дню (или неделе) на блок, только строки с движением, остатки — в заголовке блока. */
.cash-agenda { display: flex; flex-direction: column; gap: 12px; padding: 12px; background: #f8fafc; font-variant-numeric: tabular-nums; }
.cash-agenda-section { flex-shrink: 0; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; }
.cash-agenda-section[data-today=true] { border-color: #2563eb; box-shadow: inset 0 3px #2563eb; }
.cash-agenda-section.is-total { background: #f6f8fb; }
.cash-agenda-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; padding: 8px 12px; border-bottom: 1px solid #e2e8f0; }
.cash-agenda-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; color: #111827; font-size: 14px; font-weight: 600; }
.cash-agenda-week-link { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; color: #1d4ed8; text-decoration: underline; text-underline-offset: 3px; }
.cash-agenda-today { padding: 1px 6px; border-radius: 4px; background: #eef4ff; color: #1d4ed8; font-size: 12px; font-weight: 600; }
.cash-agenda-balances { display: flex; flex-wrap: wrap; gap: 2px 16px; color: #526174; font-size: 12px; }
.cash-agenda-balances > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; }
.cash-agenda-balances dd { color: #111827; font-weight: 600; white-space: nowrap; }
.cash-agenda-balances [data-negative=true] dd { color: #9f1239; }
.cash-agenda-list { display: flex; flex-direction: column; }
.cash-agenda-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 6px 12px; border-bottom: 1px solid #eef2f6; }
.cash-agenda-row:last-child { border-bottom: 0; }
.cash-agenda-row.is-group { background: #eef2f6; font-weight: 600; }
.cash-agenda-name { min-width: 0; padding-top: 2px; overflow-wrap: anywhere; color: #1f2937; font-size: 13px; }
.cash-agenda-values { display: flex; flex-shrink: 0; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 13px; text-align: right; }
button.cash-agenda-values { min-height: 32px; padding: 2px 6px; border-radius: 4px; }
button.cash-agenda-values:hover { background: #e6efff; }
.cash-agenda-empty { padding: 10px 12px; color: #526174; font-size: 12px; }
@container (max-width: 1100px) {
    .cash-flow-calendar-table { font-size: 12px; }
    .cash-flow-calendar-table col.cash-day-grid-label { width: 11rem; }
    .cash-flow-calendar-table th, .cash-flow-calendar-table td, .cash-calendar-cell, .cash-flow-calendar-table .cash-calendar-group td.cash-calendar-day { padding: 5px 4px; }
    .cash-flow-calendar-table .cash-calendar-article { padding-left: 8px; }
    .cash-calendar-data-row .cash-calendar-article { padding-left: 16px; }
}
@container (max-width: 1000px) {
    .cash-calendar-toolbar { grid-template-columns: 160px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); }
    .cash-calendar-toolbar .cash-calendar-actions { grid-column: 1 / -1; }
}
@container (max-width: 820px) {
    .cash-calendar-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px; }
    .cash-grid-bar { padding: 8px 12px; }
}
@container (max-width: 480px) {
    .cash-calendar-actions { grid-column: 1 / -1; }
    .cash-calendar-field:nth-child(3) { grid-column: 1 / -1; }
}
/* ДДС: таблица календаря поплотнее — в ячейке одна сумма, строк больше сотни. */
.dds-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; }
.dds-toolbar > .cash-calendar-field { flex: 0 1 200px; }
.dds-toolbar > .dds-report-field { flex-basis: 260px; }
.dds-toolbar > .dds-currency-field { flex-basis: 120px; }
.dds-toolbar > .cash-calendar-actions { flex-wrap: wrap; }
.dds-toolbar [aria-pressed=true] { border-color: #1d4ed8; background: #eef4ff; color: #1d4ed8; }
.dds-table { font-size: 12px; }
.dds-table col.cash-day-grid-label { width: 14rem; }
.dds-table .dds-row > *, .dds-table .dds-unallocated > *, .dds-table .dds-actual > *, .dds-table .dds-difference > * { height: 32px; }
.dds-table td.dds-day { padding: 0; }
.dds-cell { display: block; width: 100%; min-height: 31px; padding: 6px 8px; color: inherit; text-align: right; white-space: nowrap; }
/* «Заявки и бюджет» в ДДС: доля плана под суммой ячейки. */
.dds-cell-plan { display: block; margin-top: 1px; font-size: 11px; font-weight: 400; line-height: 1.2; color: #1d4ed8; }
/* Просроченные заявки в плане (ТЗ «05.11»): доля плана, «Не разнесено — заявки и бюджет» и заявка в списке ячейки — красным. */
.dds-cell-plan[data-overdue=true], .dds-agenda-plan[data-overdue=true] { font-weight: 600; color: #b91c1c; }
.dds-cell[data-overdue=true], .cash-agenda-amount[data-overdue=true] { color: #b91c1c; }
.dds-plan-item[data-overdue=true] { margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 4px; background: #fef2f2; box-shadow: inset 3px 0 0 #b91c1c; }
/* Ячейка остатка: на начало, приход, расход, на конец по счёту. */
.dds-balance-moves { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 8px; }
.dds-balance-moves dt { font-size: 11px; line-height: 1.3; color: #526174; }
.dds-balance-moves dd { margin: 0; font-size: 13px; font-variant-numeric: tabular-nums; color: #0f172a; overflow-wrap: anywhere; }
@media (max-width: 480px) { .dds-balance-moves { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
button.dds-cell:hover { background: #e6efff; }
.dds-cell:focus-visible { position: relative; outline: 2px solid #2563eb; outline-offset: -3px; border-radius: 2px; }
.dds-cell[data-negative=true], .dds-table tbody td[data-negative=true] { color: #b91c1c; }
/* Ручной ввод (ТЗ «09.11» (60), «12.11»: «для ручных операций достаточно только красного кружочка… уменьшить на 30%»):
   перед суммой, введённой вручную в самой строке, — красный кружок, без заливки и полоски; у групп, формул и остатков из
   неё кружка нет. Кружок своего размера (от шрифта строки), а не знак шрифта — одинаковый на любом компьютере; белый ободок
   — чтобы был виден и на строках с заливкой; виден при наведении на строку и в печати; ячейке position не задаётся —
   закреплённые строки и столбцы остаются на месте; без текста — экранный диктор о ручном вводе слышит из подписи. На
   образце в пояснении — такой же кружок. */
.dds-table .dds-cell[data-manual=true]::before, .dds-table td[data-manual=true]::before, [data-dds-agenda] [data-manual=true]::before, .dds-manual-swatch {
    content: ''; display: inline-block; width: .42em; height: .42em; margin-right: .3em; border-radius: 50%; background: #dc2626; box-shadow: 0 0 0 1px #fff; vertical-align: .14em; }
.dds-manual-swatch { margin-right: 4px; }
.dds-manual-forced { display: none; }
/* При печати цвет остаётся; в режиме высокой контрастности кружок — цветом текста, и пояснение говорит о кружке, а не
   о цвете. */
@media print {
    .dds-table .dds-cell[data-manual=true]::before, .dds-table td[data-manual=true]::before, [data-dds-agenda] [data-manual=true]::before, .dds-manual-swatch { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media (forced-colors: active) {
    .dds-manual-color { display: none; }
    .dds-manual-forced { display: inline; }
    .dds-table .dds-cell[data-manual=true]::before, .dds-table td[data-manual=true]::before, [data-dds-agenda] [data-manual=true]::before, .dds-manual-swatch { forced-color-adjust: none; background: CanvasText; }
}
.dds-table .dds-row:hover > *, .dds-table .dds-row:focus-within > * { background: #f5f9ff; }
.dds-row-name small { color: #526174; font-size: 11px; font-weight: 400; }
.dds-row-error { display: block; color: #b91c1c; font-size: 11px; font-weight: 400; }
.dds-table .dds-unallocated > * { background: #fffbeb; }
.dds-table .dds-unallocated .cash-calendar-article { color: #92400e; }
.dds-table .dds-unallocated .cash-calendar-article small, .dds-table .dds-difference .cash-calendar-article small { display: block; color: #526174; font-size: 11px; font-weight: 400; }
.dds-table .dds-actual > * { background: #f8fafc; color: #334155; }
.dds-table .dds-difference td[data-nonzero=true] { color: #9a3412; font-weight: 600; }
.dds-table th.dds-plan, .dds-table td.dds-plan { background: #f8fafc; }
.dds-table thead th.dds-plan { background: #eef2f6; }
.dds-table .dds-cell[data-deviation=good] { color: #14634b; }
.dds-table .dds-cell[data-deviation=bad] { color: #b91c1c; }
.dds-table .dds-info > * { color: #526174; font-style: italic; }
/* Оформление строк ДДС (ТЗ «29.10»): жирный, курсив, цвет текста, заливка, размер сумм — то же в образце формы строки. */
:is(.dds-table tr, [data-dds-row-style-preview]).dds-style-bold :is(th, td, .dds-row-name, .dds-cell) { font-weight: 700; }
:is(.dds-table tr, [data-dds-row-style-preview]).dds-style-italic :is(th, td, .dds-row-name, .dds-cell) { font-style: italic; }
:is(.dds-table tr, [data-dds-row-style-preview]).dds-color-red :is(th, td, .dds-row-name, .dds-cell) { color: #b91c1c; }
:is(.dds-table tr, [data-dds-row-style-preview]).dds-color-green :is(th, td, .dds-row-name, .dds-cell) { color: #15803d; }
:is(.dds-table tr, [data-dds-row-style-preview]).dds-color-blue :is(th, td, .dds-row-name, .dds-cell) { color: #1d4ed8; }
:is(.dds-table tr, [data-dds-row-style-preview]).dds-color-orange :is(th, td, .dds-row-name, .dds-cell) { color: #c2410c; }
:is(.dds-table tr, [data-dds-row-style-preview]).dds-color-purple :is(th, td, .dds-row-name, .dds-cell) { color: #7e22ce; }
:is(.dds-table tr, [data-dds-row-style-preview]).dds-color-gray :is(th, td, .dds-row-name, .dds-cell) { color: #526174; }
.dds-table tr.dds-fill-gray > *, [data-dds-row-style-preview].dds-fill-gray { background: #eef1f5; }
.dds-table tr.dds-fill-blue > *, [data-dds-row-style-preview].dds-fill-blue { background: #e0edff; }
.dds-table tr.dds-fill-green > *, [data-dds-row-style-preview].dds-fill-green { background: #dcfce7; }
.dds-table tr.dds-fill-yellow > *, [data-dds-row-style-preview].dds-fill-yellow { background: #fef9c3; }
.dds-table tr.dds-fill-red > *, [data-dds-row-style-preview].dds-fill-red { background: #fee2e2; }
.dds-table tr.dds-fill-purple > *, [data-dds-row-style-preview].dds-fill-purple { background: #f3e8ff; }
:is(.dds-table tr, [data-dds-row-style-preview]).dds-size-sm .dds-cell { font-size: 11px; }
:is(.dds-table tr, [data-dds-row-style-preview]).dds-size-lg .dds-cell { font-size: 15px; }
:is(.dds-table tr, [data-dds-row-style-preview]).dds-size-xl .dds-cell { font-size: 17px; }
/* Свои столбцы ДДС (созвон 30.10): месяц по столбцам — названия строк слева закреплены — или блоками друг под другом. */
.dds-layout { padding: 8px 12px 16px; }
.dds-layout-note { margin: 0 0 8px; font-size: 12px; color: #526174; }
/* Строки бюджета без юрлица, которых нет в плане ДДС (ТЗ «30.10»). */
.dds-plan-excluded { display: grid; gap: 4px; margin: 8px 12px 0; padding: 8px 12px; border: 1px solid #fcd34d; border-radius: 8px; background: #fffbeb; font-size: 13px; color: #78350f; }
.dds-plan-excluded ul { display: grid; gap: 2px; margin: 0; padding-left: 18px; list-style: disc; }
.dds-plan-excluded-link { margin-right: 4px; font-weight: 600; color: #92400e; text-decoration: underline; }
.dds-layout-table { border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; color: #17212f; }
.dds-layout-table :is(th, td) { border-bottom: 1px solid #e5eaf1; }
.dds-layout-table thead th { position: sticky; top: 0; z-index: 2; padding: 6px 8px; border-bottom-color: #c2ccda; background: #f8fafc; font-weight: 600; color: #3f4f63; text-align: right; white-space: nowrap; }
.dds-layout-table thead th:first-child { left: 0; z-index: 3; text-align: left; }
.dds-layout-table tbody th { position: sticky; left: 0; z-index: 1; min-width: 14rem; max-width: 24rem; padding: 6px 8px; background: #fff; font-weight: 500; text-align: left; overflow-wrap: anywhere; }
.dds-layout-table td { min-width: 8.5rem; padding: 0; text-align: right; }
.dds-layout-table .is-total { background: #f8fafc; font-weight: 600; }
.dds-layout-table .is-share { min-width: 5.5rem; color: #526174; }
/* Прошлый месяц — лёгкий фон ячеек; :where не добавляет веса: «Итого» и строки остатков — своим цветом, заголовки — как у всех. */
.dds-layout-table :where(td.is-previous) { background: #fbfcfe; }
.dds-layout-table .is-previous-first { border-left: 2px solid #c2ccda; }
.dds-layout-table .dds-month-label { display: block; font-size: 11px; font-weight: 400; color: #64748b; }
.dds-layout-table .dds-layout-balance > * { background: #f1f5f9; font-weight: 600; }
.dds-layout-table .dds-layout-line > * { color: #526174; font-style: italic; }
.dds-layout-table tr.is-group > * { font-weight: 600; }
.dds-layout-table tr.is-info > * { color: #526174; font-style: italic; }
.dds-layout-table td.is-negative { color: #b91c1c; }
.dds-layout-toggle { display: inline-flex; align-items: center; gap: 4px; color: inherit; font-weight: 600; text-align: left; }
/* Блоками — по дням, как календарь по организациям: блоки друг под другом листаются вбок вместе, название блока и строк — на месте. */
.dds-layout-blocks { display: grid; gap: 20px; }
.dds-layout-block-title { position: sticky; left: 0; width: max-content; margin: 0 0 4px; font-size: 14px; font-weight: 600; color: #0f172a; }
.dds-layout-block .dds-layout-table td { min-width: 6.5rem; }
.dds-zoom { display: inline-flex; align-items: center; gap: 2px; }
.dds-zoom-value { min-width: 3.5em; text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; color: #334155; }
/* Колонка строк не шире своей половины окна: длинное название обрезается, а не задвигает стрелки под форму строки. */
.dds-tree { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.dds-tree-row { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 40px; padding-right: 4px; border: 1px solid transparent; border-radius: 6px; background: #fff; }
.dds-tree-row:hover { background: #f8fafc; }
.dds-tree-row.is-selected { border-color: #93c5fd; background: #eff6ff; }
.dds-tree-row[data-drop=before] { box-shadow: inset 0 2px #2563eb; }
.dds-tree-row[data-drop=after] { box-shadow: inset 0 -2px #2563eb; }
.dds-tree-row[data-drop=inside] { border-color: #2563eb; background: #eff6ff; }
@container (max-width: 1100px) {
    .dds-table col.cash-day-grid-label { width: 11rem; }
    .dds-cell { padding: 5px 4px; }
}
@container (max-width: 820px) {
    .dds-toolbar > .cash-calendar-field, .dds-toolbar > .dds-report-field { flex: 1 1 140px; }
}
/* ДДС списком по дням: строки с суммой, группы сворачиваются, переводы и неразнесённое — в конце блока. */
.cash-agenda-amount { min-height: 32px; padding: 6px; border-radius: 4px; font-weight: 600; white-space: nowrap; }
button.cash-agenda-amount:hover { background: #e6efff; }
.cash-agenda-amount[data-negative=true] { color: #b91c1c; }
.cash-agenda-row.is-info { color: #526174; font-style: italic; }
.dds-agenda-toggle { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; text-align: left; }
.dds-agenda-plan { color: #526174; font-size: 11px; }
.dds-agenda-plan [data-deviation=good] { color: #14634b; }
.dds-agenda-plan [data-deviation=bad] { color: #b91c1c; }
.dds-agenda-unallocated { background: #fffbeb; color: #92400e; }
/* Шапка «Движения денег»: название слева, отбор организаций и «Обновить данные» справа; всё переносится, ничего не режется. */
.cash-flow-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.cash-flow-head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.cash-flow-org-filter { width: 15rem; max-width: 100%; }
/* Вкладки переносятся на вторую строку, а не уезжают вбок. */
.cash-flow-tabbar { container-type: inline-size; }
.cash-flow-tab { height: 44px; flex-shrink: 0; padding: 0 12px; border-bottom: 2px solid transparent; color: #4b5563; font-size: 14px; font-weight: 500; }
.cash-flow-tab:hover { color: #111827; }
.cash-flow-tab.is-active { border-bottom-color: #2563eb; background: #fff; color: #1d4ed8; }
@container (max-width: 560px) {
    .cash-flow-tab { height: 40px; padding: 0 10px; }
    .cash-flow-toggle-text { display: none; }
}
/* Сводка над операциями: ячейки переносятся по ширине, последняя строка растягивается. */
.cash-flow-summary { display: flex; flex-wrap: wrap; gap: 1px; background: #e5e7eb; }
.cash-flow-summary > div { flex: 1 1 9.5rem; min-width: 0; padding: 8px 12px; background: #fff; }
.cash-flow-summary > [data-account-balance-opening], .cash-flow-summary > [data-account-balance-closing] { background: #f8fafc; }
.cash-flow-summary-label { color: #4b5563; font-size: 12px; font-weight: 600; }
/* Период, счёт и банк операций: перечитываются с сервера кнопкой «Обновить таблицу». */
.cash-flow-period-bar { display: grid; grid-template-columns: 9.5rem 9.5rem minmax(12rem, 1.4fr) minmax(9rem, 1fr) auto; align-items: end; gap: 8px; margin-top: 12px; }
.cash-flow-period-hint { grid-column: 1 / -1; margin: 0; font-size: 12px; line-height: 1.4; color: #92400e; }
.cash-flow-toolbar .cash-flow-filters-toggle { display: none; }
/* Операции: прежние столбцы, как до rc217 (Татьяна 08.10): таблица шириной по содержимому прокручивается вбок только
   внутри своей области, страница — нет; галочка, номер и дата закреплены слева. Какие столбцы показывать — шестерёнка
   «Столбцы», фильтр — значком в заголовке столбца, как в Excel. Уже 768 px — плитки. */
.cash-flow-operation-table { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; color: #1f2937; font-size: 13px; line-height: 18px; }
.cash-op-host[data-scroll-x] { overflow-x: auto; overscroll-behavior-x: contain; }
.cash-flow-operation-table[data-wide] { width: max-content; min-width: 100%; table-layout: auto; }
.cash-flow-operation-table[data-wide] td { min-width: 6.5rem; max-width: 18rem; }
.cash-flow-operation-table[data-wide] thead th { white-space: nowrap; }
.cash-flow-operation-table[data-wide] .cash-op-fix { position: sticky; z-index: 1; background: #fff; }
.cash-flow-operation-table[data-wide] thead .cash-op-fix { z-index: 4; background: #f1f5f9; }
.cash-flow-operation-table[data-wide] .cash-op-fix-check { left: 0; width: 44px; min-width: 44px; max-width: 44px; }
.cash-flow-operation-table[data-wide] .cash-op-fix-number { left: 44px; width: 8rem; min-width: 8rem; max-width: 8rem; }
.cash-flow-operation-table[data-wide] .cash-op-fix-date { left: calc(44px + 8rem); width: 9rem; min-width: 9rem; max-width: 9rem; box-shadow: inset -1px 0 #cbd5e1; }
.cash-flow-operation-table[data-wide] thead .cash-op-fix-date { box-shadow: inset -1px 0 #cbd5e1, inset 0 -1px #cbd5e1; }
.cash-flow-operation-table[data-wide] tfoot .cash-op-fix { left: 0; z-index: 4; background: #1e293b; }
.cash-op-head { display: inline-flex; align-items: center; gap: 4px; }
.cash-op-number { display: block; min-height: 24px; max-width: 100%; color: #1d4ed8; font-weight: 600; text-align: left; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.cash-op-number:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; border-radius: 2px; }
.cash-op-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.cash-flow-filter-icon { display: inline-grid; flex-shrink: 0; place-items: center; width: 24px; height: 24px; border-radius: 4px; color: #64748b; }
.cash-flow-filter-icon:hover { background: #e2e8f0; color: #1f2937; }
.cash-flow-filter-icon.is-active { background: #dbeafe; color: #1d4ed8; }
.cash-flow-filter-icon:focus-visible { outline: 2px solid #2563eb; outline-offset: 1px; }
.cash-flow-filter-fields .is-wide { grid-column: 1 / -1; }
.cash-flow-filter-buttons { display: inline-flex; gap: 6px; }
.cash-flow-column-panel { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr)); align-items: end; gap: 8px 12px; margin-top: 12px; padding: 12px; border: 1px solid #e2e8f0; border-radius: 8px; background: #f8fafc; }
.cash-flow-column-panel-actions { display: flex; align-items: flex-end; }
.cash-flow-columns-count { margin-left: 4px; padding: 0 6px; border-radius: 4px; background: #dbeafe; color: #1e40af; font-size: 11px; font-weight: 600; }
.cash-flow-operation-table thead th { position: sticky; top: 0; z-index: 2; padding: 8px; background: #f1f5f9; color: #334155; font-size: 12px; font-weight: 600; text-align: left; box-shadow: inset 0 -1px #cbd5e1; }
.cash-flow-operation-table thead th.text-right { text-align: right; }
.cash-flow-operation-table td { padding: 8px; border-bottom: 1px solid #e2e8f0; vertical-align: top; overflow-wrap: anywhere; }
.cash-flow-operation-table .cash-op-check { padding: 4px 2px; text-align: center; }
.cash-op-checkbox { display: inline-grid; place-items: center; width: 32px; height: 32px; cursor: pointer; }
.cash-op-checkbox input { width: 16px; height: 16px; }
.cash-op-row { cursor: pointer; }
.cash-op-row:hover > td { background: #f5f9ff; }
.cash-op-row[data-allocation] > td { background: #fffbeb; }
.cash-op-row[data-allocation]:hover > td { background: #fef3c7; }
/* Операция с датой учёта: в ДДС она стоит не днём оплаты. */
.cash-op-row[data-accounting-date] > td:first-child { box-shadow: inset 3px 0 0 #7c3aed; }
.cash-op-accounting { display: inline-block; margin-top: 2px; padding: 0 4px; border-radius: 4px; background: #ede9fe; color: #5b21b6; font-size: 11px; font-weight: 600; white-space: nowrap; }
.cash-op-primary { color: #111827; font-weight: 600; }
.cash-op-secondary { color: #4b5563; font-size: 12px; line-height: 16px; }
.cash-op-wrap { overflow-wrap: anywhere; }
.cash-op-inn { color: #4b5563; font-size: 12px; font-weight: 400; }
.cash-op-purpose { display: -webkit-box; margin-top: 2px; overflow: hidden; color: #374151; font-size: 12px; line-height: 16px; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
/* Комментарий операции (ТЗ «09.11») — под назначением, своим цветом и значком, до двух строк. */
.cash-op-comment { display: flex; gap: 4px; align-items: flex-start; margin-top: 2px; color: #1e40af; font-size: 12px; line-height: 16px; }
.cash-op-comment > span { display: -webkit-box; min-width: 0; overflow: hidden; overflow-wrap: anywhere; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cash-op-amount { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cash-op-tag { display: inline-flex; align-items: center; padding: 1px 6px; border-radius: 4px; background: #f1f5f9; color: #334155; font-size: 12px; line-height: 16px; }
.cash-op-status { display: inline-flex; padding: 1px 6px; border: 1px solid; border-radius: 4px; font-size: 12px; font-weight: 600; line-height: 16px; }
.cash-op-link { display: block; min-height: 24px; margin-top: 2px; padding: 3px 0; color: #1d4ed8; font-size: 12px; font-weight: 500; text-align: left; text-decoration: underline; text-underline-offset: 2px; }
.cash-op-warning { display: flex; align-items: flex-start; gap: 4px; margin-top: 4px; color: #92400e; font-size: 12px; font-weight: 600; line-height: 16px; }
.cash-op-warning > svg { margin-top: 1px; }
.cash-op-open { display: inline-flex; align-items: center; gap: 2px; min-height: 32px; padding: 0 6px 0 10px; border: 1px solid var(--payflow-control-border); border-radius: 6px; background: #fff; color: #1f2937; font-size: 12px; font-weight: 600; white-space: nowrap; }
.cash-op-open:hover { background: #f3f6fa; }
.cash-op-rate { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; margin-top: 6px; text-align: left; }
.cash-op-rate label { display: flex; flex-direction: column; gap: 2px; color: #4b5563; font-size: 11px; }
.cash-op-rate-input { width: 100%; min-width: 0; height: 30px; padding: 0 4px; border: 1px solid var(--payflow-control-border); border-radius: 4px; font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
.cash-flow-operation-table tfoot td { position: sticky; bottom: 0; z-index: 2; padding: 8px; border-bottom: 0; background: #1e293b; color: #fff; font-size: 12px; font-weight: 600; }
/* Плитки: на узкой рабочей области и по выбору; галочка — для массовой разметки. */
.cash-op-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: 8px; }
.cash-op-tile { position: relative; display: flex; align-items: flex-start; gap: 4px; min-width: 0; padding: 8px 10px 10px 12px; border: 1px solid #e5e7eb; border-radius: 8px; background: #fff; box-shadow: 0 1px 2px rgb(15 23 42 / 0.05); }
.cash-op-tile[data-allocation] { background: #fffdf5; }
.cash-op-tile-accent { position: absolute; top: 0; bottom: 0; left: 0; width: 4px; border-radius: 8px 0 0 8px; }
.cash-op-tile-check { flex-shrink: 0; margin: -2px 0 0 -4px; }
.cash-op-tile-open { display: block; flex: 1; min-width: 0; padding-top: 4px; border-radius: 4px; text-align: left; }
.cash-op-tile-open:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
/* Фильтры по столбцам — панелью над таблицей, а не строкой в шапке таблицы. */
.cash-flow-action.is-active { border-color: #2563eb; color: #1d4ed8; background: #eef4ff; }
.cash-flow-toolbar-actions, .cash-flow-table-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.cash-flow-toolbar-actions { justify-content: space-between; }
.cash-flow-table-actions { margin-left: auto; }
.cash-flow-result-count { margin-right: 4px; color: #526174; font-size: 12px; white-space: nowrap; }
.cash-flow-status-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.cash-flow-status-tabs button { height: 36px; padding: 0 10px; border-radius: 6px; color: #526174; font-size: 12px; font-weight: 600; white-space: nowrap; }
.cash-flow-status-tabs button:hover { background: #f3f6fa; }
.cash-flow-status-tabs button.is-active { color: #1d4ed8; background: #eef4ff; box-shadow: inset 0 -2px #2563eb; }
.cash-flow-view-toggle { display: flex; height: 36px; border: 1px solid var(--payflow-control-border); border-radius: 6px; padding: 2px; }
.cash-flow-view-toggle button { padding: 0 10px; border-radius: 4px; color: #526174; font-size: 12px; font-weight: 600; }
.cash-flow-view-toggle button.is-active { color: #fff; background: #34445b; }
.cash-flow-control { height: 36px; min-width: 0; width: 100%; padding: 0 10px; border: 1px solid var(--payflow-control-border); border-radius: 6px; background: #fff; color: #34445b; font-size: 12px; font-weight: 400; line-height: normal; }
.cash-flow-control:disabled { opacity: .5; cursor: default; }
.cash-flow-action { display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: auto; flex-shrink: 0; font-weight: 600; white-space: nowrap; }
.cash-flow-action:hover:not(:disabled) { background: #f3f6fa; }
.cash-flow-filter-bar { display: grid; grid-template-columns: minmax(240px, 1fr) 152px 160px 188px auto auto; align-items: center; gap: 8px; margin-top: 8px; }
.cash-flow-search { display: block; position: relative; min-width: 0; }
.cash-flow-search > svg { position: absolute; top: 10px; left: 10px; color: #526174; pointer-events: none; }
.cash-flow-search input { padding-left: 34px; }
.cash-flow-filter-trigger { display: flex; align-items: center; justify-content: space-between; gap: 4px; text-align: left; }
.cash-flow-filter-trigger > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cash-flow-filter-trigger.is-active { color: #1d4ed8; background: #eef4ff; border-color: #2563eb; }
.cash-flow-filter-menu { position: fixed; z-index: 100; display: flex; flex-direction: column; padding: 8px; border: 1px solid var(--payflow-control-border); border-radius: 8px; background: #fff; color: #34445b; font-size: 12px; box-shadow: 0 8px 24px rgba(15,23,42,.16); }
.cash-flow-filter-menu header, .cash-flow-filter-menu footer { display: flex; flex-shrink: 0; align-items: center; justify-content: space-between; gap: 8px; }
.cash-flow-filter-menu header { min-height: 32px; margin-bottom: 8px; padding-left: 4px; }
.cash-flow-filter-menu header strong { font-size: 13px; overflow-wrap: anywhere; }
.cash-flow-filter-close { display: flex; flex-shrink: 0; justify-content: center; align-items: center; width: 32px; height: 32px; border-radius: 4px; }
.cash-flow-filter-close:hover { background: #f3f6fa; }
.cash-flow-filter-except { display: flex; flex-shrink: 0; flex-wrap: wrap; gap: 0 12px; margin: 0 4px 8px; padding-bottom: 4px; border-bottom: 1px solid var(--payflow-line); }
.cash-flow-filter-except label { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; cursor: pointer; }
.cash-flow-filter-except input { width: 16px; height: 16px; flex-shrink: 0; margin: 0; accent-color: #2563eb; }
.cash-flow-option-search { width: calc(100% - 8px); margin: 0 4px 8px; flex-shrink: 0; }
.cash-flow-filter-options { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.cash-flow-filter-options label { display: flex; align-items: flex-start; gap: 8px; padding: 9px 6px; border-radius: 4px; cursor: pointer; }
.cash-flow-filter-options label:hover { background: #f3f6fa; }
.cash-flow-filter-options input { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; accent-color: #2563eb; }
.cash-flow-filter-options span { overflow-wrap: anywhere; line-height: 18px; }
.cash-flow-filter-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 4px; min-height: 0; overflow-y: auto; }
.cash-flow-filter-fields label { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cash-flow-filter-menu footer { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--payflow-line); }
@container (max-width: 1000px) {
    .cash-flow-filter-bar, .cash-flow-period-bar { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .cash-flow-search { grid-column: 1 / -1; }
}
@container (max-width: 860px) {
    .cash-flow-filter-bar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .cash-flow-period-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cash-flow-period-account { grid-column: 1 / -1; }
}
@container (max-width: 640px) {
    .cash-flow-toolbar .cash-flow-filters-toggle { display: flex; justify-content: space-between; width: 100%; margin-top: 12px; }
    .cash-flow-filter-rows[data-open=false] { display: none; }
    .cash-flow-filter-bar, .cash-flow-period-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cash-flow-period-account { grid-column: 1 / -1; }
    .cash-flow-table-actions { margin-left: 0; }
    .cash-flow-result-count { width: 100%; }
}
@container (max-width: 390px) {
    .cash-flow-filter-bar, .cash-flow-period-bar { grid-template-columns: minmax(0, 1fr); }
}

.invoice-budget-row-commands { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 100%; }
.invoice-payout-hint { margin: 0 0 8px; padding: 8px 12px; border-left: 3px solid #b45309; background: #fffbeb; color: #78350f; font-weight: 600; }
.admin-flow-list { max-height: max(16rem, calc(100dvh - 14rem)); }
.admin-flow-sidebar { display: flex; flex-direction: column; min-width: 0; }
.admin-flow-list { min-height: 0; overscroll-behavior: contain; }
.admin-flow-conditions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); min-width: 0; }
.admin-flow-conditions > div { min-width: 0; }
.admin-flow-categories { grid-column: 1 / -1; }
@media (min-width: 1280px) {
    .admin-flow-sidebar { max-height: calc(100dvh - 10rem); }
    .admin-flow-list { max-height: none; }
}
.invoice-budget-row-actions summary { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; line-height: 30px; color: #34445b; cursor: pointer; list-style: none; }
.invoice-budget-row-actions summary::-webkit-details-marker { display: none; }
.invoice-budget-row-details { margin-top: 4px; font-size: 12px; line-height: 19px; color: #34445b; overflow-wrap: anywhere; }
.invoice-budget-apply { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; border: 1px solid #1d4ed8; border-radius: 5px; padding: 3px 8px; background: #1d4ed8; font-size: 12px; font-weight: 600; color: #fff; flex-shrink: 0; }
.invoice-budget-apply:hover { background: #1e40af; }
.invoice-budget-apply.is-selected { background: #fff; color: #1d4ed8; }
.invoice-budget-apply-secondary { border-color: #cbd5e1; background: #fff; color: #334155; font-weight: 500; }
.invoice-budget-apply-secondary:hover { background: #f1f5f9; border-color: #94a3b8; color: #0f172a; }
.invoice-budget-chosen { flex-shrink: 0; padding: 10px 14px; background: #eef4ff; border-bottom: 1px solid #96afd3; font-size: 12px; }
.invoice-budget-chosen > span { display: flex; align-items: center; gap: 5px; color: #1d4ed8; }
.invoice-budget-chosen strong { display: block; margin-top: 3px; font-size: 14px; overflow-wrap: anywhere; }
.invoice-budget-chosen p { margin-top: 3px; color: #34445b; }
.invoice-icon-button { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 1px solid #7f8fa2; border-radius: 6px; color: #34445b; background: #fff; }
@media (min-width: 1280px) {
    .invoice-create-layout.invoice-create-with-budget { grid-template-columns: minmax(0, 2fr) minmax(340px, 1fr); }
    .invoice-budget-picker-shell { display: block; position: sticky; top: 0; }
    .invoice-create-layout .invoice-budget-panel { height: var(--invoice-budget-panel-height, var(--invoice-workspace-height)); max-height: var(--invoice-budget-panel-height, var(--invoice-workspace-height)); }
}
@media (max-width: 1279px) {
    .invoice-budget-picker-shell.is-open { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: flex-end; background: #17212f66; padding: 12px; }
    .invoice-budget-picker-shell.is-open .invoice-budget-panel { position: relative; width: min(480px,100%); height: 100%; max-height: 100%; }
}
@media (max-width: 767px) {
    .invoice-entry-header { padding: 12px; gap: 8px; }
    .invoice-scenarios { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .invoice-scenario { padding: 8px 26px 8px 10px; }
    .invoice-reset { margin-left: 0; }
    .invoice-entry-body { padding: 14px 12px 24px; }
    .invoice-fields { grid-template-columns: minmax(0,1fr); gap: 12px; }
    .invoice-foreign-fields { grid-template-columns: minmax(0,1fr); }
    .invoice-entry :is(input:not([type=checkbox]),select,textarea) { font-size: 16px; }
    .invoice-direction-option { grid-template-columns: minmax(0,1fr); gap: 6px; }
    .invoice-submit-bar { bottom: -16px; padding: 10px 12px; gap: 6px 8px; }
    .invoice-submit-total { flex: 1; min-width: 120px; }
    .invoice-submit-button { flex: 1; }
    .invoice-review-button span { display: none; }
    .invoice-review-button { height: 40px; width: 40px; padding: 0; }
    .invoice-completion { max-width: 55%; font-size: 11px; }
}
@media (max-width: 479px) {
    .invoice-scenarios { grid-template-columns: minmax(0, 1fr); }
}

.app-update-notice { display: flex; align-items: center; gap: 8px; min-height: 40px; margin-bottom: 12px; padding: 4px 8px; border-bottom: 1px solid #ccd5e1; color: #526174; font-size: 12px; line-height: 18px; }
.app-update-label { flex: 1; min-width: 0; }
.app-update-action { color: #1d4ed8; font-weight: 600; padding: 4px 8px; min-height: 32px; border-radius: 4px; }
.app-update-dismiss { display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 32px; border-radius: 4px; }
.app-update-notice button:hover { background: #e8edf4; }
.app-update-notice button:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 2px; }
.app-update-notice button:disabled { opacity: .6; cursor: wait; }

/* Экран ноутбука и обычного монитора (видимая высота до 1080 px): шапка выписок занимала пол-экрана,
   и при фиксированной высоте блока таблице оставалось 370–450 px. На таких экранах блок растёт по содержимому,
   а окно таблицы — на высоту экрана, как у таблицы заявок: страница доводит до таблицы, дальше прокручивается
   таблица. На высоких экранах — как было. */
@media (min-width: 1024px) and (max-height: 1080px) {
    .app-main section.payflow-work-surface[data-cash-flow-surface] { height: auto; min-height: 0; }
    .app-main section[data-cash-flow-surface] > main { flex: none; min-height: 0; overflow: visible; }
    .app-main section[data-cash-flow-surface] > main > [data-cash-flow-table],
    .app-main section[data-cash-flow-surface] > main > [data-cash-flow-tiles],
    .app-main section[data-cash-flow-surface] > main[data-cash-flow-accounts],
    .app-main section[data-cash-flow-surface] > main[data-cash-flow-imports] { height: calc(100dvh - 10rem); min-height: 20rem; overflow-x: hidden; overflow-y: auto; }
    .app-main section[data-cash-flow-surface] .cash-calendar-scroll { flex: none; height: calc(100dvh - 10rem); min-height: 20rem; }
    .app-main:has(.cash-calendar-workspace) { display: block; }
    .app-main:has(.cash-calendar-workspace) > .space-y-6,
    .app-main:has(.cash-calendar-workspace) > .space-y-6 > .space-y-4 { display: block; min-height: 0; }
}

/* Закупки (Елена, 19.11: «чтобы месяц оплат был закреплен сверху»): шапка с месяцами и «Итого по списку» остаются у
   верхнего края, пока прокручивают закупки своей таблицы. Раздел и таблицы обрезают через clip: с hidden они — окна
   прокрутки, и шапка прилипала бы к ним (hidden — для браузеров без clip). Шапка прилипает к .app-main, top гасит его
   отступ (p-4 md:p-6). Линии шапки — тенью: рамки ячеек при border-collapse у закреплённой шапки не видны. */
[data-purchases-workspace] { overflow-x: hidden; overflow-x: clip; }
[data-purchases-month-group] { overflow: hidden; overflow: clip; }
[data-purchases-month-group] thead { position: sticky; top: -1rem; z-index: 2; }
[data-purchases-month-group] thead :is(th, td) { background: #f9fafb; box-shadow: inset 0 -1px var(--payflow-line); }
[data-purchases-month-group] thead [data-purchases-month] { box-shadow: inset 1px 0 var(--payflow-line), inset 0 -1px var(--payflow-line); }
[data-purchases-month-group] thead [data-purchases-total-month] { box-shadow: inset 1px 0 var(--payflow-line-soft), inset 0 -1px var(--payflow-line); }
@media (min-width: 768px) { [data-purchases-month-group] thead { top: -1.5rem; } }
/* Заказ в фокусе (Shift+Tab вверх) не остаётся под закреплённой шапкой: прокрутка оставляет над ним место на её высоту. */
[data-purchases-month-group] tbody button { scroll-margin-top: 7rem; }
