:root {
    --primary-color: var(--accent-primary);  /* legacy alias — points to design token */
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 68px;
    --sidebar-tree-width: 320px;
    --sidebar-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* No transitions during initial load */
html.no-transitions,
html.no-transitions *,
html.no-transitions *::before,
html.no-transitions *::after {
    transition: none !important;
}

/* Pre-apply sidebar state before JS runs */
html.pre-tree-mode .sidebar {
    width: var(--sidebar-tree-width) !important;
}
html.pre-tree-mode .main-content {
    margin-left: var(--sidebar-tree-width) !important;
}
html.pre-pinned .sidebar {
    width: var(--sidebar-width) !important;
}
html.pre-pinned .main-content {
    margin-left: var(--sidebar-width) !important;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-page);
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-collapsed-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--sidebar-bg-start) 0%, var(--sidebar-bg-end) 100%);
    padding: 1rem 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;
    z-index: 1000;
    transition: width var(--sidebar-transition);
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar:hover,
.sidebar.pinned {
    width: var(--sidebar-width);
}

.sidebar.tree-mode {
    width: var(--sidebar-tree-width);
}

.sidebar.tree-mode:hover {
    width: var(--sidebar-tree-width);
}

/* Sidebar resize handle */
.sidebar-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 5px;
    height: 100%;
    cursor: ew-resize;
    background: transparent;
    transition: background 0.2s;
    z-index: 1001;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle.dragging {
    background: var(--primary-color);
}

.sidebar.resizing {
    transition: none !important;
}

body.sidebar-resizing {
    cursor: ew-resize !important;
    user-select: none !important;
}

.sidebar-brand {
    color: var(--text-inverse);
    font-weight: 700;
    font-size: 1.25rem;
    padding: 0.5rem 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 1rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand .brand-icon {
    font-size: 1.5rem;
    min-width: 24px;
}

.sidebar-brand .brand-text {
    opacity: 0;
    transition: opacity var(--sidebar-transition);
}

.sidebar:hover .brand-text,
.sidebar.pinned .brand-text,
.sidebar.tree-mode .brand-text {
    opacity: 1;
}

.sidebar-brand .brand-name {
    font-size: 1.5rem;
    letter-spacing: 2px;
}

.sidebar-brand .brand-full {
    font-size: 0.65rem;
    opacity: 0.5;
    letter-spacing: 0.5px;
    display: block;
    margin-top: 2px;
}

.sidebar-brand .brand-version {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-top: 4px;
}

.sidebar-pin {
    position: absolute;
    top: 1rem;
    right: 0.75rem;
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.4);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    opacity: 0;
    transition: all 0.2s;
}

.sidebar:hover .sidebar-pin,
.sidebar.tree-mode .sidebar-pin {
    opacity: 1;
}

.sidebar-pin:hover {
    color: rgba(255,255,255,0.8);
    background: rgba(255,255,255,0.1);
}

.sidebar.pinned .sidebar-pin {
    opacity: 1;
    color: var(--primary-color);
}

.sidebar-nav {
    padding: 0;
    margin: 0;
    list-style: none;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.sidebar-nav li a i {
    font-size: 1.1rem;
    min-width: 20px;
    text-align: center;
}

.sidebar-nav li a .nav-text {
    opacity: 0;
    transition: opacity var(--sidebar-transition);
}

.sidebar:hover .nav-text,
.sidebar.pinned .nav-text,
.sidebar.tree-mode .nav-text {
    opacity: 1;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background: rgba(255,255,255,0.1);
    color: var(--text-inverse);
}

.sidebar-nav li a.active {
    border-left: 3px solid var(--primary-color);
}

.sidebar-section {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: rgba(255,255,255,0.4);
    padding: 1.5rem 1.25rem 0.5rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-section .section-text {
    opacity: 0;
    transition: opacity var(--sidebar-transition);
}

.sidebar:hover .section-text,
.sidebar.pinned .section-text,
.sidebar.tree-mode .section-text {
    opacity: 1;
}

.sidebar:not(:hover):not(.pinned):not(.tree-mode):not(.show) .sidebar-section {
    padding: 1rem 0;
    text-align: center;
}

.sidebar:not(:hover):not(.pinned):not(.tree-mode):not(.show) .sidebar-section::after {
    content: '';
    display: block;
    width: 24px;
    height: 1px;
    background: rgba(255,255,255,0.2);
    margin: 0 auto;
}

/* Tree Mode */
.sidebar-tree-toggle {
    display: none;
    padding: 0.5rem 1.25rem;
    margin-bottom: 0.5rem;
}

.sidebar-tree-toggle button {
    width: 100%;
    background: rgba(37, 99, 235, 0.2);
    border: 1px solid rgba(37, 99, 235, 0.3);
    color: var(--text-inverse);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.sidebar-tree-toggle button:hover {
    background: rgba(37, 99, 235, 0.3);
}

.sidebar-tree-toggle button.active {
    background: var(--primary-color);
}

body.estimate-page .sidebar-tree-toggle {
    display: block;
}

body.estimate-page .sidebar:hover .sidebar-tree-toggle,
body.estimate-page .sidebar.pinned .sidebar-tree-toggle,
body.estimate-page .sidebar.tree-mode .sidebar-tree-toggle {
    display: block;
}

body.estimate-page .sidebar:not(:hover):not(.pinned):not(.tree-mode):not(.show) .sidebar-tree-toggle {
    display: none;
}

.equipment-tree {
    display: none;
    padding: 0 0.5rem;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

.sidebar.tree-mode .equipment-tree {
    display: block;
}

.sidebar.tree-mode .sidebar-nav-main {
    display: none;
}

.tree-node {
    user-select: none;
}

.tree-node-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    color: rgba(255,255,255,0.8);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s;
}

.tree-node-header:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-inverse);
}

.tree-node-header .tree-icon {
    font-size: 0.75rem;
    width: 16px;
    text-align: center;
    color: rgba(255,255,255,0.5);
    transition: transform 0.2s;
}

.tree-node.expanded > .tree-node-header .tree-icon {
    transform: rotate(90deg);
}

.tree-node-header .tree-type-icon {
    font-size: 1rem;
    min-width: 18px;
}

.tree-node-header .tree-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-node-header .tree-count {
    font-size: 0.7rem;
    background: rgba(255,255,255,0.15);
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    color: rgba(255,255,255,0.6);
}

.tree-children {
    display: none;
    padding-left: 1rem;
}

.tree-node.expanded > .tree-children {
    display: block;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem 0.35rem 1.5rem;
    color: rgba(255,255,255,0.7);
    font-size: 0.8rem;
    border-radius: 4px;
    cursor: grab;
    transition: all 0.15s;
}

.tree-item:hover {
    background: rgba(37, 99, 235, 0.3);
    color: var(--text-inverse);
}

.tree-item:active {
    cursor: grabbing;
}

.tree-item.dragging {
    opacity: 0.5;
}

.tree-item .item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-item .item-price {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
}

.tree-item .item-drag-icon {
    opacity: 0.4;
    font-size: 0.75rem;
}

/* Visual flags for problem items in catalog tree:
   - zero-stock: яркий тонкий border слева (нет на складе — нечего отгружать)
   - zero-price: badge в строке (цена не выставлена)
   Видно мгновенно даже в большом списке. */
.tree-item.zero-stock {
    box-shadow: inset 3px 0 0 var(--status-danger);
}
.tree-item.zero-stock .item-stock {
    color: var(--status-danger);
    font-weight: 600;
}
.tree-item.zero-price {
    background: rgba(234, 179, 8, 0.10);
}
.tree-item.zero-price.zero-stock {
    background: rgba(239, 68, 68, 0.12);
}
.tree-item .item-flag {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    line-height: 1.3;
    flex-shrink: 0;
}
.tree-item .item-flag.flag-zero-price {
    background: var(--status-warning);
    color: #000;
}

.tree-search-results .tree-item {
    padding-left: 0.5rem;
}

.tree-search-results .search-result-type {
    font-size: 0.65rem;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    margin-left: 0.25rem;
}

.tree-search-results .search-result-type.equipment {
    background: rgba(34, 197, 94, 0.3);
    color: #86efac;
}

.tree-search-results .search-result-type.subrent {
    background: rgba(168, 85, 247, 0.3);
    color: #d8b4fe;
}

.tree-items-list {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 0.25rem;
}

.tree-search {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
}

.tree-search input {
    width: 100%;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--text-inverse);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
}

.tree-search input::placeholder {
    color: rgba(255,255,255,0.4);
}

.tree-search input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255,255,255,0.15);
}

/* Edit mode styles */
.tree-edit-toggle {
    display: none;
    padding: 0.25rem 0.5rem 0.5rem;
}

.sidebar.tree-mode .tree-edit-toggle {
    display: block;
}

.tree-edit-toggle button {
    width: 100%;
    background: rgba(168, 85, 247, 0.2);
    border: 1px solid rgba(168, 85, 247, 0.3);
    color: var(--text-inverse);
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.tree-edit-toggle button:hover {
    background: rgba(168, 85, 247, 0.3);
}

.tree-edit-toggle button.active {
    background: #a855f7;
}

.edit-mode .tree-item {
    cursor: pointer;
}

.edit-mode .tree-item .item-checkbox {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 3px;
    margin-right: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.edit-mode .tree-item.selected .item-checkbox {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.edit-mode .tree-item.selected .item-checkbox::after {
    content: "\2713";
    color: var(--text-inverse);
    font-size: 10px;
}

.edit-mode .tree-item.selected {
    background: rgba(37, 99, 235, 0.25);
}

.edit-mode .tree-item:not(.selected):hover .item-checkbox {
    border-color: rgba(255,255,255,0.7);
}

.edit-mode .tree-item .item-drag-icon {
    display: none;
}

.edit-mode .tree-node[data-type="category"].drop-target > .tree-node-header {
    background: rgba(37, 99, 235, 0.4);
    outline: 2px dashed var(--primary-color);
    outline-offset: -2px;
}

.tree-selection-info {
    display: none;
    padding: 0.5rem;
    background: rgba(37, 99, 235, 0.2);
    border-radius: 6px;
    margin: 0.5rem;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.9);
}

.tree-selection-info.visible {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tree-selection-info .selection-hint {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-left: 0.5rem;
}

.tree-selection-info button {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    color: var(--text-inverse);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
}

.tree-selection-info button:hover {
    background: rgba(255,255,255,0.1);
}

.tree-node.empty-category > .tree-node-header {
    opacity: 0.6;
}

.tree-node.empty-category > .tree-node-header .tree-name {
    font-style: italic;
}

.tree-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: rgba(255,255,255,0.5);
}

.tree-back-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin: 0.5rem;
    background: rgba(255,255,255,0.1);
    border: none;
    color: rgba(255,255,255,0.8);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.tree-back-btn:hover {
    background: rgba(255,255,255,0.2);
    color: var(--text-inverse);
}

/* Drop zones */
.drop-zone-active {
    outline: 2px dashed var(--primary-color) !important;
    outline-offset: -2px;
    background: rgba(37, 99, 235, 0.05) !important;
}

.drop-zone-hover {
    outline: 2px solid var(--primary-color) !important;
    background: rgba(37, 99, 235, 0.1) !important;
}

.drag-ghost {
    position: fixed;
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: var(--text-inverse);
    border-radius: 6px;
    font-size: 0.85rem;
    pointer-events: none;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Main content */
.main-content {
    margin-left: var(--sidebar-collapsed-width);
    padding: 2rem;
    min-height: 100vh;
    transition: margin-left var(--sidebar-transition);
}

body.sidebar-pinned .main-content {
    margin-left: var(--sidebar-width);
}

body.sidebar-tree-mode .main-content {
    margin-left: var(--sidebar-tree-width);
}

.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.card-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-default);
    padding: 1rem 1.25rem;
    border-radius: 12px 12px 0 0 !important;
}

.btn-primary {
    background: var(--primary-color);
    border: none;
}

.btn-primary:hover {
    background: var(--accent-primary-hover);
}

/* Контурная кнопка денежных экранов: краска — ТОКЕНАМИ темы (живая проверка
   24.09.2026, В7). Bootstrap красит `.btn-outline-*` фиксированными hex, не
   зависящими от темы, и в тёмной они проваливались: «Отмена» окон выплаты и
   оплаты (#6c757d) — 2,83:1, «Пополнить» бонусного счёта (#198754) — 3,23:1,
   «Вернуть клиенту» — 3,12:1. Класс ЗАМЕНЯЕТ `.btn-outline-*` на кнопке, а не
   дополняет его: надпись и рамка — одна краска `--wmr-ink`, наведение и нажатие
   заливают кнопку ею же, а надпись становится цветом карточки (как у Bootstrap).
   Глобально Bootstrap не перекрашиваем — только кнопки, которым класс дан.
   Пары «краска → поверхность» в обеих темах меряет
   tests/test_accounting_contrast.py. */
.wmr-btn-ink {
    --wmr-ink: var(--btn-quiet-ink);
    --bs-btn-color: var(--wmr-ink);
    --bs-btn-border-color: var(--wmr-ink);
    --bs-btn-hover-color: var(--bg-card);
    --bs-btn-hover-bg: var(--wmr-ink);
    --bs-btn-hover-border-color: var(--wmr-ink);
    --bs-btn-focus-box-shadow: none;
    --bs-btn-active-color: var(--bg-card);
    --bs-btn-active-bg: var(--wmr-ink);
    --bs-btn-active-border-color: var(--wmr-ink);
    --bs-btn-disabled-color: var(--wmr-ink);
    --bs-btn-disabled-bg: transparent;
    --bs-btn-disabled-border-color: var(--wmr-ink);
}
.wmr-btn-ink--success { --wmr-ink: var(--status-success-text); }
.wmr-btn-ink--primary { --wmr-ink: var(--text-link); }
/* Кольцо фокуса — ТОЙ ЖЕ краской кнопки, контуром с зазором (ревью, Minor 3). Прежде стояло
   полупрозрачное серое `--bs-btn-focus-shadow-rgb` литералом: модификаторы получали серое
   кольцо, а в тёмной slate-500 на 50 % сливался с окном. Контур с отступом отделён от
   залитой (наведённой) кнопки полосой фона, а контраст кольца к фону — контраст самой
   краски: ≥ 5,18:1 в обеих темах (пары — tests/test_accounting_contrast.py). */
/* Кнопки-ССЫЛКИ, крашенные `.wmr-ink-*` («Сторно» оплаты расхода и ✕ расхода в блоке
   «Расходы проекта»), получают ТО ЖЕ кольцо — одним правилом с `.wmr-btn-ink` (живая проверка
   24.09.2026, круг 2, хвост В7). Прежде у них оставалось кольцо Bootstrap `.btn-link` —
   полупрозрачная синяя тень, 2,02:1 / 1,84:1 к фону (тёмная / светлая), ниже 3:1. Краску
   кольца даёт тот же `--wmr-ink`: его ставит сам класс-краска (ниже). Специфичность
   `.btn.wmr-ink-*` выше `.btn:focus-visible` Bootstrap — тень снимается без `!important`. */
.btn.wmr-ink-success:focus-visible,
.btn.wmr-ink-danger:focus-visible,
.wmr-btn-ink:focus-visible { outline: 2px solid var(--wmr-ink); outline-offset: 2px; box-shadow: none; }
/* Та же краска для текста денег (бонусный баланс, строки движений): `.text-success`
   Bootstrap — тот же фиксированный #198754, 3,23:1 в тёмной.
   ⚠️ `!important` — как у текстовых утилит Bootstrap, и по той же причине: ячейку таблицы
   Bootstrap красит правилом `.table > :not(caption) > * > *` (специфичность выше класса), и без
   него сумма движения бонусного счёта печаталась чёрным — замер пикселями 24.09.2026.
   Краска — через `--wmr-ink`, как у `.wmr-btn-ink`: её же берёт кольцо фокуса выше. */
.wmr-ink-success { --wmr-ink: var(--status-success-text); color: var(--wmr-ink) !important; }
.wmr-ink-danger { --wmr-ink: var(--status-danger-text); color: var(--wmr-ink) !important; }

/* Ряд KPI фокус-экранов Бухгалтерии (сотрудник, клиент): сетка с ФИКСИРОВАННЫМ числом
   колонок (живая проверка 24.09.2026, В5). Флекс с переносом (`flex: 1 1 150px`) на
   768–991 px клал пять карточек 4+1 и растягивал пятую «Проектов» на всю строку (797 px
   на 900, 665 px на 768). Механика та же, что у шапки Казны (`.tr-overview`): число колонок
   решает ширина САМОГО ряда (`@container`), а не окна — у страницы есть сайдбар. Колонок
   2 → 3 → 5: карточка занимает свою клетку, а не строку, при любом числе карточек (у
   сотрудника их от четырёх до семи); порог 880 — тот же, что у Казны.
   ⚠️ Контейнер — обёртка, а не сам ряд: запрос стилизует ПОТОМКОВ контейнера. И не корень
   страницы: `container-type` включает layout containment, и окна выплаты/оплаты
   (`position: fixed`) внутри корня позиционировались бы от него, а не от окна браузера.
   Карточка сама — контейнер: число в ней страница вписывает `min(<потолок>, 12cqi)`. */
.wmr-kpi-grid { container: wmr-kpi-grid / inline-size; margin: 12px 0; }
.wmr-kpi-cells { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wmr-kpi-cells > * { min-width: 0; container-type: inline-size; }
@container wmr-kpi-grid (min-width: 520px) {
    .wmr-kpi-cells { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@container wmr-kpi-grid (min-width: 880px) {
    .wmr-kpi-cells { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* Сумма в таблице денег: зазор до соседней колонки справа. Сумма выровнена вправо, а
   соседняя колонка (счёт, «кто») — влево, и без зазора строка читалась одной фразой:
   «5 000 ₽ Касса», заголовки «СУММА СЧЁТ» (живая проверка 24.09.2026, В6). */
table.table .wmr-amount-col { padding-right: 1.5rem; font-variant-numeric: tabular-nums; }

/* «История выплат» (фокус сотрудника) и «История платежей» (фокус клиента) — одна раскладка
   на обе таблицы, колонки у них одни: дата, сумма, счёт, кто, куда/проект, действия
   (живая проверка 24.09.2026, В6).
   ⚠️ Ширины — по СОДЕРЖИМОМУ, а не фиксированные: прежние 110+120+140+180+96 px на 768
   сжимали «Куда пошло» до слова на строку, а широкая «Кто провёл» стояла почти пустой.
   Короткие колонки не переносятся, пятая забирает остаток.
   ⚠️ Уже 800 px (ширина САМОЙ таблицы, `@container`, а не окна) строка становится
   карточкой: слева дата, счёт и «кто», в середине «куда», справа сумма и действия. Уже
   560 px «куда» уходит под них на всю ширину (в три колонки ей досталось бы меньше 220 px). Порог — по «куда»: таблица отдаёт ей всё,
   что осталось от пяти колонок по содержимому (~530–550 px с иконками действий), и на
   720–800 px ей доставалось 170–250 px — «Межгалактический» вставал отдельной строкой.
   Замер с Bootstrap Icons (фикс-раунд 1 ревью): на пороге «куда» ≈ 260 px, колонка
   действий не выходит за край ни в одном режиме сайдбара. Таблица на 390 px была обрезана справа: прокрутка внутри прятала деньги
   за край. Подпись «кто» задаёт страница: `--wmr-who-label` («провёл»/«принял»).
   ⚠️ Метки внутри «куда» (`.sf-badge`, `.cf-badge`) — `inline-block` на странице: у
   строчной метки вплотную к тексту нет места переноса, и «25 000 ₽ одной операцией»
   становилось одним неразрывным куском шире колонки. */
.wmr-pay-history-wrap { container: wmr-pay-history / inline-size; }
/* Зазор между колонками — .75rem справа у каждой: «Расчётный счёт Коулсон Д.А.» без него
   читалось той же одной фразой, что и «5 000 ₽ Касса». */
table.wmr-pay-history th, table.wmr-pay-history td { white-space: nowrap; padding-right: .75rem; }
/* `overflow-wrap: anywhere` — длинный неразрывный токен (ссылка, имя без пробелов) иначе
   раздвигал бы таблицу, а в сложенной строке вылезал поверх суммы: у `minmax(0, 1fr)` с
   `min-width: 0` переполнение видимое. `anywhere`, а не `break-word`: только он уменьшает
   min-content, по которому таблица делит ширину. */
table.wmr-pay-history th:nth-child(5), table.wmr-pay-history td:nth-child(5) { white-space: normal; width: 100%; overflow-wrap: anywhere; }
table.wmr-pay-history td[colspan] { white-space: normal; }
@container wmr-pay-history (max-width: 799.98px) {
    table.wmr-pay-history, table.wmr-pay-history tbody { display: block; }
    table.wmr-pay-history thead {
        position: absolute; width: 1px; height: 1px; overflow: hidden;
        clip: rect(0 0 0 0); white-space: nowrap;
    }
    table.wmr-pay-history tr {
        /* Левая колонка — ОДНОЙ ширины у всех строк: каждая строка — своя сетка, и по
           содержимому «куда» начиналось бы в каждой строке с разного места. */
        display: grid; grid-template-columns: 12rem minmax(0, 1fr) auto;
        column-gap: 16px; row-gap: 2px; padding: .5rem .25rem;
        background-color: var(--bs-table-bg);
        border-bottom: 1px solid var(--border-default);
    }
    table.wmr-pay-history td {
        display: block; padding: 0; border: 0; box-shadow: none; background: transparent;
        white-space: normal; min-width: 0;
    }
    table.wmr-pay-history td:nth-child(1) { grid-column: 1; grid-row: 1; }
    table.wmr-pay-history td:nth-child(2) { grid-column: 3; grid-row: 1; padding-right: 0; font-weight: 600; white-space: nowrap; text-align: right; }
    table.wmr-pay-history td:nth-child(3) { grid-column: 1; grid-row: 2; color: var(--text-secondary); }
    table.wmr-pay-history td:nth-child(3)::before { content: 'счёт\00a0'; }
    table.wmr-pay-history td:nth-child(4) { grid-column: 1; grid-row: 3; color: var(--text-secondary); }
    table.wmr-pay-history td:nth-child(4)::before { content: var(--wmr-who-label, none); }
    table.wmr-pay-history td:nth-child(5) { grid-column: 2; grid-row: 1 / 4; width: auto; overflow-wrap: anywhere; }
    table.wmr-pay-history td:nth-child(6) { grid-column: 3; grid-row: 2 / 4; align-self: start; text-align: right; }
    table.wmr-pay-history td[colspan] { grid-column: 1 / -1; grid-row: auto; text-align: center; }
}
@container wmr-pay-history (max-width: 559.98px) {
    table.wmr-pay-history tr { grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; }
    table.wmr-pay-history td:nth-child(2) { grid-column: 2; }
    table.wmr-pay-history td:nth-child(5) { grid-column: 1 / -1; grid-row: 4; overflow-wrap: anywhere; }
    table.wmr-pay-history td:nth-child(6) { grid-column: 2; }
    table.wmr-pay-history td[colspan] { grid-column: 1 / -1; grid-row: auto; }
}

.table th {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.alert {
    border: none;
    border-radius: 8px;
}

.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--border-strong);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s, width var(--sidebar-transition);
        width: var(--sidebar-width);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar.tree-mode {
        width: 100%;
    }

    /* Открытая панель обязана быть раскрытой. Подписи держались на :hover,
       которого пальцем не вызвать, а скрепка на мобиле скрыта — панель
       выезжала на 240px «рейлом»: иконки у края, разделы чёрточками. */
    .sidebar.show .brand-text,
    .sidebar.show .nav-text,
    .sidebar.show .section-text {
        opacity: 1;
    }

    /* гамбургер лежит поверх шапки панели — уводим логотип из-под него */
    .sidebar-brand {
        padding-top: 2.75rem;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .mobile-toggle {
        display: block !important;
    }

    .sidebar-pin {
        display: none;
    }
}

.mobile-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--primary-color);
    color: var(--text-inverse);
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* ============================================
   Responsive: Tablets & Small Screens
   ============================================ */
@media (max-width: 767.98px) {
    /* Tables: horizontal scroll on mobile */
    .table-responsive-custom {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Cards: full-width, less padding */
    .card {
        border-radius: 8px;
    }
    .card-body {
        padding: 0.75rem;
    }

    /* Forms: larger touch targets */
    .form-control, .form-select, .btn {
        min-height: 42px;
        font-size: 0.95rem;
    }

    /* Modals: full-screen on mobile */
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        min-height: 100vh;
    }
    .modal-content {
        border-radius: 0;
        min-height: 100vh;
    }

    /* Badge + small elements */
    .badge {
        font-size: 0.75rem;
        padding: 0.35em 0.5em;
    }

    /* Project header: stack vertically */
    .project-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    /* Gantt: horizontal scroll */
    .gantt-card {
        overflow-x: auto;
    }

    /* Selection toolbar: compact on mobile */
    .selection-toolbar {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    .selection-toolbar select,
    .selection-toolbar input {
        font-size: 0.8rem;
        min-height: 36px;
    }

    /* Date cards: smaller */
    .date-card {
        padding: 0.5rem;
    }

    /* Finance section */
    .finance-row {
        flex-wrap: wrap;
    }

    /* Staff cards */
    .staff-row {
        flex-wrap: wrap;
    }

    /* Toast notifications */
    .toast-container {
        max-width: 90vw;
    }

    /* Bottom safe area for phones */
    .main-content {
        padding-bottom: env(safe-area-inset-bottom, 20px);
    }
}

/* Extra small screens (phones) */
@media (max-width: 575.98px) {
    .main-content {
        padding: 0.5rem;
    }

    h1, .h1 { font-size: 1.4rem; }
    h2, .h2 { font-size: 1.2rem; }
    h3, .h3 { font-size: 1.1rem; }

    /* Estimate item rows: more compact */
    .item-row td {
        padding: 0.35rem 0.25rem;
        font-size: 0.85rem;
    }

    /* Hide less-important columns on phone */
    .d-phone-none {
        display: none !important;
    }
}

/* Тач-устройства: раскрытие сайдбара — только явным действием.
   :hover после тапа «залипает», и панель разъезжалась до 240px поверх
   контента сама по себе, пока человек не ткнёт мимо. Ниже 992px раскрытие
   даёт класс .show (кнопка-гамбургер), выше — закрепление (.pinned),
   поэтому оба состояния из правил исключены. */
@media (hover: none) {
    .sidebar:hover:not(.pinned):not(.tree-mode):not(.show) {
        width: var(--sidebar-collapsed-width);
    }

    .sidebar:hover:not(.pinned):not(.tree-mode):not(.show) .brand-text,
    .sidebar:hover:not(.pinned):not(.tree-mode):not(.show) .nav-text,
    .sidebar:hover:not(.pinned):not(.tree-mode):not(.show) .section-text,
    .sidebar:hover:not(.pinned):not(.tree-mode):not(.show) .sidebar-pin {
        opacity: 0;
    }

    .sidebar:hover:not(.pinned):not(.tree-mode):not(.show) .quick-nav {
        display: none;
    }

    body.estimate-page .sidebar:hover:not(.pinned):not(.tree-mode):not(.show) .sidebar-tree-toggle {
        display: none;
    }

    .sidebar:hover:not(.pinned):not(.tree-mode):not(.show) .sidebar-section {
        padding: 1rem 0;
        text-align: center;
    }

    .sidebar:hover:not(.pinned):not(.tree-mode):not(.show) .sidebar-section::after {
        content: '';
        display: block;
        width: 24px;
        height: 1px;
        background: rgba(255,255,255,0.2);
        margin: 0 auto;
    }
}

/* Планшет в альбоме: гамбургера здесь не было вовсе, а скрепка проявлялась
   тем же :hover — раскрыть панель пальцем было нечем. Кнопка видима и
   закрепляет панель рядом с контентом, а не поверх него. */
@media (hover: none) and (min-width: 992px) {
    .mobile-toggle {
        display: block;
    }

    .sidebar-brand {
        padding-top: 2.75rem;
    }
}

/* Затемнение под выехавшей панелью: тап мимо неё закрывает меню. */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

@media (max-width: 991.98px) {
    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Touch device optimizations */
@media (hover: none) {
    /* Larger click targets */
    .btn-sm {
        min-height: 36px;
        min-width: 36px;
    }

    /* Remove hover-only effects */
    .editable:hover {
        background: inherit;
    }

    /* Better scrolling */
    .table-responsive-custom {
        -webkit-overflow-scrolling: touch;
    }
}

/* ══════════════════════════════════════════════════════════
   TOPBAR ROW — вкладки «последних проектов» + слот страницы
   Живёт в base.html. Если блок `topbar_actions` пуст (а он пуст
   почти везде), ряд рендерится ровно как раньше: единственный
   ребёнок растягивается на всю ширину, высота не меняется.
   ══════════════════════════════════════════════════════════ */
.topbar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.topbar-row > #recentProjects {
    flex: 1 1 auto;
    min-width: 0;
}

/* ══════════════════════════════════════════════════════════
   RECENT PROJECTS bar — closed-tab style bookmark widget
   Lives in base.html, rendered on every page. Persists list
   in localStorage. Tabs touch each other like browser bookmarks.
   ══════════════════════════════════════════════════════════ */
.recent-projects-bar {
    display: flex;
    align-items: stretch;
    gap: 2px;
    flex-wrap: wrap;
    font-size: 12px;
    margin-bottom: 4px;
}
.recent-projects-bar__icon {
    display: inline-flex;
    align-items: center;
    color: var(--text-tertiary);
    font-size: 13px;
    padding: 0 6px 0 2px;
}
.recent-tab {
    display: inline-flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: 6px 6px 2px 2px;
    transition: all var(--transition-fast);
    overflow: hidden;
}
.recent-tab:hover {
    background: var(--bg-subtle);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}
.recent-tab__link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 4px 4px 10px;
    color: var(--text-secondary);
    text-decoration: none;
    white-space: nowrap;
}
.recent-tab__link:hover {
    color: var(--text-primary);
}
.recent-tab__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    /* background-color set inline from status (data-driven) */
}
.recent-tab--current .recent-tab__dot {
    background-color: var(--status-success-strong) !important;
    box-shadow: 0 0 0 2px rgba(22,163,74,.2);
}
.recent-tab--current .recent-tab__link { font-weight: 700; }
.recent-tab__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0 7px 0 4px;
    color: var(--text-tertiary);
    font-size: 13px;
    line-height: 1;
    opacity: 0;
    transition: opacity var(--transition-fast), color var(--transition-fast);
}
.recent-tab:hover .recent-tab__close {
    opacity: 1;
}
.recent-tab__close:hover {
    color: var(--status-danger);
}

/* ══════════════════════════════════════════════════════════
   THEME PICKER — radio cards in profile/settings
   ══════════════════════════════════════════════════════════ */
.theme-picker__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.theme-card {
    display: block;
    cursor: pointer;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 12px;
    background: var(--bg-card);
    transition: all var(--transition-fast);
    margin: 0;
    user-select: none;
}
.theme-card:hover {
    border-color: var(--border-strong);
}
.theme-card:has(input:checked) {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary-soft);
}
.theme-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.theme-card__preview {
    display: flex;
    gap: 4px;
    height: 44px;
    border-radius: var(--radius-md);
    padding: 6px;
    margin-bottom: 8px;
    border: 1px solid var(--border-subtle);
}
.theme-card__preview--classic { background: #f8fafc; }
.theme-card__preview--linear { background: #fafafa; }
.theme-card__swatch {
    flex: 1;
    border-radius: 3px;
}
.theme-card__name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}
.theme-card__hint {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* === Quick Nav === */
.quick-nav {
    position: relative;
    margin: 0 12px 12px;
}
.quick-nav-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    pointer-events: none;
}
.quick-nav-input {
    width: 100%;
    padding: 8px 36px 8px 32px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
    outline: none;
    transition: background 120ms, border-color 120ms;
}
.quick-nav-input:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
}
.quick-nav-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}
.quick-nav-shortcut {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    padding: 1px 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 10px;
    font-family: -apple-system, system-ui, sans-serif;
    pointer-events: none;
}
.quick-nav-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 400px;
    overflow-y: auto;
    background: #1f2937;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 1100;
    padding: 4px 0;
}
.quick-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
}
.quick-nav-item:hover,
.quick-nav-item.is-active {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}
.quick-nav-item i {
    flex-shrink: 0;
    width: 16px;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
}
.quick-nav-item .quick-nav-text {
    flex: 1;
    min-width: 0;
}
.quick-nav-item .quick-nav-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.quick-nav-item .quick-nav-title mark {
    background: rgba(250, 204, 21, 0.3);
    color: #fde68a;
    padding: 0 1px;
    border-radius: 2px;
}
.quick-nav-item .quick-nav-category {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.quick-nav-empty {
    padding: 16px;
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 12px;
}
.quick-nav-empty i {
    margin-right: 6px;
}
.sidebar:not(.pinned):not(:hover):not(.show) .quick-nav,
.sidebar.tree-mode .quick-nav {
    display: none;
}

/* WMRLinkify — кликабельные ссылки в свободном тексте (примечания/комментарии).
   Контейнер переносит длинные URL без пробелов, сама ссылка может рваться где угодно. */
.wmr-linkify {
    overflow-wrap: anywhere;
    word-break: break-word;
}
a.wmr-link {
    color: var(--text-link);
    text-decoration: underline;
    word-break: break-all;
}
a.wmr-link:hover {
    color: var(--accent-primary-hover);
}

/* ── Баннеры-оповещения (общий ствол static/js/common/alert_banner.js) ────────
   Разметка — templates/includes/_alert_banner.html + _alert_chip.html.
   Потребители: федеративная субаренда и гостевой портал витрины.
   Цвета баннера — плотные заливки под белый текст, поэтому одинаковы в светлой
   и тёмной теме и в переливке dark-classic.css не участвуют. */
#wmr-banner-stack {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    pointer-events: none;   /* пустой стек не должен перехватывать клики */
}
#wmr-banner-stack > * {
    pointer-events: auto;
}
.wmr-alert-banner {
    /* Видимостью управляет модуль классом `.is-open`, а НЕ инлайновым
       `style.display`: правило класса перебило бы снятый инлайн, и баннер
       остался бы невидимым. */
    display: none;
    color: #fff;
    padding: 8px 16px;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.wmr-alert-banner__inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.wmr-alert-banner__msg {
    flex: 1;
}
.wmr-alert-banner__collapse,
.wmr-alert-banner__action {
    color: #fff;
    flex-shrink: 0;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 16px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.14);
}
.wmr-alert-banner__collapse {
    padding: 4px 13px;
    font-size: 13px;
}
.wmr-alert-banner__action {
    padding: 3px 12px;
    font-size: 12px;
    margin-left: 14px;
}
.wmr-alert-banner__collapse:hover,
.wmr-alert-banner__action:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.26);
}
.wmr-alert-banner__link {
    color: #fff;
    text-decoration: underline;
    font-weight: 600;
}
.wmr-alert-banner__link:hover {
    color: #fff;
}
.wmr-alert-banner__sep {
    margin: 0 10px;
    opacity: 0.6;
}

#wmr-chip-stack {
    position: fixed;
    top: 10px;
    /* Отступ справа = ширина переключателя темы (34px) + зазор: до выноса
       общего ствола свёрнутый чип федерации стоял ровно на нём и перехватывал
       клик по нему. Со вторым чипом это стало видно сразу. */
    right: 58px;
    z-index: 9998;
    display: flex;
    flex-direction: row-reverse;   /* первый в разметке остаётся у правого края */
    gap: 8px;
    pointer-events: none;
}
.wmr-alert-banner.is-open {
    display: block;
}
.wmr-alert-chip {
    display: none;
    color: #fff;
    padding: 5px 11px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    user-select: none;
    pointer-events: auto;
}
.wmr-alert-chip.is-open {
    display: block;
}

/* Тона. Значения — те же, что были инлайном у федеративного баннера. */
.wmr-alert-banner[data-tone="blue"],
.wmr-alert-chip[data-tone="blue"] { background: #1d4ed8; }
.wmr-alert-banner[data-tone="red"],
.wmr-alert-chip[data-tone="red"] { background: #b91c1c; }
.wmr-alert-banner[data-tone="sky"],
.wmr-alert-chip[data-tone="sky"] { background: #0369a1; }
.wmr-alert-banner[data-tone="amber"],
.wmr-alert-chip[data-tone="amber"] { background: #b45309; }
.wmr-alert-banner[data-tone="violet"],
.wmr-alert-chip[data-tone="violet"] { background: #6d28d9; }

/* Попап `.wcp-*` (отмена проекта, причина сторно) — static/css/wcp_dialog.css: его грузят и base.html, и мобильные страницы. */

/* Денежное поле: видимый отказ независимо от классов Bootstrap.
   ⚠️ Bootstrap рисует `.is-invalid` ТОЛЬКО на `.form-control`/`.form-select`/
   `.form-check-input`, а переведённые поля живут и без этих классов
   (`#ltpPrice`, `#searchQtyPrice`, `.sr-price-edit-input`, инлайн-редактор
   каталога) — у них подсветка ствола была НЕВИДИМОЙ, то есть отказ выглядел
   как «не нажалось». Правило узкое: только поля, помеченные денежными. */
[data-money-input].is-invalid {
    border-color: var(--status-danger-text, #dc3545) !important;
    background-color: rgba(220, 53, 69, 0.06);
}

/* Поиск по настройкам (права роли, карточки модулей) — static/js/settings_search.js.
   Цвета только токенами: подсветка обязана читаться и в тёмной теме. */
.settings-search-box {
    position: relative;
    flex: 1 1 auto;
    max-width: 340px;
}
.settings-search-icon {
    position: absolute;
    left: .6rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: .8rem;
    color: var(--text-tertiary);
    pointer-events: none;
}
.settings-search-input { padding-left: 1.9rem; padding-right: 1.9rem; }
/* Нативный крестик webkit убираем: он чистит поле мимо нашего обработчика. */
.settings-search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.settings-search-clear {
    position: absolute;
    right: .35rem;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--text-tertiary);
    line-height: 1;
    padding: .2rem .3rem;
    font-size: .7rem;
    cursor: pointer;
}
.settings-search-clear:hover { color: var(--text-primary); }
/* Совпавшая вложенная настройка внутри показанной карточки. */
.settings-search-hit {
    background: var(--accent-primary-soft);
    box-shadow: inset 2px 0 0 var(--accent-primary);
    border-radius: 4px;
}

/* ── Островок «Примерка роли» ────────────────────────────────────────────
   Механика один в один с Ревизором (.proebot в estimates.css): пилюля +
   панель, column-reverse, `--flip`/`--left` при перетаскивании. Расхождение
   поведения двух плавающих виджетов путало бы сильнее, чем экономия строк.
   Дефолт — правый низ НАД Ревизором (тот сидит на bottom:134px и высок ~34px),
   чтобы на странице сметы два островка не легли друг на друга. */
.rolepv {
    position: fixed;
    right: 18px;
    bottom: 186px;
    z-index: 1045;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    align-items: flex-end;
}
.rolepv[hidden] { display: none; }
.rolepv--flip { flex-direction: column; }
.rolepv--left { align-items: flex-start; }
.rolepv--dragging { transition: none; }

.rolepv-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border-default);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
    font-size: 13px;
    cursor: grab;
    user-select: none;
    touch-action: none;
    max-width: 260px;
    transition: border-color .15s ease, color .15s ease;
}
.rolepv-pill:hover { border-color: var(--accent-primary); color: var(--text-primary); }
.rolepv--dragging .rolepv-pill { cursor: grabbing; }
.rolepv-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* «Сообщить об ошибке» под пилюлей островка (bugreports/_floating_link.html).
   В обычном положении (column-reverse, островок держится за НИЗ) строка висит
   абсолютом под корнем: размер корня не меняется, и расчёт позиции пилюли при
   перетаскивании (`applyPos`) остаётся верным. Островок у верха (`--flip`,
   держится за ВЕРХ) — строка встаёт в поток сразу после пилюли, до панели. */
.bugreport-float-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-default);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
    font-size: 12px;
    white-space: nowrap;
    text-decoration: none;
}
.bugreport-float-link:hover { border-color: var(--accent-primary); color: var(--text-primary); }
.rolepv > .bugreport-float-link { position: absolute; top: calc(100% + 6px); right: 0; }
.rolepv--left > .bugreport-float-link { right: auto; left: 0; }
.rolepv--flip > .bugreport-float-link { position: static; order: -1; }
.rolepv--flip > .rolepv-pill { order: -2; }
/* У кого островка нет — строка на его месте по умолчанию (над Ревизором сметы). */
.bugreport-float { position: fixed; right: 18px; bottom: 186px; z-index: 1045; }

/* Всплывающая форма отчёта (bugreports/_panel.html) — рядом со строкой, которая её открыла; место
   считает panel.js. Вид — как у панели примерки роли. */
.bugreport-panel {
    position: fixed;
    z-index: 1046;
    width: min(380px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    display: flex;
    flex-direction: column;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .18);
}
.bugreport-panel[hidden] { display: none; }
.bugreport-panel-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-default);
    font-weight: 600;
    font-size: 13px;
}
.bugreport-panel-title { margin-right: auto; }
.bugreport-panel-head { cursor: grab; user-select: none; touch-action: none; }
.bugreport-float-link { touch-action: none; }
.rolepv--dragging .bugreport-float-link, .bugreport-float--dragging .bugreport-float-link { cursor: grabbing; }
.bugreport-panel-close { border: 0; background: none; color: var(--text-secondary); font-size: 18px; line-height: 1; }
/* Середина прокручивается, низ с кнопками закреплён: при десяти снимках и длинном тексте кнопка
   отправки уезжала за нижний край экрана (замечено владельцем 17.09). `min-height: 0` обязателен —
   без него элемент flex не сжимается ниже своего содержимого и прокрутке неоткуда взяться. */
.bugreport-panel-form { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.bugreport-panel-body { overflow-y: auto; min-height: 0; padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
/* ⚠️ Содержимое середины НЕ сжимается: у элементов flex `flex-shrink: 1` по умолчанию, и при полной
   высоте панели раскладка ужимала поля обратно. Замер на стенде 17.09: браузер ставил полю
   `height: 175px` после растягивания за уголок, а показанная высота оставалась 31 px — в обоих
   браузерах. Прокрутка у середины есть, ужимать содержимое незачем. */
.bugreport-panel-body > * { flex-shrink: 0; }
.bugreport-panel-foot { display: flex; flex-direction: column; gap: 6px; padding: 8px 12px 10px;
    border-top: 1px solid var(--border-default); background: var(--bg-elevated); border-radius: 0 0 12px 12px; }
.bugreport-panel-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin: 2px 0 0; }
.bugreport-panel-hint { font-size: 11.5px; color: var(--text-secondary); }
.bugreport-panel-warn { font-size: 11.5px; border-radius: 6px; padding: 4px 8px; background: var(--status-warning-soft); color: var(--status-warning-text); }
.bugreport-panel-preview { font-size: 12px; }
.bugreport-panel-preview summary { cursor: pointer; color: var(--text-secondary); }
.bugreport-panel-done { font-size: 12.5px; border-radius: 6px; padding: 6px 8px; background: var(--status-success-soft); color: var(--status-success-text); }
.bugreport-panel .br-shots { display: flex; flex-wrap: wrap; gap: 6px; }
.bugreport-panel .br-shots figure { position: relative; margin: 0; }
.bugreport-panel .br-shots img { width: 96px; height: 64px; object-fit: cover; border: 1px solid var(--border-default); border-radius: 6px; display: block; }
.bugreport-panel .br-shots figcaption { font-size: 10.5px; color: var(--text-secondary); max-width: 96px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bugreport-panel .br-shots button { position: absolute; top: 2px; right: 2px; line-height: 1; padding: 0 5px; }

/* Примерка активна — пилюля обязана кричать. Она заменила собой оранжевую
   полосу поверх страницы: индикатор нужен, полоса поверх макета — нет. */
.rolepv--on .rolepv-pill {
    border-color: var(--status-warning-text);
    background: var(--status-warning-soft);
    color: var(--status-warning-text);
    font-weight: 600;
}

/* Выход из примерки — единственная ручка, которая обязана работать без
   скриптов: в примерке человек может не иметь прав ни на одну страницу, где
   есть другой выход. Поэтому она снаружи панели и без `hidden`. */
.rolepv-exit-now {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    border-radius: 999px;
    border: 1px solid var(--status-warning-text);
    background: var(--bg-elevated);
    color: var(--status-warning-text);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}
.rolepv-exit-now:hover {
    background: var(--status-warning-soft);
    color: var(--status-warning-text);
}

.rolepv-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: var(--status-info-soft);
    color: var(--status-info-text);
}
.rolepv-badge[hidden] { display: none; }

.rolepv-panel {
    width: 360px;
    max-width: calc(100vw - 36px);
    max-height: 72vh;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-default);
    border-radius: 10px;
    background: var(--bg-elevated);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
    overflow: hidden;
}
.rolepv-panel[hidden] { display: none; }

.rolepv-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--border-default);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.rolepv-head-title { flex: 1 1 auto; }
.rolepv-refresh {
    flex: 0 0 auto;
    border: 1px solid var(--accent-primary);
    background: var(--accent-primary-soft);
    color: var(--accent-primary);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.rolepv-refresh[hidden] { display: none; }
.rolepv-close {
    flex: 0 0 auto;
    border: 0;
    background: none;
    color: var(--text-tertiary);
    cursor: pointer;
    line-height: 1;
    padding: 0;
}
.rolepv-close:hover { color: var(--text-primary); }

.rolepv-body { overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; min-height: 0; }
.rolepv-select {
    width: 100%;
    font-size: .82rem;
    padding: 5px 6px;
    border-radius: 6px;
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    background: var(--bg-card);
}
.rolepv-hint {
    font-size: .68rem;
    line-height: 1.35;
    color: var(--text-tertiary);
    margin-top: 6px;
}

.rolepv-perms { margin-top: 10px; border-top: 1px solid var(--border-default); padding-top: 8px; }
.rolepv-perms[hidden] { display: none; }
.rolepv-search {
    width: 100%;
    font-size: .78rem;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-default);
    background: var(--bg-card);
    color: var(--text-primary);
}
.rolepv-perms-body { margin-top: 6px; }

.rolepv-section { border-radius: 6px; margin-bottom: 2px; }
.rolepv-section[hidden] { display: none; }
.rolepv-section-head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: 6px;
}
.rolepv-section-head:hover { background: var(--bg-subtle); }
.rolepv-section-title { flex: 1 1 auto; }
.rolepv-section-count { color: var(--text-tertiary); font-weight: 400; font-size: 11px; }
.rolepv-section-hint {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-tertiary);
    padding: 0 6px 4px 20px;
}
.rolepv-section-items { padding: 2px 0 6px 20px; }
.rolepv-section-items[hidden] { display: none; }

.rolepv-perm {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    padding: 3px 6px 3px 0;
    font-size: 12px;
    line-height: 1.3;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 4px;
}
.rolepv-perm[hidden] { display: none; }
.rolepv-perm:hover { background: var(--bg-subtle); }
.rolepv-perm input { margin-top: 2px; flex: 0 0 auto; }
.rolepv-perm-label { flex: 1 1 auto; }
/* Право отличается от того, что записано в роли, — это и есть «нащёлкано». */
.rolepv-perm--dirty .rolepv-perm-label { color: var(--accent-primary); font-weight: 600; }
.rolepv-perm-desc { display: block; font-size: 11px; color: var(--text-tertiary); font-weight: 400; }

.rolepv-empty { padding: 10px 6px; font-size: 12px; color: var(--text-tertiary); text-align: center; }

.rolepv-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 12px;
    border-top: 1px solid var(--border-default);
    background: var(--bg-subtle);
}
.rolepv-foot[hidden] { display: none; }
.rolepv-btn {
    border: 1px solid var(--border-default);
    background: var(--bg-card);
    color: var(--text-secondary);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    text-decoration: none;
}
.rolepv-btn:hover { border-color: var(--accent-primary); color: var(--text-primary); }
.rolepv-btn[hidden] { display: none; }
.rolepv-btn[disabled] { opacity: .5; cursor: default; }
.rolepv-btn--commit {
    flex: 1 1 auto;
    border-color: var(--status-warning-text);
    color: var(--status-warning-text);
    font-weight: 600;
}
.rolepv-btn--exit { margin-left: auto; }

/* Диалог подтверждения записи прав в роль. Структура — как у диалога смены
   подачи налога (образец в estimate_items.js): что происходит → почему →
   числа «было → стало» → оговорка → кнопки. Нативный confirm() здесь не
   годится: он спрашивает «уверены?», не называя, что права увидят ВСЕ
   носители роли. */
.rolepv-dlg-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, .38);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.rolepv-dlg {
    width: 420px;
    max-width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .25);
    padding: 20px 22px;
}
.rolepv-dlg-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.rolepv-dlg-body { font-size: 13px; line-height: 1.45; color: var(--text-secondary); margin: 8px 0 0; }
.rolepv-dlg-nums {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 12px;
    margin-top: 14px;
    font-size: 22px;
    font-weight: 700;
}
.rolepv-dlg-was { text-decoration: line-through; color: var(--text-tertiary); }
.rolepv-dlg-now { color: var(--accent-primary); }
.rolepv-dlg-caption { text-align: center; font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.rolepv-dlg-note {
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-tertiary);
    background: var(--bg-subtle);
    border-radius: 8px;
    padding: 8px 10px;
    margin: 12px 0 0;
}
.rolepv-dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Примерка роли — инструмент админа за десктопным столом, и на телефоне она
   только мешает: островок фиксирован (`position: fixed`) и ложится поверх
   контента десктопной страницы, открытой с телефона (жалоба 29.08.2026 —
   накрывал чекбоксы настроек календаря). Прячем ЦЕЛИКОМ, а не двигаем: под
   ним всё равно нет ни одной страницы, где примеркой пользуются с телефона —
   мобильные шаблоны standalone и base.html не наследуют вовсе. */
@media (max-width: 767.98px) {
    .rolepv { display: none; }
    /* На узком экране «Сообщить об ошибке» — только в боковой панели и кабинете: плавающая строка
       накрывала бы контент так же, как островок. */
    .bugreport-float, .rolepv--on .bugreport-float-link { display: none; }

    /* ⚠️ НО ВЫХОД ОСТАЁТСЯ. Прятать целиком можно только пока примерка
       выключена: включённая подменяет права, и без ссылки человек заперт в
       чужой роли ровно там, где узкое окно, — а это не только телефон, но и
       зум 175 % на обычном мониторе (1280 px → CSS-вьюпорт 731 px) и окно,
       свёрнутое в половину экрана. Нашли «глаза человека»: правило от 29.08
       отменяло правку про выход целиком.

       Показываем ТОЛЬКО ссылку: пилюля и панель остаются скрытыми, поэтому
       жалоба, ради которой правило заводилось (островок накрывал чекбоксы),
       не возвращается — ссылка занимает одну строку в углу. */
    .rolepv--on { display: flex; }
    .rolepv--on .rolepv-pill,
    .rolepv--on .rolepv-panel { display: none; }
    .rolepv--on .rolepv-exit-now { display: inline-flex; }
}

/* ===== Лента периодов длительного проекта (спека 2026-09-26-long-term-ribbon-workflow §4, §9, §11)
   Краска — токены обеих тем; недоступное и отменённое — без opacity. Карточки — сетка с
   переносом, а не горизонтальная прокрутка: меню «⋯» (bootstrap-dropdown) обрезалось бы
   overflow-контейнером. Пары контраста — tests/test_long_term_ribbon_page.py. ===== */
.periods-strip { border: 1px solid var(--border-default); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; background: var(--bg-card); }
.periods-strip-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.periods-strip-title { font-size: 14px; font-weight: 700; color: var(--text-title); }
.periods-strip-money { font-weight: 500; font-size: 12px; color: var(--text-secondary); }
.periods-next-step { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.period-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.period-card { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 8px 10px; border: 1px solid var(--border-default); border-radius: 8px; background: var(--bg-card); }
.period-card.is-current { box-shadow: 0 0 0 2px var(--accent-primary); }
.period-card.state-cancelled { border-style: dashed; }
.period-extend-tile { border-style: dashed; justify-content: center; }
/* Шапка карточки — сетка: имя и «⋯» (всегда справа в первой строке). В имени заголовок — первой
   строкой (24 px, как высота компактной «⋯»), чип — ВСЕГДА второй, даты — следующей строкой
   карточки: даты у всех карточек на одной высоте при любой ширине (1280, 1440, 1920, 390). Чип
   в строке заголовка переносился под него только у узкой карточки (213–218 px: 1280, 1920), и
   даты соседних карточек стояли на разной высоте (живая проверка 27.09, §16 п. 15, п. 17). */
.period-card-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 4px; }
.period-card-name { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.period-card-name .period-card-title { line-height: 24px; }
.period-card-head .period-menu { display: flex; }  /* без строки-обёртки: высота = кнопке */
.period-card-head .period-menu-toggle { padding: 3px 6px; line-height: 16px; }
.period-card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); text-decoration: none; white-space: nowrap; }
.period-card-dates, .period-hint, .period-refusal { font-size: 12px; line-height: 1.35; color: var(--text-secondary); }
.period-card-money { font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
/* Чип состояния = цвет статуса его сметы в системе (`Estimate.get_status_class`, легенда
   календаря; спека §16 п. 13): «В работе» (in_work) — info, «Зарезервировано» (reserved) —
   warning, «Закрыт» (confirmed) — success. Текст — чиповые токены: `--status-info-text` и
   `--status-warning-text` на своих мягких фонах ниже AA. Пауза — нейтральный пунктир, не
   danger (пауза — не ошибка). Чип ленты и плашки сметы — один класс. */
.period-chip { font-size: 11px; font-weight: 600; border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.period-chip--draft { background: var(--chip-neutral-bg); color: var(--chip-neutral-text); }
.period-chip--current { background: var(--info-chip-bg); color: var(--info-chip-text); }
.period-chip--future { background: var(--status-warning-soft); color: var(--chip-warning-text); }
.period-chip--closed { background: var(--status-success-soft); color: var(--status-success-text); }
/* Рамка паузы съедает поле (0 7px вместо 1px 8px): высота чипа та же, и даты карточки паузы не
   опускаются на 2 px (замер финального раунда: 60 px против 58). */
.period-chip--cancelled { background: transparent; color: var(--text-secondary); border: 1px dashed var(--border-strong); padding: 0 7px; }
.period-open { font-size: 12px; color: var(--text-link); }
.period-menu { margin-left: auto; }
.period-menu-item[aria-disabled="true"] { color: var(--text-secondary); cursor: not-allowed; }
/* Меню «⋯»: причина серого пункта переносится по словам в узком меню — пункт bootstrap
   `nowrap` растягивал меню до ~650 px поверх соседних карточек, на 390 px текст обрезался. */
.period-menu .dropdown-menu { max-width: min(320px, 90vw); }
.period-menu .period-refusal { white-space: normal; overflow-wrap: break-word; }
.period-plate { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 6px 12px; margin-bottom: 12px; border-bottom: 1px solid var(--border-default); background: var(--bg-card); font-size: 13px; }
.period-plate-text { color: var(--text-primary); }
.period-plate-line, .period-plate-warn, .period-plate-error { flex-basis: 100%; font-size: 12px; }
.period-plate-warn { color: var(--chip-warning-text); }
.period-plate-error { color: var(--status-danger-text); }
.period-schedule-link { font-size: 11px; color: var(--text-link); margin-right: 6px; white-space: nowrap; }
