/* ── Экран инвентаризации (тема iiko.css) ───────────────────────── */
#screen-inventory .inv-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
#screen-inventory .btn-lg { width: 100%; justify-content: center; }
.inv-status { font-size: 14px; color: var(--ink-muted); }
.inv-online-row { display: flex; gap: 8px; }
#screen-inventory .inv-online-row .btn { width: auto; }
#screen-inventory .inv-online-row .btn[data-inv-online] {
  flex: 1 1 auto; min-width: 0; justify-content: center;
}
#screen-inventory .inv-online-row { align-items: stretch; }
#screen-inventory .inv-online-row .btn[data-inv-delete] {
  flex: 0 0 auto; width: auto; height: auto; min-height: 0; align-self: stretch;
}
/* Текст кнопки переносится на узких экранах — иначе длинная подпись
   распирает строку и кнопка «Удалить» уезжает за край. */
.inv-online-text {
  display: inline-flex; flex-direction: column; align-items: center;
  min-width: 0; line-height: 1.15; white-space: normal; text-align: center;
}
/* Подпись даты — только на оранжевой кнопке: мягкий белый для контраста */
.inv-online-date { font-size: 11px; font-weight: 400; color: rgba(255, 255, 255, 0.85); }
.inv-status-msg { font-size: 14px; color: var(--ink-muted); padding: 8px 2px; }
/* Спиннер загрузки — оверлей поверх контента (но НЕ поверх шапки с «Назад»),
   не двигает список истории. */
.inv-loading-overlay {
  position: fixed; left: 0; right: 0; bottom: 0;
  top: calc(var(--header-h) + var(--safe-top));
  z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-page);
}
.inv-loading-overlay .flow-loader-screen { min-height: 0; flex: 0 1 auto; }

/* Скелетон-загрузчик списка истории (как у остатков на складах) */
.inv-hist-skel { cursor: default; }
.inv-hist-skel .sk { border-radius: 6px; }
.inv-validate { display: flex; flex-direction: column; gap: 6px; }
.inv-row {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
  padding: 8px 10px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.inv-row.is-low { background: var(--warning-bg); }
.inv-row select {
  padding: 6px 8px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--ink);
}
.inv-row-name { font-size: 14px; }
.inv-row-sub { font-size: 12px; color: var(--ink-subtle); }

/* Печать бланка — серверный PDF (backend/inventory/pdf.py), CSS для печати не нужен. */

/* ── Онлайн-форма инвентаризации ─────────────────────────────────────── */
/* Экран — колонка во всю высоту: список скролится, кнопка всегда под ним. */
#screen-inventory-form.is-active.uses-shell {
  height: 100dvh; min-height: 0; max-height: 100dvh;
}
#screen-inventory-form .app-header { justify-content: space-between; flex-shrink: 0; }
.invf-headbtns { display: flex; align-items: center; gap: 4px; }
.invf-save { font-size: 12px; color: var(--ink-muted); margin-right: 4px; }
.invf-metarow {
  flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 12px 4px 16px;
}
.invf-meta { font-size: 13px; color: var(--ink-muted); }
.invf-metabtns { display: flex; gap: 4px; flex-shrink: 0; }
.invf-metarow .btn { flex-shrink: 0; }
[data-share-qr] img { width: 200px; height: 200px; image-rendering: pixelated; }
.invf-search {
  flex-shrink: 0; display: flex; align-items: center; gap: 8px;
  margin: 4px 12px 8px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); color: var(--ink-muted);
}
.invf-search input {
  flex: 1; border: none; background: transparent; outline: none;
  padding: 10px 0; font-size: 14px; color: var(--ink);
}
/* Единый скроллер (обе оси) — для sticky-шапки зоны и фикс-колонки имени. */
.invf-body {
  flex: 1 1 auto; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch;
  background: var(--surface-page);  /* беж вокруг таблицы */
}

/* Строка = flex по ширине контента. margin:0 auto центрирует таблицу, когда экран
   шире таблицы; когда уже — margin схлопывается в 0 и работает горизонтальный скролл.
   Фон строки белый — сама таблица на белом, вокруг беж. */
.invf-row { display: flex; width: max-content; margin: 0 auto; background: var(--surface); }
.invf-cell {
  flex: 0 0 auto; display: flex; align-items: center;
  padding: 0 10px; min-width: 0; box-sizing: border-box;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Ширины колонок: имя | Остаток | Факт | Коробки | Размер | Итого */
.invf-row > .invf-cell:nth-child(1) { width: 150px; }
.invf-row > .invf-cell:nth-child(2) { width: 74px; justify-content: flex-end; }
.invf-row > .invf-cell:nth-child(3) { width: 78px; }
.invf-row > .invf-cell:nth-child(4) { width: 76px; }
.invf-row > .invf-cell:nth-child(5) { width: 88px; }
.invf-row > .invf-cell:nth-child(6) { width: 74px; justify-content: flex-end; }
/* Шаринг без колонки «Остаток» — 5 колонок */
.invf-nobal .invf-row > .invf-cell:nth-child(2) { width: 78px; justify-content: flex-start; }
.invf-nobal .invf-row > .invf-cell:nth-child(3) { width: 76px; }
.invf-nobal .invf-row > .invf-cell:nth-child(4) { width: 88px; }
.invf-nobal .invf-row > .invf-cell:nth-child(5) { width: 74px; justify-content: flex-end; }

/* Фикс-колонка имени (sticky слева) */
.invf-cell-name {
  position: sticky; left: 0; z-index: 2;
  flex-direction: column; align-items: flex-start; justify-content: center;
  background: var(--surface); border-right: 1px solid var(--hairline);
  box-shadow: 2px 0 6px rgba(40, 30, 20, 0.04);
}
.invf-iname {
  font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.2;
  max-width: 100%;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; text-overflow: ellipsis; white-space: normal;
}
.invf-name-pack {
  font-size: 11px; font-weight: 400; color: var(--ink-subtle);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}

/* Строки позиций */
.invf-item { border-bottom: 1px solid var(--hairline); }
.invf-item .invf-cell { height: 60px; font-size: 13px; }
.invf-bal { color: var(--ink-muted); }
.invf-total { font-weight: 700; font-variant-numeric: tabular-nums; }
.invf-muted, .invf-size-fixed { color: var(--ink-subtle); }

/* Шапка зоны (sticky сверху); имя зоны — угол (sticky слева+сверху) */
.invf-zhead { position: sticky; top: 0; z-index: 3; }
.invf-zhead .invf-cell {
  height: 42px; background: var(--accent-soft);
  border-bottom: 1px solid var(--hairline);
  font-size: 11px; font-weight: 700; color: var(--ink-subtle);
  text-transform: uppercase; letter-spacing: 0.6px;
}
.invf-zhead .invf-cell-name { z-index: 4; }
.invf-zname { color: var(--ink); }

.ta-right { text-align: right; }

.invf-input {
  width: 100%; padding: 7px 6px; font-size: 13px;
  border: 1.5px solid var(--ink); border-radius: 8px;
  background: var(--surface); color: var(--ink); text-align: center;
  font-variant-numeric: tabular-nums; box-sizing: border-box;
}
.invf-input:disabled { border-color: var(--hairline); background: var(--surface-raised); }
.invf-select { padding: 6px 4px; text-align: left; }
.invf-select.invf-rec { font-weight: 700; }  /* выбран рекомендованный из накладных размер */

/* Итог завершения */
.invf-done { padding: 24px 16px; display: flex; flex-direction: column; gap: 12px; }
.invf-done-title { font-size: 17px; font-weight: 700; color: var(--ink); }
.invf-done-sub { font-size: 13px; color: var(--ink-muted); }
.invf-diffs { width: 100%; border-collapse: collapse; font-size: 13px; }
.invf-diffs th, .invf-diffs td {
  padding: 6px 8px; border-bottom: 1px solid var(--hairline); text-align: left;
}
.invf-diffs th { color: var(--ink-subtle); font-weight: 700; }

/* ── История инвентаризаций (список карточек на экране #screen-inventory) ─── */
.inv-history-divider {
  font-size: 11px; font-weight: 700; color: var(--ink-subtle);
  text-transform: uppercase; letter-spacing: 0.6px;
  padding: 4px 2px 2px;
  border-top: 1px solid var(--hairline);
  margin-top: 4px;
}
.inv-history-list {
  display: flex; flex-direction: column; gap: 6px;
}
.inv-hist-card {
  display: flex; flex-direction: column; gap: 4px;
  width: 100%; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  text-align: left; font: inherit; color: var(--ink);
  transition: background 0.12s;
}
.inv-hist-card:active { background: var(--accent-soft); }
.inv-hist-main { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.inv-hist-date { font-size: 14px; font-weight: 600; color: var(--ink); }
.inv-hist-status { font-size: 12px; font-weight: 500; }
.inv-hist-status--done { color: var(--color-success, #2a8c4a); }
.inv-hist-status--active { color: var(--ink-muted); }
.inv-hist-sub { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.inv-hist-store { font-size: 12px; color: var(--ink-muted); }
.inv-hist-count { font-size: 12px; color: var(--ink-subtle); }
.inv-hist-empty { font-size: 13px; color: var(--ink-subtle); padding: 4px 2px; margin: 0; }

/* ── Экран распределения новых позиций по зонам ──────────────────────────────── */
#screen-inventory-zones.is-active.uses-shell {
  height: 100dvh; min-height: 0; max-height: 100dvh; display: flex; flex-direction: column;
}
#screen-inventory-zones .app-header { justify-content: flex-start; gap: 8px; flex-shrink: 0; }
.invz-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.invz-body {
  flex: 1 1 auto; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch;
  padding: 12px 16px; display: flex; flex-direction: column; gap: 8px;
}
.invz-body .btn { width: 100%; justify-content: center; }

/* ── Detail экран инвентаризации (read-only таблица) ─────────────────────────── */
#screen-inventory-detail.is-active.uses-shell {
  height: 100dvh; min-height: 0; max-height: 100dvh; display: flex; flex-direction: column;
}
#screen-inventory-detail .app-header { justify-content: flex-start; gap: 8px; flex-shrink: 0; }
.invd-title {
  font-size: 15px; font-weight: 600; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.invd-body {
  flex: 1 1 auto; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch;
  background: var(--surface-page);
}
/* Фиксированная шапка detail (мета+сводка+поиск) — не скроллится с таблицей */
.invd-fixedhead { flex-shrink: 0; background: var(--surface-page); }
.invd-fixedhead .invd-search { margin: 4px 0 8px; }

/* Фиксированный низ detail с кнопкой «Анализ и сведение» */
.invd-footer {
  flex-shrink: 0; padding: 10px 16px calc(10px + var(--safe-bottom, 0px));
  background: var(--surface-page); border-top: 1px solid var(--hairline);
}
.invd-footer .btn { width: 100%; justify-content: center; }
.invd-iiko-warn {
  margin: 8px 12px; padding: 8px 12px;
  background: var(--warning-bg, #fff7e0); border: 1px solid var(--warning-border, #e6c84a);
  border-radius: var(--radius-sm); font-size: 12px; color: var(--ink-muted);
}
.invd-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 16px 4px; font-size: 13px;
}
.invd-meta-status { font-weight: 600; color: var(--ink); }
.invd-meta-date { color: var(--ink-muted); }
.invd-meta-store { color: var(--ink-subtle); }

/* Сводка по излишкам/недостаче перед таблицей */
.invd-summary { display: flex; gap: 8px; padding: 4px 16px 12px; }
.invd-sum-card {
  flex: 1 1 0; min-width: 0; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius-sm); display: flex; flex-direction: column; gap: 2px;
}
.invd-sum-label {
  font-size: 10px; font-weight: 700; color: var(--ink-subtle);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.invd-sum-val { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.invd-sum-sub { font-size: 11px; color: var(--ink-muted); }
.invd-sum-surplus .invd-sum-val { color: var(--color-success, #2e7d32); }
.invd-sum-loss .invd-sum-val { color: var(--color-danger, #c62828); }
.invd-sum-net { background: var(--accent-soft); }
.invd-sum-net .invd-sum-val { color: var(--ink); }

/* Поиск под основным блоком — отделён воздухом сверху и снизу */
.invd-search { margin-top: 10px; margin-bottom: 10px; }

/* Сортируемые заголовки колонок */
.invd-th-sortable { cursor: pointer; user-select: none; -webkit-user-select: none; }
.invd-th-sortable:hover { color: var(--ink); }
.invd-th-active { color: var(--ink); }
.invd-sort-arrow { margin-left: 3px; font-size: 9px; }
.invd-empty, .invd-error {
  font-size: 14px; color: var(--ink-muted); padding: 24px 16px; margin: 0;
}
/* Без своего скролл-контейнера: единственный скроллер (обе оси) — .invd-body,
   чтобы корректно работали sticky-шапка (top) и фикс-колонка имени (left). */
.invd-wrap { padding: 0 0 16px; }
.invd-table {
  width: 100%; min-width: 420px; border-collapse: separate; border-spacing: 0;
  font-size: 13px; background: var(--surface);
}
.invd-th {
  padding: 8px 10px; background: var(--accent-soft);
  border-bottom: 1px solid var(--hairline);
  font-size: 11px; font-weight: 700; color: var(--ink-subtle);
  text-transform: uppercase; letter-spacing: 0.5px;
  position: sticky; top: 0; z-index: 2;
  white-space: nowrap;
}
.invd-td {
  padding: 8px 10px; border-bottom: 1px solid var(--hairline);
  color: var(--ink); vertical-align: middle;
}
.invd-th-name, .invd-td-name { text-align: left; min-width: 150px; max-width: 240px; }
.invd-th-unit, .invd-td-unit { text-align: left; min-width: 44px; color: var(--ink-muted); }
.invd-th-num, .invd-td-num { text-align: right; min-width: 68px; font-variant-numeric: tabular-nums; }
.invd-bal { color: var(--ink-muted); }
.invd-sum { color: var(--ink-muted); }
.invd-diff-pos { color: var(--color-success, #2e7d32); font-weight: 600; }
.invd-diff-neg { color: var(--color-danger, #c62828); font-weight: 600; }
.invd-row:nth-child(even) .invd-td { background: var(--surface-raised, #fafaf8); }

/* Фикс-колонка имени (sticky слева). Непрозрачный фон обязателен — иначе
   при горизонтальном скролле под ней просвечивают другие колонки. */
.invd-th-name, .invd-td-name {
  position: sticky; left: 0;
  background: var(--surface);
  border-right: 1px solid var(--hairline);
  box-shadow: 2px 0 6px rgba(40, 30, 20, 0.04);
}
.invd-td-name { z-index: 1; }
.invd-th-name { z-index: 3; background: var(--accent-soft); }  /* угол: над шапкой и колонкой */
.invd-row:nth-child(even) .invd-td-name { background: var(--surface-raised, #fafaf8); }

/* Карточка истории — две колонки: слева дата+№, справа суммы. Всё в две строки. */
.inv-hist-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.inv-hist-left { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.inv-hist-doc {
  font-size: 12px; font-weight: 500; white-space: nowrap;
  color: var(--color-success, #2a8c4a);
}
.inv-hist-pos-count { color: var(--ink-subtle); font-weight: 400; }

/* Блок сумм справа: итог (жирно) сверху, излишки/недостача снизу — две строки */
.inv-hist-stats {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
  margin-left: auto; flex-shrink: 0; text-align: right;
}
.inv-hist-net {
  font-size: 14px; font-weight: 700; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.inv-hist-subsums {
  display: flex; gap: 8px; white-space: nowrap;
  font-size: 11.5px; font-variant-numeric: tabular-nums;
}
.inv-hist-pos { color: var(--color-success, #2e7d32); }
.inv-hist-neg { color: var(--color-danger, #c62828); }

/* Кнопка «Показать ещё» в истории инвентаризаций */
.inv-hist-more {
  width: 100%; margin-top: 4px;
  justify-content: center;
}

/* ── Кнопка «Анализ расхождений» в шапке detail-экрана ─────────────────────── */
.inva-trigger-btn { margin-left: auto; flex-shrink: 0; }

/* ── Экран анализа расхождений ──────────────────────────────────────────────── */
#screen-inventory-analysis.is-active.uses-shell {
  height: 100dvh; min-height: 0; max-height: 100dvh; display: flex; flex-direction: column;
}
#screen-inventory-analysis .app-header { justify-content: flex-start; gap: 8px; flex-shrink: 0; }

.inva-body {
  flex: 1 1 auto; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch;
  background: var(--surface-page);
}

/* Строка периода анализа */
.inva-period {
  padding: 2px 16px 6px;
  font-size: 12px; color: var(--ink-muted);
}

/* Сводка-чипы по кодам гипотез */
.inva-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px 16px 10px;
}
.inva-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 100px;
  background: var(--accent-soft); border: 1px solid var(--hairline);
  font-size: 12px; color: var(--ink-muted); white-space: nowrap;
}
.inva-chip b { color: var(--ink); font-weight: 700; }
.inva-chip-unclass { opacity: 0.7; }

/* Подсказка «рецептуры и AI будут позже» */
.inva-footnote {
  padding: 0 16px 8px;
  font-size: 11px; color: var(--ink-subtle);
}

/* Таблица анализа: 7 колонок, min-width шире за счёт «Причины» */
.inva-table { min-width: 520px; }

/* Колонка «Причина» */
.inva-th-reason {
  text-align: left; min-width: 130px;
}
.inva-td-reason {
  text-align: left; min-width: 130px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px;
}
.inva-reason-none { color: var(--ink-subtle); }

/* Точки confidence */
.inva-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 5px; vertical-align: middle; flex-shrink: 0;
}
.inva-dot-high { background: var(--color-success, #2e7d32); }
.inva-dot-med  { background: var(--color-warning, #e6a817); }
.inva-dot-low  { background: var(--color-danger, #c62828); opacity: 0.65; }

/* Метка гипотезы */
.inva-label { vertical-align: middle; }

/* Значок «ещё N» */
.inva-more {
  display: inline-block; margin-left: 5px;
  padding: 0 5px; border-radius: 8px;
  background: var(--hairline); color: var(--ink-muted);
  font-size: 11px; vertical-align: middle;
}

/* Строка с раскрытыми гипотезами */
.inva-row { cursor: pointer; }
/* Только строки у которых есть гипотезы — показывать указатель */
.inva-row:not([data-pid]) { cursor: default; }
.inva-row-open > .invd-td { background: var(--accent-soft) !important; }
.inva-row-open > .invd-td-name { background: var(--accent-soft) !important; }

.inva-expand-row > .inva-expand-td {
  padding: 0; background: var(--surface-raised, #fafaf8);
  border-bottom: 2px solid var(--hairline);
}
.inva-expand-body {
  padding: 10px 14px 12px;
  display: flex; flex-direction: column; gap: 10px;
}

/* Одна гипотеза внутри раскрытия */
.inva-hyp {
  display: flex; flex-direction: column; gap: 3px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--hairline);
}
.inva-hyp-head {
  display: flex; align-items: center; gap: 0;
  font-size: 13px; font-weight: 600; color: var(--ink);
}
.inva-hyp-code {
  margin-left: auto; padding: 1px 6px; border-radius: 4px;
  background: var(--accent-soft); color: var(--ink-subtle);
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
}
.inva-hyp-evidence {
  font-size: 12px; color: var(--ink-muted); line-height: 1.4;
}
.inva-hyp-action {
  font-size: 12px; color: var(--ink); font-weight: 500; line-height: 1.4;
}
.inva-action-icon {
  margin-right: 4px; color: var(--ink-muted);
}

/* ── Пресеты «Всегда по факту» v2 (именованные) ──────────────────────────── */

/* Обёртка панели */
.inva-preset-wrap {
  display: flex; align-items: stretch;
}

/* Круглые иконки-кнопки в шапке попапа состава (переименовать/удалить) */
.inva-edit-head-actions { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; margin-right: 6px; }
.inva-head-btn {
  width: 36px; height: 36px; min-height: 0; padding: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.inva-head-btn-warm { background: var(--accent-warm, #f5e6d0) !important; color: var(--color-brand, #b85c00) !important; border-color: transparent !important; }
.inva-head-btn-danger { background: var(--color-error, #c0392b) !important; color: #fff !important; border-color: transparent !important; }

/* Фиксированная полоса поиска — над скроллящейся таблицей, не едет с ней */
.inva-search-bar {
  flex-shrink: 0;
  background: var(--surface-page);
}
.inva-search-bar .invd-search { margin: 4px 0 8px; }

/* Панель — две строки */
.inva-preset-panel {
  flex: 1; display: flex; flex-direction: column; gap: 4px;
  padding: 6px 16px 6px; box-sizing: border-box;
}

/* Строка 1: кнопка «＋ Создать пресет» */
.inva-preset-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inva-preset-row1 { /* первая строка — самостоятельный ряд */ }
.inva-preset-row2 { /* вторая строка: label + select + кнопки */ }

/* Метка «Пресет:» */
.inva-preset-label {
  font-size: 12px; color: var(--ink-muted); white-space: nowrap; flex-shrink: 0;
}

/* Селектор пресетов */
.inva-preset-select {
  font-size: 13px; color: var(--ink);
  padding: 4px 8px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
  cursor: pointer; max-width: 220px; flex-shrink: 1; min-width: 0;
}
.inva-preset-select:focus { outline: 2px solid var(--color-brand, #e36b00); outline-offset: 1px; }

/* Поле ввода в попапе создания пресета */
.inva-preset-new-input {
  font-size: 14px; color: var(--ink);
  padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--surface);
  width: 100%; box-sizing: border-box;
}
.inva-preset-new-input:focus { outline: 2px solid var(--color-brand, #e36b00); outline-offset: 1px; }

/* Кнопка «Редактировать» — оранжевый warm-стиль с иконкой карандаша */
.btn-warm {
  background: var(--accent-warm, #f5e6d0);
  color: var(--color-brand, #b85c00);
  border-color: transparent;
  display: inline-flex; align-items: center; gap: 5px;
}
.btn-warm:not(:disabled):hover {
  background: var(--color-brand, #e36b00);
  color: #fff;
}
.btn-warm .ic { flex-shrink: 0; }

/* Кнопка опасного действия (удалить пресет) — сплошная красная, белый текст */
.btn-danger {
  background: var(--color-error, #c0392b) !important;
  color: #fff !important;
  border-color: transparent !important;
}
.btn-danger:not(:disabled):hover { background: #a8311f !important; color: #fff !important; }

/* Строки пресета: ненавязчивая подсветка (тёплый тон, не перебивает diff-цвета) */
.inva-row-preset > .invd-td {
  background: var(--preset-row-bg, #fffaf4) !important;
}
.inva-row-preset > .invd-td-name {
  background: var(--preset-row-bg, #fffaf4) !important;
}
/* Even-строки пресета — чуть темнее */
.inva-row-preset:nth-child(even) > .invd-td {
  background: var(--preset-row-bg-alt, #fff5ea) !important;
}
.inva-row-preset:nth-child(even) > .invd-td-name {
  background: var(--preset-row-bg-alt, #fff5ea) !important;
}

/* Выбранный в дропбоксе пресет — сильная цветная подсветка строк (зелёный тон) */
.inva-row-highlight > .invd-td,
.inva-row-highlight > .invd-td-name {
  background: var(--preset-hl-bg, #e3f3e0) !important;
}
.inva-row-highlight:nth-child(even) > .invd-td,
.inva-row-highlight:nth-child(even) > .invd-td-name {
  background: var(--preset-hl-bg-alt, #d9eed5) !important;
}

/* Попап «Принять по факту» (превью) */
.inva-apply-warn {
  background: var(--warn-soft, #fff4e0); color: var(--ink, #333);
  border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.4;
  margin-bottom: 14px;
}
.inva-apply-group { margin-bottom: 14px; }
.inva-apply-group-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--ink-muted, #888); margin-bottom: 6px;
}
.inva-apply-row {
  display: flex; align-items: baseline; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid var(--border-soft, #eee);
}
.inva-apply-name { flex: 1; font-size: 14px; }
.inva-apply-unit { color: var(--ink-muted, #999); font-size: 12px; min-width: 28px; }
.inva-apply-qty { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Инкремент B: выбор счёта + метаданные */
.inva-apply-account-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.inva-apply-account-label {
  font-size: 13px; font-weight: 600; white-space: nowrap;
  color: var(--ink, #333);
}
.inva-apply-account-select {
  flex: 1; min-width: 180px; max-width: 100%;
  font-size: 14px; padding: 7px 10px;
  border: 1.5px solid var(--border, #ddd); border-radius: 8px;
  background: var(--surface, #fff); color: var(--ink, #333);
  appearance: auto; cursor: pointer;
}
.inva-apply-account-select--error {
  border-color: var(--color-danger, #d9534f);
}
.inva-apply-meta {
  font-size: 13px; color: var(--ink-muted, #888);
  margin-bottom: 10px;
}
.inva-apply-meta b { color: var(--ink, #333); }
.inva-apply-idempotency-note {
  font-size: 12px; color: var(--ink-muted, #888);
  margin-top: 12px; padding: 8px 10px;
  background: var(--surface-alt, #f8f8f8); border-radius: 8px;
  line-height: 1.45;
}
.inva-apply-success {
  font-size: 14px; line-height: 1.55;
  padding: 6px 0;
}
.inva-apply-success b { color: var(--color-brand, #b85c00); }
.inva-apply-error {
  font-size: 14px; color: var(--color-danger, #d9534f); line-height: 1.45;
}

/* Бейдж с именем пресета рядом с названием позиции */
.inva-preset-badge {
  display: inline-block; margin-left: 5px;
  padding: 1px 6px; border-radius: 100px;
  background: var(--accent-warm, #f5e6d0); color: var(--color-brand, #b85c00);
  font-size: 10px; font-weight: 600; letter-spacing: 0.2px;
  vertical-align: middle; white-space: nowrap; cursor: default;
}
.inva-preset-badge-more {
  background: var(--surface-alt, #ede8df); color: var(--ink-muted);
}

/* ── Попап редактирования состава пресета (Sheet) ───────────────────────── */

/* Обёртка: поле поиска + прокручиваемый список */
.inva-edit-sheet-wrap {
  display: flex; flex-direction: column; height: 100%; min-height: 0;
}

/* Строка поиска внутри попапа */
.inva-edit-sheet-search-wrap {
  flex-shrink: 0; padding: 4px 0 10px;
}
.inva-edit-sheet-search {
  width: 100%; box-sizing: border-box;
  font-size: 14px; color: var(--ink);
  padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--surface); outline: none;
}
.inva-edit-sheet-search:focus { outline: 2px solid var(--color-brand, #e36b00); outline-offset: 1px; }

/* Прокручиваемый список позиций */
.inva-edit-sheet-list {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border); border-radius: var(--r-sm);
}

/* Одна строка-позиция: чекбокс + имя + ед. */
.inva-edit-sheet-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; cursor: pointer;
  border-bottom: 1px solid var(--hairline, #eee);
  transition: background 0.1s;
}
.inva-edit-sheet-row:last-child { border-bottom: none; }
.inva-edit-sheet-row:hover { background: var(--surface-raised); }
.inva-edit-sheet-cb {
  flex-shrink: 0; width: 16px; height: 16px; cursor: pointer;
  accent-color: var(--color-brand, #e36b00);
}
.inva-edit-sheet-name { flex: 1; font-size: 14px; color: var(--ink); }
.inva-edit-sheet-unit {
  font-size: 12px; color: var(--ink-muted); min-width: 28px; text-align: right; flex-shrink: 0;
}

/* Строка кнопок управления пресетом (Переименовать / Удалить) в заголовке попапа */
.inva-edit-sheet-mgmt {
  display: flex; gap: 8px; padding-top: 6px;
}

/* Попап создания нового пресета */
.inva-create-sheet-wrap { padding: 4px 0; }

/* Бейдж «по факту» (оставлен для обратной совместимости, не используется в v2) */
.inva-fact-badge {
  display: inline-block; margin-left: 6px;
  padding: 1px 6px; border-radius: 100px;
  background: var(--accent-warm, #f5e6d0); color: var(--color-brand, #b85c00);
  font-size: 10px; font-weight: 600; letter-spacing: 0.2px;
  vertical-align: middle; white-space: nowrap;
}

/* ── AI-бейдж (инкремент 3: LLM-причины) ───────────────────────────────────── */
.inva-ai-badge {
  display: inline-flex; align-items: center;
  margin-left: 5px;
  padding: 1px 5px; border-radius: 4px;
  background: #e8f0fe; color: #1a56db;
  font-size: 10px; font-weight: 700; letter-spacing: 0.3px;
  vertical-align: middle; white-space: nowrap;
  border: 1px solid #c7d9fc;
  line-height: 1.4;
}

/* Сноска «AI-версии недоступны» */
.inva-llm-footnote {
  margin: 8px 16px 0;
  font-size: 12px; color: var(--ink-muted);
  font-style: italic;
}
