:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1d2733;
  --muted: #6b7785;
  --line: #dde2e8;
  --accent: #1f6feb;
  --accent-dark: #1a5cc4;
  --ok: #1a7f4b;
  --warn: #b5730a;
  --err: #c0392b;
  --ok-bg: #e8f5ee;
  --warn-bg: #fdf3e0;
  --err-bg: #fdecea;
  --info-bg: #e8f0fd;
}

* { box-sizing: border-box; }

/* Атрибут hidden должен побеждать любой класс, задающий display.
   Без этого правила display: flex на скрываемой панели перекрывал бы
   браузерное [hidden] { display: none } — панель была бы видна всегда. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 14px/1.45 "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ шапка */

.top {
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 52px;
  background: #22303f; color: #fff;
}
.top .brand { color: #fff; font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a {
  color: #c9d4de; padding: 6px 12px; border-radius: 6px; font-size: 13.5px;
}
.top nav a:hover { background: #2d3d4e; color: #fff; text-decoration: none; }
.top nav a.on { background: var(--accent); color: #fff; }
/* Счётчик новых заказов у вкладки — как непрочитанные в мессенджере. */
.nav-badge {
  display: inline-block; min-width: 18px; height: 18px; margin-left: 5px; padding: 0 5px;
  border-radius: 9px; background: #e5484d; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; vertical-align: 1px;
}
.nav-badge[hidden] { display: none; }
.top .who { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #c9d4de; }
.top .who .name { color: #fff; }
.top form { margin: 0; }
.location-switch {
  display: flex; align-items: center; gap: 6px;
  background: #2d3d4e; border: 1px solid var(--accent); border-radius: 16px;
  padding: 3px 10px 3px 8px;
}
.location-switch-icon { color: var(--accent); font-size: 13px; line-height: 1; }
.location-switch-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: #9fb3c8;
}
.location-switch select {
  background: transparent; color: #fff; border: 0;
  font: inherit; font-size: 13px; font-weight: 600; padding: 2px 2px; cursor: pointer;
}
.location-switch select:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
/* В открытом списке браузер рисует фон непрозрачным белым, но цвет текста
   наследуется от select (#fff) — на некоторых сборках Chrome/Edge (Windows)
   пункты становятся белым по белому и не видны, кроме наведённого. */
.location-switch select option { background: #fff; color: var(--ink); }
.link {
  background: none; border: 0; color: #c9d4de; cursor: pointer;
  font: inherit; padding: 4px 6px; text-decoration: underline;
}
.link:hover { color: #fff; }

.chip {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  background: #3c4d5f; font-size: 11px; text-transform: uppercase; letter-spacing: .4px;
}
.chip.sign { background: var(--ok); color: #fff; }

.chip-list { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; }
.chip-check { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 400; }

.mode-banner {
  background: #fff3cd; border-bottom: 1px solid #e5cf8a; color: #6b5407;
  padding: 7px 20px; font-size: 13px; text-align: center;
}
.mode-banner a { margin-left: 8px; }

/* ----------------------------------------------------------------- layout */

.wrap { max-width: 1180px; margin: 22px auto 60px; padding: 0 20px; }
.wide { max-width: 1600px; margin: 22px auto 60px; padding: 0 20px; }
.board-page { max-width: none; margin: 22px 0 60px; padding: 0 20px; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 26px 0 10px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
.sub { color: var(--muted); margin: 0 0 18px; font-size: 13px; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 16px 18px; margin-bottom: 16px;
}
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 0 0 auto; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ----------------------------------------------------------------- формы */

label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=email], select, textarea {
  font: inherit; padding: 6px 9px; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #cfe0fb; border-color: var(--accent); }
textarea { min-height: 120px; font-family: Consolas, "Courier New", monospace; font-size: 13px; }

.btn {
  font: inherit; padding: 7px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.btn:hover { background: #f0f3f7; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { border-color: #e3b5b0; color: var(--err); }
.btn.danger:hover { background: var(--err-bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
/* Финальное подтверждение заказов на сверке (review.html) — крупнее
   остальных кнопок страницы и внизу, после всех заказов: это последний шаг
   перед отправкой подрядчикам, не должен теряться среди рабочих кнопок
   («Обновить цены из ЛК» и т. п.) в шапке страницы. */
.btn.large { padding: 13px 28px; font-size: 16px; font-weight: 600; border-radius: 8px; }
.approve-panel { text-align: center; }

/* Группа кнопок-решений (сверка): визуально кнопки, по сути — radio,
   без JS. Скрытый input остаётся в потоке табуляции. */
.decision-group { display: flex; flex-wrap: wrap; gap: 4px; }
.decision-group input {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.decision-group label {
  font: inherit; padding: 4px 9px; font-size: 12.5px; border-radius: 6px;
  cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.decision-group label:hover { background: #f0f3f7; }
.decision-group button {
  font: inherit; padding: 4px 9px; font-size: 12.5px; border-radius: 6px;
  cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.decision-group button:hover { background: #f0f3f7; }
.decision-group input:checked + label {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.decision-group input:focus-visible + label { outline: 2px solid #cfe0fb; outline-offset: 1px; }
.decision-group label.danger { border-color: #e3b5b0; color: var(--err); }
.decision-group label.danger:hover { background: var(--err-bg); }
.decision-group input:checked + label.danger { background: var(--err); border-color: var(--err); color: #fff; }

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

.flashes { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 9px 13px; border-radius: 6px; border: 1px solid transparent; }
.flash.success { background: var(--ok-bg); border-color: #b7dfc8; color: var(--ok); }
.flash.error { background: var(--err-bg); border-color: #f0bdb7; color: var(--err); }
.flash.warning { background: var(--warn-bg); border-color: #ebd39a; color: var(--warn); }
.flash.info { background: var(--info-bg); border-color: #bed3f7; color: var(--accent-dark); }

.note { padding: 9px 13px; border-radius: 6px; background: var(--info-bg); font-size: 13px; }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note.err { background: var(--err-bg); color: var(--err); }

/* ---------------------------------------------------------------- таблицы */

table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 12.5px; background: #fafbfc; position: sticky; top: 0; z-index: 2; }
tbody tr:hover { background: #fbfcfd; }
/* Кликабельная строка таблицы (журнал заказов): вся строка ведёт по ссылке
   в первой ячейке через растянутый поверх строки псевдоэлемент — без JS. */
tr.row-link { position: relative; cursor: pointer; }
tr.row-link .stretched-link::after { content: ""; position: absolute; inset: 0; }
/* Отметки УПД / 1С в журнале — поверх ссылки строки. */
td.flag-cell { position: relative; z-index: 2; text-align: center; }
.flag-btn {
  min-width: 26px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
  color: var(--muted); font: inherit; cursor: pointer; padding: 1px 6px;
}
.flag-btn.done, .btn.done { border-color: var(--ok); color: var(--ok); background: var(--ok-bg); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.tight th, table.tight td { padding: 5px 8px; }

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

.st { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; white-space: nowrap; }
.st-checking { background: var(--info-bg); color: var(--accent-dark); }
.st-approved { background: #e6e9fb; color: #3b41a8; }
.st-placed { background: var(--ok-bg); color: var(--ok); }
.st-placement_error { background: var(--err-bg); color: var(--err); }
.st-invoiced { background: #eef3d9; color: #5c6b16; }
.st-payment_sent { background: #fdf3e0; color: #8a5a00; }
.st-paid { background: #e4f2f6; color: #16697a; }
.st-delivered { background: #e2e6ea; color: #3d4852; }
.st-completed { background: #dff3e4; color: #1d6b35; }
.st-cancelled { background: #ececec; color: #7a7a7a; }

.ls-ok { color: var(--ok); }
.ls-price_changed { color: var(--warn); font-weight: 600; }
.ls-out_of_stock { color: var(--err); font-weight: 600; }
.ls-partial { color: var(--warn); font-weight: 600; }
.ls-excluded { color: var(--muted); }
tr.problem { background: #fffaf0; }
/* Строка заказа повторяет выбранное решение сразу, до «Применить решения»:
   «Исключить» — красная и перечёркнутая, принятое расхождение («Принять цену»,
   «Оставить», «Доступное») — зелёная, «Вернуть» — обычная. Без переключателей
   (нет права подписи, заказ уже отправлен) исключённая строка выглядит так же.
   Ячейка с переключателями не перечёркивается. */
tr.excluded:not(:has(.decision-group)),
tr:has(.decision-group input[value="exclude"]:checked) { background: var(--err-bg); }
tr.excluded:not(:has(.decision-group)) td,
tr:has(.decision-group input[value="exclude"]:checked) td:not(.decision-cell) {
  text-decoration: line-through; text-decoration-color: var(--err);
}
tr.problem:has(.decision-group input[value="keep"]:checked),
tr.problem:has(.decision-group input[value="available"]:checked) { background: var(--ok-bg); }

/* --------------------------------------------------------------- плитки */

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 14px; }
.tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 14px 16px; display: block; color: var(--ink);
}
.tile:hover { border-color: var(--accent); text-decoration: none; box-shadow: 0 2px 8px rgba(31,111,235,.10); }
.tile .code { font-size: 17px; font-weight: 700; }
.tile .name { color: var(--muted); font-size: 13px; margin-top: 2px; min-height: 18px; }
.tile .meta { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #eef1f4; color: var(--muted); }
.badge.work { background: var(--info-bg); color: var(--accent-dark); }
.badge.attn { background: var(--warn-bg); color: var(--warn); }

/* ------------------------------------------------------- экран локации */

.catalog-toolbar {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: 10px 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); margin-bottom: 4px;
}
.catalog-toolbar input[type=text] { width: 320px; }

/* Выпадающая панель на <details>/<summary> — без JS, CSP не задет. */
.dropdown { position: relative; }
.dropdown > summary { list-style: none; cursor: pointer; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown[open] > summary { border-color: var(--accent); color: var(--accent-dark); }
.dropdown-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; width: 280px;
  padding: 12px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(0,0,0,.15);
}
.dropdown-panel .field { margin: 0; }
.dropdown-panel select { width: 100%; }

.cat-block { margin-top: 18px; }
.cat-head {
  background: #e9edf2; padding: 7px 12px; border-radius: 6px 6px 0 0;
  font-weight: 600; border: 1px solid var(--line); border-bottom: 0;
}
.sub-head { padding: 6px 12px; background: #f6f8fa; color: var(--muted); font-size: 12.5px;
  border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.cat-block table { background: #fff; border: 1px solid var(--line); }
.cat-block th { position: static; }

.qty-input { width: 78px; text-align: right; }
.qty-input.filled { border-color: var(--accent); background: #f4f8ff; font-weight: 600; }
.offer-select { max-width: 240px; }

/* --------------------------------------------- донаполнение заказа: поиск */
.line-add { position: relative; width: 320px; }
.line-add input[type=text] { width: 100%; }
.line-search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.15); max-height: 260px; overflow-y: auto;
}
.line-search-item {
  display: block; width: 100%; text-align: left; padding: 8px 12px; border: 0;
  border-bottom: 1px solid var(--line); background: none; font: inherit; cursor: pointer;
}
.line-search-item:last-child { border-bottom: 0; }
.line-search-item:hover, .line-search-item:focus-visible { background: #f0f3f7; }
.line-search-empty { padding: 8px 12px; }

.totals-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: #22303f; color: #fff; padding: 10px 20px;
  display: flex; align-items: center; gap: 22px; justify-content: flex-end;
  box-shadow: 0 -2px 10px rgba(0,0,0,.15);
}
.totals-bar .val { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.totals-bar .lbl { color: #b9c5d1; font-size: 12.5px; }

/* ------------------------------------------------- витрина экрана локации */
/* Ф-2.2 (разбивка по статьям ДДС и типам товаров) + Ф-2.3..2.6, в виде     */
/* интернет-магазина: категории слева, карточки товаров, плавающая корзина. */

.shop { display: flex; align-items: flex-start; gap: 18px; margin-top: 10px; }

.shop-nav {
  flex: 0 0 230px; position: sticky; top: 66px;
  max-height: calc(100vh - 90px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 3px;
}
.shop-nav-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em;
  padding: 4px 10px; }
.cat-chip {
  display: flex; justify-content: space-between; gap: 8px; text-align: left;
  padding: 8px 10px; border-radius: 6px; border: 1px solid transparent;
  background: transparent; color: var(--ink); font: inherit; cursor: pointer;
}
.cat-chip:hover { background: #e9edf2; }
.cat-chip.on { background: var(--accent); color: #fff; }
.cat-chip.on .cnt { color: #fff; }
.cat-chip .cnt { color: var(--muted); font-variant-numeric: tabular-nums; }

.shop-main { flex: 1 1 auto; min-width: 0; }

.sub-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.sub-chip {
  padding: 5px 11px; border-radius: 14px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-size: 12.5px; cursor: pointer;
}
.sub-chip:hover { border-color: var(--accent); }
.sub-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.shop-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px; margin-top: 12px;
}
.product-card {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 11px 12px; display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.product-card.has-qty { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
/* Ф-2.1: каталог грузится страницами (см. main.grid, /grid) — кнопка
   дозагрузки занимает всю ширину сетки отдельной строкой. */
.load-more { grid-column: 1 / -1; justify-self: center; margin: 6px 0; }
/* Кнопка «Из Excel» у поиска и строка результата чтения файла. */
.excel-search { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.excel-search label.btn { cursor: pointer; }
.error-text { color: var(--err); }
/* Поиск по нескольким артикулам: какие не нашлись — строкой над сеткой. */
.search-missing {
  grid-column: 1 / -1; margin: 0; padding: 8px 12px;
  border-radius: 8px; background: var(--warn-bg); color: var(--warn);
}
/* Квадрат под фото есть всегда, даже без картинки — иначе карточки без
   фото и с фото сбивали бы ряды сетки на разную высоту. Несколько фото
   лежат друг на друге (position: absolute), видно только текущее. */
.card-image {
  position: relative; aspect-ratio: 1 / 1; border-radius: 6px; background: var(--bg);
  overflow: hidden;
}
.card-image img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
}
.card-image img.hidden-slide { display: none; }
.img-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(255,255,255,.9); color: var(--ink); font-size: 15px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.img-nav:hover { background: #fff; border-color: var(--accent); }
.img-nav.prev { left: 5px; }
.img-nav.next { right: 5px; }
/* Карандашик правки товара (JS-хук item_edit.js) — админ/сотрудник с правом
   на справочники, шаблоны вообще не рендерят кнопку остальным. На карточке
   каталога (.product-card) — круглая кнопка поверх фото; в списке товаров и
   на витрине /catalog/items/<id> — обычная .btn.small в потоке. */
.product-card .card-edit {
  position: absolute; top: 7px; right: 7px; z-index: 3;
  width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(255,255,255,.92); color: var(--ink); font-size: 13px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.product-card .card-edit:hover { background: #fff; border-color: var(--accent); color: var(--accent); }
/* Название товара показываем целиком: в каталоге важно отличить похожие
   позиции без наведения мыши. Карточки одной строки сетки сами выравниваются
   по самой высокой из них. */
.card-top { min-height: 55px; }
.card-title {
  font-weight: 600; line-height: 1.3;
}
.card-sku {
  font-family: monospace; height: 18px; line-height: 18px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Строка подрядчика — фиксированная высота под select (несколько
   предложений) и под обычный текст (одно предложение) одинаково. */
.card-supplier {
  font-size: 12.5px; color: var(--muted); height: 34px;
  display: flex; align-items: center; overflow: hidden;
}
.card-supplier .offer-select { width: 100%; max-width: none; height: 34px; }
.card-supplier-name { display: block; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-price {
  font-size: 13.5px; height: 20px; line-height: 20px;
  white-space: nowrap; overflow: hidden;
}
.card-price .price-val { font-weight: 700; font-variant-numeric: tabular-nums; }
/* margin-top: auto подстраховывает от остатка места, если карточка в ряду
   растянута под самую высокую соседку (грид растягивает ячейки по
   умолчанию) — на практике при фиксированных высотах строк выше остатка
   уже не бывает. Сама высота строки фиксирована — «В корзину» и степпер
   количества одного размера, чтобы переключение между ними не сдвигало
   «Сумма» ниже. */
.card-qty { margin-top: auto; padding-top: 2px; height: 36px; display: flex; align-items: center; }
.card-qty .add-to-cart { width: 100%; }
.qty-stepper { display: flex; width: 100%; align-items: center; gap: 6px; }
/* min-width: 0 — иначе поле ввода не сжимается ниже своей встроенной
   минимальной ширины и выталкивает кнопку «+» за край карточки. */
.qty-stepper .qty-input { flex: 1 1 auto; width: auto; min-width: 0; text-align: center; }
.qty-btn {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 16px; line-height: 1; cursor: pointer;
}
.qty-btn:hover { background: #f0f3f7; border-color: var(--accent); }
.card-sum {
  color: var(--muted); font-variant-numeric: tabular-nums; height: 18px; line-height: 18px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.product-card.has-qty .card-sum { color: var(--accent-dark); font-weight: 600; }

/* Плавающая кнопка корзины + панель оформления, поверх всего экрана. */
.cart-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 30;
  width: 54px; height: 54px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; font-size: 22px; cursor: pointer;
  box-shadow: 0 3px 14px rgba(0,0,0,.25); display: flex; align-items: center; justify-content: center;
}
.cart-fab:hover { background: var(--accent-dark); }
.cart-badge {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 4px;
  border-radius: 10px; background: var(--err); color: #fff; font-size: 11.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums;
}
.cart-overlay { position: fixed; inset: 0; z-index: 29; background: rgba(20,26,33,.4); }
.cart-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 31; width: min(380px, 100vw);
  background: var(--panel); border-left: 1px solid var(--line); box-shadow: -4px 0 16px rgba(0,0,0,.15);
  padding: 16px; display: flex; flex-direction: column;
}
.cart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cart-lines { flex: 1 1 auto; overflow-y: auto; border-top: 1px solid var(--line); }
.cart-line {
  display: grid; grid-template-columns: 1fr auto auto; column-gap: 8px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.cart-line-name { grid-column: 1 / 3; font-weight: 600; }
.cart-line-detail { grid-column: 1 / 3; }
.cart-line-sum { font-variant-numeric: tabular-nums; font-weight: 600; }
.cart-line-remove {
  grid-row: 1 / 3; border: none; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 14px; padding: 4px;
}
.cart-line-remove:hover { color: var(--err); }
/* Количество в корзине — поле и «−»/«+», как в карточке. */
.cart-line-qty { grid-column: 1 / 3; display: flex; align-items: center; gap: 6px; }
.cart-line-qty .cart-qty { width: 70px; text-align: center; }
.cart-line-qty .qty-btn { width: 24px; height: 24px; flex-basis: 24px; font-size: 14px; }
.cart-footer { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 8px; }
/* «Подобрать замену»: бейдж наличия в карточке и панель с аналогами. */
.card-stock { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 22px; }
.stock-out { color: var(--err); font-weight: 600; }
.analog-btn {
  margin-left: auto; border: 1px solid var(--line); background: #fff; color: var(--accent);
  border-radius: 6px; padding: 2px 8px; font: inherit; font-size: 12px; cursor: pointer;
}
.analog-btn.attn { border-color: var(--accent); background: var(--info-bg); font-weight: 600; }
.analog-btn:hover { border-color: var(--accent); }
.analog-row {
  display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--line); font-size: 13px;
}
.analog-img { width: 64px; height: 64px; object-fit: contain; background: #f4f6f8; border-radius: 6px; }
.analog-name { font-weight: 600; }
.analog-meta { color: var(--muted); font-size: 12px; margin: 2px 0 6px; }
.analog-meta .in { color: var(--ok, #1d7a3a); }
.analog-meta .out { color: var(--err); }
.analog-buy { display: flex; align-items: center; gap: 6px; }
.analog-buy .analog-qty { width: 60px; text-align: center; }
.analog-new { display: inline-block; font-size: 11px; color: var(--accent); background: var(--info-bg); border-radius: 8px; padding: 0 6px; }
.cart-footer .lbl { color: var(--muted); font-size: 12.5px; }
.cart-footer .val { font-weight: 700; font-variant-numeric: tabular-nums; }
.cart-footer .btn { margin-top: 10px; }

/* Спарклайн цены в карточке каталога — тренд последних заказов, клик
   открывает полный график (история цены). Оформлена как кнопка «В корзину»
   (та же рамка/отступы), график — маленькая иконка слева от подписи
   (растянутый на всю кнопку фон не читался и спорил с текстом). .card-history
   высотой с саму кнопку — зарезервировано всегда, у товара без истории
   заказов карточка не должна становиться ниже соседних. */
.card-history { height: 36px; margin-top: 4px; overflow: hidden; }
.price-spark {
  display: flex; width: 100%; align-items: center; justify-content: center; gap: 8px;
  padding: 7px 0; border-radius: 6px; border: 1px solid var(--accent); background: #fff;
  color: var(--accent); font: inherit; font-weight: 600; cursor: pointer;
}
.price-spark:hover { background: var(--info-bg); }
.price-spark svg { width: 26px; height: 14px; overflow: visible; flex: 0 0 auto; }
.price-spark polyline {
  fill: none; stroke: var(--accent); stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}
.price-spark:hover polyline { stroke: var(--accent-dark); }

/* Модалка с полным графиком истории цены — поверх каталога, по клику на спарклайн. */
.price-history-overlay { position: fixed; inset: 0; z-index: 39; background: rgba(20,26,33,.4); }
.price-history-modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 40;
  width: min(560px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.22); padding: 16px;
}
.price-history-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.price-history-chart { height: 260px; }

/* Модалка правки/создания товара — карандашик карточки и «+ Добавить товар». */
.item-edit-overlay { position: fixed; inset: 0; z-index: 39; background: rgba(20,26,33,.4); }
.item-edit-modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 40;
  width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.22); padding: 16px;
}
.item-edit-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.item-edit-modal h3 { margin: 16px 0 8px; }
.item-edit-error {
  background: var(--err-bg, #fdeeee); color: var(--err); border-radius: 6px;
  padding: 8px 10px; font-size: 13px; margin: 0 0 10px;
}
.item-edit-offer {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.item-edit-offer .supplier-title { font-weight: 600; min-width: 140px; }
.item-edit-offer .price-check-result { font-size: 12.5px; color: var(--muted); }
.item-edit-photos {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px;
  margin-bottom: 4px;
}
.item-edit-photo {
  position: relative; aspect-ratio: 1 / 1; border-radius: 6px; overflow: hidden;
  border: 1px solid var(--line); background: var(--bg);
}
.item-edit-photo img { width: 100%; height: 100%; object-fit: cover; }
.item-edit-photo .photo-remove {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%;
  border: none; background: rgba(20,26,33,.65); color: #fff; font-size: 12px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.item-edit-photo .photo-remove:hover { background: var(--err); }

@media (max-width: 860px) {
  .shop { flex-direction: column; }
  .shop-nav { position: static; flex-direction: row; flex-wrap: wrap; max-height: none; width: 100%; }
}

/* --------------------------------------------------------------- прогресс */

.progress { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 14px 16px; }
.bar { height: 8px; border-radius: 4px; background: #e6eaee; overflow: hidden; margin: 10px 0 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.progress.indeterminate .bar > i { width: 35%; animation: progress-slide 1.2s ease-in-out infinite; }
@keyframes progress-slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(310%); } }

/* ---------------------------------------------------------------- прочее */

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* Редактор шаблона письма (карточка подрядчика): слева правка, справа
   живой предпросмотр; на узком экране — друг под другом. */
.tpl-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.tpl-preview { position: sticky; top: 12px; }
.tpl-preview pre.mail { max-height: 70vh; overflow: auto; white-space: pre; }
@media (max-width: 1100px) { .tpl-editor { grid-template-columns: minmax(0, 1fr); } .tpl-preview { position: static; } }
.tpl-chips { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--accent); border-radius: 12px;
  padding: 2px 8px; font: inherit; font-size: 12px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); background: var(--info-bg); }
/* Столбцы таблицы позиций: флажок + ◀ ▶ для порядка. */
.column-picks {
  display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 0;
}
.column-picks legend { font-size: 12.5px; color: var(--muted); padding: 0 4px; }
.column-picks label { display: inline-flex; align-items: center; gap: 4px; }
.column-pick {
  display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
.column-pick.off { opacity: .55; }
.col-move {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 10px; padding: 2px 3px; line-height: 1;
}
.col-move:hover { color: var(--accent); }
.column-total { flex-basis: 100%; }
/* Выбор даты и интервала доставки на карточке заказа (Комус). */
.delivery-days, .delivery-slots { display: flex; flex-wrap: wrap; gap: 6px; }
.delivery-days .chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.delivery-slots label {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border: 1px solid var(--line); border-radius: 6px; font-size: 13px; cursor: pointer; background: #fff;
}
.delivery-slots label:has(input:checked) { border-color: var(--accent); background: var(--info-bg); }
/* Правка письма в заказе — моноширинный, как оно выглядит у подрядчика. */
textarea.mail-edit { min-height: 360px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; white-space: pre; }
pre.mail {
  background: #fbfcfd; border: 1px solid var(--line); border-radius: 6px;
  padding: 12px; overflow-x: auto; font-size: 12.5px; white-space: pre-wrap;
}
.matrix { overflow-x: auto; }
.matrix table { min-width: 100%; width: auto; }
.matrix td.num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------- служебные классы */
/* Заменяют атрибуты style= в шаблонах: с ними политика безопасности может
   запретить встроенные стили, а не разрешать их ради нескольких ширин. */

.w-full { width: 100%; }
.w-60 { width: 60px; }
.w-70 { width: 70px; }
.w-75 { width: 75px; }
.w-80 { width: 80px; }
.w-90 { width: 90px; }
.w-100 { width: 100px; }
.w-110 { width: 110px; }
.w-120 { width: 120px; }
.w-130 { width: 130px; }
.w-140 { width: 140px; }
.w-150 { width: 150px; }
.w-160 { width: 160px; }
.w-170 { width: 170px; }
.w-180 { width: 180px; }
.w-200 { width: 200px; }
.w-220 { width: 220px; }
.w-230 { width: 230px; }
.w-240 { width: 240px; }
.w-280 { width: 280px; }
.w-300 { width: 300px; }
.w-320 { width: 320px; }

/* Доли ширины таблицы: колонки состава заказа и списков справочника. */
.wp-5 { width: 5%; }
.wp-7 { width: 7%; }
.wp-8 { width: 8%; }
.wp-9 { width: 9%; }
.wp-11 { width: 11%; }
.wp-12 { width: 12%; }
.wp-15 { width: 15%; }
.wp-20 { width: 20%; }
.wp-30 { width: 30%; }
.wp-38 { width: 38%; }

.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mb-10 { margin-bottom: 10px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.mt-18 { margin-top: 18px; }

/* Поля, растягивающиеся в строке формы. */
.grow-320 { flex: 1 1 320px; }
.grow-340 { flex: 1 1 340px; }
.grow-420 { flex: 1 1 420px; }
.grow-full { flex: 1 1 100%; }
.min-300 { min-width: 300px; }

.narrow { max-width: 420px; }
.tall { min-height: 260px; }
/* Не .top — этот класс уже занят шапкой сайта (background/height/padding),
   тот же класс на .row унаследовал бы их и сломал вёрстку (было именно так). */
.align-top { align-items: flex-start; }
.middle { align-items: center; }
.to-right { justify-content: flex-end; }
.gap-16 { gap: 16px; }
/* Отделяет опасное действие (удаление) от остальной формы. */
.divided { border-top: 1px solid var(--line); padding-top: 12px; }
/* Итоговая сумма заказа на карточке. */
.amount { font-size: 17px; font-weight: 700; }
/* Номер текущей страницы в постраничной навигации. */
.current-page { background: #e9edf2; }

.login-page { max-width: 340px; margin: 90px auto; }
.login-page .panel { padding: 24px; }
.login-page label.field { margin-bottom: 12px; }
.login-page input { width: 100%; }
.login-page .btn { width: 100%; }

.issues { margin: 0; padding-left: 20px; font-size: 13px; }
.issues li { margin-bottom: 3px; }
details summary { cursor: pointer; color: var(--accent); }

/* -------------------------------------------------------------- дашборд */

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs a, .tabs button {
  padding: 8px 14px; color: var(--muted); font-size: 13.5px;
  border: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: none; font-family: inherit; cursor: pointer;
}
.tabs a:hover, .tabs button:hover { color: var(--ink); text-decoration: none; }
.tabs a.on, .tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ------------------------------------------------------------ канбан заказов */

.board { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; padding-bottom: 8px; }
.board-col {
  flex: 0 0 240px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; display: flex; flex-direction: column;
}
.board-col-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px 0;
}
.board-col-count { color: var(--muted); font-size: 12.5px; }
.board-col-total { padding: 2px 12px 10px; border-bottom: 1px solid var(--line); }
.board-col-body { padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.board-card {
  display: block; border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 10px; background: #fff; color: inherit;
  position: relative; transition: opacity .12s;
}
/* Вся карточка ведёт в заказ — ссылка на номере растянута поверх неё;
   метка заявки (.req-tag) лежит выше и ведёт своей ссылкой. */
.board-card .stretched-link, .board-card .stretched-link:hover { color: inherit; text-decoration: none; }
.board-card .stretched-link::after { content: ""; position: absolute; inset: 0; }
.board-card:hover { border-color: var(--accent); text-decoration: none; background: #f7fafe; }
.board-card-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.board-card-bottom { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; }

/* ------------------------------------------------- заявка над заказами */

/* Метка «Заявка № … · 2 из 3 ●●○» у заказа: журнал, доска, карточка. */
.req-tag { position: relative; z-index: 2; white-space: nowrap; }
.req-dots { display: inline-flex; gap: 3px; vertical-align: middle; margin-left: 2px; }
/* Точка — статус одной части заявки: цвет текста своего .st-*, без его фона. */
.req-dots .req-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.req-dots .req-dot.self { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px currentColor; margin: 0 3px; }
/* Наведение на заказ (app.js, data-req-hover): остальные части его заявки
   подсвечиваются; на доске прочие карточки ещё и приглушаются. */
.board-card.req-on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.board.req-focus .board-card:not(.req-on) { opacity: .45; }
/* Не var(--info-bg): на нём пропадает плашка статуса «На сверке». */
tr.req-on, tbody tr.req-on:hover { background: #f5f8fe; }
tr.req-on td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
/* Шапка заявки в списке «по заявкам». */
tr.req-head td { background: #fafbfc; border-top: 2px solid var(--line); padding-top: 9px; }
tr.req-head .st { margin-left: 4px; }

.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 340px; }

/* --------------------------------------- ручная проверка Комуса (временно) */

.komus-vnc-wrap { max-width: 1440px; }
/* noVNC масштабирует canvas под размер этого контейнера (scaleViewport) —
   без явной высоты контейнер и canvas схлопываются в 0 по кругу: у canvas
   стиль 0x0, у контейнера высота от контента — тоже 0. aspect-ratio рвёт
   этот цикл, высота считается от ширины независимо от canvas. */
.komus-vnc-screen {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 1440 / 900;
}
.komus-vnc-screen canvas { display: block; width: 100%; height: 100%; }
