/**
 * table-layout.css — унифицированные стили таблиц Marketplace-Assist
 * Эталон: /pricing/
 * Подключать во ВСЕХ страницах с :is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) (analytics, assembly-sort, advertising,
 * returns, price-alerts, my-expenses, payroll).
 *
 * Принципы:
 *  • Sticky ТОЛЬКО на th, НИКОГДА на thead
 *  • Num-колонки: label + controls-stack (absolute right:0) + (опционально) toggle
 *  • 3 режима ширины справа:
 *    1) Standalone (нет toggle)   → th-inner 20px, controls right:0      → td 28px
 *    2) Aggregate (свёрнутая+▸)   → th-inner 44px, controls right:24     → td 52px
 *    3) Group-child (раскрытая)   → th-inner 38px, controls right:0      → td 46px
 *  • Треугольник раскрытия: font-size 22px (крупный), width/height 20×20
 *  • Каждый th должен иметь title=hint (tooltip через браузер)
 */

/* === Core table === */
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th { position: sticky; top: 0; z-index: 18; background: var(--surface); padding: 17px 4px 17px 10px; font-size: 11px; font-weight: 600; color: var(--text); text-align: left; border-bottom: 2px solid var(--border); cursor: default; white-space: nowrap !important; user-select: none; overflow: hidden; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th:hover { background: var(--surface2); }

/* === th-inner: flex row with label + controls === */
.th-inner { display: inline-flex; align-items: center; gap: 0; width: 100%; overflow: hidden; }
.th-label { flex: 1; overflow: hidden; text-overflow: ellipsis; text-align: center; white-space: nowrap; }

/* === Sort/filter icons === */
.th-sort { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text2); flex-shrink: 0; border-radius: 2px; transition: all .15s; }
.th-sort:hover { background: rgba(110,128,247,0.12); color: var(--accent); }
.sort-active .th-sort { color: var(--accent); }
.th-sort svg { display: block; }
.th-filter { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text2); flex-shrink: 0; border-radius: 2px; transition: all .15s; }
.th-filter:hover { opacity: 1 !important; background: rgba(110,128,247,0.12); color: var(--accent); }
.th-filter.active { opacity: 1 !important; color: #fff; background: var(--accent); }
.th-filter svg { display: block; }

/* === Controls stack (вертикальный по умолчанию: sort ↕ сверху, filter ▽ снизу) === */
.th-controls-stack { display: flex; flex-direction: column; gap: 0; flex-shrink: 0; margin-left: 3px; background: var(--surface2); border-radius: 3px; padding: 1px; }
.th-controls-stack .th-sort { width: 16px; height: 13px; margin: 0; padding: 0; border-radius: 2px 2px 0 0; }
.th-controls-stack .th-filter { width: 16px; height: 13px; margin: 0; padding: 0; border-radius: 0 0 2px 2px; opacity: 0.4; border-top: 1px solid var(--border); }
.th-controls-stack .th-sort svg { width: 10px; height: 11px; }
.th-controls-stack .th-filter svg { width: 9px; height: 9px; }

/* === Column vertical borders === */
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th { border-right: none; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th::after { content: ''; position: absolute; right: 0; top: 25%; bottom: 25%; width: 1px; background: var(--border); }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th:last-child::after { display: none; }

/* === Num-колонки: 3 режима ширины справа === */
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th.num { text-align: right; padding-right: 4px; overflow: visible; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th.num .th-inner { position: relative; padding-right: 20px; overflow: visible; width: 100%; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th.num .th-label { text-align: right; flex: 1 1 0; padding-right: 4px; overflow: visible; text-overflow: clip; min-width: 0; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th.num .th-controls-stack {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%); margin: 0;
}
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th.num .th-group-toggle {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%); margin: 0;
}
/* Aggregate (свёрнутая группа с ▸): резервируем место под крупный toggle справа */
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th.num.th-aggregate .th-inner { padding-right: 44px; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th.num.th-aggregate .th-controls-stack { right: 24px; }

/* === Body cells — 3 варианта padding-right === */
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) tbody td.num { padding-right: 28px; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) tbody td.num.num-agg { padding-right: 52px; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) tbody td.num[data-group] { padding-right: 46px; }
.compact :is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) tbody td.num { padding-right: 30px !important; }
.compact :is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) tbody td.num.num-agg { padding-right: 54px !important; }
.compact :is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) tbody td.num[data-group] { padding-right: 28px !important; }

/* === Special narrow columns: img, ozonLink (globe) === */
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) td[data-col="img"], :is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) th[data-col="img"] { min-width: 52px; max-width: 52px; }
/* Глобус (ozonLink) — уже чекбокса (36px) или максимум на 10% шире (≤ 40px) */
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) td[data-col="ozonLink"], :is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) th[data-col="ozonLink"] { min-width: 30px !important; max-width: 30px !important; width: 30px !important; padding-left: 2px !important; padding-right: 2px !important; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th[data-col="ozonLink"] { text-align: center !important; padding: 4px !important; }

/* === Min-widths (можно переопределить per-page) === */
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) td, :is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) th { min-width: 110px; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) th[data-col="name"], :is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) td[data-col="name"] { min-width: 80px; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) th[data-col="sku"], :is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) td[data-col="sku"] { min-width: 80px; }

/* === Label — текст с правильным wrap/ellipsis === */
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th .th-label { overflow: visible; text-overflow: clip; }
/* Аггрегатные лейблы — pre-line, чтоб «Логистика\nи хранение» умещалось в 2 строки */
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th.th-aggregate .th-label { white-space: pre-line; line-height: 1.15; }

/* === Body cells: базовый стиль === */
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) td { padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; white-space: nowrap; overflow: hidden; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) td.num { text-align: right; font-variant-numeric: tabular-nums; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) tr:hover td { background: rgba(110,128,247,0.03); }

/* === Margin with delta (для колонки margin/profit) === */
.margin-main { display: inline-block; min-width: 48px; text-align: right; }
.margin-delta { display: inline-block; min-width: 62px; text-align: right; font-size: 11px; opacity: 0.85; margin-left: 2px; }
.ad-fact-cell { font-style: italic; color: var(--text2); }

/* === Checkbox column === */
.col-check { width: 36px; min-width: 36px; text-align: center !important; padding-left: 8px !important; }
.col-check input { cursor: pointer; }
.row-selected td { background: rgba(110,128,247,0.08) !important; }
.row-selected td.pinned { background: rgba(110,128,247,0.08) !important; }

/* === Cell colors === */
td.cell-positive { color: var(--green, #22c55e); font-weight: 700; }
td.cell-negative { color: var(--red, #ef4444); font-weight: 700; }
td.cell-warning { color: #ca8a04; font-weight: 600; }
td.cell-muted { color: var(--text2, #888); }
.heatmap-cell .cell-positive,
.heatmap-cell .cell-negative,
.heatmap-cell .cell-warning { text-shadow: 0 0 2px var(--bg); }

/* === Pin/freeze === */
td.pinned { position: sticky; left: 0; z-index: 5; background: var(--bg); }
th.pinned { z-index: 19 !important; background: var(--surface) !important; }
.pinned-shadow { box-shadow: 4px 0 8px rgba(0,0,0,0.1); clip-path: inset(0 -10px 0 0); }
tr:hover td.pinned { background: rgba(110,128,247,0.03); }

/* === Σ Итого summary row (tfoot) — sticky bottom === */
.te-tfoot { position: sticky; bottom: 0; z-index: 10; }
.te-tfoot .te-summary-row td { background: var(--surface); border-top: 2px solid var(--accent); padding: 10px; font-size: 12px; }
.te-summary-cell { color: var(--text); }
.te-summary-cell.num { text-align: right; font-variant-numeric: tabular-nums; }

/* === Column resize === */
.col-resize-handle { position: absolute; right: 0; top: 0; bottom: 0; width: 8px; cursor: col-resize; background: transparent; z-index: 5; }
.col-resize-handle:hover { background: var(--accent); }

/* === Column drag === */
.col-dragging { opacity: 0.4; }
.col-drop-left { box-shadow: inset 3px 0 0 var(--accent) !important; }
.col-drop-right { box-shadow: inset -3px 0 0 var(--accent) !important; }

/* === Per-column filter popup === */
.col-filter-popup { position: fixed; min-width: 180px; background: var(--surface, #fff); border: 1px solid var(--border, #e0e0e0); border-radius: 8px; padding: 12px; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,0.18); }
.col-filter-popup label { display: block; font-size: 11px; color: var(--text2, #888); margin-bottom: 2px; }
.col-filter-popup input { width: 100%; padding: 6px 8px; font-size: 12px; font-family: inherit; border: 1px solid var(--border, #e0e0e0); border-radius: 6px; background: var(--bg, #f5f5f5); color: var(--text, #333); margin-bottom: 6px; box-sizing: border-box; outline: none; }
.col-filter-popup input:focus { border-color: var(--accent, #6e80f7); box-shadow: 0 0 0 2px rgba(110,128,247,0.15); }
.col-filter-popup input[type="number"] { -moz-appearance: textfield; }
.col-filter-popup input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
.col-filter-popup .filter-row { display: flex; gap: 6px; }
.col-filter-popup .filter-row input { flex: 1; min-width: 0; }
.col-filter-popup button { width: 100%; padding: 5px 8px; font-size: 11px; font-family: inherit; border: 1px solid var(--border, #e0e0e0); border-radius: 6px; background: var(--surface2, #f0f0f0); color: var(--text, #333); cursor: pointer; margin-top: 2px; }
.col-filter-popup button:hover { border-color: var(--accent, #6e80f7); color: var(--accent, #6e80f7); }

/* === Heatmap === */
.heatmap-cell { position: relative; }
.heatmap-bg { position: absolute; inset: 0; z-index: 0; }
.heatmap-cell span { position: relative; z-index: 1; }

/* === Compact mode === */
.compact :is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) td { padding: 3px 6px; font-size: 12px; }
.compact :is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th { padding: 17px 6px; font-size: 10px; }
.compact td[data-col="img"], .compact th[data-col="img"] { display: none; }

/* === Name cell === */
.name-cell { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.sku-cell { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.wrap-names .name-cell { white-space: normal !important; word-break: break-word; max-width: 220px; min-width: 100px; display: inline-block !important; overflow: visible !important; text-overflow: clip !important; }
.wrap-names td[data-col="name"] { vertical-align: top; }
.compact.wrap-names .name-cell { max-width: 180px; }

/* === Summary bar === */
.summary-bar { display: flex; gap: 20px; padding: 10px 24px; font-size: 12px; color: var(--text2); background: var(--surface); border-top: 1px solid var(--border); flex-shrink: 0; position: relative; align-items: center; }
.summary-bar .sb-val { font-weight: 600; color: var(--text); }

/* === Scroll arrows === */
.scroll-arrow { position: absolute; top: 50%; transform: translateY(-50%); z-index: 15; width: 28px; height: 48px; border: none; border-radius: var(--radius-md); background: rgba(0,0,0,0.25); color: #fff; font-size: 14px; cursor: pointer; opacity: 0; transition: opacity .2s; pointer-events: none; }
.scroll-arrow.visible { opacity: 0.6; pointer-events: auto; }
.scroll-arrow:hover { opacity: 1; }
.scroll-arrow-left { left: 4px; }
.scroll-arrow-right { right: 4px; }

/* === Scroll minimap === */
.scroll-minimap { height: 6px; background: var(--surface2); border-top: 1px solid var(--border); position: relative; cursor: pointer; flex-shrink: 0; display: none; transition: height .15s; }
.scroll-minimap:hover { height: 10px; }
.scroll-minimap.visible { display: block; }
.minimap-thumb { position: absolute; top: 0; height: 100%; background: var(--accent); border-radius: 3px; opacity: 0.5; min-width: 20px; cursor: grab; }
.minimap-thumb:hover { opacity: 0.8; }

/* === Column Groups: toggle + aggregate + expanded === */
.th-group-toggle { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; cursor: pointer; color: var(--accent); font-size: 22px; line-height: 1; border-radius: 3px; flex-shrink: 0; transition: background .15s; margin-left: 4px; overflow: visible; }
.th-group-toggle:hover { background: rgba(110,128,247,0.15); }
.th-aggregate { background: var(--surface) !important; min-width: 85px; overflow: hidden; }
.th-aggregate .th-label { text-align: center; overflow: hidden; white-space: pre-line; line-height: 1.15; }
.compact .th-aggregate { min-width: 70px; }
.th-group-expanded { background: var(--surface) !important; text-align: center; border-bottom: none !important; }
[data-theme="dark"] .th-group-expanded { background: var(--surface) !important; }
.th-group-child { border-top: 2px solid var(--accent) !important; font-size: 10px !important; width: 1px; }
th.th-group-child { background: color-mix(in srgb, var(--accent) 8%, var(--surface)) !important; }
.th-group-expanded { background: color-mix(in srgb, var(--accent) 12%, var(--surface)) !important; }
/* Spurt 1 fix: статичная (non-expandable, non-fixed) группа в 2-row thead — */
/* визуально как expanded (заголовок-спаннер сверху + дочерние th снизу), но без toggle. */
.th-group-static { background: color-mix(in srgb, var(--accent) 12%, var(--surface)) !important; text-align: center; border-bottom: none !important; }
[data-theme="dark"] .th-group-static { background: color-mix(in srgb, var(--accent) 12%, var(--surface)) !important; }
.compact .th-group-static { padding: 4px 8px !important; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead tr.thead-row2 th { top: var(--row1-h, 30px); z-index: 18; background: var(--surface); }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead tr.thead-row1 th { top: 0; z-index: 18; background: var(--surface); }
.compact .th-group-child { font-size: 9px !important; padding: 4px 6px !important; }
.compact .th-group-expanded { padding: 4px 8px !important; }

/* Рамка группы: боковые границы */
td.group-first { border-left: 1px solid rgba(110,128,247,0.15); }
td.group-last { border-right: 1px solid rgba(110,128,247,0.15); }
th.group-first { border-left: 1px solid rgba(110,128,247,0.15) !important; }
th.group-last { border-right: 1px solid rgba(110,128,247,0.15) !important; }
td[data-group] { background: rgba(110,128,247,0.03); }

/* Раскрытая группа: иконки sort/filter горизонтально, прижаты к правому краю */
.th-group-child .th-controls-stack { flex-direction: row; gap: 1px; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th.th-group-child .th-label { white-space: normal !important; line-height: 1.15; font-size: 10px; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th.th-group-child { vertical-align: top; }
.th-group-child .th-controls-stack .th-sort { border-radius: 2px 0 0 2px; border-top: none; }
.th-group-child .th-controls-stack .th-filter { border-radius: 0 2px 2px 0; border-top: none; border-left: 1px solid var(--border); }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th.num.th-group-child .th-inner { padding-right: 38px; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th.num.th-group-child .th-controls-stack { right: 0; transform: translateY(-50%); }
/* Compact: вертикальные иконки 16px → padding-right = 16 + 4 + 2 = 22px */
.compact .th-group-child .th-controls-stack { flex-direction: column; gap: 0; }
.compact .th-group-child .th-controls-stack .th-sort { border-radius: 2px 2px 0 0; }
.compact .th-group-child .th-controls-stack .th-filter { border-radius: 0 0 2px 2px; border-top: 1px solid var(--border); border-left: none; }
.compact :is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th.num.th-group-child .th-inner { padding-right: 22px; }
.compact :is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table) thead th.num.th-group-child .th-controls-stack { right: 0; }

/* === Адаптивные подписи кнопок тулбара ===
   <span class="tb-full">Полный текст</span><span class="tb-compact">Кратко</span>
   На <1400px показывается tb-compact, иначе tb-full. */
.tb-btn .tb-compact { display: none; }
@media (max-width: 1399px) {
  .tb-btn .tb-full { display: none; }
  .tb-btn .tb-compact { display: inline; }
}

/* === Категории-аккордеон (опционально — используется на /pricing/ и /analytics/) === */
.cat-row td { background: var(--surface2); padding: 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.cat-row-inner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-weight: 600; font-size: 13px; }
.cat-arrow { transition: transform .2s; font-size: 12px; color: var(--text2); }
.cat-row.collapsed .cat-arrow { transform: rotate(-90deg); }
.cat-stats { display: flex; gap: 10px; margin-left: auto; font-size: 12px; font-weight: 400; color: var(--text2); }
.compact .cat-row-inner { padding: 5px 12px; font-size: 12px; }

/* ============================================================
   ADR-0017 Core — chrome для .te-table (TableEngine self-contained)
   Issue: Stage 3 Spurt 1 QA (2026-04-29) — sticky/pin-left/group-row CSS
   жил только под .lab-table селекторами; pricing-v2 рендерит
   <table class="te-table"> и не получает sticky/pin → headers убегают,
   pin:'left' не применяется. Engine должен быть self-contained: любой
   caller с .te-table получает все Core-фичи без импорта legacy-chrome.
   Sticky правило: ТОЛЬКО на <th> (ADR-0007), НИКОГДА на <thead>.
   ============================================================ */

/* === Базовая геометрия .te-table (на уровне с .lab-table семейством) ===
 * ВНИМАНИЕ: это правило дублирует base.css:566 (исторически). Источник истины
 * для всех движковых таблиц — base.css. Здесь оставляем только override-нюансы.
 * min-width:100% УБРАН (Александр 2026-05-20) — он форсил растяжение таблицы
 * до container width когда sum_declared < container, browser распределял
 * extra space пропорционально по всем колонкам ⇒ «двигается в обе стороны». */
.te-table { width: max-content; border-collapse: separate; border-spacing: 0; font-size: var(--table-font-size); }
/* Шапка = канон-высота --table-header-h (32px, эталон AG-Grid /analytics/).
   box-sizing:border-box → height точная. Раньше padding 17px давал ~48px шапку,
   расходясь с AG-Grid-эталоном и base.css. Шрифт метки 11px — намеренно. */
.te-table thead th {
  position: sticky;
  top: 0;
  z-index: 18;
  box-sizing: border-box;
  height: var(--table-header-h);
  background: var(--surface);
  padding: 4px 4px 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  border-bottom: 2px solid var(--border);
  cursor: default;
  white-space: nowrap !important;
  user-select: none;
  overflow: hidden;
}
.te-table thead th:hover { background: var(--surface2); }
.te-table thead th { border-right: none; }
.te-table thead th::after {
  content: ''; position: absolute; right: 0; top: 25%; bottom: 25%;
  width: 1px; background: var(--border);
}
.te-table thead th:last-child::after { display: none; }

/* Двухуровневый thead: row1 (группы) над row2 (дочерние) — sticky-стек */
.te-table thead tr.thead-row1 th { top: 0; z-index: 19; background: var(--surface); }
.te-table thead tr.thead-row2 th { top: var(--te-row1-h, 36px); z-index: 18; background: var(--surface); }

/* Body cells / num-колонки / hover (минимум для self-contained рендера).
 * Глобальное правило: при сужении колонки длинный текст обрезается красиво
 * с многоточием (Александр 2026-05-20: «принцип как на /pricing/ Название»).
 * Требования: table-layout:fixed (выставлено _lockTableLayout). */
.te-table td {
  padding: 8px 10px;                  /* строка ≈ --table-row-h (34px) */
  font-size: var(--table-font-size);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Inner spans/divs наследуют ellipsis — если их max-width не ограничен явно,
 * родитель TD ограничит. Свойство применяется к flow content. */
.te-table td > span,
.te-table td > div { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.te-table td.num,
.te-table thead th.num { text-align: right; }
.te-table td.num { font-variant-numeric: tabular-nums; }
.te-table tr:hover td { background: rgba(110,128,247,0.03); }

/* === D24 (Wave 1, 2026-05-04): nowrap для агрегатных лейблов .te-table ===
   На /analytics/ был page-specific override (analytics/index.html:182) с целью запретить
   перенос «Продано ₽» на следующую строку. Та же потребность у /system-health/ и
   /assembly-sort/ (короткие aggregate-лейблы). Извлечено в shared CSS, чтобы все
   пользователи TableEngine получили consistent поведение. Legacy `.lab-table` rule
   (table-layout.css:85, pre-line) — оставлен для существующих non-engine таблиц с
   многострочными лейблами; analytics page override (line 182) → удалится Frontend
   Engineer'ом в Этапе 3 после миграции на TableEngine. */
.te-table thead th.th-aggregate .th-label {
  white-space: nowrap !important;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === Pin-left колонки (Spurt 1 fix MAJOR) ===
   TableEngine добавляет class te-pin-left на th/td и выставляет style.left
   inline по накопленному offset'у (см. _applyPinLeftOffsets в table-engine.js).
   ADR-0007 требует sticky на leaf — здесь мы только on <th>/<td>, не на <tr>.
   Cap: до 3 pin-left колонок (документ ограничение Spurt 1 — pricing-v2 use case). */
.te-table th.te-pin-left,
.te-table td.te-pin-left {
  position: sticky;
  left: var(--te-pin-left, 0);
  z-index: 17;            /* ниже sticky-thead, выше обычных body cells */
  background: var(--surface);
}
/* Pin-left + sticky-top одновременно: thead-th получает обе оси */
.te-table thead th.te-pin-left { z-index: 20; }
/* Тонкая «теневая» граница справа от последнего pin-left — визуальная отбивка */
.te-table th.te-pin-left.te-pin-last,
.te-table td.te-pin-left.te-pin-last {
  box-shadow: 1px 0 0 var(--border);
}
/* Hover-фон pin-left td не должен «теряться» поверх своего sticky background */
.te-table tr:hover td.te-pin-left { background: var(--surface2); }
.te-table tr.te-row-selected td.te-pin-left { background: var(--row-highlight) !important; }

/* ============================================================
   ADR-0017 Stage 2 — расширенные фичи TableEngine
   ============================================================ */

/* === Feature 1: Bulk select (колонка чекбоксов) === */
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table, .te-table) th.te-bulk-col,
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table, .te-table) td.te-bulk-col {
  width: 36px; min-width: 36px; max-width: 36px;
  text-align: center !important;
  padding: 4px 4px !important;
}
.te-bulk-cb {
  width: 16px; height: 16px;
  cursor: pointer;
  accent-color: var(--accent-primary);
  vertical-align: middle;
}
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table, .te-table) tr.te-row-selected td {
  background: var(--row-highlight) !important;
}

/* === Feature 3: Row grouping (группировочные строки) === */
.te-group-row td {
  background: var(--surface2);
  padding: 0;
  border-top: 2px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-weight: 600;
}
.te-group-row-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text);
}
.te-group-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  font-size: 12px;
  color: var(--text2);
  transition: transform .2s;
  flex-shrink: 0;
}
.te-group-row.te-group-collapsed .te-group-chevron { transform: rotate(-90deg); }
.te-group-title { flex: 0 1 auto; }
.te-group-count { color: var(--text2); font-weight: 400; font-size: 12px; }
.te-group-aggs {
  display: flex;
  gap: 14px;
  margin-left: auto;
  font-size: 12px;
  font-weight: 400;
  color: var(--text2);
}
.te-group-agg-val { color: var(--text); font-weight: 600; margin-left: 4px; }
.compact .te-group-row-inner { padding: 5px 12px; font-size: 12px; }

/* === Feature 4: Inline-edit === */
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table, .te-table) td.te-editable { cursor: text; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table, .te-table) td.te-editable:hover {
  outline: 1px dashed var(--border);
  outline-offset: -1px;
}
.te-edit-input {
  width: 100%;
  height: 100%;
  padding: 4px 8px;
  margin: -8px -10px;            /* съесть padding ячейки td */
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--accent-primary);
  border-radius: 0;
  outline: none;
  box-sizing: border-box;
}
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table, .te-table) td.num .te-edit-input { text-align: right; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table, .te-table) td.te-edit-pending { background: var(--edit-pending) !important; }
:is(.lab-table, .fbs-table, .ad-table, .ret-table, .sku-table, .te-table) td.te-edit-error {
  background: var(--edit-error) !important;
  animation: te-flash-error 0.5s ease-in-out;
}
@keyframes te-flash-error {
  0% { background: var(--edit-error); }
  50% { background: transparent; }
  100% { background: var(--edit-error); }
}

/* === Feature 5: Expandable rows (drilldown) === */
.te-expand-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  font-size: 15px;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: transform .2s, background .15s;
  margin-right: 6px;
  vertical-align: middle;
  border-radius: 4px;
}
.te-expand-chevron.te-expanded { transform: rotate(90deg); }
.te-expand-chevron:hover { color: var(--accent-primary); background: rgba(110,128,247,0.12); }
.te-row-child td:first-child { padding-left: calc(10px + var(--te-nest-pad, 24px)); }
.te-row-child { background: var(--surface2); }
.te-row-child:hover td { background: rgba(110,128,247,0.05); }

/* === Feature 2: XLSX export modal === */
.te-export-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9000;
  display: flex; align-items: center; justify-content: center;
}
.te-export-modal {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 14px);
  box-shadow: 0 12px 36px rgba(0,0,0,0.25);
  padding: 24px;
  min-width: 420px;
  max-width: 90vw;
}
.te-export-modal h3 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
}
.te-export-modal label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
  border-bottom: 1px solid var(--border);
}
.te-export-modal label:last-of-type { border-bottom: none; }
.te-export-modal input[type="radio"] {
  margin-top: 2px;
  accent-color: var(--accent-primary);
  flex-shrink: 0;
}
.te-export-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.te-export-modal button {
  padding: 7px 16px;
  font-size: 13px;
  font-family: inherit;
  border-radius: var(--radius-md, 10px);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  transition: all .15s;
}
.te-export-modal button:hover { border-color: var(--accent-primary); }
.te-export-modal button.te-primary {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}
.te-export-modal button.te-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* ============================================================
   Stage 2.5: Display modes — плотность строк
   Применяется через table.setDisplayMode('compact'|'regular'|'expanded').
   Управляющий класс ставится на корневой <table class="te-table"> и на
   обёртку .te-scroll. Высоты: 22 / 32 / 44 px = sane defaults для
   desktop tables (CHARTER T4: desktop-first, 22"/24" мониторы).
   ============================================================ */
.te-table.te-mode-compact   tbody td { padding: 2px 8px; line-height: 18px; font-size: 12px; }
.te-table.te-mode-compact   thead th { padding: 4px 6px; font-size: 11px; }
.te-table.te-mode-compact   tbody tr { height: 22px; }

.te-table.te-mode-regular   tbody td { padding: 6px 10px; line-height: 20px; font-size: 13px; }
.te-table.te-mode-regular   thead th { padding: 8px 8px; font-size: 12px; }
.te-table.te-mode-regular   tbody tr { height: 32px; }

.te-table.te-mode-expanded  tbody td { padding: 12px 12px; line-height: 20px; font-size: 13px; }
.te-table.te-mode-expanded  thead th { padding: 12px 10px; font-size: 12px; }
.te-table.te-mode-expanded  tbody tr { height: 44px; }

/* Картинки в expanded — крупнее (помогают визуальному скану) */
.te-table.te-mode-expanded  tbody td img { width: 60px; height: 60px; }
.te-table.te-mode-compact   tbody td img { width: 32px; height: 32px; }

/* === Этап 2 Wave 5 (2026-05-06): auto-toolbar anchor для «⚙ Колонки» ===
   Универсальное правило для всех страниц с .toolbar (analytics, pricing, и т.д.):
   кнопка «⚙ Колонки» (как обёрнутая `.col-settings-wrap`, так и одиночная
   `#btn-col-settings`/`#te-btn-col-settings`) ВСЕГДА прижимается к правому краю
   тулбара через `margin-left: auto`. На широких экранах (1920×1080) свободное
   пространство съедается auto-margin'ом и кнопка остаётся в одной строке с
   остальными feature-кнопками (Знаки ±, Σ Итого, Округление до ₽).

   На узких экранах flex-wrap всё ещё работает, но «⚙ Колонки» по-прежнему якорь
   правого края своей строки. Не ломает существующие callers: правило применяется
   только к .toolbar (НЕ к произвольным контейнерам), а селекторы #btn-col-settings/
   #te-btn-col-settings/.col-settings-wrap уникальны для feature column-settings.

   Было до фикса: ⚙ Колонки переносилась на 2-ю строку при добавлении кнопки
   «Округление до ₽» (Wave 2 Extract) — суммарная ширина превышала container.
   Failure-taxonomy: NEW (2026-05-06) — auto-toolbar wrap без anchor.
*/
.toolbar #btn-col-settings,
.toolbar #te-btn-col-settings,
.toolbar .col-settings-wrap { margin-left: auto; }

/* === W1.1 DELTA #9 (2026-05-19, PL-specified — Александр): право-
   якорная группа 💾 Excel + ⚙ Настройки ===
   Engine-managed Wave 5 toolbar рендерит пару mandatory-right внутри
   .te-toolbar-right-group. margin-left:auto съедает свободное место
   и прижимает пару к ПРАВОМУ краю строки тулбара независимо от числа
   предшествующих optional-кнопок (раньше право-якорился только legacy
   #te-btn-col-settings — Wave 5 right-cluster шёл «встык» после
   optional без якоря). Порядок внутри группы = порядок DOM
   (WAVE5_MANDATORY_RIGHT: 💾 Excel → ⚙ Настройки, т.е. Настройки
   самая правая). Применяется на всех TableEngine-таблицах (ADR-0027
   Layer 3, CLAUDE.md §22). На узких экранах flex-wrap сохраняется,
   группа остаётся якорем правого края своей строки. Не ломает
   non-Wave5/inline тулбары — селектор уникален для engine-группы.
   Gap наследует .toolbar (между группой и кнопкой внутри). */
.te-toolbar-right-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

/* === Wave 5 (2026-05-08): Configurable Toolbar — Settings Popup ===
   По spec docs/specs/configurable-toolbar-wave5-spec-2026-05-08.md §7.
   Modal-окно для настройки видимости optional кнопок тулбара.
   Все цвета через theme.css tokens — light/dark автоматически.
   Stripe double-shadow elevation, NO bouncy easing, NO transition:all,
   NO pure #000000 — anti-patterns CLAUDE.md GLOBAL_DESIGN.
   ============================================================ */

/* Overlay (полупрозрачный фон) */
.te-toolbar-settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: te-tbs-fade-in 180ms cubic-bezier(0, 0, 0.2, 1);
}

/* Modal box */
.te-toolbar-settings-box {
  width: 480px;
  max-width: calc(100vw - 32px);
  /* запас 160px (chrome + taskbar + воздух сверху/снизу) — popup всегда с margin */
  max-height: min(760px, calc(100vh - 160px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  box-shadow:
    0 8px 24px rgba(50, 50, 93, 0.12),
    0 4px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  animation: te-tbs-scale-in 180ms cubic-bezier(0, 0, 0.2, 1);
}

@keyframes te-tbs-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes te-tbs-scale-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

/* Header */
.te-toolbar-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}
.te-toolbar-settings-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.te-toolbar-settings-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--text2);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm, 4px);
  transition: background-color 150ms cubic-bezier(0, 0, 0.2, 1),
              color 150ms cubic-bezier(0, 0, 0.2, 1);
}
.te-toolbar-settings-close:hover {
  background: var(--surface2);
  color: var(--text);
}
.te-toolbar-settings-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent);
}

/* Body (scroll) */
.te-toolbar-settings-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 0;
}
.te-toolbar-settings-subtitle {
  padding: 4px 20px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text2);
}

/* Item row */
.te-toolbar-settings-row {
  display: grid;
  grid-template-columns: 24px auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px 20px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background-color 150ms cubic-bezier(0, 0, 0.2, 1);
}
.te-toolbar-settings-row:last-child {
  border-bottom: none;
}
.te-toolbar-settings-row:hover {
  background: var(--surface2);
}
.te-toolbar-settings-row .te-tbs-check {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}
.te-tbs-icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 14px;
  color: var(--text2);
}
.te-tbs-text {
  min-width: 0;
}
.te-tbs-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.te-tbs-desc {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
  max-width: 380px;
}

/* Если row не имеет icon (3-я колонка только text) — auto-fill grid */
.te-toolbar-settings-row:not(:has(.te-tbs-icon-only)) {
  grid-template-columns: 24px 1fr;
}
.te-toolbar-settings-row:not(:has(.te-tbs-icon-only)) .te-tbs-text {
  grid-column: 2;
}

/* Footer */
.te-toolbar-settings-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
  position: sticky;
  bottom: 0;
}
.te-toolbar-settings-reset,
.te-toolbar-settings-done {
  padding: 7px 14px;
  font-size: 12px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background-color 150ms cubic-bezier(0, 0, 0.2, 1),
              border-color 150ms cubic-bezier(0, 0, 0.2, 1);
}
.te-toolbar-settings-reset:hover {
  background: var(--surface2);
}
.te-toolbar-settings-done {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}
.te-toolbar-settings-done:hover {
  filter: brightness(1.05);
}
.te-toolbar-settings-reset:focus-visible,
.te-toolbar-settings-done:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent);
}

/* Toolbar single-row preference (Wave 5) — поверх существующего .toolbar
   правила (line ~29 в page-level CSS-копиях). Не задаёт !important чтобы
   не ломать legacy /pricing/ /analytics/ HTML, использующие inline-toolbar
   до миграции на Wave 5. .te-toolbar-managed — маркер автоматически добавляется
   _initToolbarV5() и сигнализирует «engine управляет, можно безопасно
   no-wrap». Мы не делаем nowrap: на 1366×768 spec §3.4 явно допускает wrap. */
.te-toolbar-managed { /* placeholder для будущих стилей */ }

/* === Wave 5b (2026-05-08): tb-btn-disabled — visual disabled для Excel-кнопки
   когда страница не передала excelHandler (см. spec §5.3). */
.tb-btn.tb-btn-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.tb-btn.tb-btn-disabled:hover {
  background: var(--surface);
}

/* === Wave 5b (2026-05-08): ⚙ Настройки — двухколоночный popup ===
   Spec docs/specs/configurable-toolbar-wave5b-spec-2026-05-09.md §3.
   Расширяет существующий te-toolbar-settings-* (Wave 5a) через модификатор
   --v5b. Wave 5a styles остаются (могут переиспользоваться будущими
   single-column popup'ами). NO bounce easing, NO transition:all,
   focus-visible через box-shadow. Width 540 + max-height min(760, 100vh-160).
   ============================================================ */

/* Wave 5b.7 box — wider (900px responsive), inline column-settings внутри.
   Раньше 540px (Wave 5b spec) — слишком узко на 1920×1080, плюс «Колонки»
   tab делегировал в отдельный popup (двойной popup UX). Теперь tab
   «Колонки» рендерит drag-and-drop list inline → нужен полноценный width.
   На 1366×768: sidebar 240 + popup 900 + margin 32 = 1172px → fits. */
/* ADR-0029-v2 W1 §8 (item 8, D1) — ФИКСИРОВАННЫЙ размер модала G.
   Раньше: max-height + content-driven sizing → переключение секций
   Колонки↔Пользовательские↔Кнопки меняло габариты («прыжок»,
   замечание Александра на живом B001). Теперь: ЖЁСТКО заданная
   height/width (НЕ max-height, НЕ fit-content, НЕ auto), рассчитана
   под крупнейшую секцию «Колонки». Контент скроллится ВНУТРИ
   .te-tbs-panel (per-section overflow-y:auto, min-height:0).
   Resize при смене секции физически невозможен — width/height не
   зависят от контента секции (заданы фикс. CSS, не fit-content).
   1920×1080: 900×720 (1080−96=984, cap 720). 1366×768: 900×672
   (calc(100vh−96px)=672). min() = помещается на обеих, не растёт. */
.te-toolbar-settings-box--v5b {
  width: min(900px, calc(100vw - 240px));
  max-width: calc(100vw - 32px);
  height: min(720px, calc(100vh - 96px));
  max-height: min(720px, calc(100vh - 96px));
}

/* Body — flex row (nav + content). Заменяет single-column body Wave 5a. */
.te-toolbar-settings-box--v5b .te-tbs-body-row {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

/* Left nav (200px wide, vertical tablist) */
.te-toolbar-settings-box--v5b .te-tbs-nav {
  width: 200px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  overflow-y: auto;
}

.te-toolbar-settings-box--v5b .te-tbs-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 150ms cubic-bezier(0, 0, 0.2, 1),
              border-color 150ms cubic-bezier(0, 0, 0.2, 1);
  min-height: 44px;
  box-sizing: border-box;
}
.te-toolbar-settings-box--v5b .te-tbs-nav-item:hover {
  background: var(--surface2);
}
.te-toolbar-settings-box--v5b .te-tbs-nav-item.active {
  background: var(--surface2);
  border-left-color: var(--accent);
  font-weight: 600;
}
.te-toolbar-settings-box--v5b .te-tbs-nav-item:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent);
}
.te-toolbar-settings-box--v5b .te-tbs-nav-icon {
  font-size: 16px;
  width: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.te-toolbar-settings-box--v5b .te-tbs-nav-label {
  font-size: 14px;
}

/* Right content — scrollable */
.te-toolbar-settings-box--v5b .te-tbs-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.te-toolbar-settings-box--v5b .te-tbs-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px;
}
.te-toolbar-settings-box--v5b .te-tbs-panel[hidden] {
  display: none;
}

/* Panel header (для обоих табов) */
.te-toolbar-settings-box--v5b .te-tbs-panel-header {
  margin-bottom: 16px;
}
.te-toolbar-settings-box--v5b .te-tbs-panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.te-toolbar-settings-box--v5b .te-tbs-panel-helper {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
}

/* Tab «Колонки» — launcher CTA */
.te-toolbar-settings-box--v5b .te-tbs-columns-launcher {
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.te-toolbar-settings-box--v5b .te-tbs-cta {
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid var(--accent);
  border-radius: var(--radius-md, 8px);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: filter 150ms cubic-bezier(0, 0, 0.2, 1);
}
.te-toolbar-settings-box--v5b .te-tbs-cta:hover {
  filter: brightness(1.05);
}
.te-toolbar-settings-box--v5b .te-tbs-cta:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent);
}
.te-toolbar-settings-box--v5b .te-tbs-helper-note {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
}
.te-toolbar-settings-box--v5b .te-tbs-helper-note--warn {
  color: var(--text2);
  padding: 8px 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm, 4px);
  /* NB: убран `border-left: 3px solid var(--accent)` — анти-AI-tell (ma-design §2).
     Выноску определяют фон surface2 + рамка-радиус. */
  border: 1px solid var(--border);
}
.te-toolbar-settings-box--v5b .te-tbs-helper-note code {
  background: var(--surface2);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
  color: var(--text);
}

/* Tab «Кнопки» — список (использует ту же te-toolbar-settings-row сетку,
   но без лишнего grid-column 24px (icon-only оставлен для Wave 5a совместимости) */
.te-toolbar-settings-box--v5b .te-tbs-buttons-list {
  display: flex;
  flex-direction: column;
}
.te-toolbar-settings-box--v5b .te-tbs-buttons-list .te-toolbar-settings-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  grid-template-columns: 24px 1fr;
}
.te-toolbar-settings-box--v5b .te-tbs-buttons-list .te-toolbar-settings-row:hover {
  background: transparent;  /* в плотном списке не подсвечиваем — иначе шум */
}
.te-toolbar-settings-box--v5b .te-tbs-buttons-list .te-toolbar-settings-row:last-child {
  border-bottom: none;
}

/* === Wave 5b.7: inline column-settings host (tab «Колонки») ===
   MA_ColumnSettings.renderInline() кладёт свой <div class="cs-inline cs-modal">
   внутрь .te-tbs-cs-inline-host. Класс cs-modal у inline-обёртки нужен,
   чтобы переиспользовать delegate-селекторы (event handlers ищут
   .cs-modal__columns / .cs-create-group через closest()). Но визуальные
   modal-стили (фиксированный размер, shadow, animation) переопределяем
   на «обычный flex-блок».
   ============================================================ */
.te-tbs-cs-inline-host {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
/* Inline-обёртка cs-modal — отменяем все modal-визуальные правила. */
.te-tbs-cs-inline-host .cs-modal.cs-inline {
  position: static;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  animation: none;
  display: flex;
  flex-direction: column;
  overflow: visible;
}
/* Inline список — без border-right (нет preview-pane справа), занимаем
   всю ширину панели. Скролл — уже на .te-tbs-panel. */
.te-tbs-cs-inline-host .cs-modal__columns {
  border-right: none;
  background: transparent;
  padding: 0;
  overflow-y: visible;
}
/* Cs-warn (calc deps warning) — компактнее в inline-режиме. */
.te-tbs-cs-inline-host .cs-warn {
  margin: 0 0 8px;
}
/* Create-group кнопка — растянуть на всю ширину контейнера. */
.te-tbs-cs-inline-host .cs-create-group {
  width: 100%;
  margin: 12px 0 0;
}

/* === 5.C.11: prefers-reduced-motion fallback (Этап 5.C.1) ===
   Уважаем системную настройку «уменьшить анимации» — отключаем все
   transitions/animations внутри TableEngine, поведение остаётся.
   Скоуп: только .te-table и его потомки + .te-scroll (pin/scroll handles). */
@media (prefers-reduced-motion: reduce) {
  .te-table,
  .te-table *,
  .te-scroll,
  .te-scroll *,
  .te-toolbar-settings-overlay,
  .te-toolbar-settings-overlay * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ============================================================
   ADR-0029-v2 E6 + W1.1 DELTA §7 (item 7, D8) — ГОРЧИЧНЫЙ маркер
   шапки пользовательской (вычисляемой) колонки.
   CHARTER T1: селлер не должен спутать свою производную с истиной
   Ozon. Маркер ТОЛЬКО на <th> (НЕ на <td> — heatmap/zebra/знак± в
   теле работают как у системных колонок). Отстройка дальтоник-safe:
   ƒ-глиф + курсив + текстовый бейдж + tooltip + горчичный цвет
   (цвет = УСИЛИТЕЛЬ, не единственный носитель — frozen base §3.3).
   Горчичный токен --te-usercol-accent НЕ зелёный (heatmap --green)
   и НЕ синий (--accent expand/zebra). Tooltip = нативный title= на
   <th> (ставится движком, R6 _escAttr). Только токены theme.css.
   ============================================================ */
.te-calc-fmark {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-style: italic;
  color: var(--te-usercol-accent);
  margin-right: var(--space-1);
  font-weight: 600;
}
/* Маркер ТОЛЬКО на th: горчичная inset-полоса снизу + очень тонкая
   заливка шапки. НЕ применять к td (см. шапку блока). */
.te-calc-th {
  box-shadow: inset 0 -2px 0 0 var(--te-usercol-accent);
  background: var(--te-usercol-bg);
}
.te-calc-th .th-label {
  font-style: italic;
  color: var(--te-usercol-accent);
}

