/* Рабочий интерфейс склада. Оформление намеренно скупое: это инструмент для
   ежедневных операций, а не витрина. Приоритеты — читаемость цифр, крупные
   зоны нажатия для работы с телефона, отсутствие лишних движений мышью. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #16191d;
  --ink-soft: #454e57;
  /* 5.12 на белом и 4.69 на сером фоне таблиц: прежний #6b7681 давал
     на сером 4.25 — ниже нормы 4.5, а именно там стоят нули и подписи. */
  --muted: #656f79;
  --border: #dbe0e5;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --ok-bg: #e4f3ea;
  --ok-ink: #1d6b41;
  --warn-bg: #fdf0dc;
  --warn-ink: #8a5a10;
  --err-bg: #fbe6e4;
  --err-ink: #a3291d;
  --radius: 8px;

  /* Шкала размеров. Было двенадцать произвольных значений, включая 14.5px:
     разнобой не читается как система и мешает выравнивать блоки между собой.
     Пять ступеней покрывают всё, 12px — нижняя граница: мельче на складском
     экране не прочитать, особенно с телефона. */
  --text-xs: 12px;   /* служебные подписи, шапки таблиц */
  --text-sm: 13px;   /* подсказки под полями */
  --text-md: 14px;   /* вторичный текст, кнопки в строках */
  --text-lg: 15px;   /* основной текст таблиц */
  --text-xl: 18px;   /* заголовки разделов */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* --- Шапка ---------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
}
.brand { font-weight: 700; font-size: var(--text-xl); color: var(--ink); text-decoration: none; }
.topbar nav { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.topbar nav a {
  padding: 8px 14px;
  border-radius: var(--radius);
  color: var(--ink-soft);
  text-decoration: none;
}
.topbar nav a:hover { background: var(--bg); }
.topbar nav a.active { background: var(--accent); color: var(--accent-ink); }

/* --- Справочники: выпадающий пункт меню -------------------------------------- */

.topbar nav .menu { position: relative; }
.topbar nav .menu > summary {
  padding: 8px 14px;
  border-radius: var(--radius);
  color: var(--ink-soft);
  cursor: pointer;
  list-style: none;          /* убираем встроенный треугольник <details> */
  user-select: none;
  white-space: nowrap;
}
.topbar nav .menu > summary::-webkit-details-marker { display: none; }
.topbar nav .menu > summary::after {
  content: "▾";
  margin-left: 6px;
  font-size: var(--text-xs);
  opacity: .7;
}
.topbar nav .menu > summary:hover { background: var(--bg); }
/* Раздел внутри подсвечивает сам пункт — иначе, находясь в «Товарах», не видно,
   где ты в меню: сам раздел ведь спрятан. */
.topbar nav .menu.active > summary { background: var(--accent); color: var(--accent-ink); }
.topbar nav .menu[open] > summary { background: var(--bg); }

.topbar nav .menu-items {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .10);
}
.topbar nav .menu-items a { padding: 7px 10px; }

/* Невидимый слой на весь экран: клик мимо меню закрывает его, а не проваливается
   в страницу. Лежит под самим списком, поэтому по пунктам кликается как обычно. */
.topbar nav .menu[open] > summary::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 10;
}
.current-user { font-size: var(--text-md); color: var(--ink-soft); font-weight: 500; }
.logout { color: var(--muted); text-decoration: none; font-size: var(--text-md); }
.logout:hover { color: var(--ink); }

/* Ширина под таблицы, а не под текст: в остатках одиннадцать столбцов, и на
   1200px они не помещались — приходилось листать вбок. Ограничение остаётся,
   чтобы на очень широком мониторе строка таблицы не растягивалась через весь
   экран и взгляд не терял строку между первым и последним столбцом. */
main { max-width: 1600px; margin: 0 auto; padding: 24px 20px 64px; }

/* Сплошной текст при этом держим узким: читать строку в 1600px невозможно. */
.subtitle, .hint, .empty { max-width: 90ch; }

h1 { font-size: 24px; margin: 0 0 4px; }
.subtitle { color: var(--muted); margin: 0 0 24px; font-size: var(--text-lg); }

/* --- Панель фильтров ------------------------------------------------------ */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; }
/* Подписи держим в одну строку одинаковой высоты: иначе длинная подпись
   переносится, её поле становится выше остальных, и при выравнивании по
   нижнему краю подписи соседних полей оказываются на разной высоте. */
.field label {
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 18px;
  min-height: 18px;
  white-space: nowrap;
}
.field.grow { flex: 1; min-width: 200px; }
/* Кнопка в строке фильтров — вровень с полями, а не с их подписями. */
.filters button { align-self: flex-end; }

input[type="text"], input[type="number"], input[type="password"], select, textarea {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  width: 100%;
  min-height: 44px; /* палец, а не курсор */
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

button, .btn {
  font: inherit;
  font-weight: 600;
  padding: 10px 18px;
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
button.secondary, .btn.secondary {
  background: var(--surface);
  color: var(--ink-soft);
  border-color: var(--border);
}
button:hover { filter: brightness(1.06); }

.checkbox { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.checkbox input { width: 18px; height: 18px; min-height: 0; }
.checkbox label { font-size: var(--text-md); color: var(--ink-soft); }

/* --- Таблица -------------------------------------------------------------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}
table { border-collapse: collapse; width: 100%; }
th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
thead th {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 600;
  background: var(--bg);
  position: sticky;
  top: 0;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
td.name { white-space: normal; min-width: 220px; }
td.sku { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--text-sm); color: var(--ink-soft); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.num.zero { color: var(--muted); }
.num.reserved { color: var(--warn-ink); }
/* «В пути» — товара на складе ещё нет, поэтому цвет отличается от фактического
   остатка: это будущее поступление, а не наличие. */
.num.incoming { color: var(--accent); }
.num.total { font-weight: 600; }
.col-group { border-left: 2px solid var(--border); }
td[title] { cursor: help; }

/* --- Сообщения ------------------------------------------------------------ */

.msg { padding: 14px 16px; border-radius: var(--radius); margin-bottom: 20px; }
.msg.ok { background: var(--ok-bg); color: var(--ok-ink); }
.msg.err { background: var(--err-bg); color: var(--err-ink); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* --- Вход ----------------------------------------------------------------- */

.login-wrap { max-width: 380px; margin: 80px auto; }
.login-wrap h1 { text-align: center; margin-bottom: 24px; }
.login-wrap .field { margin-bottom: 14px; }
.login-wrap button { width: 100%; justify-content: center; }

/* --- Форма операции ------------------------------------------------------- */

.form-grid { display: grid; gap: 14px; max-width: 560px; }
.form-grid.wide { max-width: 860px; }
/* Блок во всю ширину — для таблиц внутри формы: поля ввода узкие, потому что
   читать их удобнее в колонку, а таблице нужен весь экран. */
.form-grid.full { max-width: none; }
.two-col { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }

/* Элемент сетки по умолчанию не сжимается меньше своего содержимого
   (min-width: auto). Из-за этого широкая таблица внутри формы распирала её
   мимо max-width и ломала страницу, а overflow-x у .table-wrap не срабатывал:
   сжиматься было некуда. min-width: 0 возвращает возможность сжаться —
   и тогда таблица честно прокручивается внутри себя. */
.form-grid > *,
.two-col > *,
.collapse-body > * { min-width: 0; }
.hint { font-size: var(--text-sm); color: var(--muted); margin-top: 4px; }
.hint a { color: var(--accent); }
textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--text-md);
  line-height: 1.6;
}
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
button[disabled] { opacity: .5; cursor: not-allowed; }

/* --- Заголовок с кнопкой справа -------------------------------------------- */

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

/* --- Статусы --------------------------------------------------------------- */

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: var(--text-sm);
  white-space: nowrap;
}
.pill.draft { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.pill.transit { background: #e5effc; color: #17508f; }
.pill.done { background: var(--ok-bg); color: var(--ok-ink); }
.pill.cancelled { background: var(--err-bg); color: var(--err-ink); }

.status-bar { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; }
.status-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.status-actions form { margin: 0; }
.tag {
  display: block;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: 2px;
}

/* Поле ввода количества в таблице приёмки — узкое, чтобы строка не разъезжалась */
.qty-input { width: 96px; text-align: right; }
tr.inactive { opacity: .55; }
h3 { margin: 28px 0 8px; font-size: var(--text-xl); }

@media (max-width: 640px) {
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  main { padding: 16px 12px 48px; }
  .topbar { padding: 10px 12px; gap: 12px; }
  th, td { padding: 10px; }
}

/* --- Сворачиваемый блок в форме --------------------------------------------- */

.collapse {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.collapse summary {
  cursor: pointer;
  padding: 12px 16px;
  font-weight: 600;
  font-size: var(--text-md);
  color: var(--ink-soft);
  user-select: none;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.collapse summary:hover { color: var(--ink); }
.collapse[open] summary { border-bottom: 1px solid var(--border); }
.collapse-body { padding: 16px; display: grid; gap: 14px; background: var(--surface); }
.collapse-body .hint { margin-top: 0; }

/* --- Настройка столбцов таблицы --------------------------------------------- */

/* Шестерёнка в шапке, в одном столбце с шестерёнками строк. Маркер списка
   убран: треугольник рядом с иконкой читался бы как вторая кнопка. */
.col-menu > summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
}
.col-menu > summary::-webkit-details-marker { display: none; }
.col-menu > summary:hover,
.col-menu[open] > summary { color: var(--accent); }

/* Панель позиционируется скриптом (position: fixed), потому что таблица лежит
   в контейнере с горизонтальной прокруткой: обычное абсолютное меню он бы
   обрезал по своему краю. */
.col-menu-panel {
  position: fixed;
  z-index: 60;
  min-width: 220px;
  max-width: 280px;
  padding: 12px 14px;
  display: grid;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
  text-align: left;
  font-weight: 400;
}
.col-menu-title {
  margin: 0 0 2px;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
/* Метка целиком кликабельна: попасть в сам квадратик 13 пикселей мышью —
   занятие на любителя, а отмечают тут по нескольку штук подряд. */
.col-menu-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--ink);
  padding: 3px 0;
  white-space: nowrap;
}
.col-menu-panel input { cursor: pointer; }
.col-menu-panel button { margin-top: 4px; width: 100%; }
.col-menu-panel .hint { margin: 0; font-size: var(--text-xs); white-space: normal; }

/* Спрятанный столбец. Браузер и сам не показывает [hidden], но у ячеек
   таблицы своё display, и полагаться на то, чья возьмёт, не стоит. */
table [hidden] { display: none !important; }

/* --- ФБС: экран сборки ------------------------------------------------------ */

/* Сводка сверху: сколько работы, что горит, всё ли обеспечено остатком.
   Три числа, а не таблица показателей: кладовщик читает их за секунду. */
.fbs-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.fbs-metric {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
}
.fbs-metric b { display: block; font-size: 24px; line-height: 1.15; }
.fbs-metric span { display: block; font-size: var(--text-sm); color: var(--ink-soft); margin-top: 2px; }
.fbs-metric i { display: block; font-style: normal; font-size: var(--text-xs); color: var(--muted); margin-top: 6px; }
.fbs-metric.warn { border-left-color: #d98324; }
.fbs-metric.warn b { color: #b96a17; }
.fbs-metric.crit { border-left-color: #c0392b; }
.fbs-metric.crit b { color: #c0392b; }

/* Вкладки со счётчиками — как в кабинете площадки: работают с одним
   состоянием за раз, и общий список заставлял бы искать глазами. */
.fbs-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.fbs-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  font-size: var(--text-sm);
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -1px;
}
.fbs-tab:hover { color: var(--ink); background: var(--bg); }
.fbs-tab.active {
  color: var(--ink);
  font-weight: 600;
  background: var(--surface);
  border-color: var(--border);
}
.fbs-tab .count {
  font-size: var(--text-xs);
  color: var(--muted);
  background: var(--bg);
  border-radius: 10px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}
.fbs-tab.active .count { background: var(--accent); color: var(--accent-ink); }

/* Панель массовых действий: показывается, только когда что-то отмечено. */
.fbs-bulk {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.fbs-bulk > span:first-child { margin-right: auto; font-size: var(--text-sm); }

/* Список заказов. Строки просторные намеренно: в них фотография и три
   строки текста, и плотная вёрстка остатков тут читалась бы кашей. */
.fbs-list { width: 100%; border-collapse: collapse; }
.fbs-list th {
  text-align: left;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.fbs-list th.num, .fbs-list td.num { text-align: right; }
.fbs-list td { padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.fbs-list tr:hover td { background: var(--bg); }
.fbs-list tr.inactive td { opacity: 0.55; }
.fbs-list .muted { color: var(--muted); font-size: var(--text-xs); margin-top: 2px; }

.fbs-order .order-number { font-weight: 600; font-variant-numeric: tabular-nums; text-decoration: none; }
.fbs-order .badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

/* Время ожидания — главный сигнал строки, поэтому оно цветное, а не серое. */
.wait, .tag {
  font-size: var(--text-xs);
  border-radius: 10px;
  padding: 2px 8px;
  white-space: nowrap;
}
.wait.ok { background: #e8f5ec; color: #1e7a3c; }
.wait.warn { background: #fdf1e0; color: #a4661a; }
.wait.crit { background: #fdeaea; color: #c0392b; font-weight: 600; }
.tag { background: var(--bg); color: var(--ink-soft); border: 1px solid var(--border); }
.tag.danger { background: #fdeaea; color: #c0392b; border-color: #f3c3c0; }
.tag.state { background: var(--surface); }

.fbs-product .product-cell { display: flex; gap: 10px; align-items: flex-start; }
.fbs-product .product-text { min-width: 0; }
.fbs-product .product-name { font-weight: 500; text-decoration: none; color: var(--ink); }
.fbs-product .product-name:hover { color: var(--accent); }
.fbs-where b { font-weight: 500; }

/* Меню строки: те же ссылки, что и в настройке столбцов, но списком. */
.col-menu-panel a {
  display: block;
  padding: 6px 4px;
  font-size: var(--text-sm);
  color: var(--ink);
  text-decoration: none;
  border-radius: 4px;
}
.col-menu-panel a:hover { background: var(--bg); color: var(--accent); }

/* --- Лист сборки ------------------------------------------------------------ */

.picking-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0 14px;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 10px;
}
.picking { width: 100%; border-collapse: collapse; }
.picking th {
  text-align: left;
  font-size: var(--text-xs);
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.picking th.num, .picking td.num { text-align: right; }
.picking td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.picking .take b { font-size: 20px; font-variant-numeric: tabular-nums; }
.picking tr.short td { background: #fdf6f5; }
.picking .shortage { color: #c0392b; font-weight: 600; }
.picking .orders-col { max-width: 320px; font-size: var(--text-xs); word-break: break-word; }
/* Квадрат под галочку карандашом: лист печатают и идут с ним по складу. */
.picking .tick-col { width: 34px; }
.picking .tick {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--ink-soft);
  border-radius: 3px;
}

@media print {
  .no-print, .topbar, .fbs-bulk { display: none !important; }
  .picking td, .picking th { padding: 6px 8px; }
  .picking tr { break-inside: avoid; }
  .picking .orders-col { display: none; }
  body { background: #fff; }
}

/* --- Габариты: несколько узких полей в ряд ---------------------------------- */

.dims {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.dim { display: flex; flex-direction: column; gap: 4px; }
.dim span { font-size: var(--text-xs); color: var(--muted); white-space: nowrap; }
.dim input { text-align: right; }

@media (max-width: 640px) {
  .dims { grid-template-columns: repeat(2, 1fr); }
}

/* Форма передачи упаковки прямо в строке таблицы */
.inline-form { display: flex; gap: 8px; align-items: center; margin: 0; }
.inline-form select { width: auto; min-width: 130px; }
.inline-form button { white-space: nowrap; }

/* Итоговая строка таблицы */
.total-row td { font-weight: 600; background: var(--bg); border-top: 2px solid var(--border); }

/* Размеры упаковки — три поля вместо четырёх */
.dims.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 640px) { .dims.three { grid-template-columns: repeat(2, 1fr); } }

/* Строка с конфликтом артикулов в предпросмотре импорта */
.row-conflict td { background: var(--err-bg); }
.sku-input { width: 180px; font-family: ui-monospace, Menlo, monospace; font-size: var(--text-sm); }
input[type="file"] { padding: 9px 12px; }

/* --- Миниатюра товара ------------------------------------------------------- */

.thumb-col { width: 56px; padding-right: 0; }
.thumb {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
}
/* Пустая заглушка того же размера — чтобы строки не прыгали по высоте */
.thumb-empty { background: var(--bg); }

/* Название товара в списке: не даём растянуться на пол-экрана */
td.name.compact { max-width: 340px; min-width: 200px; }

/* --- Плотная таблица (списки на сотни строк) -------------------------------- */

/* Высоту строки задаёт самый высокий элемент, поэтому ужимать надо всё сразу:
   отступы, миниатюру и перенос названия. Иначе строка останется прежней. */
.dense th,
.dense td { padding: 5px 10px; }
.dense .thumb-col { width: 38px; }
.dense .thumb { width: 28px; height: 28px; border-radius: 4px; }
/* Название в одну строку с многоточием: разная высота строк мешает вести
   взгляд по цифрам, а полное имя всегда есть в подсказке и в карточке. */
.dense td.name.compact {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}
.dense .cat { margin-left: 6px; font-size: var(--text-xs); padding: 0 6px; }
.dense .pill { font-size: var(--text-xs); padding: 0 6px; }

/* Цифры по центру столбца: столбцы узкие (2–4 знака), и при выравнивании
   вправо число отрывается от собственного заголовка. tabular-nums всё равно
   держит разряды в колонку. */
.dense .num { text-align: center; }

/* Категория отдельным столбцом: в имени товара она мешала читать само имя,
   а сама по себе нужна как признак, по которому список группируют и сортируют. */
.dense td.cat-col {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Сортировка по клику на заголовок --------------------------------------- */

th.sortable { padding: 0; }
th.sortable > a {
  display: block;
  padding: 12px 14px;   /* повторяет отступы обычной ячейки: кликается вся шапка */
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.dense th.sortable > a { padding: 5px 10px; }
th.sortable > a:hover { color: var(--ink); }
th.sortable.num > a { text-align: center; }
th.sorted > a { color: var(--ink); }
/* Стрелка занимает место всегда, иначе заголовки прыгают при смене сортировки. */
.arrow { display: inline-block; width: 12px; text-align: left; }

/* --- Действие в строке (шестерёнка) ------------------------------------------ */

/* Ссылка повторяется в каждой строке. Текстом («Изменить») она набирает вес
   сотней повторов и спорит с цифрами, ради которых список открывают, поэтому
   значок и приглушённый цвет; что он делает — в подсказке title. */
td.row-action { width: 34px; text-align: center; }
td.row-action > a {
  color: var(--muted);
  text-decoration: none;
  line-height: 0;
  display: inline-block;
  padding: 3px;
  border-radius: 4px;
}
td.row-action > a:hover { color: var(--accent); background: var(--bg); }

/* Значок рисуется вектором и красится currentColor — поэтому подхватывает
   цвет ссылки и приглушение/подсветку при наведении без отдельных правил. */
.icon {
  width: 15px;
  height: 15px;
  display: block;
  fill: currentColor;
}

/* --- Растягивание столбцов --------------------------------------------------- */

th { position: relative; }
.col-resize {
  position: absolute;
  top: 0;
  right: 0;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  /* Линию видно только при наведении: постоянная сетка из вертикальных полос
     спорила бы с разделителями групп столбцов (col-group). */
  border-right: 2px solid transparent;
}
.col-resize:hover { border-right-color: var(--accent); }
/* Пока тянем — курсор col-resize на всей странице, и текст не выделяется. */
body.col-resizing { cursor: col-resize; user-select: none; }
.cat {
  display: inline-block;
  margin-left: 8px;
  font-size: var(--text-xs);
  color: var(--muted);
  background: var(--bg);
  border-radius: 10px;
  padding: 1px 8px;
  white-space: nowrap;
}

/* Метка площадки, которая ведёт на карточку. Выглядит как обычная метка, пока
   на неё не наведёшь: в столбце их сотни, и подчёркивать каждую значило бы
   зарябить таблицу. */
a.cat.link { color: var(--text); text-decoration: none; }
a.cat.link:hover { color: var(--accent); text-decoration: underline; }

/* Фото-ссылка не должна отличаться от простого фото ничем, кроме курсора. */
.thumb-col a { display: inline-block; line-height: 0; }

/* --- Интеграции: карточки по кабинетам --------------------------------------- */

/* Каждый кабинет — своя форма: сохранять ключи по одному безопаснее, чем одной
   большой формой, где промах по кнопке перезаписывает все шесть. */
.integration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.integration-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.err-text { color: var(--err-ink); }

/* Поле с несъёмной приставкой — код магазина перед номером заказа. Приставка
   не поле ввода: код меняется в справочнике магазинов, а не в каждом заказе. */
.prefixed { display: flex; align-items: stretch; }
.prefixed .prefix {
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--bg);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
}
.prefixed input { border-radius: 0 var(--radius) var(--radius) 0; }

/* --- Опасное действие ------------------------------------------------------- */

/* Удаление отделено от формы правки и подписано: оно необратимо, и случайное
   попадание по кнопке рядом с «Сохранить» стоило бы дорого. */
.danger-zone { border-color: var(--err-ink); }
.danger-zone > b { color: var(--err-ink); }
.danger-zone form { margin-top: 12px; }
button.danger {
  background: var(--surface);
  color: var(--err-ink);
  border-color: var(--err-ink);
}
button.danger:hover { background: var(--err-bg); }

/* --- Массовые действия над строками ------------------------------------------ */

.pick-col { width: 34px; text-align: center; }
/* Галочка крупнее и с запасом вокруг: ею отмечают десятки строк подряд,
   часто с планшета. 17px — размер, в который на ходу не попадают. */
.pick-col input { width: 20px; height: 20px; min-height: 0; margin: 0; cursor: pointer; }
.pick-col { padding: 0; }
.pick-col label { display: flex; align-items: center; justify-content: center; min-height: 40px; cursor: pointer; }

/* Панель прилипает к низу экрана: при сотне строк выбор делают в середине
   списка, и кнопка внизу страницы оказалась бы за пределами видимого. */
.bulk-bar {
  position: sticky;
  bottom: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, .08);
}
.bulk-count { color: var(--muted); font-size: var(--text-md); margin-right: 4px; white-space: nowrap; }
.bulk-count b { color: var(--ink); font-size: var(--text-lg); }
.bulk-action { display: flex; gap: 0; }
.bulk-input {
  width: auto;
  min-width: 150px;
  border-radius: var(--radius) 0 0 var(--radius);
  border-right: none;
}
.bulk-action button { border-radius: 0 var(--radius) var(--radius) 0; }
/* Удаление отодвинуто от остальных кнопок: рядом с «Снять с оборота» по нему
   легко промахнуться, а отменить его нельзя. */
.bulk-bar > button.danger { margin-left: auto; }

/* --- Выбор позиций заказа ---------------------------------------------------- */

/* Таблица прокручивается внутри себя: номенклатура магазина — сотни строк,
   и без этого кнопка «Создать заказ» уезжала бы за три экрана вниз. */
.order-picker { max-height: 460px; overflow-y: auto; }
.pick-filter {
  max-width: 420px;
  margin-bottom: 10px;
}
/* Поле количества — то, во что менеджер бьёт цифры десятки раз за заказ.
   34px было ниже пальцевого минимума. */
.order-picker .qty-input { width: 92px; min-height: 40px; padding: 6px 10px; text-align: right; }

/* --- Итоги по документу ------------------------------------------------------ */

tfoot td {
  border-top: 2px solid var(--border);
  border-bottom: none;
  font-weight: 600;
  background: var(--bg);
}
.total-label { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: var(--text-xs); letter-spacing: .04em; }
td.num.total { font-size: var(--text-lg); }

/* Итог под таблицей в формах — крупно и справа: это то число, ради которого
   на форму смотрят последним, перед тем как нажать «сохранить». */
.order-total {
  text-align: right;
  font-size: 16px;
  color: var(--ink-soft);
  padding: 12px 2px 0;
}
.order-total b { font-size: 20px; color: var(--ink); font-variant-numeric: tabular-nums; }

/* Строка, отмеченная к удалению, гасится: видно, что она уже не в счёте. */
.row-removed { opacity: .45; }
.row-removed .name { text-decoration: line-through; }


/* Свёрнутый блок, который является действием, а не разделом: серая полоска
   во всю ширину читалась как заголовок и её не замечали. Здесь summary —
   обычная кнопка по ширине текста, а рамку и фон несёт уже раскрытое тело. */
.action-collapse { border: none; background: none; border-radius: 0; }
.action-collapse > summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
}
.action-collapse > summary:hover { background: var(--bg); }
.action-collapse[open] > summary { margin-bottom: 12px; }
.action-collapse[open] > summary { border-radius: var(--radius); }
/* Раскрытый — плюс поворачивается в крестик: одна иконка на оба состояния,
   и «закрыть» читается без второго значка. */
.action-collapse > summary .plus { transition: transform .15s; }
.action-collapse[open] > summary .plus { transform: rotate(45deg); }
.action-collapse > .collapse-body {
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* --- Оценка запаса ----------------------------------------------------------- */

.valuation { display: grid; gap: 14px; }
.valuation-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.valuation-label { color: var(--muted); font-size: var(--text-lg); }
.valuation-main b { font-size: 26px; font-variant-numeric: tabular-nums; }
/* Слагаемые мельче итога: сумму читают первой, разбивку — если она понадобится. */
.valuation-parts {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.valuation-parts > div { display: flex; flex-direction: column; gap: 2px; }
.valuation-parts span { color: var(--muted); font-size: var(--text-sm); }
.valuation-parts b { font-size: 17px; font-variant-numeric: tabular-nums; }

/* Ссылка внутри ячейки таблицы: не должна выглядеть как ссылка в тексте —
   подчёркивание в каждой строке превратило бы столбец в частокол. */
td.sku > a, td.name > a { color: inherit; text-decoration: none; }
td.sku > a:hover, td.name > a:hover { color: var(--accent); text-decoration: underline; }

/* Контакты поставщика в шапке заказа: ссылки-действия, а не просто текст —
   с телефона по ним звонят и пишут в один тап. */
.contacts { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 4px; }
.contacts a { color: var(--accent); text-decoration: none; }
.contacts a:hover { text-decoration: underline; }

/* --- Сводка: блок «требует внимания» ----------------------------------------- */

/* Карточки-ссылки: система нашла проблему — она же и приводит к ней.
   Показать число без способа его открыть значит заставить искать вручную. */
.attention-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.attention {
  display: block;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--muted);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
}
.attention:hover { background: var(--bg); }
.attention.crit { border-left-color: var(--err-ink); }
.attention.warn { border-left-color: var(--warn-ink); }
.attention.ok { border-left-color: var(--accent); }
.attention > b {
  display: block;
  font-size: 30px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.attention.crit > b { color: var(--err-ink); }
.attention.warn > b { color: var(--warn-ink); }
.attention.ok > b { color: var(--accent); }
.attention-label { display: block; font-weight: 600; margin-top: 4px; }
.attention-hint {
  display: block;
  font-size: var(--text-sm);
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}

/* --- Сводка: плитки метрик ---------------------------------------------------- */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 22px;
}
.metric-grid .metric { background: var(--surface); padding: 16px 18px; }
.metric-grid .metric > b {
  display: block;
  font-size: 24px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.metric-grid .metric > b.zero { color: var(--muted); }
.metric-grid .metric > b.reserved { color: var(--warn-ink); }
.metric-grid .metric > b.incoming { color: var(--accent); }
.metric-grid .metric > span {
  display: block;
  font-size: var(--text-sm);
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.4;
}

/* Блок про то, чего пока нет: приглушён, чтобы не спорить с живыми цифрами. */
.pending-metrics { background: var(--bg); border-style: dashed; }
.pending-metrics > b { color: var(--ink-soft); }

/* Сообщение-предупреждение: не ошибка, но требует внимания — например
   артикулы, которых нет у нас, или заказы, оставшиеся без резерва. */
.msg.warn-msg { background: var(--warn-bg); color: var(--warn-ink); }

/* --- Отметка свежести данных ------------------------------------------------- */

/* Строка под заголовком: когда обмен с площадкой проходил последний раз.
   Неудача заметнее удачи — отвалившийся ключ снаружи выглядит ровно как
   «новых заказов нет», и молчать о нём нельзя. */
.sync-status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: -12px 0 16px;
  font-size: var(--text-xs);
  color: var(--muted);
}
.sync-item b { font-weight: 600; color: var(--ink-soft); }
.sync-item.failed { color: var(--err-ink); }
.sync-item.failed b { color: var(--err-ink); }
