/* DenStock — минимальный скелетный стиль Слоя 1.
   Без декоративного дизайна: только читаемый рабочий каркас.
   Компонентные стили на Tailwind подключаются на UI-слоях. */

* { box-sizing: border-box; }

:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #d8dce2;
  --text: #1c2430;
  --muted: #6b7280;
  --accent: #1f6feb;
  --ok-bg: #e7f6ec; --ok-fg: #1a7f37; --ok-line: #b7e0c4;
  --err-bg: #fdeaea; --err-fg: #b42318; --err-line: #f3b9b4;
  --warn-bg: #fdf6e3; --warn-fg: #9a6700; --warn-line: #f1dca0;
}

body.app {
  margin: 0;
  font-family: system-ui, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* ===========================================================================
   App shell (v1.2 UI-polish): собранный деловой каркас — topbar + сайдбар с
   разделами/иконками/активным пунктом + мобильное меню. Один синий акцент,
   спокойные границы, мягкие тени. Без декоративных эффектов.
   =========================================================================== */
:root {
  --topbar-h: 56px;
  --sidebar-w: 252px;
  --nav-active-bg: var(--info-bg);
  --accent-ring: rgba(31, 111, 235, 0.14);
  --link-quiet: #33507a;
}

/* Общий стиль inline-иконок из спрайта (символы содержат только геометрию). */
.icon { fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }

/* Верхняя панель */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  height: var(--topbar-h); padding: 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar__menu { display: none; }
.topbar__brand { display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text); font-weight: 700; }
.topbar__mark { display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 16px; }
.topbar__wordmark { font-size: 18px; letter-spacing: -0.01em; }
.topbar__spacer { flex: 1 1 auto; }
.topbar__searchform { position: relative; flex: 1; max-width: 460px; }
.topbar__searchicon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.topbar__search { width: 100%; padding: 9px 12px 9px 36px; font-size: 15px;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; }
.topbar__search:focus { background: var(--panel); border-color: var(--accent);
  outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.topbar__user { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.topbar__username { color: var(--muted); font-size: 14px; max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Поле сканера в топбаре */
.scanfield { display: flex; align-items: center; gap: 8px; }
.scanfield__label { font-size: 13px; color: var(--muted); }
.scanfield__input { padding: 8px 10px; font-size: 15px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; min-width: 180px; }
.scanfield__input:focus { background: var(--panel); border-color: var(--accent); outline: none; }

/* Раскладка: закреплённый сайдбар + контент */
.layout { display: flex; align-items: flex-start; }
.sidebar { flex: 0 0 var(--sidebar-w); width: var(--sidebar-w);
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h));
  overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line);
  padding: 10px 10px 24px; }
.content { flex: 1 1 auto; min-width: 0; padding: 24px 28px; }
.content:focus { outline: none; }
.content--loading { opacity: .72; transition: opacity .12s ease; }
.content--loading::before { content: ""; display: block; height: 2px;
  margin: -2px 0 0; background: var(--accent); animation: content-loading .7s ease-in-out infinite alternate; }
@keyframes content-loading { from { opacity: .25; } to { opacity: 1; } }
.content--centered { min-height: 100vh; display: flex; align-items: center;
  justify-content: center; padding: 24px; }

@media (prefers-reduced-motion: reduce) {
  .content--loading { transition: none; }
  .content--loading::before { animation: none; }
}

/* Навигация: независимые раскрывающиеся разделы. */
.nav__group { margin: 0; }
.nav__group + .nav__group { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.nav__group-title { display: flex; align-items: center; justify-content: space-between; width: 100%;
  min-height: 40px; gap: 8px; padding: 9px 12px 7px; border: 0; border-radius: 8px;
  background: transparent; cursor: pointer; font-family: inherit;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); text-align: left; user-select: none; }
.nav__group-heading { display: flex; align-items: center; min-width: 0; gap: 9px; }
.nav__group-icon { flex: 0 0 auto; width: 17px; height: 17px; }
.nav__group-title:hover { color: var(--text); background: var(--bg); }
.nav__group.is-active > .nav__group-title { color: var(--accent); }
.nav__chevron { width: 14px; height: 14px; color: var(--muted);
  transition: transform .15s ease; }
.nav__group.is-collapsed > .nav__group-title .nav__chevron { transform: rotate(-90deg); }
.nav__list { list-style: none; margin: 0; padding: 0; }
.nav__list--primary { padding-top: 4px; }
.nav__list--primary .nav__link { padding-top: 10px; padding-bottom: 10px; }
.nav__list li { margin: 1px 0; }
.nav__link { display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-radius: 8px; text-decoration: none; color: var(--text);
  font-size: 14px; font-weight: 500; }
.nav__icon { flex: 0 0 auto; width: 18px; height: 18px; color: var(--muted); }
.nav__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav__link:hover { background: var(--bg); }
.nav__link:hover .nav__icon { color: var(--text); }
.nav__link.is-active { background: var(--nav-active-bg); color: var(--accent); font-weight: 600; }
.nav__link.is-active .nav__icon { color: var(--accent); }
.nav__link--soon { color: var(--muted); cursor: default; }
.nav__soon { margin-left: auto; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted); background: var(--bg);
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; }

/* Мобильный бэкдроп (виден только при открытом меню на мобильном) */
.nav-backdrop { display: none; }

/* Локальная навигация внутри крупных пользовательских разделов. */
.section-tabs,
.section-subtabs {
  display: flex; align-items: center; gap: 4px; overflow-x: auto;
  margin: 0 0 18px; padding: 3px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
}
.section-subtabs {
  display: inline-flex; margin-top: -8px; background: transparent;
}
.section-tabs__link,
.section-subtabs__link {
  flex: 0 0 auto; padding: 8px 11px; border-radius: 6px;
  color: var(--muted); font-size: 14px; font-weight: 600; text-decoration: none;
}
.section-subtabs__link { padding: 6px 9px; font-size: 13px; }
.section-tabs__link:hover,
.section-subtabs__link:hover { color: var(--text); background: var(--bg); }
.section-tabs__link.is-active,
.section-subtabs__link.is-active {
  color: var(--accent); background: var(--nav-active-bg);
}

/* Спокойные текстовые ссылки в контенте (не «википедийная» ярко-синяя) */
.content a:not([class]) { color: var(--link-quiet); font-weight: 500; text-decoration: none; }
.content a:not([class]):hover { color: var(--accent); text-decoration: underline; }

/* Плитки-скелет */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-top: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; }
.tile__label { color: var(--muted); font-size: 14px; }
.tile__value { font-size: 28px; font-weight: 700; margin-top: 6px; }

.page-title { margin: 0 0 8px; }
.muted { color: var(--muted); }

/* Кнопки */
.btn { display: inline-block; padding: 12px 18px; font-size: 16px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Вход */
.login { width: 320px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 24px; }
.login__title { margin: 0; }
.login__subtitle { margin: 4px 0 16px; color: var(--muted); }
.login__form { display: flex; flex-direction: column; gap: 8px; }
.login__form input { padding: 10px 12px; font-size: 16px; border: 1px solid var(--line);
  border-radius: 8px; }
.login__form button { margin-top: 8px; }

/* Статус-блок: цвет + текст + иконка */
.status { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px;
  border-radius: 8px; border: 1px solid var(--line); margin: 8px 0; font-weight: 600; }
.status__icon { display: inline-flex; width: 22px; height: 22px; align-items: center;
  justify-content: center; border-radius: 50%; font-size: 14px; color: #fff; }
.status--success { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-line); }
.status--success .status__icon { background: var(--ok-fg); }
.status--error { background: var(--err-bg); color: var(--err-fg); border-color: var(--err-line); }
.status--error .status__icon { background: var(--err-fg); }
.status--warning { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-line); }
.status--warning .status__icon { background: var(--warn-fg); }

/* Таблицы и формы (минимум для экранов пользователей) */
.table { width: 100%; border-collapse: collapse; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table th { background: var(--bg); font-size: 14px; color: var(--muted); }
.table-sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.table-sort-link:hover, .table-sort-link--active { color: var(--accent); text-decoration: underline; }
.inline-form { display: inline; margin-left: 8px; }
.inline-form button { padding: 6px 10px; cursor: pointer; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; }
.return-complete-form { margin-left: 0; }
.return-complete-form .return-complete-button {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.return-complete-form .return-complete-button:hover,
.return-complete-form .return-complete-button:focus-visible {
  background: #1a5fd0; border-color: #1a5fd0; color: #fff;
}
.return-complete-form .return-complete-button:active {
  background: #184fb0; border-color: #184fb0; color: #fff;
}
.return-complete-form .return-complete-button:disabled {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.customs-quick-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; }
.customs-quick-form input[type="text"] { width: 92px; }
.form p { margin: 10px 0; }
.form label { display: inline-block; margin-bottom: 4px; color: var(--muted); }
.form input[type="text"], .form input[type="password"] { padding: 10px 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 8px; min-width: 280px; }
.messages { margin-bottom: 12px; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input, .toolbar select, .toolbar button { padding: 8px 10px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 8px; }
.tile a { font-size: 18px; text-decoration: none; color: var(--accent); }

/* Фотографии деталей/экземпляров (Слой 24, UI-polish): крупное основное фото +
   компактная приглушённая галерея превью. */
.photo-primary { margin: 8px 0 12px; }
.photo-primary img { display: block; width: 100%; max-width: 400px; max-height: 320px;
  object-fit: contain; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; }
.photo-primary .muted { margin: 4px 0 0; font-size: 13px; }

.photo-gallery { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 12px; }
.photo-thumb { width: 96px; margin: 0; display: flex; flex-direction: column; gap: 4px; }
/* Кликабельная миниатюра: голая кнопка-обёртка вокруг изображения. */
.photo-thumb__view { display: block; padding: 0; border: 0; background: none;
  cursor: pointer; line-height: 0; border-radius: 8px; }
.photo-thumb__view:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.photo-thumb img { width: 96px; height: 96px; object-fit: cover; border: 1px solid var(--line);
  border-radius: 8px; opacity: 0.7; transition: opacity .15s ease, box-shadow .15s ease; }
.photo-thumb__view:hover img { opacity: 1; box-shadow: 0 0 0 2px var(--line); }
/* «Выбрано для просмотра» (только UI; is_primary в БД — отдельно, через badge). */
.photo-thumb--selected img { opacity: 1; border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent); }
.photo-thumb figcaption { font-size: 11px; color: var(--muted); line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.photo-actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.photo-actions .inline-form { margin: 0; }
.photo-actions button { padding: 3px 7px; font-size: 12px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.badge { display: inline-block; padding: 2px 8px; font-size: 11px; font-weight: 600;
  color: var(--ok-fg); background: var(--ok-bg); border: 1px solid var(--ok-line);
  border-radius: 999px; }

/* ===========================================================================
   v1.1.1 — Дизайн-фундамент (этап 1 из плана аудита docs/audits/01-...).
   ТОЛЬКО аддитивные правила: существующие селекторы выше не изменяются.
   Эти компоненты применяются в шаблонах на последующих маленьких этапах.
   =========================================================================== */

/* --- Токены (новые; существующие в :root выше не трогаем) --- */
:root {
  --surface: var(--panel);
  --border: var(--line);
  /* Семантические алиасы поверх существующих ok/err/warn. */
  --success-bg: var(--ok-bg); --success-fg: var(--ok-fg); --success-line: var(--ok-line);
  --warning-bg: var(--warn-bg); --warning-fg: var(--warn-fg); --warning-line: var(--warn-line);
  --danger: #b42318; --danger-bg: var(--err-bg); --danger-fg: var(--err-fg); --danger-line: var(--err-line);
  --info-bg: #e8f1fe; --info-fg: #1f6feb; --info-line: #bcd7fb;
  /* Скруления и тени. */
  --radius-sm: 6px; --radius-md: 8px; --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.10);
  /* Интервалы и типографика. */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px;
  --fs-sm: 13px; --fs-base: 15px; --fs-lg: 20px;
}

/* --- Доступность: единый видимый фокус для интерактивных элементов --- */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px;
}

/* --- Кнопки: новые варианты (базовый .btn/.btn--primary выше без изменений) --- */
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled, .btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn--secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn--secondary:hover { background: var(--bg); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(0.94); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn--ghost:hover { background: var(--bg); }
.btn--small { padding: 6px 12px; font-size: 14px; border-radius: var(--radius-sm); }

/* --- Карточки / зоны --- */
.card { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); margin: 0 0 16px; overflow: hidden; }
.card__header { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card__title { margin: 0; font-size: 16px; font-weight: 700; }
.card__body { padding: 16px; }
.card__actions { display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px 16px; border-top: 1px solid var(--border); }
.page-header { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin: 0 0 16px; }
.page-header__actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* --- Статус-pill (готовим классы; шаблоны подключат позже) --- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px;
  font-size: 12px; font-weight: 600; line-height: 1.7; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--text); }
.pill--success { background: var(--success-bg); color: var(--success-fg); border-color: var(--success-line); }
.pill--warning { background: var(--warning-bg); color: var(--warning-fg); border-color: var(--warning-line); }
.pill--danger { background: var(--danger-bg); color: var(--danger-fg); border-color: var(--danger-line); }
.pill--info { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-line); }
.pill--muted { background: var(--bg); color: var(--muted); border-color: var(--line); }

/* --- Пустые состояния --- */
.empty { text-align: center; padding: 32px 16px; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius-lg); }
.empty__title { margin: 0 0 4px; font-size: 16px; font-weight: 700; color: var(--text); }
.empty__text { margin: 0 0 12px; }
.empty__actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* --- Числа / деньги (правое выравнивание, табличные цифры) --- */
.num, .num--money, .num--qty { text-align: right; font-variant-numeric: tabular-nums; }
.num--money { white-space: nowrap; }
th.num, td.num, .table th.num, .table td.num,
.table .num, .table .num--money, .table .num--qty { text-align: right; }

/* --- Формы (готовим классы; existing .form ниже/выше не трогаем) --- */
.field { margin: 0 0 12px; }
.field__label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 14px; }
.field__label--required::after { content: " *"; color: var(--danger); }
.field__hint { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.field__error { margin: 4px 0 0; font-size: 13px; color: var(--err-fg); }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; }
.form-grid { display: grid; gap: 12px 16px; }
.form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* --- Таблицы: вспомогательные модификаторы (базовый .table без изменений) --- */
.table tbody tr:hover { background: var(--bg); }
.table--compact th, .table--compact td { padding: 6px 10px; font-size: 14px; }
.table__actions { white-space: nowrap; text-align: right; }

/* --- Поиск / сканер: классы уже используются в шаблонах, но не имели CSS --- */
.search-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.scanner-page { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.scanner-page__input { flex: 1; min-width: 280px; max-width: 560px; padding: 12px 14px;
  font-size: 18px; border: 1px solid var(--line); border-radius: var(--radius-md); }
.scanner-candidates { margin-top: 12px; }
.scanfield__result { font-size: 13px; color: var(--muted); }
.search-result { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 16px; margin: 0 0 12px; }
.search-result__header { display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; }
.search-result > h2, .search-result__title { margin: 0 0 4px; font-size: 18px; }
.search-result__meta { color: var(--muted); font-size: 14px; }
.search-result__avail { font-size: 15px; margin: 8px 0; }
.search-result__avail strong { font-size: 18px; color: var(--ok-fg); }

/* --- Адаптив --- */
@media (max-width: 1024px) {
  :root { --sidebar-w: 216px; }
  .content { padding: 20px; }
  .form-grid--2 { grid-template-columns: 1fr; }
}

/* Мобильный: сайдбар превращается в выезжающую панель по кнопке «Меню».
   Открытие — pure-CSS через #nav-toggle:checked (работает и без JS). */
@media (max-width: 900px) {
  .topbar { gap: 10px; }
  .topbar__menu { display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; margin-left: -6px; border-radius: 8px;
    color: var(--text); cursor: pointer; }
  .topbar__menu:hover { background: var(--bg); }
  .topbar__menu .icon { width: 22px; height: 22px; }
  .scanfield { display: none; }
  .topbar__username { display: none; }
  .layout { display: block; }
  .sidebar { position: fixed; top: 0; left: 0; z-index: 60;
    width: 288px; max-width: 84vw; height: 100vh; padding-top: 16px;
    box-shadow: var(--shadow-md); transform: translateX(-100%); transition: transform .2s ease; }
  .nav-toggle:checked ~ .layout .sidebar { transform: none; }
  .nav-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(16, 24, 40, 0.44); }
  .nav-toggle:checked ~ .layout .nav-backdrop { display: block; }
  .content { padding: 16px; }
  /* Широкие таблицы не ломают раскладку — горизонтальный скролл. */
  .table { display: block; overflow-x: auto; }
}

@media (max-width: 560px) {
  .content { padding: 14px; }
  .topbar__wordmark { display: none; }
  .scanner-page__input { min-width: 0; width: 100%; }
  .table { white-space: nowrap; }
}

/* ===========================================================================
   v1.2.1 — Product-grade screens: единый filter-toolbar, таблицы, empty-states,
   кнопки без подчёркивания, code-pill, status-card, action-panel, segmented.
   Только аддитивные/уточняющие правила поверх дизайн-фундамента.
   =========================================================================== */

/* --- Кнопки: единый вид для <a>/<button>, без подчёркивания --- */
.btn { text-decoration: none; font-weight: 500; line-height: 1.2;
  transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease; }
.btn:hover, .btn:focus { text-decoration: none; }
.btn--primary:hover { background: #1a5fd0; border-color: #1a5fd0; }
.btn--primary:active { background: #184fb0; border-color: #184fb0; }
.btn--secondary:hover { background: var(--bg); border-color: #c4cad3; }
.btn--danger:hover { filter: none; background: #9f1e14; border-color: #9f1e14; }

/* --- Заголовок страницы --- */
.page-subtitle { margin: -4px 0 16px; color: var(--muted); font-size: 14px; max-width: 72ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* --- Filter toolbar: единый продуктовый ряд фильтров ---
   Работает и для существующих .toolbar / .form (фильтры списков). */
.filter-toolbar, form.toolbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px;
  padding: 12px 14px; margin: 0 0 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.filter-toolbar label, form.toolbar label {
  display: inline-flex; flex-direction: column; gap: 4px;
  margin: 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.filter-toolbar .filter-spacer { margin-left: auto; }
.filter-field { display: flex; flex-direction: column; gap: 4px; }
.filter-label { font-size: 12px; font-weight: 600; color: var(--muted); }

/* Единый вид полей ввода в фильтрах (и селектов в обычных формах) */
.filter-toolbar input, .filter-toolbar select, .filter-toolbar button, .filter-toolbar .btn,
form.toolbar input, form.toolbar select, form.toolbar button, form.toolbar .btn {
  height: 38px; font-size: 14px; }
.filter-toolbar input, .filter-toolbar select,
form.toolbar input, form.toolbar select {
  padding: 0 12px; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius-md); }
.filter-toolbar .btn, form.toolbar .btn {
  display: inline-flex; align-items: center; padding-top: 0; padding-bottom: 0; }
.filter-toolbar button:not(.btn), form.toolbar button:not(.btn) {
  padding: 0 16px; color: var(--text); background: var(--panel); cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius-md); font-weight: 500; }
.filter-toolbar button:not(.btn):hover, form.toolbar button:not(.btn):hover { background: var(--bg); }
.filter-toolbar input:focus, .filter-toolbar select:focus,
form.toolbar input:focus, form.toolbar select:focus {
  border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }

/* Кастомная стрелка у select (убираем «нативный» вид) */
.filter-toolbar select, form.toolbar select, .form select {
  appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%236b7280' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='2 4.5 6 8.5 10 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
.form select { height: 40px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background-color: var(--panel); padding: 0 32px 0 12px; }

/* --- Таблицы: продуктовый вид (усиление базового .table) --- */
.table { box-shadow: var(--shadow-sm); }
.table thead th { background: #fbfcfd; text-transform: uppercase; letter-spacing: 0.04em;
  font-size: 11.5px; font-weight: 700; color: var(--muted); border-bottom: 1px solid var(--border); }
.table th, .table td { padding: 11px 14px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-card { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; margin: 0 0 16px; }
.table-card > .table, .table-card .table { border: 0; border-radius: 0; box-shadow: none; margin: 0; }
.table-card__header { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.table-card__title { margin: 0; font-size: 15px; font-weight: 700; }

/* --- Empty state: спокойный, с нейтральным маркером --- */
.empty { background: var(--surface); border: 1px solid var(--border); padding: 40px 20px; }
.empty__icon { display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.empty__icon .icon { width: 22px; height: 22px; }

/* --- Code pill: технические коды (PRESET-ENG, run_id, коммит) --- */
.code-pill { display: inline-block; padding: 1px 7px; border-radius: 6px;
  font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace; font-size: 12.5px;
  color: var(--text); background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }

/* --- Status card (offsite и т.п.) --- */
.status-card { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px;
  margin: 0 0 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.status-card__dot { flex: 0 0 auto; width: 10px; height: 10px; margin-top: 5px;
  border-radius: 50%; background: var(--muted); }
.status-card--ok .status-card__dot { background: var(--ok-fg); }
.status-card--danger .status-card__dot { background: var(--danger); }
.status-card__body { flex: 1 1 auto; min-width: 0; }
.status-card__title { margin: 0 0 2px; font-weight: 600; }
.status-card__meta { margin: 0; font-size: 13px; color: var(--muted); word-break: break-word; }

/* --- Action panel (сканер / поиск) --- */
.action-panel { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 16px; margin: 0 0 16px; }
.action-panel .search-form, .action-panel .scanner-page { margin: 0; }
.action-panel__hint { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

/* --- Индикатор готовности сканера (ненавязчивый, у подсказки поля) --- */
.scan-indicator {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 8px; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; color: var(--muted);
  background: var(--surface-2, #f1f3f5); border: 1px solid var(--line, #dfe3e8);
  cursor: pointer;
}
.scan-indicator::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
}
.scan-indicator.is-ready {
  color: var(--ok-fg); background: var(--ok-bg); border-color: var(--ok-line);
}
.scan-indicator.is-ready::before { background: var(--ok-fg); }

/* --- Segmented control (пресеты периода в отчётах) --- */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius-md); }
.segmented a { padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 500;
  color: var(--muted); text-decoration: none; }
.segmented a:hover { color: var(--text); }
.segmented a.is-active { background: var(--panel); color: var(--accent);
  box-shadow: var(--shadow-sm); font-weight: 600; }

/* --- Сетка колонок отчётов --- */
.report-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

@media (max-width: 760px) {
  .report-columns { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .filter-toolbar, form.toolbar { padding: 12px; }
  .filter-toolbar label, form.toolbar label,
  .filter-toolbar input, .filter-toolbar select, .filter-toolbar .btn, .filter-toolbar button,
  form.toolbar input, form.toolbar select, form.toolbar .btn, form.toolbar button { width: 100%; }
}

/* ===========================================================================
   v1.2.2 — Вертикальный ритм и компактность (без нового стиля).
   Крупные секции: 24-32px; внутренние подблоки: 12-20px.
   =========================================================================== */

/* Dashboard: крупные секции читаются как отдельные группы. */
.dashboard-section { margin-bottom: 28px; }
.dashboard-section:last-child { margin-bottom: 0; }
.dashboard-section > .card:last-child,
.dashboard-section > .empty:last-child { margin-bottom: 0; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Reports: отделяем аналитические секции друг от друга. */
.reports-section { margin-top: 28px; }
.report-columns { margin-top: 16px; }

/* Компактный filter-toolbar для страниц с 1-2 фильтрами:
   не растягивается в пустую белую полосу. */
.filter-toolbar--compact { display: inline-flex; width: auto; max-width: 100%; padding: 10px 12px; }

/* Компактный empty-state для простых списков (баланс воздуха). */
.empty { padding: 30px 20px; }
.empty--compact { padding: 20px; }
.empty--compact .empty__icon { width: 40px; height: 40px; margin-bottom: 10px; }
.empty--compact .empty__title { font-size: 15px; }
.empty--compact .empty__text { margin-bottom: 10px; }

/* Action panel: поле и кнопка одной высоты, спокойная подсказка. */
.action-panel .search-form, .action-panel .scanner-page { align-items: stretch; }

@media (max-width: 560px) {
  .dashboard-section { margin-bottom: 20px; }
  .reports-section { margin-top: 20px; }
  /* На узком экране компактный toolbar снова во всю ширину. */
  .filter-toolbar--compact { display: flex; width: 100%; }
}

/* Слой 32.4: кликабельная плитка + модальное окно расчёта стоимости ячейки.
   Чистый CSS :target, без JS: работает везде, закрытие ссылкой на #scan. */
.tile--link { display: block; text-decoration: none; color: inherit; }
.tile--link:hover { border-color: var(--accent); }
.tile__hint { margin-top: 6px; font-size: 12px; color: var(--muted); }
.tile--link:hover .tile__hint { color: var(--accent); }

.css-modal { display: none; }
.css-modal:target { display: block; position: fixed; inset: 0; z-index: 80; }
.css-modal__backdrop { position: absolute; inset: 0; background: rgba(16, 24, 40, 0.44); }
.css-modal__dialog { position: relative; z-index: 1; margin: 4vh auto; width: min(920px, calc(100vw - 24px));
  max-height: 88vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 20px; }
.css-modal__header { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 4px; }
.css-modal__title { margin: 0; font-size: 20px; }
.css-modal__table-wrap { overflow-x: auto; margin-top: 12px; }
/* Итоговый блок «математической скобки»: строки складываются в одну сумму. */
.value-total { margin-top: 14px; padding: 12px 16px; border-left: 3px solid var(--accent);
  background: var(--bg); border-radius: 0 8px 8px 0; }
.value-total__sum { font-size: 22px; font-weight: 700; margin: 2px 0; }
.value-total__formula { font-size: 13px; color: var(--muted); }
@media (max-width: 560px) {
  .css-modal__dialog { margin: 2vh auto; padding: 14px; max-height: 92vh; }
}

/* Пакетная приёмка: компактные группы по физическим ячейкам. */
.receiving-queue-line { padding: 14px 0; border-top: 1px solid var(--line); }
.receiving-queue-line:first-of-type { border-top: 0; }
.receiving-queue-line p { margin: 0 0 10px; }
.receiving-group { margin-top: 14px; }
.receiving-group h2 { margin-top: 0; }
.receiving-group .inline-form input[type="number"],
.receiving-queue-line .inline-form input[type="number"] { width: 78px; }
.receiving-group .inline-form .btn--danger { background: var(--danger);
  border-color: var(--danger); color: #fff; }
.receiving-location-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.receiving-location-form input { flex: 1 1 260px; min-width: 0; }

@media (max-width: 560px) {
  .receiving-group .card__body, .receiving-queue-line { padding-left: 0; padding-right: 0; }
  .receiving-group .table { white-space: normal; }
  .receiving-group .table thead { display: none; }
  .receiving-group .table tbody { display: block; }
  .receiving-group .table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto;
    gap: 3px 10px; padding: 10px; border-bottom: 1px solid var(--line); }
  .receiving-group .table tbody td { display: block; padding: 2px 0; border: 0; min-width: 0; }
  .receiving-group .table tbody td:nth-child(1),
  .receiving-group .table tbody td:nth-child(2),
  .receiving-group .table tbody td:nth-child(3),
  .receiving-group .table tbody td:nth-child(5),
  .receiving-group .table tbody td:nth-child(6) { grid-column: 1; text-align: left; }
  .receiving-group .table tbody td:nth-child(4) { grid-column: 2; grid-row: 1 / span 3; }
  .receiving-group .table tbody td:nth-child(5)::before { content: "Оценка: "; color: var(--muted); }
  .receiving-group .table tbody td:nth-child(6)::before { content: "Сумма: "; color: var(--muted); }
  .receiving-group .table tbody td:nth-child(7) { display: flex; grid-column: 1 / -1;
    flex-wrap: wrap; gap: 6px; margin-top: 5px; text-align: left; }
  .receiving-group .table__actions .inline-form { display: block; margin: 0; }
  .receiving-location-form input, .receiving-location-form button { width: 100%; }
  .receiving-queue-line .form-actions { align-items: stretch; }
  .receiving-queue-line .form-actions form { width: 100%; }
  .receiving-queue-line .form-actions input,
  .receiving-queue-line .form-actions button { min-height: 40px; }
  .movement-table { display: table; white-space: normal; table-layout: fixed; }
  .movement-table th, .movement-table td { padding: 8px 6px; font-size: 13px; }
  .movement-table th:nth-child(1) { width: 25%; }
  .movement-table th:nth-child(2) { width: 29%; }
  .movement-table th:nth-child(3) { width: 31%; }
  .movement-table th:nth-child(5) { width: 15%; }
  .movement-table th:nth-child(4), .movement-table td:nth-child(4),
  .movement-table th:nth-child(6), .movement-table td:nth-child(6),
  .movement-table th:nth-child(7), .movement-table td:nth-child(7),
  .movement-table th:nth-child(8), .movement-table td:nth-child(8) { display: none; }
}
