/* Приложение приёмок — мобильная вёрстка.
   Одна колонка, крупные зоны нажатия (минимум 44px), фиксированная нижняя панель,
   безопасные отступы под вырез экрана. Светлая и тёмная темы. */

:root {
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --text: #14161a;
  --muted: #667085;
  --line: #dfe3e8;
  --accent: #1f5fd0;
  --accent-text: #ffffff;
  --accent-soft: #eaf0fc;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --warn: #8a5300;
  --warn-soft: #fdf2df;
  --ok: #056b46;
  --ok-soft: #e7f5ef;
  --info-soft: #eef1f5;
  --shadow: 0 1px 2px rgba(16, 24, 40, .08);

  --topbar-h: 56px;
  --tap: 48px;
  --radius: 12px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1013;
    --surface: #171a1f;
    --surface-2: #1d2127;
    --text: #e9ecf1;
    --muted: #98a2b3;
    --line: #272c34;
    --accent: #4c8dff;
    --accent-text: #0c1220;
    --accent-soft: #16233a;
    --danger: #ff7b6b;
    --danger-soft: #2a1614;
    --warn: #f0b64d;
    --warn-soft: #2a2113;
    --ok: #5cd0a0;
    --ok-soft: #12261f;
    --info-soft: #1d2127;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------- Верхняя панель ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) calc(8px + var(--safe-right)) 0 calc(8px + var(--safe-left));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-titles {
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 4px;
  text-align: center;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbtn {
  flex: 0 0 auto;
  min-width: 64px;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.topbtn:active { background: var(--accent-soft); }

/* Ненужная кнопка скрывается, но место сохраняет — заголовок остаётся по центру */
.topbtn.is-hidden {
  visibility: hidden;
  pointer-events: none;
}

/* ---------- Основная область ---------- */

.main {
  flex: 1 1 auto;
  padding-bottom: 16px;
}

body.has-bottombar .main {
  padding-bottom: calc(84px + var(--safe-bottom));
}

.view[hidden] { display: none; }

.pad {
  padding: 16px calc(16px + var(--safe-right)) 8px calc(16px + var(--safe-left));
}

.pad-tight {
  padding: 0 calc(16px + var(--safe-right)) 0 calc(16px + var(--safe-left));
}

.lead {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
}

.note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Поля ввода ---------- */

.field {
  display: block;
  margin-bottom: 14px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="tel"],
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* не менее 16px — иначе iOS зумит при фокусе */
  appearance: none;
  -webkit-appearance: none;
}

textarea { resize: vertical; }

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input.invalid {
  border-color: var(--danger);
}

input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.sticky-search {
  position: sticky;
  top: calc(var(--topbar-h) + var(--safe-top));
  z-index: 20;
  padding-top: 10px;
  padding-bottom: 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.field-flat { margin-bottom: 0; }

/* ---------- Кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.btn-wide {
  display: flex;
  width: 100%;
  margin-top: 12px;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn-primary:active { filter: brightness(.92); }

.btn-ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.btn-danger-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--danger);
}

/* Плитка главного экрана: название операции и строка-пояснение под ним.
   Пояснение обязательно — «Отгрузка» и «Возврат поставщику» без него сотрудник
   различает по догадке. */
.btn-tile {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 14px 16px;
  text-align: left;
}

.btn-tile .tile-title { font-size: 17px; font-weight: 700; }

.btn-tile .tile-sub {
  font-size: 13px;
  font-weight: 400;
  opacity: .8;
  white-space: normal;
}

/* Разделитель «создать» / «посмотреть»: списки документов — другой класс
   действия, и стоять вплотную к кнопкам создания они не должны. */
.home-divider {
  margin: 26px 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* Атрибут hidden проигрывает по специфичности .btn-wide{display:flex} — скрытая
   кнопка оставалась на экране (ссылка результата, кнопка ручного ввода). */
.btn[hidden] { display: none; }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: .55;
  cursor: default;
  pointer-events: none;
}

/* ---------- Списки (магазины, контрагенты, товары) ---------- */

.list {
  padding: 8px calc(12px + var(--safe-right)) 8px calc(12px + var(--safe-left));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.row:active { background: var(--surface-2); }

/* Справочная строка списка приёмок магазина: документ создан в МойСклад, править
   его приложение не умеет (Д9), а ссылок в МС у приложения нет — нажимать
   на такую строку нечего, и она не должна выглядеть нажимаемой. */
.row.is-static {
  cursor: default;
  box-shadow: none;
  background: var(--surface-2);
}

.row.is-static:active { background: var(--surface-2); }

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

.row-title {
  font-size: 16px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.row-sub {
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.row-side {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--muted);
  text-align: right;
}

.row.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.row.in-cart .row-side {
  color: var(--accent);
  font-weight: 600;
}

/* Отсканированная позиция — не кнопка: нажимать на неё нечего,
   количество и цена правятся в корзине. */
.row.in-cart { cursor: default; }

/* ---------- Сканирование ---------- */

.scanner {
  position: relative;
  /* Во всю ширину экрана, за пределы отступов .pad: чем крупнее кадр,
     тем проще навести. Отрицательные поля повторяют padding .pad. */
  margin: 0 calc(-16px - var(--safe-right)) 12px calc(-16px - var(--safe-left));
  border-left: 0;
  border-right: 0;
  border-radius: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  /* Ни фиксированной пропорции, ни object-fit: cover. Соотношение сторон задаёт
     сам поток камеры, кадр виден ЦЕЛИКОМ. Прежний вариант (4/3 + cover) срезал
     у потока 16/9 четверть по бокам: сотрудник видел центральные три четверти
     кадра, а распознавался весь, и рамка не значила ничего. */
  line-height: 0;
}

.scanner video {
  display: block;
  width: 100%;
  height: auto;
}

/* Прицел. Размер приходит из js/scanner.js теми же долями, по которым вырезается
   область распознавания: что обведено, то и разбирается. Значения по умолчанию
   держатся в согласии с ROI_WIDTH и ROI_HEIGHT. */
.scanner-frame {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: var(--roi-w, 92%);
  height: var(--roi-h, 30%);
  border: 2px solid rgba(255, 255, 255, .92);
  border-radius: 8px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .38);
  pointer-events: none;
  transition: border-color .12s linear, background-color .12s linear;
}

.scanner-frame.is-hit {
  border-color: #3ddc97;
  background-color: rgba(61, 220, 151, .28);
}

/* Красная вспышка отказа: отказ обязан отличаться от «код ещё не пойман»
   в той же точке экрана, где сотрудник ждёт зелёную. Цвета яркие и литеральные,
   как у .is-hit: полупрозрачный слой лежит на живом видео, а не на теме. */
.scanner-frame.is-miss {
  border-color: #ff5a4a;
  background-color: rgba(255, 90, 74, .28);
}

/* Фонарик для тёмной подсобки. Появляется только если камера отдаёт torch. */
.scan-torch {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 10px;
  background: rgba(0, 0, 0, .45);
  color: #fff;
  font-size: 14px;
}

.scan-torch.is-on {
  background: #fff;
  border-color: #fff;
  color: #14161a;
}

/* При включённой камере js/scanner.js переносит вердикт внутрь .scanner — поверх
   кадра, в зоне взгляда. В потоке страницы (камера выключена, пистолет) он остаётся
   обычным блоком под кнопкой. */
.scanner .scan-verdict {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 4;
  margin: 0;
  max-height: calc(100% - 16px);
  overflow-y: auto;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .4);
  line-height: 1.4;   /* .scanner несёт line-height:0 против зазора под video */
}

/* Карточки РЕШЕНИЯ (выбор из нескольких товаров, подтверждение найденного) —
   исключение из правила выше. Вердикт скана живёт на кадре и обязан в него
   помещаться; решение надо дочитать до конца, и обрезать его кадром нельзя:
   полосы прокрутки на телефоне в покое не видно, обрыв читается как конец
   карточки. Сотрудник принял бы единственный видимый вариант за единственный
   существующий, а на карточке подтверждения не увидел бы «Отмену» — осталась
   бы одна кнопка, добавляющая товар. Поэтому такие карточки раскрываются
   на весь экран поверх кадра, от нижней панели вверх. */
.scanner .scan-verdict.is-choice {
  position: fixed;
  left: calc(8px + var(--safe-left));
  right: calc(8px + var(--safe-right));
  bottom: calc(92px + var(--safe-bottom));
  /* Выше нижней панели (z-index 40): она перекрыла бы кнопки выбора. */
  z-index: 45;
  max-height: calc(100vh - 150px);
  max-height: calc(100dvh - 150px);   /* iOS: адресная строка съедает vh */
}

/* На кадре вердикт читается с расстояния вытянутой руки — заголовок крупнее. */
.scanner .scan-verdict .scan-verdict-title {
  font-size: 19px;
}

/* Подсказка о расстоянии: телефон на 5 см от коробки не наводится на резкость,
   и это выглядит как «сканер не работает». */
.scanner-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  text-align: center;
  font-size: 13px;
  line-height: 1.3;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .9);
  pointer-events: none;
}

.scan-hid { margin-top: 12px; }

/* Ручной ввод кода для весового товара. Отдельная форма, а не поле пистолета:
   то поле намеренно не открывает экранную клавиатуру. */
.manual-box {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.manual-box[hidden] { display: none; }

.manual-box .msg { margin-bottom: 0; }

.manual-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* Обе кнопки одной ширины: «Отмена» рядом с «Найти» не должна выглядеть основной. */
.manual-actions .btn { flex: 1 1 0; }

/* Итог последнего скана. Цвет — основной носитель смысла на расстоянии вытянутой
   руки, поэтому он дублируется текстом «Позиция не добавлена». */
.scan-verdict {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 14px;
}

.scan-verdict-title {
  font-size: 16px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.scan-verdict-text {
  margin-top: 4px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* Предупреждение внутри карточки подтверждения — не приглушённая подсказка,
   а повод остановиться (весовая этикетка с фиксированной ценой: количество
   рискует уехать в тысячу раз меньше фактического). Приглушённым серым такое
   не отличить от описания строкой выше. */
.scan-verdict-alert {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--warn-soft);
  color: var(--warn);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.scan-verdict .btn { margin-top: 8px; }

/* Состав карточки в подтверждении товара (Р3.2): штрихкоды, упаковки, признак
   «штучная карточка / упаковка». Мельче основного текста — это справка для
   сверки с коробкой, а не то, что читают с расстояния вытянутой руки. */
.scan-verdict-detail {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* Один вариант выбора «код — это несколько товаров»: кнопка и состав именно
   этой карточки держатся вместе, иначе состав читается как подпись к соседней. */
.scan-verdict-variant {
  margin-top: 10px;
  padding: 8px 10px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.scan-verdict-variant .btn { margin-top: 0; }

.scan-verdict.is-ok {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.scan-verdict.is-ok .scan-verdict-title { color: var(--ok); }

.scan-verdict.is-bad {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.scan-verdict.is-bad .scan-verdict-title { color: var(--danger); }

.scan-verdict.is-warn {
  border-color: var(--warn);
  background: var(--warn-soft);
}

.scan-verdict.is-warn .scan-verdict-title { color: var(--warn); }

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

.msg {
  margin: 8px 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.msg-error { background: var(--danger-soft); color: var(--danger); }
.msg-warn  { background: var(--warn-soft);  color: var(--warn); }
.msg-info  { background: var(--info-soft);  color: var(--muted); }
.msg[hidden] { display: none; }

.msg strong { font-weight: 600; }

/* ---------- Дата прихода (Р0.1) ---------- */

.datepick {
  margin: 16px 0 4px;
  padding: 12px 14px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.datepick-title { font-weight: 600; }

.datepick-hint {
  margin: 6px 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.datepick-btns {
  display: flex;
  gap: 10px;
}

.datepick-btns .btn { flex: 1 1 0; }

/* Поля документа: комментарий сотрудника (Р3.3) и признак «НЕ ПОЛНАЯ НАКЛАДНАЯ»
   (Д12). Карточка — как у даты прихода и фото: экран подтверждения собран из
   блоков-решений, и один из них без рамки читался бы как обрывок соседнего. */
.editfields {
  margin: 16px 0 4px;
  padding: 12px 14px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.editfields .field { margin-bottom: 0; }

.editfields .datepick-hint { margin: 6px 0 2px; }

.checkline {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 6px 2px;
  cursor: pointer;
}

.checkline input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

/* Отметка «бесплатно» в карточке позиции: та же строка с чекбоксом, но внутри
   карточки — отступ сверху отделяет её от полей ввода. */
.cart-free {
  margin-top: 2px;
}

/* Поле, выключенное отметкой «бесплатно»: видно, что значение есть, но правке
   оно не подлежит. */
.field.is-disabled .field-label { opacity: 0.6; }

.field.is-disabled input {
  background: var(--surface-2);
  color: var(--muted);
}

/* Выбранный день — как выбранная строка списка: акцентная рамка и подложка */
.datepick-btns .btn.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- Фото накладной ---------- */

.photos {
  margin: 16px 0 4px;
  padding: 12px 14px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.photos-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.photos-title { font-weight: 600; }
.photos-count { color: var(--muted); font-size: 13px; }

.photos-hint {
  margin: 6px 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

/* Миниатюры в ряд с переносом: накладная на пяти листах не должна растянуть экран. */
.photos-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.photos-grid:empty { display: none; }

.photo-thumb {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Зона удаления держится крупной: палец в перчатке на складе промахивается. */
.photo-drop {
  position: absolute;
  top: 0;
  right: 0;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 0 0 0 var(--radius);
  background: rgba(20, 22, 26, .72);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.photo-size {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 2px 4px;
  background: rgba(20, 22, 26, .6);
  color: #fff;
  font-size: 11px;
  text-align: center;
}

/* Пропуск фото по причине (Р0.2): список причин и карточка выбранной */
.photo-skip-reasons .photos-hint { margin: 10px 0 0; }

.photo-skip-box { margin-top: 12px; }
.photo-skip-box .msg { margin: 0; }

/* ---------- Корзина ---------- */

.cart {
  padding: 4px calc(12px + var(--safe-right)) 8px calc(12px + var(--safe-left));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cart-item {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.cart-item-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.cart-item-title {
  flex: 1 1 auto;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.cart-item-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.cart-remove {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
  margin: -8px -8px 0 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--danger);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.cart-remove:active { background: var(--danger-soft); }

.cart-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  /* Подпись «· рассчитана» переносит заголовок поля на вторую строку. Выравнивание
     по низу держит сами поля ввода на одной линии независимо от высоты подписей. */
  align-items: end;
  gap: 10px;
  margin-top: 10px;
}

.cart-inputs .field { margin-bottom: 0; }

/* Сумма строки — во всю ширину карточки: это второй способ задать цену,
   и делить его пополам с ценой за единицу значит путать их местами. */
.cart-inputs .field-wide { grid-column: 1 / -1; }

/* Поле, которое считает приложение, а не заполняет сотрудник. Приглушено,
   но остаётся редактируемым: тронул — стало ведущим. */
.cart-inputs .is-derived input {
  background: var(--bg);
  color: var(--muted);
}

.cart-line-note {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.cart-item-error {
  margin-top: 8px;
  font-size: 13px;
  color: var(--danger);
}

/* ---------- Сводка и таблица подтверждения ---------- */

.summary {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.summary div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  font-size: 14px;
}

.summary dt { color: var(--muted); flex: 0 0 auto; }
.summary dd { margin: 0; text-align: right; overflow-wrap: anywhere; }

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.tbl th, .tbl td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.tbl th {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; white-space: nowrap; }

/* ---------- Результат ---------- */

.result-card {
  padding: 18px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.result-status {
  font-size: 14px;
  font-weight: 600;
  color: var(--ok);
}

.result-status.is-repeat { color: var(--warn); }

.result-number {
  margin: 6px 0 16px;
  font-size: 26px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.result-card .summary { text-align: left; }

/* ---------- Нижняя фиксированная панель ---------- */

.bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px calc(16px + var(--safe-right)) calc(10px + var(--safe-bottom)) calc(16px + var(--safe-left));
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.bottombar[hidden] { display: none; }

.bottom-info {
  flex: 1 1 auto;
  min-width: 0;
}

.bottom-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bottom-value {
  font-size: 19px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bottom-action {
  flex: 0 0 auto;
  min-width: 140px;
}

/* ---------- Уведомление и индикатор загрузки ---------- */

.toast {
  position: fixed;
  left: calc(12px + var(--safe-left));
  right: calc(12px + var(--safe-right));
  bottom: calc(90px + var(--safe-bottom));
  z-index: 60;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}

.toast[hidden] { display: none; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .35);
}

.overlay[hidden] { display: none; }

.overlay-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-width: 160px;
  padding: 22px 26px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.overlay-text {
  font-size: 14px;
  color: var(--muted);
}

/* ---------- Модальный вопрос ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--safe-left)) 16px calc(16px + var(--safe-bottom));
  background: rgba(0, 0, 0, .45);
}

.modal[hidden] { display: none; }

.modal-box {
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
}

.modal-text {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.modal-actions {
  margin-top: 8px;
}

/* .btn-wide уже несёт свой отступ сверху — здесь только выравниваем шаг между кнопками */
.modal-actions .btn-wide { margin-top: 10px; }

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}

/* ---------- Широкий экран: ограничиваем колонку ---------- */

@media (min-width: 640px) {
  .app { max-width: 560px; margin: 0 auto; }
  .bottombar { max-width: 560px; left: 50%; transform: translateX(-50%); }
  .toast { max-width: 536px; left: 50%; right: auto; transform: translateX(-50%); }
}

/* ---------- Заглушка второго окна ---------- */

/* z-index выше и оверлея занятости (70), и модального вопроса (80): окно,
   в котором работать нельзя, должно быть закрыто целиком — иначе под
   заглушкой остаётся живой вопрос или поле сканера-пистолета. */
.lockout {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--safe-left)) 16px calc(16px + var(--safe-bottom));
  background: rgba(0, 0, 0, .72);
}

.lockout[hidden] { display: none; }

.lockout-box {
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
}

/* --- Сверка ценников -------------------------------------------------------
   Экран, на который смотрят с вытянутой руки у полки: цена должна читаться
   мгновенно и не путаться с ценой на ценнике. Отсюда крупный кегль и моноширинные
   цифры — 1 500 и 1 800 не должны отличаться шириной строки. */
.pc-price {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.15;
  margin: 6px 0 2px;
  font-variant-numeric: tabular-nums;
}

.pc-unit {
  font-size: 1rem;
  font-weight: 600;
  opacity: 0.7;
}

.pc-meta {
  font-size: 0.85rem;
  opacity: 0.75;
  margin-top: 2px;
}

.pc-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.pc-actions .btn { flex: 1 1 0; }

.pc-shelf { margin-top: 10px; }
.pc-shelf .input { width: 100%; margin: 6px 0; }
/* Поле ввода цены: крупный кегль и моноширинные цифры — набирают стоя у полки,
   часто одной рукой, и опечатка в разряде здесь дороже всего. */
.pc-shelf-input {
  /* Тип tel — ради цифровой клавиатуры без букв; оформление берётся из общего
     стиля полей выше, там он теперь перечислен наравне с text и number. */
  font-size: 1.6rem;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 10px 12px;
}

.pc-panel { margin-top: 10px; }
.pc-head { font-weight: 600; margin-bottom: 4px; }

.pc-recent { margin-top: 10px; }
.pc-recent-item {
  font-size: 0.85rem;
  padding: 4px 0;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pc-recent-item.is-mismatch { font-weight: 600; }
