/* === Дизайн «Итог» (Р2, решение Дмитрия 28.11.2026): цвета, размеры, кнопки — через эти переменные === */
:root {
  --bg: #f2f4f7; --card: #fff; --text: #1f2933; --muted: #667085; --border: #d6dbe1;
  --accent: #2f4858; --accent-h: #243a47; --accent-text: #fff;          /* меню и главная кнопка */
  --post: #1f7a3d; --post-h: #17602f;                                   /* «Провести», «Оплатить», «Принять» */
  --danger: #b42318; --danger-bg: #fef3f2;                              /* опасное */
  --ok: #1f7a3d; --ok-bg: #e7f5ec; --error: #b42318; --error-bg: #fef3f2;
  --warn: #8a5a00; --warn-bg: #fff6dd; --info: #1d4f80; --info-bg: #e8f1fb;
  --focus: rgba(47, 72, 88, .25);
  --r: 8px; --h: 44px; --fs: 16px; --h1: 24px; --th: 13px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
@media (max-width: 700px) { :root { --h: 48px; --fs: 17px; } }   /* телефон — крупнее */
* { box-sizing: border-box; }
body { margin: 0; font: var(--fs)/1.5 var(--font); background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
a { color: var(--accent); }
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 16px; padding: 10px 16px; background: var(--accent); color: var(--accent-text); }
.topbar a, .topbar .link { color: var(--accent-text); text-decoration: none; }
.brand { font-weight: 700; font-size: 18px; }
.menu { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.inline { display: inline; margin: 0; }
.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.page { max-width: 960px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: calc(var(--r) + 4px); padding: 20px 22px;
  box-shadow: var(--shadow); }
.narrow { max-width: 420px; margin: 24px auto; }
h1 { font-size: var(--h1); margin: 0 0 16px; font-weight: 700; }
label { display: block; margin-bottom: 12px; font-weight: 600; }

/* --- Поля: 44 px (телефон 48), скругление 8, мягкая обводка фокуса --- */
input[type=text], input[type=password], input[type=search], input[type=email], input[type=tel],
input[type=number]:not(.num), input[type=date], select {
  display: block; width: 100%; margin-top: 4px; min-height: var(--h); padding: 0 12px; font: inherit;
  border: 1px solid var(--border); border-radius: var(--r); background: var(--card); color: var(--text); }
textarea { display: block; width: 100%; padding: 10px 12px; font: inherit; border: 1px solid var(--border);
  border-radius: var(--r); background: var(--card); color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
input[type=file] { display: block; width: 100%; margin-top: 4px; }

/* --- Кнопки: 4 вида (Р2) ---
   главная  — заливка (одна на экране): button[type=submit] по умолчанию, a.button, .btn-pri
   итоговая — зелёная: «Провести / Оплатить / Принять» — .btn-post (и кнопки name="do" value="post")
   обычная  — белая с рамкой: .secondary, .secondary-submit, .button-light, .btn-sec
   опасная  — красный текст (в окне подтверждения — заливка): .btn-dan, .btn-dan.fill
   тихая    — ссылка-кнопка: .btn-ghost, .link-dark                                              */
button[type=submit]:not(.link):not(.link-dark):not(.icon-btn):not(.secondary-submit):not(.btn-sec):not(.btn-dan):not(.btn-ghost):not(.more-item):not(.button-light):not(.secondary):not(.tile):not(.sheet-exit),
a.button, .btn, .secondary, .secondary-submit, .button-light {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--h); padding: 0 18px;
  font: inherit; font-weight: 600; line-height: 1.2; border: 1px solid transparent; border-radius: var(--r);
  background: var(--accent); color: var(--accent-text); cursor: pointer; text-decoration: none; text-align: center;
  transition: background .12s, border-color .12s; }
button[type=submit]:not(.link):not(.link-dark):not(.icon-btn):not(.secondary-submit):not(.btn-sec):not(.btn-dan):not(.btn-ghost):not(.more-item):not(.button-light):not(.secondary):not(.tile):not(.sheet-exit):hover,
a.button:hover, .btn-pri:hover { background: var(--accent-h); }
.btn:focus-visible, button:focus-visible, a.button:focus-visible, .button-light:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 1px; }
.btn-post, button[name=do][value=post]:not(.link-dark), .button-post { background: var(--post) !important; color: #fff !important; }
.btn-post:hover, button[name=do][value=post]:not(.link-dark):hover, .button-post:hover { background: var(--post-h) !important; }
.btn-sec, .secondary, .secondary-submit, .button-light {
  background: var(--card); color: var(--text); border-color: var(--border); font-weight: 500; }
.btn-sec:hover, .secondary:hover, .secondary-submit:hover, .button-light:hover { background: var(--bg); border-color: var(--muted); }
.btn-dan { background: var(--card); color: var(--danger); border-color: var(--border); font-weight: 500; }
.btn-dan:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-dan.fill { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-dan.fill:hover { background: #912018; }
.btn-ghost { background: none; border: 0; color: var(--accent); padding: 0 8px; font-weight: 500; }
.btn-ghost:hover { background: var(--bg); }
button:disabled, .btn:disabled { opacity: .5; cursor: default; }
.link-dark.danger, .danger-link { color: var(--danger); }

/* --- Сообщения: 4 цвета со значком (Р2/Р3) --- */
.flash { display: block; position: relative; padding: 11px 14px 11px 36px; border-radius: var(--r);
  margin-bottom: 12px; border: 1px solid transparent; }
.flash::before { position: absolute; left: 14px; top: 11px; font-weight: 700; }
.flash-error { background: var(--error-bg); color: var(--error); border-color: rgba(180, 35, 24, .25); }
.flash-error::before { content: "!"; }
.flash-info { background: var(--info-bg); color: var(--info); border-color: rgba(29, 79, 128, .2); }
.flash-info::before { content: "ℹ"; }
.flash-ok, .flash-success { background: var(--ok-bg); color: var(--ok); border-color: rgba(31, 122, 61, .25); }
.flash-ok::before, .flash-success::before { content: "✓"; }
.flash-warning { background: var(--warn-bg); color: var(--warn); border-color: rgba(138, 90, 0, .25); }
.flash-warning::before { content: "!"; }
.error { display: block; color: var(--error); font-weight: 400; font-size: 14px; }
.muted { color: var(--muted); font-weight: 400; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.pager { display: flex; gap: 16px; }
.head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.head-row h1 { margin: 0; }
.tabs { margin: 12px 0; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px 4px; margin: 0 0 16px; }
legend { font-weight: 700; padding: 0 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }
.with-button { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.with-button label { flex: 1 1 220px; }
.with-button button { margin-bottom: 12px; }
.link-dark { background: none; border: 0; padding: 0; font: inherit; color: var(--accent);
  text-decoration: underline; cursor: pointer; }
.hint { margin: -6px 0 10px; font-size: 14px; color: var(--muted); min-height: 1em; }
.hint.error { color: var(--error); }
label.check { font-weight: 400; display: flex; gap: 8px; align-items: center; }
.badge { font-size: 13px; font-weight: 400; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 2px 8px; vertical-align: middle; }
.logo-preview { max-height: 80px; max-width: 240px; border: 1px solid var(--border); border-radius: 4px; }

/* --- Боковое меню --- */
.with-sidebar { padding-left: 240px; }
.sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 240px; display: flex; flex-direction: column;
  background: var(--accent); color: var(--accent-text); overflow-y: auto; z-index: 20; }
.sidebar .brand { display: block; padding: 16px 20px; font-weight: 700; font-size: 20px;
  color: var(--accent-text); text-decoration: none; }
.sidebar nav { flex: 1; display: flex; flex-direction: column; padding: 4px 0 16px; }
.sidebar nav a, .sidebar-user a { display: block; padding: 8px 20px; color: var(--accent-text);
  text-decoration: none; opacity: .9; }
.sidebar nav a.sub { padding-left: 32px; }
.sidebar nav a:hover, .sidebar-user a:hover { background: rgba(255,255,255,.08); opacity: 1; }
.sidebar nav a.active, .sidebar-user a.active { background: rgba(255,255,255,.16); opacity: 1;
  box-shadow: inset 3px 0 0 #fff; }
.nav-group { margin-top: 14px; padding: 4px 20px; font-size: 12px; text-transform: uppercase;
  letter-spacing: .06em; opacity: .65; }
.sidebar-user { border-top: 1px solid rgba(255,255,255,.15); padding: 12px 0; }
.sidebar-user .who { padding: 0 20px 8px; font-size: 14px; }
.sidebar-user .muted { color: inherit; opacity: .7; }
.sidebar-user .link { color: var(--accent-text); padding: 8px 20px; opacity: .9; }
.mobile-bar { display: none; }
@media (max-width: 860px) {
  .with-sidebar { padding-left: 0; }
  .mobile-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px;
    background: var(--accent); color: var(--accent-text); position: sticky; top: 0; z-index: 10; }
  .mobile-bar .brand { color: var(--accent-text); text-decoration: none; font-weight: 700; }
  .menu-toggle { background: none; border: 0; color: var(--accent-text); font-size: 22px; cursor: pointer; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .menu-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
}
.page { max-width: 1100px; }

/* --- Вкладки карточки --- */
.tab-bar { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 2px solid var(--border); margin: 8px 0 16px; }
.tab-bar a, .tab-bar span { padding: 10px 16px; text-decoration: none; color: var(--accent);
  border-bottom: 3px solid transparent; margin-bottom: -2px; font-weight: 600; }
.tab-bar a.active { border-bottom-color: var(--accent); }
.tab-bar span.disabled { color: var(--muted); cursor: not-allowed; font-weight: 400; }
.form-actions { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
.accounts { list-style: none; padding: 0; margin: 0 0 16px; }
.accounts li { border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; margin-bottom: 10px; }
.accounts .acc-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-weight: 600; }
.accounts .acc-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; }
.badge.main { background: #e3f4e8; border-color: #9fd3ae; color: #1e6b36; }
.settings-group { margin-bottom: 20px; }
.setting { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.setting input { margin-top: 4px; width: 18px; height: 18px; }
.setting .label { font-weight: 600; }

/* --- Обязательные поля --- */
.req { color: #c62828; font-weight: 700; margin-left: 3px; }
.small { font-size: 13px; margin: 0 0 12px; }
.org-type { color: var(--accent); font-weight: 600; }

/* Атрибут hidden должен прятать и блоки с display:block */
[hidden] { display: none !important; }

/* --- Платные функции в настройках --- */
.badge.paid { background: #fff4e0; border-color: #f0c36d; color: #8a5a00; margin-left: 6px; }
.setting.locked { opacity: .75; }
.setting.locked input { cursor: not-allowed; }

/* --- Подписи и печать --- */
.images-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.image-slot { border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.image-title { font-weight: 600; margin-bottom: 8px; }
.image-preview { height: 120px; display: flex; align-items: center; justify-content: center; margin-bottom: 8px;
  border-radius: var(--r); background-color: #fff;
  background-image: linear-gradient(45deg, #eee 25%, transparent 25%), linear-gradient(-45deg, #eee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eee 75%), linear-gradient(-45deg, transparent 75%, #eee 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0; }
.image-preview img { max-height: 110px; max-width: 100%; }

.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }
@media (max-width: 760px) { .grid-3 { grid-template-columns: 1fr; } }

.setting input.num { width: 90px; height: auto; padding: 6px 8px; font: inherit;
  border: 1px solid var(--border); border-radius: var(--r); margin-top: 0; }

/* --- Подразделения --- */
h2.org-group { margin: 20px 0 8px; font-size: 18px; }
.tree-mark { color: var(--muted); margin-right: 4px; }
.small-text { font-size: 13px; }
.chip { display: inline-block; font-size: 12px; padding: 1px 8px; margin: 1px 2px; border-radius: 10px;
  background: var(--info-bg); color: var(--info); white-space: nowrap; }
.row-actions { white-space: nowrap; }
.row-actions a { margin-right: 12px; }

input.locked-input { background: var(--bg); color: var(--muted); cursor: not-allowed; }

/* --- Дерево подразделений (вид 2) --- */
.tree-cell { display: flex; align-items: flex-start; gap: 6px; }
.tree-toggle { background: none; border: 0; cursor: pointer; font-size: 14px; color: var(--muted);
  width: 20px; padding: 2px 0; line-height: 1.4; }
.tree-toggle:hover { color: var(--accent); }
.tree-toggle-space { display: inline-block; width: 20px; }
.tree-name { font-weight: 600; text-decoration: none; color: var(--accent); }
.tree-name:hover { text-decoration: underline; }
.chip-sells { background: #e3f4e8; color: #1e6b36; }
.chip-stores { background: #e8f1fb; color: #1d4f80; }
.chip-produces { background: #fff4e0; color: #8a5a00; }
.chip-office { background: #f0ecf9; color: #5b3e96; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  border-radius: 50%; border: 1px solid var(--border); background: var(--card); color: var(--muted);
  cursor: pointer; text-decoration: none; font-size: 18px; line-height: 1; padding: 0; vertical-align: middle; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn.add { font-weight: 700; color: var(--accent); }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions > * { margin-left: 6px; }
@media (hover: hover) {
  table.tree .row-actions > * { opacity: 0; transition: opacity .15s; }
  table.tree tr:hover .row-actions > *, table.tree .row-actions > *:focus-within,
  table.tree .row-actions > *:focus { opacity: 1; }
}

/* --- Контрагенты --- */
.search-row { display: flex; gap: 8px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.search-row input[type=search] { flex: 1 1 280px; width: auto; margin: 0; padding: 0 12px; font: inherit; border: 1px solid var(--border);
  border-radius: var(--r); }
label.check.locked { opacity: .55; }
fieldset[disabled] input, fieldset[disabled] select, fieldset[disabled] textarea { background: var(--bg); }
h3 { font-size: 16px; margin: 16px 0 8px; }
.tab-panel[hidden] { display: none !important; }
.tab-bar a.has-error { color: var(--error); }
.tab-bar a.has-error::after { content: " •"; }

.consent-actions { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.consent-upload { margin: 12px 0; padding: 12px; border: 1px dashed var(--border); border-radius: 8px; }
.consent-upload input[type=file] { margin: 6px 0; }

/* --- Номенклатура --- */
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.items-layout { display: grid; grid-template-columns: 240px 1fr; gap: 20px; margin-top: 12px; }
@media (max-width: 860px) { .items-layout { grid-template-columns: 1fr; } }
.groups-tree { border-right: 1px solid var(--border); padding-right: 12px; max-height: 70vh; overflow-y: auto; }
.groups-tree a { display: block; padding: 6px 10px; border-radius: var(--r); text-decoration: none; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.groups-tree a:hover { background: var(--bg); }
.groups-tree a.active { background: var(--info-bg); color: var(--info); font-weight: 600; }
.search-row select { padding: 0 12px; font: inherit; border: 1px solid var(--border); border-radius: var(--r); width: auto; display: inline-block; margin: 0; }
td.thumb { width: 52px; }
td.thumb img { width: 44px; height: 44px; object-fit: cover; border-radius: var(--r); border: 1px solid var(--border); }
.inline-add { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin: 12px 0; }
.inline-add label { margin: 0; }
.inline-add input, .inline-add select { padding: 0 12px; min-height: var(--h); font: inherit; border: 1px solid var(--border); border-radius: var(--r); display: block; margin-top: 4px; }
.check-cell { display: flex; align-items: center; padding-top: 22px; }
.mono { font-family: ui-monospace, Consolas, monospace; letter-spacing: .04em; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-top: 16px; }
.photo-slot { border: 1px solid var(--border); border-radius: 8px; padding: 8px; position: relative; }
.photo-slot.main { border-color: #9fd3ae; }
.photo-slot img { width: 100%; height: 150px; object-fit: cover; border-radius: var(--r); display: block; }
.photo-slot .badge { position: absolute; top: 12px; left: 12px; }
.photo-actions { display: flex; gap: 12px; margin-top: 6px; flex-wrap: wrap; font-size: 14px; }
.narrow-wide { max-width: 640px; }

/* --- Архив не на виду; значки; шрифт списков --- */
.archive-link { text-align: right; margin: 10px 0 0; font-size: 14px; }
.archive-link a { color: var(--muted); text-decoration: none; }
.archive-link a:hover { color: var(--accent); text-decoration: underline; }
.archive-banner { background: var(--bg); border: 1px dashed var(--border); border-radius: var(--r); padding: 8px 12px;
  margin: 8px 0 12px; color: var(--muted); }
.group-title { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.icon-btn { font-size: 16px; }
table { font-size: 16px; }
th { font-size: 14px; color: var(--muted); font-weight: 600; }
td { padding-top: 10px; padding-bottom: 10px; }
.small-text { font-size: 14px; }
.chip { font-size: 13px; padding: 2px 9px; }

/* --- Дерево групп номенклатуры --- */
.groups-tree .group-row { display: flex; align-items: center; border-radius: var(--r); }
.groups-tree .group-row:hover { background: var(--bg); }
.groups-tree .group-row.active { background: var(--info-bg); }
.groups-tree .group-row.active .tree-link { color: var(--info); font-weight: 600; }
.groups-tree .tree-link { flex: 1; padding: 6px 6px; }
.groups-tree .tree-link:hover { background: none; }
.group-toggle, .tree-toggle { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 16px;
  width: 22px; padding: 0; line-height: 1; }
.group-toggle:hover, .tree-toggle:hover { color: var(--accent); }
.group-toggle-space { display: inline-block; width: 22px; }
.group-edit { visibility: hidden; text-decoration: none; color: var(--muted); padding: 4px 8px; }
.group-row:hover .group-edit { visibility: visible; }
.group-edit:hover { color: var(--accent); }
@media (hover: none) { .group-edit { visibility: visible; } }

/* Прайс-лист */
.price-table .price-cell { text-align: right; white-space: nowrap; }
.price-input { width: 120px; padding: 6px 8px; font: inherit; text-align: right; border: 1px solid var(--border); border-radius: var(--r); }
.price-input::placeholder { color: #9aa3ad; }
.price-table .variant-row td:first-child { padding-left: 28px; font-size: .95em; }
.bulk-box { margin-top: 16px; border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; background: var(--bg); }
.bulk-title { margin: 0 0 4px; }
.price-table .sel-cell { width: 28px; text-align: center; }
.price-table .var-toggle { margin-right: 4px; }
.var-note { margin-left: 2px; }
.promo-note { color: #b4231b; font-size: .85em; margin-top: 2px; }
.promo-price { color: #b4231b; font-weight: 600; font-size: .9em; margin-top: 3px; }
.old-price { text-decoration: line-through; color: var(--muted, #6b7580); }
.price-table td.up { color: #1e6b36; }
.price-table td.down { color: #b4231b; }
.export-box { border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; margin: 8px 0 16px; background: var(--bg); }
.export-box h2 { margin-top: 0; }
.export-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.export-grid fieldset { border: 1px solid var(--border); border-radius: var(--r); padding: 8px 12px; margin: 0; }
.export-grid label.check { display: block; margin: 4px 0; }
.points-list { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 6px; }
.settings-list { margin-top: 28px; padding-top: 8px; border-top: 1px solid var(--border); }
.remove-toggle { display: inline-flex; align-items: center; gap: 2px; margin-left: 4px; color: #b4231b; cursor: pointer; font-weight: 600; }
.remove-toggle input { margin: 0; }
.price-table td.cell-removed .price-input { text-decoration: line-through; border-color: #d9534f; background: #fdecea; }
.removed-hint { color: #b4231b; }
.nav-more { display: block; width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  color: rgba(255, 255, 255, .6); font: inherit; font-size: .9em; padding: 6px 20px 6px 32px; }
.sidebar nav a[hidden] { display: none; }
.nav-more:hover { color: #fff; }
.new-rights { border: 2px solid #e0a800; background: #fff8d6; border-radius: 8px; padding: 10px 14px; margin: 10px 0; }
.new-rights ul { margin: 4px 0 6px 20px; }
.new-mark { color: #8a5a00; background: #fff4e0; border-radius: 10px; padding: 0 6px; font-size: .8em; white-space: nowrap; }
.nav-group-toggle { cursor: pointer; user-select: none; display: flex; justify-content: space-between; }
.nav-group-toggle::after { content: "▾"; opacity: .6; }
.nav-group-toggle.closed::after { content: "▸"; }
.nav-group-toggle:hover { color: #fff; }
.nav-section[hidden] { display: none; }
.perm-modules { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 12px; }
.perm-module { border: 1px solid var(--border); border-radius: 8px; padding: 0 14px; }
.perm-module > summary { cursor: pointer; padding: 10px 0; list-style: none; }
.perm-module > summary::-webkit-details-marker { display: none; }
.perm-module > summary::before { content: "⊞ "; color: var(--info); }
.perm-module[open] > summary::before { content: "⊟ "; }
.perm-module[open] > summary { border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.perm-module .right-row { grid-template-columns: 18px 1fr auto auto; }
.perm-module .perm-row { padding: 3px 0; }
.price-table td.neg { color: #b4231b; }
.qty-input { width: 100px; }
.report-filters { margin-bottom: 8px; }
.filter-line { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin: 4px 0 8px; }
.small-btn { font-size: .55em; vertical-align: middle; padding: 4px 10px; margin-left: 8px; }
.filters-box { border: 1px solid var(--border); border-radius: 8px; padding: 0 12px; margin: 6px 0 12px; }
.filters-box > summary { cursor: pointer; padding: 8px 0; color: var(--info); }
.filters-grid { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; padding-bottom: 10px; }
.filters-grid label { margin: 0; }
.filters-grid select, .filters-grid input { display: block; width: auto; margin-top: 4px; padding: 0 12px; min-height: var(--h); font: inherit; border: 1px solid var(--border); border-radius: var(--r); }
.filters-actions { display: flex; gap: 12px; align-items: center; }
.pick-chip { display: inline-flex; gap: 6px; align-items: center; background: var(--info-bg); color: var(--info);
  border-radius: 12px; padding: 2px 10px; font-size: .9em; }
.pick-chip a { text-decoration: none; color: inherit; font-weight: 700; }
option.create-option { color: #1e7b34; font-weight: 700; }
.default-submit { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.doc-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 14px 0 6px; }
.cell-hint { font-size: .78em; color: var(--muted, #6b7580); margin-top: 2px; white-space: nowrap; }
.price-table td.cell-changed .price-input, .price-table td.cell-changed b { background: #fff8d6; }
.price-table td.cell-low .price-input, .price-table td.cell-low b { border-color: #d9534f; color: #b4231b; }
.manual-mark { color: var(--info); margin-left: 3px; }
.rule-edit summary { list-style: none; display: inline-block; }
.rule-edit summary::-webkit-details-marker { display: none; }
.rule-edit[open] form { margin-top: 6px; }
.mech-option { display: flex; gap: 10px; align-items: flex-start; margin: 6px 0; }
.mech-option input { margin-top: 4px; }
.promo-block { margin-top: 22px; padding-top: 6px; border-top: 1px solid var(--border); }
.promo-search input { width: 100%; padding: 0 12px; font: inherit; border: 1px solid var(--border); border-radius: var(--r); }
.live-results .found-table { width: 100%; margin: 6px 0 10px; border: 1px solid var(--border); border-radius: var(--r); background: var(--bg); }
.promo-price-inline { color: #b4231b; }
.search-with-button { display: flex; gap: 8px; }
.search-with-button input { flex: 1; }
.picker-dialog { width: min(1100px, 96vw); max-height: 90vh; padding: 0; border: 1px solid var(--border); border-radius: 10px; display: none; flex-direction: column; }
.picker-dialog[open] { display: flex; }
.picker-dialog::backdrop { background: rgba(20, 30, 40, .45); }
.picker-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.picker-head h2 { margin: 0; }
.picker-search { display: flex; gap: 8px; flex: 1; max-width: 520px; }
.picker-search input { flex: 1; margin: 0; padding: 0 12px; min-height: var(--h); font: inherit; border: 1px solid var(--border); border-radius: var(--r); }
.picker-body { overflow: auto; padding: 12px 16px; flex: 1; min-height: 300px; }
.picker-layout { display: grid; grid-template-columns: 230px 1fr; gap: 16px; }
.picker-tree { max-height: none; }
.picker-foot { display: flex; gap: 12px; align-items: center; justify-content: flex-end; padding: 10px 16px; border-top: 1px solid var(--border); }
.picker-foot #picker-count { margin-right: auto; }
@media (max-width: 700px) { .picker-dialog { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; } .picker-layout { grid-template-columns: 1fr; } .picker-tree { border-right: none; border-bottom: 1px solid var(--border); max-height: 30vh; } }
.temp-password { border: 2px solid #e0a800; background: #fff8d6; border-radius: 8px; padding: 10px 14px; margin: 10px 0; }
.temp-password .big { font-size: 1.4em; letter-spacing: 2px; }
.user-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 14px; }
.perm-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.perm-row { display: block; margin: 4px 0; }
.right-row { display: grid; grid-template-columns: 18px 1fr auto auto; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.right-row select { padding: 4px 6px; font: inherit; border: 1px solid var(--border); border-radius: var(--r); }
.right-on .right-mark { color: #1e6b36; font-weight: 700; }
.right-off { color: var(--muted, #6b7580); }
.right-row .star { color: #e0a800; }
.right-row .until input { padding: 3px 5px; font: inherit; }
.support-list { list-style: none; padding: 0; font-size: 1.1em; }
.support-list li { margin: 10px 0; }
.small-dialog { width: min(480px, 94vw); border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px; }
.small-dialog::backdrop { background: rgba(20, 30, 40, .45); }
.small-dialog h2 { margin-top: 0; }
.debt-sum { float: right; font-size: .9em; }
.debt-total { text-align: right; margin-top: 10px; }
@media (max-width: 700px) { .debt-sum { float: none; display: block; } }

/* Деньги */
.plus-new { color: #1b7f3b; font-weight: 700; }
.pay-info { margin: .6rem 0; padding: .5rem .75rem; border-left: 3px solid #c9d6e3; background: rgba(0,0,0,.02); }
.create-menu select { max-width: 16rem; }

/* Закупка выше розницы (предупреждение) */
.warn-row td { background: #fff7e6; }
.warn-text { color: #9a5b00; }

/* ================= Дизайн, этап 1: стиль, кнопки, окна (Р2, Р3) ================= */
td input[type=text], td input[type=number], td select, .price-input, .qty-input { min-height: calc(var(--h) - 6px); }
.price-input { padding: 0 8px; }
th { font-size: var(--th); color: var(--muted); font-weight: 600; background: var(--bg); }
td { vertical-align: middle; }
.badge { border-radius: 20px; }

/* Статусы — плашки с точкой: черновик (жёлтая), на проверке (синяя), проведён (зелёная), в архиве (серая) */
.st { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; padding: 2px 10px;
  border-radius: 20px; white-space: nowrap; vertical-align: middle; text-decoration: none; }
.st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-draft { background: var(--warn-bg); color: var(--warn); }
.st-check { background: var(--info-bg); color: var(--info); }
.st-ok { background: var(--ok-bg); color: var(--ok); }
.st-off { background: #eef0f3; color: var(--muted); }
h1 .st { font-size: 14px; }

/* Круглые значки ✎ ＋ 🗄 — 34 px */
.icon-btn { width: 34px; height: 34px; }

/* Всплывашки: «✓ Сохранено» (3 с), «Убрано … Вернуть» (5 с). ПК — сверху справа, телефон — снизу. */
.toasts { position: fixed; top: 16px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 8px;
  align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: center; max-width: 420px; padding: 10px 16px;
  border-radius: var(--r); background: #1f2933; color: #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  animation: toast-in .18s ease-out; }
.toast b { color: #7ee2a0; }
.toast .toast-undo { background: none; border: 0; color: #9cc8ff; font-weight: 700; cursor: pointer; padding: 4px 6px; min-height: 0; }
.toast .toast-undo:hover { background: rgba(255, 255, 255, .1); }
.toast.hide { opacity: 0; transition: opacity .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Свои окна (вместо confirm() браузера) */
dialog.dlg { width: min(460px, 94vw); padding: 0; border: 0; border-radius: calc(var(--r) + 6px); background: var(--card);
  color: var(--text); box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
dialog.dlg::backdrop { background: rgba(16, 24, 40, .5); }
.dlg-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 16px 20px 6px; }
.dlg-h h2 { margin: 0; font-size: 19px; display: flex; gap: 10px; align-items: center; }
.dlg-x { flex: none; background: none; border: 0; font-size: 20px; color: var(--muted); cursor: pointer; width: 36px;
  height: 36px; border-radius: 50%; }
.dlg-x:hover { background: var(--bg); }
.dlg-b { padding: 6px 20px 8px; }
.dlg-b p { margin: 6px 0; }
.dlg-f { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; padding: 14px 20px 18px; }
.dlg-ico { width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; flex: none; }
.dlg-ico.dan { background: var(--danger-bg); color: var(--danger); }
.dlg-ico.warn { background: var(--warn-bg); color: var(--warn); font-weight: 700; }

/* Окна создания («＋ Новый …») и прочие <dialog> программы — тот же вид */
.small-dialog { border: 0; border-radius: calc(var(--r) + 6px); box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.small-dialog::backdrop, .picker-dialog::backdrop { background: rgba(16, 24, 40, .5); }

/* Долгое действие: «⟳ Проводим…» */
.spin { width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%;
  display: inline-block; animation: spin .8s linear infinite; }
.btn-sec .spin, .secondary-submit .spin { border-color: rgba(0, 0, 0, .2); border-top-color: var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 700px) {
  /* Телефон: окна выезжают снизу на всю ширину, кнопки одна под другой */
  dialog.dlg, .small-dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 16px 16px 0 0;
    animation: sheet-in .2s ease-out; }
  .dlg-f { flex-direction: column-reverse; }
  .dlg-f .btn { width: 100%; }
  .toasts { top: auto; bottom: 16px; left: 10px; right: 10px; align-items: stretch; }
  .toast { max-width: none; }
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Окна создания («＋ Новый …»): ✕ в заголовке, внизу справа «Отмена» и «Создать и выбрать» (Р1.16) */
.small-dialog { padding: 16px 20px 18px; position: relative; }
.small-dialog > h2 { margin: 0 40px 12px 0; font-size: 19px; }
.small-dialog .form-actions { flex-direction: row-reverse; justify-content: flex-start; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.small-dialog .dlg-x { position: absolute; top: 12px; right: 12px; }
@media (max-width: 700px) {
  .small-dialog .form-actions { flex-direction: column; }
  .small-dialog .form-actions > * { width: 100%; }
}
button[type=button]:not([class]) { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--h); padding: 0 18px; font-weight: 500; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--card); color: var(--text); cursor: pointer; }
button[type=button]:not([class]):hover { background: var(--bg); border-color: var(--muted); }
.small-text.button-light { font-size: 15px; }
dialog.dlg.wide { width: min(560px, 94vw); }

/* ================= Дизайн, этап 2: документы и карточки (Р1.9–Р1.13) ================= */
/* Путь над заголовком вместо «← назад» */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; font-size: 14px; color: var(--muted);
  margin: 0 0 6px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs .sep { opacity: .6; }
/* Шапка: заголовок и статус слева, «⋯ Ещё» справа */
.doc-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.doc-head h1 { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 0; }
.doc-head-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
/* «⋯ Ещё» — меню редких действий */
.more-menu { position: relative; }
.more-menu > summary { list-style: none; user-select: none; }
.more-menu > summary::-webkit-details-marker { display: none; }
.more-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 260px; padding: 6px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r); box-shadow: 0 10px 28px rgba(0, 0, 0, .15); }
.more-list form { display: block; margin: 0; }
.more-list hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.more-item, .more-list button.more-item { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px;
  padding: 8px 12px; border: 0; border-radius: calc(var(--r) - 2px); background: none; color: var(--text); font: inherit;
  font-weight: 400; text-align: left; text-decoration: none; cursor: pointer; }
.more-item:hover, .more-list button.more-item:hover { background: var(--bg); }
.more-item.danger, .more-list button.more-item.danger { color: var(--danger); }
.more-item.danger:hover { background: var(--danger-bg); }
/* Нижняя панель кнопок — всегда видна */
.actbar { position: sticky; bottom: 0; z-index: 15; display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin: 18px -22px 0; padding: 12px 22px; background: var(--card); border-top: 1px solid var(--border);
  box-shadow: 0 -4px 14px rgba(0, 0, 0, .05); border-radius: 0 0 calc(var(--r) + 4px) calc(var(--r) + 4px); }
.actbar .sp { flex: 1; }
/* панель — последнее в карточке: прижимаем к нижнему краю карточки; иначе — обычный отступ до того, что ниже */
.card > form:last-child > .actbar:last-child { margin-bottom: -20px; }
.actbar + *, form:has(> .actbar:last-child) + * { margin-top: 16px; }
/* Кнопки работы с позициями — над таблицей */
.tbl-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0 10px; }
.tbl-tools .sp { flex: 1; }
/* Свёрнутая подсказка */
details.tip { margin: 12px 0 0; font-size: 14px; color: var(--muted); }
details.tip > summary { cursor: pointer; color: var(--accent); list-style: none; display: inline-block; }
details.tip > summary::-webkit-details-marker { display: none; }
details.tip .tip-body { margin-top: 6px; }
details.tip p { margin: 4px 0; }
.doc-info { margin: 0 0 12px; }

@media (max-width: 700px) {
  .card { padding: 14px; }
  .actbar { margin: 18px -14px 0; padding: 10px 12px; gap: 8px; }
  .card > form:last-child > .actbar:last-child { margin-bottom: -14px; }
  .actbar .btn-post, .actbar .act-main { order: -1; flex: 1 1 100%; }
  .actbar > button:not(.btn-post):not(.act-main), .actbar > a { flex: 1 1 0; padding: 0 6px; font-size: 15px; }
  .actbar .sp { display: none; }
  .more-menu .lbl { display: none; }
  .more-list { min-width: 240px; }
}
.tool-select { display: inline-block; width: auto; max-width: 240px; margin: 0; }
.bulk-box .inline-add { align-items: flex-end; }
.bulk-box .sp { flex: 1; }
input.price-input { display: inline-block; width: 120px; margin-top: 0; text-align: right; }
input.price-input.qty-input { width: 100px; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
td.row-buttons { white-space: nowrap; text-align: right; }
td.row-buttons form + form { margin-left: 6px; }

/* ================= Дизайн, этап 3: списки (Р1.1–Р1.6) ================= */
.list-search { margin: 14px 0 12px; }
.sbar { display: flex; gap: 8px; align-items: center; }
.sfield { position: relative; flex: 1; min-width: 0; }
.sfield::before { content: "🔍"; position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: 15px;
  opacity: .55; pointer-events: none; }
.sfield input[type=search] { margin: 0; padding-left: 40px; }
.fbtn .cnt { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 700;
  margin-left: 2px; }
.fbtn[aria-expanded="true"] { background: var(--bg); border-color: var(--muted); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.pills:empty { display: none; }
.pill { display: inline-flex; gap: 6px; align-items: center; background: var(--info-bg); color: var(--info); border-radius: 20px;
  padding: 3px 5px 3px 12px; font-size: 14px; }
.pill .pill-x { border: 0; background: rgba(0, 0, 0, .07); color: inherit; border-radius: 50%; width: 22px; height: 22px;
  cursor: pointer; line-height: 1; padding: 0; font-size: 12px; }
.pill .pill-x:hover { background: rgba(0, 0, 0, .15); }
.pills .pill-reset { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: 14px;
  text-decoration: underline; padding: 3px 6px; }
.fpanel { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r); background: var(--bg); }
.fgrid { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.fgrid > label { margin: 0; min-width: 160px; flex: 0 1 220px; }
.fgrid > label.check { min-width: 0; flex: 0 0 auto; align-self: center; }
.fgrid select, .fgrid input:not([type=checkbox]) { width: 100%; }
.fgrid .pick-line { flex: 1 1 100%; }
.fpanel-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.found { font-size: 14px; color: var(--muted); margin: 0 0 8px; }
/* Строка таблицы нажимается целиком */
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: #f6f8fa; }
/* Шапка списка: заголовок и одна главная кнопка «＋ …» */
.head-row { margin-bottom: 4px; }
.head-row .head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.head-row .head-actions form { margin: 0; }
/* Дерево групп: «＋» в заголовке */
.tree-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.tree-head b { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
@media (max-width: 700px) {
  .fbtn .lbl { display: none; }
  .fgrid > label { flex: 1 1 100%; }
}
.groups-tree .tree-head a.icon-btn { display: inline-flex; padding: 0; overflow: visible; flex: none; }
.groups-tree .tree-head a.icon-btn:hover { background: var(--card); }
.pill a.pill-x { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.local-hidden { display: none !important; }
.items-layout > * { min-width: 0; }   /* колонка не растягивается под широкую таблицу (замечание 5) */

/* ================= Дизайн, этап 4: телефон (Р4/Р1) ================= */
.bnav, .grpbtn { display: none; }
@media (max-width: 860px) {
  /* Верхняя полоса: без «☰» (разделы — внизу); в документе — «‹ назад» по пути */
  .mobile-bar .menu-toggle { display: none; }
  .mobile-bar.with-back .brand { display: none; }
  .mb-back { color: #fff; text-decoration: none; font-weight: 600; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; max-width: 100%; }
  /* Нижняя панель разделов */
  .bnav { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--card); border-top: 1px solid var(--border); box-shadow: 0 -2px 10px rgba(0, 0, 0, .06);
    padding-bottom: env(safe-area-inset-bottom, 0); }
  .bnav-item { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 2px 9px; min-height: 56px;
    background: none; border: 0; font: inherit; font-size: 12px; color: var(--muted); text-decoration: none; cursor: pointer; }
  .bnav-item b { font-size: 21px; font-weight: 400; line-height: 1.2; }
  .bnav-item.on { color: var(--accent); font-weight: 700; }
  body.has-bnav .page { padding-bottom: 80px; }
  body.has-bnav .toasts { bottom: 76px; }
  /* В документе панель разделов прячется — внизу кнопки документа */
  body.on-doc .bnav { display: none; }
  body.on-doc .page { padding-bottom: 16px; }
  body.on-doc .toasts { bottom: 140px; }
  /* Лист «Ещё»: все разделы плитками */
  dialog.dlg.sheet { max-height: 85vh; }
  .sheet-body { overflow-y: auto; max-height: calc(85vh - 70px); padding-bottom: 18px; }
  .sheet-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 14px 0 6px; }
  .tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .tile { display: flex; align-items: center; min-height: 52px; padding: 8px 12px; border: 1px solid var(--border);
    border-radius: var(--r); background: var(--card); color: var(--text); text-decoration: none; font: inherit; font-weight: 500;
    line-height: 1.25; cursor: pointer; text-align: left; width: 100%; }
  .tile.on { border-color: var(--accent); color: var(--accent); font-weight: 700; background: var(--bg); }
  .tile-form { margin: 0; }
  .tile.tile-exit { color: var(--danger); }
  /* Дерево групп — по кнопке */
  .grpbtn { display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: var(--h);
    padding: 0 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--card); color: var(--text);
    font: inherit; cursor: pointer; margin-bottom: 8px; }
  .items-layout > .groups-tree { display: none; border: 1px solid var(--border); border-right: 1px solid var(--border);
    border-radius: var(--r); padding: 8px; max-height: 50vh; }
  .items-layout > .groups-tree.open { display: block; }
  .items-layout { gap: 0; }
}
@media (max-width: 700px) {
  /* Таблицы — карточками: строка = карточка, у ячейки подпись столбца слева */
  table.phone-cards, table.phone-cards tbody, table.phone-cards tfoot { display: block; width: 100%; }
  table.phone-cards thead { display: none; }
  table.phone-cards tr { display: block; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--border);
    border-radius: var(--r); background: var(--card); }
  table.phone-cards td { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 3px 0;
    border: 0; text-align: right; }
  table.phone-cards td::before { content: attr(data-label); color: var(--muted); font-size: 14px; text-align: left; flex: none;
    max-width: 50%; }
  table.phone-cards td[data-label=""]::before, table.phone-cards td:not([data-label])::before { content: none; }
  table.phone-cards td.pc-title { display: block; text-align: left; font-size: 17px; }
  table.phone-cards td.pc-title::before { content: none; }
  table.phone-cards td.thumb { float: left; width: auto; padding: 0 10px 0 0; }
  table.phone-cards td.thumb::before { content: none; }
  table.phone-cards td.sel-cell { float: right; padding: 0 0 0 8px; width: auto; }
  table.phone-cards td:empty { display: none; }
  table.phone-cards td[colspan] { display: block; text-align: left; }
  table.phone-cards td[colspan]::before { content: none; }
  table.phone-cards tfoot tr { background: var(--bg); }
  table.phone-cards input.price-input { width: 140px; }
  table.phone-cards td:has(select, textarea, input:not([type=checkbox]):not([type=hidden])) { flex-wrap: wrap; }
  table.phone-cards td select { flex: 1 1 100%; min-width: 0; }
  .table-wrap:has(> table.phone-cards) { overflow-x: visible; border: 0; }
  tr.row-link:hover td { background: none; }
}

/* Этап 4б: двухуровневое меню на телефоне (решение Дмитрия 30.11.2026) */
@media (max-width: 860px) {
  button.mb-back { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: #fff; cursor: pointer;
    text-align: left; }
  .sheet .dlg-h { align-items: center; }
  .sheet-back { background: none; border: 0; padding: 6px 8px 6px 0; font: inherit; font-weight: 600; color: var(--accent);
    cursor: pointer; flex: none; }
  .sheet .dlg-h h2 { flex: 1; min-width: 0; }
  .tile.tile-section { min-height: 64px; font-size: 17px; font-weight: 600; }
  .crumb-section { cursor: pointer; text-decoration: underline; text-decoration-style: dotted; }
}
@media (max-width: 860px) {
  .sheet-user { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 16px; padding-top: 10px;
    border-top: 1px solid var(--border); font-size: 14px; color: var(--muted); }
  .sheet-who { flex: 1 1 auto; min-width: 0; }
  .sheet-link { color: var(--muted); text-decoration: none; }
  .sheet-logout { margin: 0; }
  .sheet-exit { background: none; border: 0; padding: 6px 0; font: inherit; color: var(--danger); cursor: pointer; }
}

/* Не переносить (номер и дата документа в журнале). */
.nowrap { white-space: nowrap; }
