/* Мобильная версия /m/: крупный шрифт (от 17 px), строки и кнопки от 48 px, без таблиц.
   Тема — по настройке телефона (prefers-color-scheme). Полная версия эти стили не видит. */

:root {
  --photo-size: 96px;
  --photo-gap: 8px;
  --theme-light: #ffffff;
  --theme-dark: #151a21;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1a1d21;
  --muted: #5d6673;
  --line: #e2e5ea;
  --accent: #ea580c;
  --accent-text: #ffffff;
  --accent-soft: #fdeee4;
  --warn: #b45309;
  --warn-soft: #fff4e0;
  --bad: #b91c1c;
  --ok: #15803d;
  --ok-bg: #dcfce7;      /* бейдж остатка: тёмно-зелёный на светло-зелёном, контраст ≈ 7:1 */
  --ok-text: #166534;
  --press: #eceef2;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 14px;
  --pad: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1217;
    --surface: #151a21;
    --text: #eef1f4;
    --muted: #a3acb8;
    --line: #2a313b;
    --accent: #fb8a3c;
    --accent-text: #1a1d21;
    --accent-soft: #3a2415;
    --warn: #fbbf24;
    --warn-soft: #3a2e12;
    --bad: #f87171;
    --ok: #4ade80;
    --ok-bg: #14532d;    /* тёмная тема: светло-зелёный на тёмно-зелёном, контраст ≈ 9:1 */
    --ok-text: #bbf7d0;
    --press: #222a34;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

button, input { font: inherit; color: inherit; }
select, textarea { font: inherit; color: inherit; }
/* iPhone: поле со шрифтом меньше 16px увеличивает страницу при фокусе */
input, select, textarea { font-size: max(16px, 1em); }
/* Без увеличения по двойному тапу нигде — ни по кнопкам, ни по фону и тексту (iPhone смотрит на элемент под пальцем);
   масштаб двумя пальцами на обычных страницах остаётся. На экране сканера — ниже, .scan */
html, body, * { touch-action: manipulation; }

/* ── шапка ─────────────────────────────────────────── */
.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  padding: env(safe-area-inset-top) calc(8px + env(safe-area-inset-right)) 0 calc(8px + env(safe-area-inset-left));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.bar-back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 48px;
  padding: 0 12px 0 4px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  flex: none;
}
.bar-back svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.bar-back:active { background: var(--press); }
.bar-title {
  flex: 1;
  min-width: 0;
  padding: 0 8px;
  font-weight: 700;
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-back:not([hidden]) + .bar-title { padding-left: 0; }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--pad) calc(var(--pad) + env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) calc(var(--pad) + env(safe-area-inset-left));
}

/* ── общие блоки ───────────────────────────────────── */
.doc-danger-zone { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line); }
#docTrashForm { gap: 16px; }
#docTrashForm .field-block { display: flex; flex-direction: column; gap: 8px; }
.section-title {
  margin: 24px 4px 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--muted);
}
.section-title:first-child { margin-top: 4px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.list { display: flex; flex-direction: column; gap: 10px; }

.row {
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 14px var(--pad);
  text-align: left;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
}
a.row:active, button.row:active { background: var(--press); }
.row-name { font-weight: 600; overflow-wrap: anywhere; }
.row-sub {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 12px;
  margin-top: 6px;
  color: var(--muted);
}
.row-qty { color: var(--text); font-weight: 700; white-space: nowrap; }
.row-qty.none { color: var(--muted); font-weight: 500; }
.row-qty.neg { color: var(--bad); }
.row-qty.pos, .qty-big.pos {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--ok-text);
}
.row-line { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.row-line + .row-line { margin-top: 4px; }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  background: var(--warn-soft);
  color: var(--warn);
  vertical-align: middle;
}

.note { margin: 12px 4px; color: var(--muted); }
.note-warn {
  margin: 12px 0;
  padding: 12px var(--pad);
  border-radius: var(--radius);
  background: var(--warn-soft);
  color: var(--warn);
}
.error {
  margin: 12px 0;
  color: var(--bad);
  font-weight: 500;
}
.error:empty { display: none; }
.hint { margin-top: 12px; color: var(--muted); font-size: 16px; }

/* ── поле и кнопки ─────────────────────────────────── */
.input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 18px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::-webkit-search-cancel-button { -webkit-appearance: none; }

.search { display: flex; gap: 8px; margin-bottom: 16px; }
#scanBtn { margin-bottom: 16px; }
.search .input { flex: 1; min-width: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-weight: 600;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.btn:active { background: var(--press); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:active { filter: brightness(.92); background: var(--accent); }
.btn-block { display: flex; width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: default; }
.btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.big-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 0 var(--pad);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 18px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.big-btn:active { background: var(--press); }
.big-btn .count {
  min-width: 40px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  text-align: center;
  font-weight: 700;
}
.big-btn.dim { opacity: .45; box-shadow: none; cursor: default; }
.big-btn.dim .count { background: var(--press); color: var(--muted); }
.chev { color: var(--muted); font-size: 22px; line-height: 1; }

/* склад над поиском */
.wh-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  margin-bottom: 14px;
  padding: 8px var(--pad);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.wh-btn:active { background: var(--press); }
.wh-btn .wh-label { display: block; font-size: 15px; color: var(--muted); }
.wh-btn .wh-name { display: block; font-weight: 700; overflow-wrap: anywhere; }
.wh-icon { flex: none; width: 26px; height: 26px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.wh-btn .grow { flex: 1; min-width: 0; }

.check-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.check-row .tick { color: var(--accent); font-size: 22px; font-weight: 700; }

/* ── товар ─────────────────────────────────────────── */
.product-head { display: flex; align-items: flex-start; gap: 4px; margin: 0 0 12px; }
.product-head .product-name { flex: 1; min-width: 0; margin: 4px; }
.product-head .copy { margin-top: -4px; }
.product-name { margin: 4px 4px 16px; font-size: 22px; line-height: 1.3; font-weight: 700; overflow-wrap: anywhere; }
.fields { padding: 4px 0; }
.field {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 6px 6px 6px var(--pad);
}
.field + .field { border-top: 1px solid var(--line); }
.field-body { flex: 1; min-width: 0; }
.field-label { display: block; font-size: 15px; color: var(--muted); }
.field-value { display: block; font-weight: 600; overflow-wrap: anywhere; }
.field-value.empty { color: var(--muted); font-weight: 500; }
.qty-big { display: inline-block; font-size: 26px; font-weight: 800; }
.qty-big.pos { margin-top: 4px; padding: 2px 14px; }
.qty-big.neg { color: var(--bad); }
.qty-big.none { font-size: 20px; color: var(--muted); font-weight: 600; }

.copy {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.copy:active { background: var(--press); }
.copy svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.copy.done { color: var(--ok); }

.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.share-btn { margin-top: 16px; min-height: 56px; font-size: 18px; }

/* ── документ ──────────────────────────────────────── */
.doc-head { padding: 14px var(--pad); }
.doc-type { font-size: 22px; font-weight: 700; }
.doc-meta { margin-top: 4px; color: var(--muted); }
.doc-route { margin-top: 10px; font-weight: 600; overflow-wrap: anywhere; }
.status { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.status .tag.ok { background: var(--press); color: var(--ok); }
.status .tag.off { background: var(--press); color: var(--bad); }

/* ── прочее ────────────────────────────────────────── */
.footer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: 36px;
  color: var(--muted);
  font-size: 16px;
}
.footer a, .footer button {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 12px;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.footer .time { width: 100%; text-align: center; }

.loading { padding: 32px 0; text-align: center; color: var(--muted); }
.more { margin-top: 12px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  z-index: 30;
}

/* ── вход ──────────────────────────────────────────── */
.login {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--pad);
  background: var(--bg);
}
.login[hidden] { display: none; }
.login-box { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 10px; }
.login-brand { margin-bottom: 16px; font-size: 26px; font-weight: 800; text-align: center; color: var(--accent); }
.login-box .btn { margin-top: 6px; }

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

/* ── сканер (/m/scan) ─────────────────────────────── */
body.scanning { overflow: hidden; overscroll-behavior: none; }
body.scanning .bar { display: none; }
.scan {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #000;
  color: #fff;
  overflow: hidden;
}
/* Экран сканера — во весь экран, без прокрутки и масштаба (ни двойным тапом, ни двумя пальцами). Нажатия и ввод
   с touch-action: none работают как обычно — запрещены только жесты прокрутки и увеличения. Панель товара может
   прокручиваться (несколько товаров с одним штрихкодом) — только по вертикали, без масштаба. */
html:has(body.scanning), body.scanning, body.scanning * { touch-action: none; }
body.scanning .scan-panel, body.scanning .scan-panel * { touch-action: pan-y; }
.scan-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scan-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 8px calc(12px + env(safe-area-inset-left));
  background: linear-gradient(rgba(0, 0, 0, .55), transparent);
}
.scan-wh { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px #000; }
.scan-round {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .2);
  color: #fff;
  cursor: pointer;
}
.scan-round svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.scan-round[aria-pressed="true"] { background: #fde047; color: #1a1d21; }
/* рамка-прицел: всё вокруг затемнено тенью */
.scan-frame {
  position: absolute;
  left: 50%;
  top: 42%;
  width: min(78vw, 340px);
  height: min(48vw, 210px);
  transform: translate(-50%, -50%);
  border: 3px solid rgba(255, 255, 255, .9);
  border-radius: 18px;
  box-shadow: 0 0 0 200vmax rgba(0, 0, 0, .45);
  pointer-events: none;
}
.scan-frame span {   /* линия-подсказка посередине */
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 2px;
  background: rgba(234, 88, 12, .85);
}
.scan-frame.hit { animation: scan-hit .5s ease-out; }
@keyframes scan-hit {
  0% { border-color: #22c55e; box-shadow: 0 0 0 200vmax rgba(34, 197, 94, .45); }
  100% { border-color: #22c55e; box-shadow: 0 0 0 200vmax rgba(0, 0, 0, .45); }
}
.scan-hint {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(42% + min(24vw, 105px) + 16px);
  margin: 0;
  padding: 0 16px;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  text-shadow: 0 1px 3px #000;
}
.scan-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  background: linear-gradient(transparent, rgba(0, 0, 0, .7) 30%);
}
.scan-msg {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(20, 24, 30, .92);
  color: #fff;
  font-size: 17px;
  max-height: 45vh;
  overflow-y: auto;
}
.scan-msg p { margin: 0 0 10px; }
.scan-manual { display: flex; gap: 8px; }
.scan-manual .input { flex: 1; min-width: 0; color: var(--text); }
.scan-btn { background: rgba(255, 255, 255, .95); color: #1a1d21; border-color: transparent; }
.scan-btn:active { background: #e5e7eb; }

/* крупная кнопка сканера (главная, «Сканировать ещё») */
.btn-scan {
  min-height: 60px;
  border: 2px solid var(--accent);
  color: var(--accent);
  background: var(--surface);
  font-size: 18px;
}
.btn-scan svg { width: 26px; height: 26px; }
.scan-again { margin-top: 16px; }
.actions .scan-again { margin-top: 0; }
/* «Посмотреть в интернете» — не крупная, под «Поделиться» */
.btn-quiet { margin-top: 8px; border-color: transparent; background: none; color: var(--accent); flex-direction: column; gap: 0; min-height: 48px; }
.web-by { font-size: 15px; font-weight: 500; color: var(--muted); }
.notfound { padding: 16px; }
.notfound-code { margin-top: 4px; font-size: 24px; font-weight: 800; overflow-wrap: anywhere; }

/* ── черновики приёмки и оприходования (drafts.js) ── */
.draft-home { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.draft-home-btn {
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  min-height: 92px;
  padding: 12px 8px;
  text-align: center;
  font-size: 17px;
}
.draft-home-btn svg { width: 30px; height: 30px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* третья кнопка (перемещение) — на всю ширину, ниже и в строку */
.draft-home-btn:nth-child(3):last-child { grid-column: 1 / -1; flex-direction: row; min-height: 64px; }
.draft-new { margin-bottom: 16px; min-height: 56px; font-size: 18px; }
.draft-actions { margin-top: 16px; }
.tag-ready { background: var(--ok-bg); color: var(--ok-text); }
.tag-gone { background: var(--press); color: var(--bad); }
.btn-danger { color: var(--bad); border-color: transparent; background: none; }
.form { display: flex; flex-direction: column; gap: 18px; }
.field-block { display: flex; flex-direction: column; gap: 8px; }
.field-block .wh-btn { margin-bottom: 0; }
.picker-panel { display: flex; flex-direction: column; gap: 10px; }
.picker-list .row { min-height: 52px; padding: 12px var(--pad); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}
.chip-btn:active { background: var(--press); }
.qty-ctl { display: flex; align-items: stretch; gap: 8px; flex: 1; min-width: 0; }
.qty-step {
  flex: none;
  width: 60px;
  min-height: 60px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
}
.qty-step:active { background: var(--press); }
.qty-input { flex: 1; min-width: 0; text-align: center; font-size: 26px; font-weight: 800; min-height: 60px; }
.panel-qty { display: flex; gap: 8px; align-items: stretch; }
.panel-qty select.input { flex: none; width: 104px; min-height: 60px; font-size: 18px; }
.panel-unit { align-self: center; min-width: 48px; font-size: 20px; font-weight: 700; }
.thumbs { display: flex; flex-flow: row wrap; align-items: flex-start; gap: var(--photo-gap); margin-top: 8px; }
.thumbs > a { display: block; flex: 0 0 var(--photo-size); width: var(--photo-size); height: var(--photo-size); }
.thumb { box-sizing: border-box; display: block; flex: 0 0 var(--photo-size); width: var(--photo-size); height: var(--photo-size);
  object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--press); }
.photo-btn { gap: 8px; }
.photo-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
/* панель количества поверх камеры */
.scan-panel {
  padding: 14px;
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  max-height: 62vh;
  overflow-y: auto;
}
.panel-title { font-size: 19px; font-weight: 700; overflow-wrap: anywhere; }
.panel-sub { margin-top: 2px; color: var(--muted); overflow-wrap: anywhere; }
.panel-already { margin-top: 8px; padding: 8px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-weight: 700; }
.scan-panel .panel-qty { margin-top: 12px; }
.scan-panel .scan-row { margin-top: 12px; }
.panel-list { margin: 10px 0; }
.scan-row { display: flex; gap: 10px; }
.scan-row .btn { flex: 1; }
.row-line .tag { flex: none; white-space: nowrap; }

/* Строка, только что добавленная сканером, — коротко подсвечена (drafts.js, FLASH_MS) */
.row-flash { animation: row-flash 2.4s ease-out; }
@keyframes row-flash {
  0%, 35% { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
  100% { background: transparent; box-shadow: inset 4px 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .row-flash { animation: none; background: var(--accent-soft); }
}

/* резервы под объекты (задача 21): свёрнутый блок в карточке товара, только просмотр */
.res-block { margin-top: 12px; }
.res-block > summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 56px;
  padding: 14px var(--pad); cursor: pointer; font-weight: 600; list-style: none; }
.res-block > summary::-webkit-details-marker { display: none; }
.res-block > summary::after { content: '›'; color: var(--muted); font-size: 22px; transform: rotate(90deg); }
.res-block[open] > summary::after { transform: rotate(-90deg); }
.res-title { flex: 1; }
.res-block .count { color: var(--accent); }
.res-none { color: var(--muted); font-weight: 500; }
.res-body { padding: 0 var(--pad) 12px; border-top: 1px solid var(--line); }
.res-store { margin-top: 12px; color: var(--muted); }
.res-store b { color: var(--text); }
.res-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.res-item.res-closed { opacity: .7; }
.res-status { color: var(--muted); white-space: nowrap; }
.res-nums { margin-top: 4px; }
.res-meta { margin-top: 4px; color: var(--muted); overflow-wrap: anywhere; }
.res-meta a { color: var(--accent); }
.res-short { color: var(--bad); font-weight: 600; }
.res-history { margin-top: 6px; }
.res-history > summary { color: var(--accent); cursor: pointer; min-height: 32px; }
.res-history ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); }
.res-hdate { font-variant-numeric: tabular-nums; }
/* «доступно» (остаток − в резерве): ≥ 0 — приглушённо, < 0 — .res-short (красным) */
.res-free { color: var(--muted); }
.res-store .res-short { color: var(--bad); }   /* «доступно −N» в сводке склада — красным (иначе .res-store b) */

/* ── документы = непроведённые документы МойСклад (docs.js) ── */
.row-pending { opacity: .7; border-style: dashed; }
.attn { border-left: 4px solid var(--warn, #b4402f); }
.attn-item { padding: 8px 0; border-top: 1px solid var(--line, rgba(0, 0, 0, .1)); }
.attn-item:first-of-type { border-top: 0; }
.attn-item .scan-row { margin-top: 8px; }

/* Токены главной, результатов, товара, его документов и мест хранения. */
.home-brand, .home-full, .wh-chevron { display: none; }
body.redesigned-page {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --text: #14202b;
  --muted: #5b6772;
  --line: #d5dbe1;
  --card-line: #e1e6eb;
  --accent: #c2410c;
  --accent-text: #ffffff;
  --link: #0f5fa8;
  --ok-bg: #dcfce7;
  --ok-text: #166534;
  --neutral-bg: #e8ecf0;
  --neutral-text: #44505b;
  --orange-bg: #fff1e8;
  --orange-text: #7a2e0a;
  --accent-soft: var(--orange-bg);
  --warn: var(--orange-text);
  --warn-soft: var(--orange-bg);
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --ok: var(--ok-text);
  --press: var(--neutral-bg);
  --shadow: none;
  --theme-light: #f3f5f7;
  --theme-dark: #0e1015;
  color-scheme: light;
  font-family: "Manrope", system-ui, sans-serif;
  font-weight: 500;
}
@media (prefers-color-scheme: dark) {
  body.redesigned-page {
    --bg: #0e1015;
    --surface: #161a21;
    --text: #f1f3f6;
    --muted: #9aa3ae;
    --line: #2a303a;
    --card-line: #262b33;
    --accent: #ec8f4f;
    --accent-text: #17110b;
    --link: #6fb1f2;
    --ok-bg: #1e4a2b;
    --ok-text: #a9f0b9;
    --neutral-bg: #232830;
    --neutral-text: #aeb6c0;
    --orange-bg: #3a2616;
    --orange-text: #f6c9a3;
    --accent-soft: var(--orange-bg);
    --warn: var(--orange-text);
    --warn-soft: var(--orange-bg);
    --bad: #f87171;
    --bad-bg: #3a1f22;
    --ok: var(--ok-text);
    --press: var(--neutral-bg);
    --shadow: none;
    --theme-light: #f3f5f7;
    --theme-dark: #0e1015;
    color-scheme: dark;
  }
}
.redesigned-page main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 480px;
  padding: 12px calc(16px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}
.home-page .bar {
  position: static;
  max-width: 480px;
  min-height: 64px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 0 calc(16px + env(safe-area-inset-left));
  gap: 10px;
  border: 0;
  background: transparent;
}
.home-page .home-brand {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
}
.home-page .bar-title { padding: 0; font-size: 20px; font-weight: 800; }
.home-page .home-full {
  display: inline-flex;
  flex: none;
  align-items: center;
  min-height: 44px;
  color: var(--link);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.redesigned-page svg {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.catalog-page .wh-btn {
  min-height: 56px;
  margin: 0;
  padding: 8px 16px;
  box-shadow: none;
}
.catalog-page .wh-btn .wh-icon, .catalog-page .wh-btn .chev { display: none; }
.catalog-page .wh-label { font-size: 12px; font-weight: 600; }
.catalog-page .wh-name { font-size: 16px; font-weight: 700; }
.catalog-page .wh-chevron { display: block; width: 20px; height: 20px; color: var(--muted); }
.catalog-page .search {
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  gap: 8px;
  margin: 0;
}
.catalog-page .search-field {
  display: flex;
  width: 100%;
  min-width: 0;
  height: 52px;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.catalog-page .search-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.catalog-page .search-clear {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.catalog-page .search-clear svg { width: 20px; height: 20px; }
.catalog-page .search-actions { display: flex; gap: 8px; min-width: 0; }
.catalog-page .search-submit, .catalog-page .search-ai {
  display: inline-flex;
  flex: 1 1 0;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 8px;
  border: 1.5px solid transparent;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}
.catalog-page .search-submit svg, .catalog-page .search-ai svg { width: 20px; height: 20px; }
.catalog-page .search-ai {
  border: 1.5px solid var(--accent);
  background: var(--surface);
  color: var(--accent);
}
.catalog-page .search-ai:disabled { opacity: .45; cursor: default; }
.catalog-page .search-ai[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.catalog-page .ai-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px;
  border-radius: 14px;
  background: var(--orange-bg);
  color: var(--orange-text);
  font-size: 14px;
}
.catalog-page .ai-banner svg { flex: none; width: 20px; height: 20px; }
.catalog-page .ai-banner span { min-width: 0; }
.catalog-page .ai-without { border: 1.5px solid var(--link); color: var(--link); background: transparent; }
.catalog-page .search .input {
  min-height: 44px;
  height: 44px;
  padding: 10px 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: 16px;
}
.catalog-page .search .input::placeholder { color: var(--muted); opacity: 1; }
.catalog-page #scanBtn {
  height: 56px;
  min-height: 56px;
  margin: 0;
  padding: 12px;
  gap: 10px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 16px;
  font-weight: 800;
}
.home-brand svg { width: 24px; height: 24px; }
.catalog-page #scanBtn svg { width: 24px; height: 24px; }
.catalog-page .draft-home { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
.catalog-page .draft-home-btn,
.catalog-page .draft-home-btn:nth-child(3):last-child {
  grid-column: auto;
  flex-direction: column;
  min-width: 0;
  min-height: 72px;
  padding: 10px 4px;
  gap: 6px;
  box-shadow: none;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.catalog-page .draft-home-btn svg { width: 24px; height: 24px; color: var(--accent); stroke: currentColor; }
.catalog-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.catalog-heading > :first-child { font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.catalog-page .list { gap: 8px; }
.catalog-product {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 76px;
  padding: 12px 14px 12px 16px;
  border-color: var(--card-line);
  box-shadow: none;
}
.catalog-product-text { flex: 1; min-width: 0; }
.catalog-product .row-name { font-size: 15px; font-weight: 700; line-height: 1.3; }
.catalog-product .row-sub { display: block; margin-top: 4px; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.catalog-product .row-qty {
  flex: none;
  max-width: 48%;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
}
.catalog-product .row-qty.pos { background: var(--ok-bg); color: var(--ok-text); }
.catalog-product .row-qty.none { background: var(--neutral-bg); color: var(--neutral-text); }
.catalog-product .row-qty.neg { background: var(--bad-bg); color: var(--bad); }
.catalog-product .product-chevron { width: 16px; height: 16px; color: var(--muted); }
.catalog-page .more {
  min-height: 48px;
  margin: 0;
  padding: 8px 12px;
  border: 1.5px solid var(--link);
  border-radius: 14px;
  background: transparent;
  color: var(--link);
  font-size: 15px;
  font-weight: 700;
}
.catalog-page .hint, .catalog-page .note, .catalog-page .note-warn, .catalog-page .error, .catalog-page .footer { margin: 0; }
.catalog-page .hint, .catalog-page .footer { font-size: 14px; }
.home-page .search-home-hint { font-size: 13px; font-weight: 600; color: var(--muted); }
.catalog-page .more-count { margin-top: 8px; text-align: center; font-size: 12px; }
.catalog-page .footer button { min-height: 44px; color: var(--link); }
.redesigned-page a:focus-visible, .redesigned-page button:focus-visible, .redesigned-page summary:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }
.catalog-page .search-submit:active { filter: brightness(.92); }
.catalog-page #scanBtn:active { filter: brightness(.92); }
.catalog-page #resultMore:empty { display: none; }

/* Общие элементы переработанных экранов. */
.redesigned-page .card, .redesigned-page .row, .redesigned-page .big-btn {
  border-color: var(--card-line);
  box-shadow: none;
}
.redesigned-page:not(.home-page) .bar {
  max-width: 480px;
  margin: 0 auto;
  min-height: 60px;
  padding: env(safe-area-inset-top) calc(16px + env(safe-area-inset-right)) 0 calc(16px + env(safe-area-inset-left));
  gap: 8px;
  border: 0;
  background: var(--bg);
}
.redesigned-page .bar-back {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  justify-content: center;
  color: var(--text);
}
.redesigned-page .bar-back span { display: none; }
.redesigned-page .bar-back svg { width: 24px; height: 24px; }
.redesigned-page .bar-title { padding: 0; font-size: 20px; font-weight: 800; }
.redesigned-page .btn:not(.btn-primary) {
  min-height: 52px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}
.redesigned-page .tag { background: var(--orange-bg); color: var(--orange-text); }
.redesigned-page .warning-icon { width: 20px; height: 20px; vertical-align: middle; margin-right: 6px; }

/* Карточка товара: оформление, без изменений действий и данных. */
.product-page main { padding-top: 16px; }
.product-page .product-head { gap: 8px; margin: 0; }
.product-page .product-head .product-name { margin: 0; font-size: 22px; font-weight: 800; line-height: 1.25; }
.product-page .copy { width: 44px; height: 44px; }
.product-page .product-head .copy { margin-top: 0; }
.product-page .fields { padding: 0; border-radius: 16px; overflow: hidden; }
.product-page .field { min-height: 72px; padding: 12px 8px 12px 16px; gap: 8px; }
.product-page .field + .field { border-color: var(--card-line); }
.product-page .field-label { font-size: 12px; font-weight: 600; }
.product-page .field-value { font-size: 18px; font-weight: 700; }
.product-page .field-value.empty { color: var(--muted); }
.product-page .stock-field { padding: 16px; }
.product-page .stock-field .field-label { font-size: 13px; }
.product-page .qty-big {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  max-width: 100%;
  margin-top: 8px;
  padding: 4px 18px;
  border-radius: 999px;
  font-size: 32px;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.product-page .qty-big.pos { background: var(--ok-bg); color: var(--ok-text); }
.product-page .qty-big.none { background: var(--neutral-bg); color: var(--neutral-text); }
.product-page .qty-big.neg { background: var(--bad-bg); color: var(--bad); }
.product-page .qty-big .warning-icon { width: 24px; height: 24px; }
.product-page .note-warn { margin: 0; }
.product-page .share-btn {
  min-height: 56px;
  margin: 0;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 800;
}
.product-page .share-btn svg { width: 22px; height: 22px; }
.product-page .product-web { text-align: center; min-width: 0; }
.product-page .web-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  max-width: 100%;
  gap: 6px;
  color: var(--link);
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
}
.product-page .web-btn svg { width: 16px; height: 16px; }
.product-page .web-by { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.product-page .actions { margin: 0; gap: 12px; }
.product-page .big-btn { min-height: 60px; padding: 12px 16px; gap: 8px; font-size: 16px; font-weight: 700; }
.product-page .action-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.product-page .product-chevron { width: 16px; height: 16px; color: var(--muted); }
.product-page .count {
  flex: none;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--orange-bg);
  color: var(--orange-text);
  font-size: 15px;
  font-weight: 800;
}
.product-page .res-block { margin: 0; border-radius: 16px; }
.product-page .res-block > summary { min-height: 60px; font-size: 16px; font-weight: 700; gap: 8px; }
.product-page .res-block > summary::after { display: none; }
.product-page .res-block > summary > .product-chevron { transform: rotate(90deg); }
.product-page .res-block[open] > summary > .product-chevron { transform: rotate(-90deg); }
.product-page .res-title { min-width: 0; overflow-wrap: anywhere; }
.product-page .res-block .count { color: var(--orange-text); }
.product-page .res-body, .product-page .res-item { border-color: var(--card-line); }
.product-page .res-meta a { display: inline-flex; min-height: 44px; align-items: center; color: var(--link); }
.product-page .res-history > summary { min-height: 44px; color: var(--link); }
.product-page .scan-again { margin: 0; min-height: 52px; }

/* Документы по товару, ячейки и другие склады: только оформление. */
.product-details-page main { padding-top: 16px; }
.product-details-page .bar-title {
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
  line-height: 1.3;
}
.product-details-page .detail-product-name {
  margin: 0;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.product-details-page .section-title {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .06em;
  overflow-wrap: anywhere;
}
.product-details-page .list { gap: 8px; }
.product-details-page .detail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 60px;
  padding: 0 16px;
  border: 1px solid var(--card-line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
}
.product-details-page .place-row { cursor: default; }
.product-details-page .row-body { flex: 1; min-width: 0; padding: 10px 0; overflow-wrap: anywhere; }
.product-details-page .row-name { font-size: 16px; font-weight: 700; }
.product-details-page .doc-type-row, .product-details-page .document-row { min-height: 64px; }
.product-details-page .doc-icon-tile {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--orange-bg);
  color: var(--accent);
}
.product-details-page .doc-type-icon { width: 22px; height: 22px; }
.product-details-page .product-chevron { width: 18px; height: 18px; color: var(--muted); }
.product-details-page .count {
  flex: none;
  min-width: 0;
  max-width: 28%;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--orange-bg);
  color: var(--orange-text);
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  overflow-wrap: anywhere;
}
.product-details-page .doc-type-row[aria-disabled="true"] .row-name { color: var(--muted); }
.product-details-page .doc-date {
  display: flex;
  flex-wrap: wrap;
  gap: 0 8px;
  font-size: 15px;
  font-weight: 700;
}
.product-details-page .doc-date > span { min-width: 0; overflow-wrap: anywhere; }
.product-details-page .row-caption { margin-top: 4px; color: var(--muted); font-size: 13px; font-weight: 600; }
.product-details-page .doc-status { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.product-details-page .tag { max-width: 100%; font-size: 13px; overflow-wrap: anywhere; }
.product-details-page .stock-badge {
  flex: none;
  min-width: 0;
  max-width: 45%;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  overflow-wrap: anywhere;
}
.product-details-page .document-row .stock-badge { font-size: 15px; }
.product-details-page .stock-badge.pos { background: var(--ok-bg); color: var(--ok-text); }
.product-details-page .stock-badge.none { background: var(--neutral-bg); color: var(--neutral-text); }
.product-details-page .stock-badge.neg { background: var(--bad-bg); color: var(--bad); }
.product-details-page .note, .product-details-page .note-warn, .product-details-page .error { margin: 0; overflow-wrap: anywhere; }
.product-details-page .note-warn { background: var(--orange-bg); color: var(--orange-text); font-size: 14px; font-weight: 600; }
.product-details-page .more { margin: 0; font-size: 15px; font-weight: 700; }
