:root {
  --bg: #fafafa;
  --panel: #ffffff;
  --soft: #f7f7f7;
  --line: color-mix(in srgb, var(--accent) 22%, #e1e5e8);
  --line-soft: color-mix(in srgb, var(--accent) 12%, #edf0f2);
  --line-strong: color-mix(in srgb, var(--accent) 35%, #c5cdd3);
  --text: #1b2530;
  --muted: #526170;
  --accent: #7fc7ff;
  --accent-hover: color-mix(in srgb, var(--accent) 88%, black);
  --accent-ink: color-mix(in srgb, var(--accent) 42%, black);
  --accent-on: #142b3d;
  --accent-soft: #f5f5f5;
  --in: var(--accent-ink);
  --in-soft: var(--accent-soft);
  --out: #c22749;
  --out-soft: var(--soft);
  --warn: #ffa756;
  --warn-soft: var(--soft);
  --violet: #6226ef;
  --violet-soft: var(--soft);

  --h: 40px;          /* кнопки, поля, списки, поиск */
  --h-icon: 36px;     /* квадратные кнопки-значки */
  --fs-xs: 12px;      /* подписи капсом, счётчики, статусы */
  --fs-sm: 13px;      /* мета-информация, подсказки, подписи полей */
  --fs-md: 14px;      /* основной текст, кнопки, поля */
  --fs-lg: 16px;      /* названия карточек, подзаголовки */
  --fs-xl: 20px;      /* заголовки окон, номер позиции */
  --fs-2xl: 28px;     /* заголовок страницы, остаток */
  --gap: 24px;
  --radius: 14px;
  --radius-sm: 8px;
  --radius-md: 12px;

  --shadow: 0 1px 2px rgb(22 34 56 / 5%);
  --shadow-hover: 0 6px 20px rgb(22 34 56 / 9%);
  --shadow-lg: 0 24px 60px rgb(32 34 36 / 22%);
  color-scheme: light;
}


* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: var(--fs-md)/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, h5, h6, th, b, strong, button { font-weight: 400; }
:focus-visible:not(input, textarea, select, button, [role="button"], [contenteditable]) { outline: 2px solid var(--accent); outline-offset: 2px; }
button, [role="button"], summary { -webkit-tap-highlight-color: transparent; }
button:focus, [role="button"]:focus { outline: none; }
:is(input, textarea, select, [contenteditable]):focus { outline: none; }
/* Значки — блочные и по центру своего места, без сдвига по базовой линии текста */
.ic { display: block; width: 18px; height: 18px; flex: none; }
span[data-icon] { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.muted { color: var(--muted); }
.required-mark { color: var(--out); }
.spacer { flex: 1; }

.stale-banner { padding: 12px var(--gap); background: var(--warn-soft); color: var(--text); font-weight: 400; border-bottom: 1px solid var(--line-soft); }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--h); padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--panel);
  cursor: pointer; text-decoration: none; font-size: var(--fs-md); font-weight: 400; line-height: 1; white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-on); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
#itemsView .btn-primary { background: var(--panel); border-color: var(--accent); color: var(--text); }
#itemsView .btn-primary:hover { background: var(--soft); }
:is(#itemForm, #locForm) .btn-primary, :is(#itemForm, #locForm) .btn-primary:hover {
  background: transparent; border-color: var(--accent); color: var(--text);
}
:is(#itemForm, #locForm) .btn-primary:hover { background: var(--soft); }
.btn-danger { background: var(--out); border-color: var(--out); color: #fff; }
.btn-danger:hover { background: var(--out); filter: brightness(1.06); }
.btn-ghost-danger { border-color: transparent; background: none; color: var(--out); }
.btn-ghost-danger:hover { background: var(--out-soft); }
.icon-btn {
  display: inline-grid; place-items: center; width: var(--h-icon); height: var(--h-icon); padding: 0; flex: none;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }

select {
  height: var(--h); padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--panel); font-size: var(--fs-md); font-weight: 400;
}
/* Места хранения — кнопки-«таблетки»: в фильтре над списком и в форме позиции */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: var(--h-icon); padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: calc(var(--h-icon) / 2); background: var(--panel);
  font-size: var(--fs-md); font-weight: 400; line-height: 1; white-space: nowrap; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent-ink); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-on); }
.chip .count { min-width: 0; color: var(--muted); }
.chip.active .count { color: var(--accent-on); }
.chip-add { border-style: dashed; color: var(--accent-ink); }
/* Карандаш на выбранном месте — открывает переименование и удаление */
.chip-edit {
  display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: -8px;
  border-radius: 50%; background: rgb(255 255 255 / 20%);
}
.chip-edit:hover { background: rgb(255 255 255 / 35%); }
.chip-edit .ic { width: 14px; height: 14px; }
.chip-add .ic { width: 16px; height: 16px; }
.loc-bar { margin: calc(-1 * var(--gap) / 2) 0 var(--gap); }
.field .chips .chip { background: var(--bg); }
.field .chips .chip.active { background: var(--accent); }
.seg { display: inline-flex; height: var(--h); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--panel); }
.seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: calc(var(--h) - 2px);
  border: 0; background: none; padding: 0 12px; cursor: pointer; color: var(--muted); font-weight: 400;
}
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.active { background: var(--accent-soft); color: var(--accent-ink); }
/* Значки переключателя вида — тоньше остальных */
.seg .ic { stroke-width: 1.5; }

.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field > span:first-child, .field > label:first-child { font-size: var(--fs-sm); font-weight: 400; color: var(--muted); }
.field small { font-size: var(--fs-xs); color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; height: var(--h); padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--bg); outline: 0; font-size: var(--fs-md); font-weight: 400;
}
.field textarea { height: auto; min-height: 96px; padding: 10px 12px; font-weight: 400; }
textarea { resize: vertical; }
.hint { color: var(--muted); font-size: var(--fs-sm); margin: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---------- Карточки позиций ---------- */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--gap); }
@media (min-width: 1100px) {
  #items.grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
}
.card {
  display: flex; flex-direction: column; overflow: hidden; cursor: pointer;
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: box-shadow .15s, transform .15s;
}
.card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.thumb { position: relative; aspect-ratio: 4 / 3; background: var(--soft); }
.thumb img, .mini img { display: block; width: 100%; height: 100%; object-fit: cover; }
.noimg {
  display: grid; place-items: center; width: 100%; height: 100%;
  color: var(--c); background: var(--soft);
}
.noimg .ic { width: 40px; height: 40px; opacity: .55; }
.noimg.big { align-content: center; justify-items: center; gap: 8px; font-size: var(--fs-sm); font-weight: 400; color: var(--muted); }
.noimg.big .ic { color: var(--c); }
.flag {
  position: absolute; top: 12px; left: 12px; padding: 4px 12px; border-radius: 6px;
  font-size: var(--fs-xs); font-weight: 400;
}
.flag.out { background: var(--out); color: #fff; }
.card-body { display: flex; flex-direction: column; gap: 4px; flex: 1; padding: 16px; }
.card-cat { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); font-weight: 400; color: var(--muted); }
.category-tag { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.category-dot { display: inline-block; flex: 0 0 9px; height: 9px; margin-inline: 2.5px; align-self: center; border-radius: 50%; background: var(--category-color); }
.card-title {
  margin: 0; font-size: var(--fs-lg); font-weight: 400; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: var(--fs-sm); line-height: 18px; color: var(--muted); }
.card-meta span { display: inline-flex; align-items: center; gap: 6px; height: 18px; }
.card-meta .ic { width: 14px; height: 14px; stroke-width: 1.75; }
.card-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 8px; }
.qty { font-size: var(--fs-lg); font-weight: 400; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.qty small { font-size: var(--fs-sm); font-weight: 400; color: var(--muted); }
.card-foot .qty, .inventory-table .item-stock .qty { white-space: normal; overflow-wrap: anywhere; }
#items .qty, #items .qty small { font-size: var(--fs-xs); font-weight: 400; font-variant-numeric: normal; }

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

.panel { padding: var(--gap); background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); }
.table-wrap { overflow: auto; }
#items.table-wrap { background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th, .table td { padding: 12px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { height: 48px; background: var(--panel); font-size: var(--fs-md); font-weight: 400; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--bg); }
.table .num { text-align: right; }
/* Таблица журнала — шапка на сером фоне со скруглением, как Deals Details */
.table-soft th { background: var(--soft); border-bottom: 0; }
.table-soft th:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.table-soft th:last-child { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.table small { font-size: var(--fs-xs); color: var(--muted); }
.mini { width: 48px; height: 72px; overflow: hidden; border-radius: var(--radius-sm); background: var(--soft); }
.mini .noimg .ic { width: 24px; height: 24px; }
.t-name { width: 36%; }
.t-name b { display: block; font-weight: 400; }
.t-name small { display: block; margin-top: 2px; }
.note-cell { max-width: 360px; overflow-wrap: anywhere; }
.empty-row { padding: 40px !important; text-align: center !important; color: var(--muted); }
.pos { color: var(--in); font-weight: 400; }
.neg { color: var(--out); font-weight: 400; }

/* Статусы — мягкие «таблетки» как в Order Lists */
.badge {
  display: inline-flex; align-items: center; justify-content: center; height: 24px; padding: 0 12px; border-radius: 6px; white-space: nowrap;
  font-size: var(--fs-xs); font-weight: 400; background: var(--soft); color: var(--muted);
}
.badge.t-in { background: var(--in-soft); color: var(--in); }
.badge.t-out, .badge.t-delete { background: var(--out-soft); color: var(--out); }
.badge.t-create { background: var(--accent-soft); color: var(--accent-ink); }
.badge.t-adjust { background: var(--warn-soft); color: var(--warn); }
.badge.t-edit { background: var(--violet-soft); color: var(--violet); }

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 56px var(--gap);
  text-align: center; color: var(--muted); background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
}
.empty .ic { width: 48px; height: 48px; color: var(--accent); opacity: .6; }
.empty h3 { margin: 8px 0 0; color: var(--text); font-size: var(--fs-xl); font-weight: 400; }
.empty p { margin: 0 0 8px; }

/* ---------- Окна ---------- */

.dlg {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0;
  border: 0; border-radius: var(--radius); background: var(--panel); color: var(--text); box-shadow: var(--shadow-lg);
}
.dlg-wide { width: min(920px, calc(100vw - 24px)); }
.dlg-narrow { width: min(440px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgb(27 36 49 / 55%); }
.dlg-inner { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.dlg-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 68px;
  padding: 12px 16px 12px var(--gap); border-bottom: 1px solid var(--line-soft);
}
.dlg-head h2 { margin: 0; font-size: var(--fs-xl); font-weight: 400; line-height: 1.3; }
.dlg-head .card-cat { margin-bottom: 2px; }
#viewContent .dlg-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
.item-category-block { margin-bottom: 12px; padding: 8px 12px; background: var(--soft); border-radius: var(--radius-sm); }
.item-category-block .card-cat { white-space: nowrap; }
.item-category-block .category-tag { max-width: none; }
.dlg-body { padding: var(--gap); overflow: auto; }
.dlg-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  padding: 16px var(--gap); border-top: 1px solid var(--line-soft);
}
.dlg-foot .hint { margin-right: auto; }
.item-actions .btn-ghost-danger { border-color: currentColor; }
.confirm-text { margin: 0; font-size: var(--fs-lg); font-weight: 400; }

.form-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); grid-template-areas: "photo fields" "photo description"; align-content: start; align-items: start; gap: var(--gap); }
.form-grid > .fields { grid-area: fields; min-width: 0; }
.form-grid > .photo-field { grid-area: photo; }
:is(#itemForm, #locForm) select, #sort {
  appearance: none;
  padding-inline-end: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23808a85' stroke-width='1.15' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.form-section-label { margin: 0; font-weight: 400; }
.photo-field .form-section-label { margin-bottom: 8px; }
.item-description { grid-area: description; border-top: 1px solid var(--line); padding-top: 10px; }
.item-description summary { display: flex; align-items: center; cursor: pointer; padding: 6px 16px 6px 0; list-style: none; }
.item-description summary::-webkit-details-marker { display: none; }
.item-description summary::after { content: ""; width: 6px; height: 6px; margin-left: auto; border: solid currentColor; border-width: 0 1px 1px 0; transform: rotate(45deg); }
.item-description[open] summary::after { transform: rotate(225deg); }
.item-description summary span { margin-left: 4px; font-size: var(--fs-xs); }
.item-description .field { margin-top: 8px; }
.item-form-actions { flex: none; flex-wrap: wrap; }
:is(#itemFormMessage, #locFormMessage) { width: 100%; color: var(--out); }
.entry-dialog .dlg-head h2:focus { outline: none; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-content: start; }
.span-2 { grid-column: span 2; }
/* Портретная рамка 2:3 — та же пропорция, что у сохраняемого фото (1000×1500), превью в карточках и окне позиции */
.photo-drop {
  position: relative; display: grid; place-items: center; aspect-ratio: 2 / 3; overflow: hidden; cursor: pointer;
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius-md); background: var(--bg);
}
.photo-drop:hover, .photo-drop.drag { border-color: var(--accent); background: var(--accent-soft); }
.photo-drop img {
  position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0;
  user-select: none; -webkit-user-drag: none; pointer-events: none;
}
.photo-drop.has-photo { cursor: grab; touch-action: none; border-style: solid; border-color: var(--line-strong); background: var(--bg); }
.photo-drop.has-photo.grabbing { cursor: grabbing; }
.photo-drop.has-photo.drag { border-color: var(--accent); }
.photo-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px; text-align: center; font-size: var(--fs-sm); font-weight: 400; color: var(--muted); }
.photo-empty .ic { width: 36px; height: 36px; color: var(--accent); }
.photo-actions { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }


.field .prefix-input { width: 100px; font-weight: 400; text-transform: uppercase; letter-spacing: .05em; }
.sku-sm { font-weight: 400; letter-spacing: .02em; }
.field .sku-input { color: var(--muted); font-weight: 400; letter-spacing: .03em; cursor: default; }
/* Блок «Остаток» по высоте равен блоку с QR слева (96px код + 2×12px отступ), содержимое — по центру */
.stat-label { font-size: var(--fs-sm); font-weight: 400; color: var(--muted); }
.view-qty {
  display: flex; flex-direction: column; justify-content: center; gap: 6px; height: 120px; padding: 12px 16px;
  border-radius: var(--radius-md); background: var(--bg);
}
.view-qty .stat-label { line-height: 1; }
.view-qty .big { font-size: var(--fs-2xl); font-weight: 400; line-height: 1.2; font-variant-numeric: tabular-nums; }
.view-qty .big small { font-size: var(--fs-lg); color: var(--muted); font-weight: 400; }
/* Свойства позиции — строками с разделителями; у «Создано» и «Изменено» имя сверху, дата под ним */
.props { margin: 8px 0 0; }
.prop { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 16px; padding: 12px 0; }
.prop + .prop { border-top: 1px solid var(--line); }
.props dt { color: var(--muted); font-weight: 400; }
.props dd { margin: 0; overflow-wrap: anywhere; font-weight: 400; }
.props dd small { display: block; margin-top: 2px; font-size: var(--fs-sm); font-weight: 400; color: var(--muted); }
.desc { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line-soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.section-title { margin: var(--gap) 0 12px; font-size: var(--fs-lg); font-weight: 400; }
.hist { margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: var(--radius-md); }
.hist li {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: var(--fs-sm);
}
.hist li:last-child { border-bottom: 0; }
.hist-note { color: var(--muted); overflow-wrap: anywhere; }
.hist-meta { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }

.swatches { display: flex; flex-wrap: wrap; gap: 12px; }
.swatch { width: 32px; height: 32px; border: 2px solid transparent; border-radius: 50%; cursor: pointer; }
.swatch.active { border-color: var(--text); box-shadow: inset 0 0 0 3px var(--panel); }

/* ---------- Уведомления ---------- */

.toasts {
  inset: auto var(--gap) var(--gap) auto; margin: 0; padding: 0; border: 0; background: none; overflow: visible;
  display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px));
}
.toasts:not(:popover-open) { display: none; }
.toast {
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: #1b2530; color: #fff; font-size: var(--fs-md); font-weight: 400; box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease-out; transition: opacity .3s, transform .3s;
}
.toast.error { background: var(--out); }
.toast.hide { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 520px) {
  .fields { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .hist li { grid-template-columns: auto minmax(0, 1fr); }
  .hist-note, .hist-meta { grid-column: 1 / -1; }
  .dlg-foot { flex-wrap: wrap; }
}


/* ---------- Рабочая область ---------- */

.app { min-height: 100dvh; }
.masthead { position: sticky; top: 0; z-index: 10; background: var(--panel); border-bottom: 1px solid var(--line); }
.mast-inner, main { width: min(100%, 1440px); margin-inline: auto; padding-inline: clamp(16px, 4vw, 52px); }
.mast-inner { min-height: 65px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.workspace-nav { display: flex; align-items: stretch; align-self: stretch; gap: 20px; }
.workspace-nav button { min-height: 44px; padding: 0 4px; background: none; border: 0; border-bottom: 2px solid transparent; font-weight: 400; color: var(--muted); cursor: pointer; }
.workspace-nav button.active { color: var(--text); border-bottom-color: var(--text); }
.session { min-width: 0; margin-left: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 12px; }
#userBtn { min-width: 0; max-width: 100%; flex-shrink: 0; height: auto; min-height: var(--h); padding-block: 10px; white-space: normal; }
#userName { overflow-wrap: anywhere; line-height: 1.3; }
.live { display: flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--muted); font-size: var(--fs-xs); }
.live i { width: 7px; height: 7px; border-radius: 50%; background: #16a34a; }
.live.off i { background: #dc2626; }
main { padding-top: var(--gap); padding-bottom: 48px; }
.workbench { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(400px, 1.45fr); gap: 14px 16px; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-md); }
.inventory-workbench { grid-template-columns: minmax(140px, 1fr) minmax(150px, .45fr) auto; align-items: end; }
.text-action { cursor: pointer; color: var(--text); font-weight: 400; }
.text-action { border: 0; background: none; min-height: 36px; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.results-bar { min-height: 58px; display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding-block: 8px; }
.results-bar p { margin: 0; color: var(--muted); }
.item-pages { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; }
.results-bar .seg { margin-left: auto; height: 34px; }
.seg button { width: auto; padding-inline: 12px; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); }
.table th { background: var(--soft); color: var(--muted); font-size: var(--fs-xs); }
.table td { overflow-wrap: anywhere; }
.table-item { display: flex; align-items: center; gap: 10px; }
.table-item > :last-child { min-width: 0; }
.item-mini { flex: none; width: 40px; height: 40px; overflow: hidden; border-radius: var(--radius-sm); background: var(--soft); }
.item-mini img { display: block; width: 100%; height: 100%; object-fit: cover; }
.inventory-table th.num, .inventory-table td.item-stock, .inventory-table td.item-location { text-align: left; }
.inventory-table .item-stock .qty { font-size: var(--fs-md); font-weight: 400; }
.item-link { display: block; background: none; padding: 3px 0; border: 0; color: var(--text); font-weight: 400; text-align: left; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; cursor: pointer; overflow-wrap: anywhere; }
.item-link:hover { text-decoration-color: currentColor; }
#items .item-link { font-weight: 600; text-decoration: none; cursor: inherit; }
#items [data-open] { cursor: pointer; }
.item-number { display: block; color: var(--muted); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.item-meta { display: flex; align-items: center; gap: 6px; }
.item-meta .ic { display: block; width: 14px; height: 14px; flex: 0 0 14px; align-self: center; stroke-width: 1.4; color: var(--muted); }
.item-meta > span { min-width: 0; overflow-wrap: anywhere; }
.item-card .item-place { color: var(--muted); }
#items .qty, #items .qty small { color: #000; }
#items .item-place { color: var(--muted); }
.item-card { cursor: default; }
.item-card:hover { transform: none; }
.card-foot { justify-content: space-between; flex-wrap: wrap; }
.journal-filters { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); margin-bottom: 16px; }
.journal-wrap { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel); }
.journal-table th:nth-child(n+3):nth-child(-n+5),
.journal-table td:nth-child(n+3):nth-child(-n+5) { text-align: center; }
.journal-table .badge, .hist .badge { background: transparent; border: 1px solid currentColor; }
.item-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.item-media { display: grid; gap: 12px; margin-bottom: 16px; }
.item-media.has-photo { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
.item-summary .view-qty { height: auto; min-height: 120px; overflow-wrap: anywhere; }
.item-summary .view-qty, .item-summary .storage-summary { text-align: left; }
.directory-list { display: grid; gap: 8px; }
.workspace-body { display: grid; grid-template-columns: 196px minmax(0, 1fr); gap: 20px; width: min(100%, 1440px); margin-inline: auto; padding-inline: clamp(16px, 3vw, 40px); }
.workspace-body main { min-width: 0; padding-inline: 0; }
#settingsView { --h-icon: 36px; --gap: 24px; min-width: 0; width: 196px; padding-top: 24px; scroll-margin-top: 70px; font-size: 14px; }
#dataToggle { display: none; }
.directory + .directory { border-top: 1px solid var(--line); padding-top: 6px; }
.directory header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-left: 10px; }
.directory header .icon-btn { flex: none; width: var(--h-icon); justify-items: center; font-size: 22px; line-height: 1; }
.directory h2 { min-width: 0; margin: 0; font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; }
.directory-row { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; border-radius: var(--radius-sm); }
.directory-row:has(.directory-edit) { grid-template-columns: minmax(0,1fr) 32px; }
.directory-row .directory-edit { width: 32px; height: 36px; }
.directory-edit .ic { width: 16px; height: 16px; }
@media (max-width: 600px) {
  .directory-row:has(.directory-edit) { grid-template-columns: minmax(0,1fr) 44px; }
  .directory-row .directory-edit { width: 44px; height: 44px; }
}
.directory-rename { width: 100%; min-width: 0; min-height: 36px; padding: 3px 10px; border: 0; outline: 0; background: transparent; font-size: 16px; }
.directory-link[aria-pressed="true"] { background: var(--accent-soft); border-radius: var(--radius-sm); }
.directory-link:hover { background: var(--soft); border-radius: var(--radius-sm); }
.directory-link { display: flex; align-items: center; gap: 6px; width: 100%; min-width: 0; min-height: 36px; padding: 3px 0 3px 10px; border: 0; background: none; text-align: left; white-space: nowrap; cursor: pointer; touch-action: manipulation; }
#settingsView .directory-link > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#settingsView .category-tag > :last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.directory-row small { flex: none; min-width: var(--h-icon); margin-inline-start: auto; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.directory-empty { margin: 0; padding: 12px 16px; color: var(--muted); }
.directory-entry { cursor: grab; }
.directory-entry.dragging { opacity: .4; }

@media (max-width: 600px) {
  .workspace-body { grid-template-columns: minmax(0, 1fr); gap: 0; }
  #settingsView, #settingsView.is-open { display: none; }
}
.storage-summary { display: grid; align-content: center; gap: 6px; padding: 16px; border-radius: var(--radius-md); background: var(--bg); overflow-wrap: anywhere; }
.item-details { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 12px; }
.item-details summary { cursor: pointer; font-weight: 400; min-height: 36px; }
.item-extras { display: grid; gap: 12px; margin-bottom: 12px; }
.detail-photo { display: block; position: relative; border-radius: var(--radius-md); }
.detail-photo::before { content: ""; display: block; aspect-ratio: 2 / 3; }
.detail-photo img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; background: var(--soft); border-radius: inherit; }
.item-label {
  min-width: 0; display: grid; align-content: center; justify-items: center; gap: 12px;
  padding: 16px; background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius-md);
}
.item-label-heading, .item-label .btn, .item-label .hint { width: 100%; }
.item-label-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 8px; }
.item-label-heading span { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
/* Код наклеенной этикетки — как его прочитал сканер */
.label-code { width: 100%; font-size: var(--fs-xl); font-weight: 800; letter-spacing: .03em; text-align: center; overflow-wrap: anywhere; }
.item-label .btn { height: auto; min-height: 44px; padding: 6px; white-space: normal; text-align: center; line-height: 1.2; }
#viewDialog {
  --line: transparent;
  --line-soft: transparent;
  --line-strong: transparent;
}
#viewDialog .item-label { border: 0; }
#viewDialog .btn:not(.btn-primary):not(.btn-danger):not(.btn-ghost-danger):not([data-close]):not([data-edit]) { background: var(--soft); }
#viewDialog .hist { background: transparent; }
#viewDialog .desc {
  display: grid;
  gap: 6px;
  margin-top: 16px;
  padding: 16px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--bg);
  white-space: normal;
}
#viewDialog .description-text { white-space: pre-wrap; font-size: 15px; font-weight: 400; color: #000; }
#viewDialog .item-details { margin-top: 16px; padding-top: 0; border: 0; }
#viewDialog .item-details::before {
  content: none;
}
#viewDialog .item-details + .item-details { margin-top: 12px; }
#viewDialog .item-details summary {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 48px; padding: 12px; list-style: none;
  background: var(--soft); border-radius: var(--radius-sm);
}
#viewDialog .item-details summary::-webkit-details-marker { display: none; }
#viewDialog .item-details summary::after {
  content: ""; flex: 0 0 7px; width: 7px; height: 7px; margin-right: 8px;
  border: solid var(--muted); border-width: 0 1px 1px 0; transform: rotate(45deg);
}
#viewDialog .item-details[open] summary::after { transform: rotate(225deg); }
#viewDialog .item-details[open] summary { margin-bottom: 8px; }
#viewDialog .item-details summary:hover { background: var(--soft); }
#viewDialog .props { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin: 0; padding: 12px; }
#viewDialog .prop { grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 0; }
#viewDialog .prop, #viewDialog .hist li { position: relative; border: 0; }
#viewDialog .prop + .prop::before, #viewDialog .hist li + li::before {
  content: none;
}
#viewDialog .hist { display: grid; gap: 16px; padding: 12px; border: 0; }
#viewDialog .hist li { padding: 0; }
#viewDialog #history { padding-bottom: 12px; }
.mobile-only { display: none; }


@media (max-width: 900px) {
  :root { --gap: 16px; --h: 44px; --h-icon: 44px; }
  .workbench { grid-template-columns: minmax(0, 1fr); }
  .journal-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .desktop-only { display: none !important; }
  span.mobile-only { display: inline; }
  input, select, textarea, .field input, .field select, .field textarea { font-size: 16px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "fields" "photo" "description"; }
  .form-grid .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .form-grid .span-2 { grid-column: 1 / -1; }
  .photo-field .photo-drop:not(.has-photo) { aspect-ratio: auto; min-height: 104px; }
  .photo-field .photo-drop.has-photo { width: min(100%, 180px); margin-inline: auto; }
  #items.table-wrap, .journal-wrap { background: none; border: 0; }
  .inventory-table, .inventory-table tbody, .journal-table, .journal-table tbody { display: block; }
  .inventory-table thead, .journal-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .inventory-table tbody, .journal-table tbody { display: grid; gap: 8px; }
  .inventory-table tr, .journal-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto); gap: 6px 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel); }
  .inventory-table td, .journal-table td { padding: 0; border: 0; white-space: normal; }
  .inventory-table tr { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 12px; padding: 14px; }
  .inventory-table .t-name { grid-area: 1 / 1 / 2 / -1; width: auto; }
  .inventory-table .item-category {
    display: block;
    grid-area: 2 / 1 / 3 / -1;
    width: 100%;
    min-width: 0;
    color: var(--muted);
    font-size: var(--fs-sm);
  }
  .inventory-table .item-category .category-tag { display: flex; overflow-wrap: normal; word-break: normal; }
  .category-tag { max-width: 100%; }
  .inventory-table .item-location { grid-area: 3 / 1; }
  .inventory-table .item-stock { grid-area: 3 / 2; }
  .inventory-table .item-location, .inventory-table .item-stock { padding-top: 8px; border-top: 1px solid var(--line-soft); }
  .inventory-table .stock-caption { display: block; color: var(--muted); font-size: var(--fs-xs); margin-bottom: 3px; }
  .inventory-table .item-mini { width: 52px; height: 52px; }
  .inventory-table .item-link { font-size: var(--fs-lg); }
  .inventory-table .item-stock .qty { white-space: normal; }
  .journal-table tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .journal-table td:nth-child(2) { grid-row: 1; grid-column: 1 / -1; font-weight: 400; }
  .journal-table td:nth-child(1), .journal-table td:nth-child(7) { color: var(--muted); font-size: var(--fs-xs); }
  .journal-table td[data-label]:not(:empty)::before { display: block; content: attr(data-label); font-size: var(--fs-xs); color: var(--muted); }
  .journal-table .note-cell, .journal-table .empty-row { grid-column: 1 / -1; }
  .journal-table td[data-label]:empty { display: none; }
  .journal-table tr { align-items: center; }
  .journal-table td { display: block; min-width: 0; }
}

@media (max-width: 600px) {
  .item-form-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 8px; }
  .item-form-actions .btn { min-height: 44px; height: auto; padding: 8px; white-space: normal; }
  :is(#itemFormMessage, #locFormMessage) { grid-column: 1 / -1; }
  .item-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .item-actions .btn { min-width: 0; min-height: 44px; height: auto; padding: 8px 4px; white-space: normal; text-align: center; line-height: 1.2; }
  .item-label { gap: 8px; padding: 8px; }
  .item-summary { gap: 6px; }
  .item-summary .view-qty, .item-summary .storage-summary { padding: 8px; }
  .item-summary .stat-label { font-size: 11px; line-height: 1.25; }
  .item-summary .view-qty .big { font-size: 18px; }
  .mast-inner { min-height: 56px; gap: 8px; flex-wrap: wrap; padding-block: 8px; }
  .workspace-nav { width: 100%; order: 2; gap: 20px; }
  .session { margin-left: auto; }
  #dataToggle, #settingsView.is-open { display: none; }
  #userBtn { padding-inline: 12px; }
  .live { gap: 4px; }
  main { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .toasts { bottom: calc(16px + env(safe-area-inset-bottom)); }
  .workbench { padding: 12px; }
  .journal-filters { grid-template-columns: minmax(0, 1fr); }
  .dlg-wide { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .dlg-wide .dlg-inner { height: 100%; max-height: 100dvh; }
  .dlg-wide .dlg-body { flex: 1; }
  .dlg-wide .dlg-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}

#viewDialog .view-qty .big, #viewDialog .view-qty .big small {
  font-size: var(--fs-xs);
  font-weight: 400;
  font-variant-numeric: normal;
  color: #000;
}
#viewDialog .storage-summary strong {
  font-size: var(--fs-xs);
  font-weight: 400;
  color: #000;
}

/* Размер текста зависит от экрана; длинные значения подгоняются под строку. */
#items { --preview-text: 14px; --preview-title: 16px; }
#items .card-body { padding: 12px; gap: 6px; }
#items .item-link { font-size: var(--preview-title); }
#items .qty, #items .item-meta, #items .card-cat { font-size: var(--preview-text); }
#items .qty small { font-size: inherit; }
#items .qty, #items .item-link, #items .item-meta > span, #items .category-tag > :last-child,
#viewDialog .view-qty .big, #viewDialog .storage-summary strong {
  display: block; min-width: 0; max-width: 100%; white-space: nowrap; overflow-wrap: normal;
}
#items .item-meta > span, #items .category-tag > :last-child { flex: 1; }
#items .card-cat, #items .category-tag { max-width: 100%; }
#viewDialog .view-qty .big, #viewDialog .storage-summary strong { font-size: 15px; }
#viewDialog .view-qty .big small { font-size: inherit; }
@media (max-width: 900px) {
  #items { --preview-text: 15px; --preview-title: 18px; }
  .inventory-table .item-location { grid-column: 1 / -1; }
  .inventory-table .item-stock { grid-area: 4 / 1 / 5 / -1; }
  #viewDialog .item-summary { grid-template-columns: minmax(0, 1fr); }
  #viewDialog .item-summary .view-qty, #viewDialog .storage-summary { min-height: 72px; padding: 12px; }
}

#viewDialog .dlg-head, .entry-dialog .dlg-head { padding-inline: var(--gap); }
#viewDialog .item-actions, .entry-dialog .item-form-actions {
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px;
}
:is(#itemFormMessage, #locFormMessage) { flex-basis: 100%; }
#viewContent { overflow-y: auto; scrollbar-gutter: stable; }
#viewContent > .dlg-body { overflow: visible; flex: none; }
#viewContent > .dlg-head, #viewContent > .dlg-foot {
  flex: none; position: sticky; z-index: 1; background: var(--panel);
  padding-inline: var(--gap);
}
#viewContent > .dlg-head { top: 0; }
#viewContent > .dlg-foot { bottom: 0; justify-content: flex-end; }

:is(dialog, #viewDialog) .btn:is([data-close], [value="cancel"], [data-edit]) {
  min-height: 44px;
  height: auto;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--soft);
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 400;
  line-height: 1.3;
}
:is(dialog, #viewDialog) .btn:is([data-close], [value="cancel"], [data-edit]):hover { background: #ededed; }

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

/* Окно сканирования этикетки */
#scanDialog { width: min(440px, calc(100vw - 24px)); }
#scanForm { --scan-control-height: 44px; }
#scanForm .dlg-head { min-height: 68px; padding: 16px 20px; gap: 12px; }
#scanForm .dlg-head h2 { min-width: 0; font-size: 20px; font-weight: 600; line-height: 1.3; }
#scanForm .dlg-body { padding: 20px; gap: 16px; }
#scanForm .btn { min-height: var(--scan-control-height); height: auto; padding: 10px 14px; font-size: 14px; line-height: 1.4; border-radius: 8px; }
#scanForm .dlg-head .btn { flex: none; }
#scanLead { font-size: 14px; line-height: 1.55; }
#scanForm .scan-photo { width: 100%; border-color: var(--line-strong); background: var(--panel); color: var(--text); white-space: normal; }
#scanForm .scan-photo:hover { background: var(--soft); }
.scan-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.scan-divider::before, .scan-divider::after { content: ''; flex: 1; height: 1px; background: var(--line-soft); }
#scanForm .field { gap: 8px; }
#scanForm .field > span { font-size: 13px; line-height: 1.4; }
#scanForm .field input { height: var(--scan-control-height); padding: 0 12px; border-radius: 8px; background: var(--panel); font-size: 16px; line-height: 1.4; }
#scanForm .field input::placeholder { color: var(--muted); opacity: .75; }
#scanForm .field input:focus { border-color: var(--accent-ink); box-shadow: 0 0 0 3px rgb(127 199 255 / 20%); }
#scanForm .btn:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
#scanForm .dlg-foot { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 16px 20px; }
#scanForm .scan-status { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--soft); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
#scanForm .scan-status.error { background: #fff1f2; color: var(--out); }
@media (max-width: 600px) {
  #scanForm .dlg-head, #scanForm .dlg-body { padding: 16px; }
  #scanForm .dlg-foot { padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
}

/* Итерация 01: пересчёт и перенос прямо с карточки */
.tap-card {
  width: 100%; border: 1px solid transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
  touch-action: manipulation; transition: border-color .15s, background-color .15s;
}
.tap-card:hover, .tap-card:focus-visible { border-color: var(--accent); }
.tap-card:active { background: var(--accent-soft); }
.tap-hint { color: var(--accent); font-size: var(--fs-sm); }
.checked-line { color: var(--muted); font-size: var(--fs-xs); }
.item-summary .view-qty.tap-card { height: auto; }

.count-input { display: grid; grid-template-columns: 56px minmax(0, 1fr) 56px; gap: 8px; align-items: stretch; }
.count-input input {
  min-width: 0; height: 56px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--panel); font-size: 28px; text-align: center; font-variant-numeric: tabular-nums;
}
.count-input input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.count-step { height: 56px; padding: 0; font-size: 26px; touch-action: manipulation; }
.count-unit { margin-top: -8px; text-align: center; }
.count-reasons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; }
.count-reasons legend { margin-bottom: 6px; padding: 0; color: var(--muted); font-size: var(--fs-sm); }
.count-reason { position: relative; display: flex; min-width: 0; cursor: pointer; }
.count-reason input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.count-reason span {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--panel); color: var(--text); font-size: var(--fs-sm); line-height: 1.3; text-align: center; overflow-wrap: anywhere;
}
.count-reason:last-child:nth-of-type(odd) { grid-column: 1 / -1; }
.count-reason:hover span { border-color: var(--accent); }
.count-reason input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.count-reason input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.count-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.count-actions .btn { min-height: 48px; }
#countSave:disabled { opacity: .45; cursor: default; }

.place-list { display: grid; gap: 6px; max-height: min(60dvh, 480px); overflow-y: auto; }
.place-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; padding: 8px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--panel);
  color: inherit; font: inherit; font-size: 16px; text-align: left; cursor: pointer; touch-action: manipulation;
}
.place-row:hover, .place-row:focus-visible { border-color: var(--accent); }
.place-row span { min-width: 0; overflow-wrap: anywhere; }
.place-row small { flex: none; color: var(--muted); font-size: var(--fs-xs); }
.place-row.current { background: var(--soft); cursor: default; }
.place-new { justify-content: center; border-style: dashed; color: var(--accent); }

/* Итерация 02: место хранения на телефоне, обход места, резервная копия */
.round-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 12px; padding: 12px 16px;
  border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel);
}
.round-bar.complete { border-color: var(--accent); }
.round-bar p { display: grid; gap: 2px; flex: 1 1 200px; min-width: 0; margin: 0; overflow-wrap: anywhere; }
.round-bar p span { color: var(--muted); font-size: var(--fs-sm); }
.round-bar.complete p span { color: var(--in); font-weight: 600; }
.round-bar .btn { min-height: 44px; }
.round-list { display: grid; gap: 8px; }
.round-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 10px;
  border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel);
}
.round-row.done { background: var(--soft); }
.round-item {
  display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 44px; padding: 0; border: 0; background: none;
  color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.round-item > span { display: grid; gap: 2px; min-width: 0; }
.round-item strong { font-weight: 600; overflow-wrap: anywhere; }
.round-item small, .checked-ago { color: var(--muted); font-size: var(--fs-xs); }
.checked-ago { display: block; }
.round-qty {
  min-height: 44px; padding: 4px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--panel); color: inherit; font: inherit; white-space: nowrap; cursor: pointer; touch-action: manipulation;
}
.round-qty small { color: var(--muted); }
.round-qty:hover, .round-qty:focus-visible { border-color: var(--accent); }
.round-ok { min-width: 96px; min-height: 44px; touch-action: manipulation; }
.round-ok.is-done { background: transparent; color: var(--in); }
@media (max-width: 520px) {
  .round-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .round-item { grid-column: 1 / -1; }
  .round-qty { white-space: normal; }
}
.backup-info { margin: 4px 10px 8px; color: var(--muted); font-size: var(--fs-xs); line-height: 1.45; overflow-wrap: anywhere; }
.backup-info.warn { color: var(--out); }
.backup-box .btn { margin: 0 0 12px 10px; }

/* Итерация 03: вложенные места, этикетки и фото мест */
#settingsView .directory-entry .directory-link { padding-left: calc(10px + var(--depth, 0) * 14px); }
.place-list .place-row { padding-left: calc(14px + var(--depth, 0) * 18px); }
.place-list-sep { margin: 6px 0 0; color: var(--muted); font-size: var(--fs-xs); }
.scan-place { width: 100%; min-height: 48px; }
.loc-select-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: stretch; }
.loc-select-row .btn { height: auto; min-height: var(--h); white-space: nowrap; }
.loc-path-hint { color: var(--muted); font-size: var(--fs-xs); overflow-wrap: anywhere; }
.loc-photo {
  display: grid; place-items: center; min-height: 96px; max-height: 220px; overflow: hidden; cursor: pointer;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--soft); color: var(--muted);
}
.loc-photo img { display: block; width: 100%; max-height: 220px; object-fit: contain; }
.label-choice { min-height: 64px; }
.label-choice span { display: grid; gap: 2px; }
.label-choice small { color: var(--muted); font-size: var(--fs-xs); }
.place-kind { display: block; color: var(--muted); font-size: var(--fs-xs); }
.place-path { margin: 0 0 12px; color: var(--muted); overflow-wrap: anywhere; }
.place-path .text-action { min-height: 32px; color: var(--text); }
.place-photo::before { aspect-ratio: 4 / 3; }
.place-contents { display: grid; gap: 6px; margin-top: 16px; }
.place-contents h3 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0 0 4px; font-size: var(--fs-md); font-weight: 600; }
.place-contents h3 small { color: var(--muted); font-size: var(--fs-xs); font-weight: 400; }
.place-contents .place-row span small { color: var(--muted); font-size: var(--fs-xs); }
.place-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 52px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.place-item:hover, .place-item:focus-visible { border-color: var(--accent); }
.place-item > span:not(.item-mini) { display: grid; min-width: 0; }
.place-item strong { font-weight: 600; overflow-wrap: anywhere; }
.place-item small { color: var(--muted); font-size: var(--fs-xs); }
.place-item-qty { white-space: nowrap; }
.place-item-qty small { color: var(--muted); }
.open-place { display: block; margin-top: 8px; text-align: left; }
.round-place { padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 700; text-align: left; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.round-inner { color: var(--muted); font-size: var(--fs-xs); }
#placeViewContent { overflow-y: auto; }
#placeViewContent > .dlg-head, #placeViewContent > .dlg-foot { position: sticky; z-index: 1; background: var(--panel); }
#placeViewContent > .dlg-head { top: 0; }
#placeViewContent > .dlg-foot { bottom: 0; }
#placeViewContent > .dlg-body { overflow: visible; flex: none; }
#placeViewDialog .item-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
@media (max-width: 600px) {
  #placeViewDialog .item-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #placeViewDialog .item-actions .btn { min-width: 0; min-height: 44px; padding: 8px 4px; }
}

/* Цепочка в карточке: предмет → коробка → паллета → стеллаж (фото слева, этикетка с QR справа) */
.chain { display: grid; gap: 0; margin-bottom: 16px; }
.chain-row {
  display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 12px; width: 100%; padding: 10px;
  border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel); color: inherit; font: inherit; text-align: left;
}
button.chain-row { cursor: pointer; touch-action: manipulation; }
button.chain-row:hover, button.chain-row:focus-visible { border-color: var(--accent); }
#viewDialog .chain-row, #placeViewDialog .chain-row { background: var(--bg); }
.chain-thumb {
  display: block; width: 96px; padding: 0; overflow: hidden; border: 0; border-radius: var(--radius-sm); background: var(--soft);
  color: var(--muted); cursor: pointer;
}
.chain-thumb-item { aspect-ratio: 2 / 3; }
.chain-thumb-place { aspect-ratio: 1; }
.chain-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.chain-thumb .noimg { display: grid; place-items: center; width: 100%; height: 100%; min-height: 0; }
.chain-thumb .noimg .ic { width: 32px; height: 32px; stroke-width: 1.4; }
.chain-label { display: grid; grid-template-columns: 88px minmax(0, 1fr); align-items: center; gap: 12px; min-width: 0; }
.chain-qr { display: block; width: 88px; aspect-ratio: 1; }
.chain-qr .qr { display: block; width: 100%; height: 100%; border-radius: 4px; }
.chain-noqr {
  display: grid; place-items: center; width: 100%; height: 100%; padding: 4px; border: 1px dashed var(--line-strong);
  border-radius: 4px; color: var(--muted); font-size: var(--fs-xs); text-align: center;
}
.chain-text { display: grid; gap: 4px; min-width: 0; }
.chain-text strong { font-size: var(--fs-md); font-weight: 700; overflow-wrap: anywhere; }
.chain-text small { color: var(--muted); font-size: var(--fs-xs); overflow-wrap: anywhere; }
.chain-text .btn { justify-self: start; height: auto; min-height: 36px; white-space: normal; }
.chain-link {
  position: relative; margin: 0; padding: 4px 0 4px 58px; color: var(--muted); font-size: var(--fs-xs);
}
.chain-link::before { content: ""; position: absolute; left: 58px; top: 0; bottom: 0; border-left: 2px solid var(--line-strong); transform: translateX(-12px); }
.chain-end::before { bottom: 50%; }
.place-add { width: 100%; min-height: 48px; margin-bottom: 8px; }
#placeViewContent .desc + .place-add { margin-top: 12px; }
@media (max-width: 420px) {
  .chain-row { grid-template-columns: 76px minmax(0, 1fr); gap: 10px; padding: 8px; }
  .chain-thumb { width: 76px; }
  .chain-label { grid-template-columns: 76px minmax(0, 1fr); gap: 10px; }
  .chain-qr { width: 76px; }
  .chain-link { padding-left: 48px; }
  .chain-link::before { left: 48px; }
}

/* Карточка предмета: две одинаковые плитки — предмет слева, место справа (фото сверху, QR с подписью снизу) */
.pair { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 8px; margin-bottom: 16px; align-items: stretch; overflow-x: auto; padding-bottom: 4px; }
.pair-blank { opacity: .5; }
.pair-blank .chain-text small { text-align: center; }
.pair-tile {
  display: flex; flex-direction: column; gap: 10px; min-width: 0; width: 100%; padding: 10px;
  border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--bg); color: inherit; font: inherit; text-align: left;
}
button.pair-tile { cursor: pointer; touch-action: manipulation; }
button.pair-tile:hover, button.pair-tile:focus-visible { border-color: var(--accent); }
.pair-empty { border-style: dashed; }
.pair-empty .chain-text strong { color: var(--muted); }
.pair-photo {
  display: block; width: 100%; aspect-ratio: 1; padding: 0; overflow: hidden; border: 0; border-radius: var(--radius-sm);
  background: var(--soft); color: var(--muted); cursor: pointer;
}
.pair-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pair-photo .noimg { display: grid; place-items: center; width: 100%; height: 100%; min-height: 0; }
.pair-photo .noimg .ic { width: 40px; height: 40px; stroke-width: 1.4; }
.pair-label { display: grid; grid-template-columns: 1fr; justify-items: center; gap: 6px; min-width: 0; text-align: center; }
.pair-label .chain-text { justify-items: center; }
.pair-qr { display: block; width: 100%; max-width: 110px; aspect-ratio: 1; }
.pair-qr .qr { display: block; width: 100%; height: 100%; border-radius: 4px; }
.pair-btn { align-self: stretch; height: auto; min-height: 36px; white-space: normal; margin-top: auto; }
.pair-code { text-align: center; font-size: var(--fs-xs); color: var(--muted); overflow-wrap: anywhere; }
.pair-code code { display: block; color: var(--text); font: 13px/1.5 ui-monospace, Consolas, monospace; }
@media (max-width: 560px) {
  .pair { gap: 4px; }
  .pair-tile { padding: 4px; gap: 4px; }
  .pair-photo .noimg .ic { width: 24px; height: 24px; }
  .pair-label .chain-text strong { font-size: var(--fs-xs); }
  .pair-label .chain-text small { display: block; }
  .pair-btn { min-height: 32px; padding: 2px 4px; font-size: var(--fs-xs); }
}

/* Фото позиции: нажатие в карточке открывает его крупно */
button.detail-photo { width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
button.detail-photo:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.photo-zoom-dlg { width: fit-content; max-width: calc(100vw - 24px); }
.photo-zoom-dlg .dlg-head h2 { min-width: 0; font-size: var(--fs-lg); overflow-wrap: anywhere; }
.photo-zoom-body { display: grid; place-items: center; padding: 12px; background: var(--soft); cursor: zoom-out; }
.photo-zoom-body img {
  /* фото сохраняются в пропорции 2:3 — ширина считается от доступной высоты */
  display: block; width: min(calc(100vw - 48px), calc((100dvh - 140px) * 2 / 3)); height: auto;
  border-radius: var(--radius-sm); object-fit: contain;
}

.toast { display: flex; align-items: center; gap: 12px; }
.toast-action {
  flex: none; min-height: 36px; margin-left: auto; padding: 0 12px; border: 1px solid currentColor;
  border-radius: var(--radius-sm); background: transparent; color: inherit; font: inherit; cursor: pointer;
}

/* Оценка состояния: 5 Отличное … 1 Негоден */
.condition-summary strong { display: flex; align-items: center; gap: 8px; }
.cond-score {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--soft); color: var(--text); font-weight: 700; flex: none;
}
.cond-5 .cond-score, .cond-4 .cond-score { background: var(--accent-soft); color: var(--accent-ink); }
.cond-3 .cond-score { background: #fff1e3; color: #9a5a12; }
.cond-2 .cond-score, .cond-1 .cond-score { background: #fde8ed; color: var(--out); }
.cond-note { color: var(--text); font-size: var(--fs-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.badge.t-condition { background: var(--accent-soft); color: var(--accent-ink); }
@media (max-width: 600px) {
  #viewDialog .item-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* Две независимые оценки, числовая шкала 5–1. */
.condition-comparison { display: grid; align-self: center; gap: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); overflow: hidden; }
.assessment-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 6px 8px; padding: 6px 10px; }
.assessment-row + .assessment-row { border-top: 1px solid var(--line); }
.assessment-row .cond-buttons { width: 122px; grid-template-columns: repeat(5, 22px); }
.assessment-author { grid-column: 2; color: var(--muted); font-size: var(--fs-xs); line-height: 1.3; overflow-wrap: anywhere; }
.assessment-row > .cond-draft, .assessment-note { grid-column: 1 / -1; }
.assessment-note { font-size: var(--fs-xs); }
.assessment-note summary { color: var(--muted); cursor: pointer; }
.assessment-note .cond-note { margin-top: 6px; }
.cond-buttons { display: grid; width: 50%; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; }
.cond-btn { display: grid; place-items: center; min-width: 0; height: 22px; min-height: 22px; padding: 0 1px; border: 1px solid var(--rating-color); border-radius: calc(var(--radius-sm) / 2); background: color-mix(in srgb, var(--rating-color) 8%, var(--panel)); color: var(--text); font: inherit; font-size: 12px; line-height: 1; touch-action: manipulation; }
button.cond-btn { cursor: pointer; }
.cond-5 { --rating-color: #16a34a; }
.cond-4 { --rating-color: #84cc16; }
.cond-3 { --rating-color: #eab308; }
.cond-2 { --rating-color: #f97316; }
.cond-1 { --rating-color: #dc2626; }
.cond-btn.active { background: var(--rating-color); border-color: var(--rating-color); box-shadow: inset 0 0 0 1px var(--rating-color); font-weight: 700; color: #14212b; }
.cond-btn.active.cond-5, .cond-btn.active.cond-1 { color: white; }
button.cond-btn:focus-visible { outline: 2px solid var(--rating-color); outline-offset: 2px; }
.cond-draft { display: grid; gap: 6px; }
.cond-draft textarea { width: 100%; min-height: 56px; padding: 8px; border: 1px solid var(--out); border-radius: var(--radius-sm); font: inherit; resize: vertical; }
.cond-draft-actions { display: flex; justify-content: flex-end; gap: 6px; }
/* Место в форме позиции — только сканом */
.loc-scan-btn { width: 100%; min-height: var(--h); height: auto; white-space: normal; }
/* Форма места — по образцу формы позиции */
.loc-parent-clear { justify-self: start; align-self: flex-start; }
/* Выбор места: скан этикетки или помещение (у помещений этикеток нет) */
.loc-pick-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.loc-pick-row .btn { min-height: var(--h); height: auto; white-space: normal; }
.loc-path-hint.is-fixed-place { display: block; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); font-size: var(--fs-sm); line-height: 1.5; overflow-wrap: anywhere; }
.place-new-room { width: 100%; min-height: 48px; margin-top: 8px; }
#placeViewDialog .pair-tile { background: var(--bg); }

/* Реестр этикеток */
.labels-table { min-width: 640px; }
.label-filters { grid-template-columns: minmax(0,2fr) minmax(0,1fr) minmax(0,1fr); }
.label-batch-details { margin: 16px 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel); }
.label-batch-details > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.label-batch-details h3 { margin: 0; font-size: 18px; font-weight: 600; }
.label-batch-details > header > span { color: var(--muted); font-size: 13px; }
.label-batch-stats,.label-batch-actions { display: flex; flex-wrap: wrap; gap: 10px 20px; margin-top: 14px; }
.label-batch-stats > span { color: var(--muted); font-size: 13px; }
.label-batch-stats strong { margin-left: 5px; color: var(--text); font-weight: 600; }
#labelBatchIssueError { color: var(--out); }
.label-print-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 12px 0; }
.label-print-controls > span { margin-right: auto; }
.serial-entry { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.serial-entry > input { flex: 1 1 180px; min-width: 0; }
.serial-none { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.serial-none input { width: 18px; height: 18px; margin: 0; flex: none; }
.serial-photo-editor { display: grid; grid-template-columns: minmax(0, 144px) minmax(0, 1fr); align-items: center; gap: 14px; width: 100%; max-width: 360px; padding: 10px; border: 1px solid #e5e9ed; border-radius: 10px; background: var(--panel); }
.serial-photo-box { width: 100%; aspect-ratio: 1200 / 756; border-radius: 8px; }
.serial-photo-box .photo-empty { padding: 8px; gap: 4px; font-size: 11px; line-height: 1.3; }
.serial-photo-box .photo-empty .ic { width: 22px; height: 22px; }
.serial-photo-controls { display: grid; align-content: center; gap: 4px; min-width: 0; }
.serial-ocr-result { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
#serialPhotoPick { justify-self: start; align-self: flex-start; }
@media (max-width: 600px) {
  .serial-photo-editor { grid-template-columns: minmax(0, 140px) minmax(0, 1fr); gap: 10px; }
}
.serial-details { display: flex; align-items: center; gap: 14px; min-width: 0; }
.serial-details .props { flex: 1; min-width: 0; margin: 0; }
.serial-details .prop { grid-template-columns: minmax(0, 1fr); gap: 4px; }
.serial-details:has(.serial-detail-photo) { padding: 12px; border: 1px solid #e5e9ed; border-radius: 10px; background: var(--soft); }
.serial-details .prop dd { font-weight: 600; }
.serial-detail-photo { flex: none; width: 112px; aspect-ratio: 1200 / 756; padding: 0; border: 1px solid #dce2e8; border-radius: 6px; overflow: hidden; background: var(--soft); cursor: zoom-in; }
.serial-detail-photo img { width: 100%; height: 100%; object-fit: contain; }
.item-audit { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding-top: 10px; }
.item-audit .prop { display: block; border: 0; padding: 0; }
.item-audit dd { margin-top: 4px; }
.item-serial { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 12px; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .cond-buttons { width: 100%; max-width: 280px; gap: 5px; }
  .assessment-row { grid-template-columns: minmax(0, 1fr); }
  .assessment-row .cond-buttons { width: 100%; grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .assessment-author { grid-column: 1; }
  .cond-btn { height: 40px; min-height: 40px; font-size: 16px; }
}
.labels-table th:first-child, .labels-table td:first-child { width: 44px; text-align: center; }
.labels-table .label-code { width: auto; font: 16px/1.4 ui-monospace, Consolas, monospace; text-align: left; letter-spacing: .04em; }
.label-state { display: inline-block; padding: 4px 8px; border: 1px solid transparent; border-radius: var(--radius-sm); background: var(--panel); color: var(--text); white-space: nowrap; }
.label-state.status-free { border-color: #16a34a; }
.label-state.status-used { border-color: #eab308; }
.label-state.status-retired { border-color: #dc2626; }
.label-print-marker { display: block; width: fit-content; margin-bottom: 4px; padding: 3px 7px; border-radius: 5px; background: #e9f3ff; color: #245984; font-size: 12px; line-height: 1.4; }
#labelPreviewStatus { white-space: normal; }
.label-preview { display: grid; justify-items: center; gap: 12px; text-align: center; }
.label-preview-actions { justify-content: center; }
.label-preview .qr { display: block; width: min(240px, 65vw); height: auto; }
#labelPreviewCode { font: 22px/1.4 ui-monospace, Consolas, monospace; letter-spacing: .08em; }
#labelSummary { margin-block: 20px 8px; }
.location-navigation { display: flex; flex: 1 1 260px; min-width: 0; height: 44px; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; gap: 6px; align-items: center; margin: 0; padding: 0; border: 0; background: transparent; font-size: var(--fs-lg); }
.location-navigation::-webkit-scrollbar { display: none; }
.location-navigation > button:not(.btn) { border: 0; border-radius: 0; background: transparent; padding: 5px 0; color: var(--text); font: inherit; cursor: pointer; }
.location-navigation > button:not(.btn):hover { background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.location-navigation > button:not(.btn):focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 1px; }
.location-navigation > span { flex: none; padding-inline: 2px; color: var(--muted); }
.location-navigation > button[aria-current] { color: var(--text); background: transparent; }
.location-navigation-row { display: flex; flex: 1 1 360px; align-items: stretch; gap: 10px; min-width: 0; }
.location-navigation-row .location-navigation { flex: 1 1 0; }
.location-navigation-row .location-navigation > button { display: block; flex: 0 1 auto; min-width: 20px; max-width: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.location-navigation-row .location-navigation > button[aria-current] { flex: none; max-width: none; overflow: visible; }
.location-navigation-row .location-navigation > button:first-child { flex: none; max-width: none; }
.location-card-button { flex: none; min-height: 44px; height: auto; color: var(--accent-ink); }
@media (max-width: 600px) {
  .location-navigation-row { flex-basis: 100%; gap: 8px; }
  .location-card-button { max-width: 108px; padding: 8px 10px; font-size: 13px; white-space: normal; }
}
.location-levels { margin-block: 24px; }
.location-levels h2, .level-items-title { margin: 20px 0 12px; font-size: var(--fs-lg); }
.location-levels-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-bottom: 12px; }
.location-levels-heading h2 { margin: 0; }
.location-level-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 10px; }
.location-type-sections { display: grid; gap: 22px; }
.location-type-section, .catalog-positions { min-width: 0; }
.catalog-always-open { width: 100%; margin-top: 6px; }
.catalog-items-heading { display: flex; align-items: center; gap: 8px; min-height: 44px; margin-bottom: 10px; }
.catalog-items-heading :is(h2, h4) { margin: 0; font-size: var(--fs-md); font-weight: 600; }
.catalog-items-heading > span { color: var(--muted); font-size: var(--fs-xs); }
.location-type-section > summary, .catalog-positions > summary { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--soft); list-style: none; cursor: pointer; }
.location-type-section[open] > summary, .catalog-positions[open] > summary { margin-bottom: 10px; }
.location-type-section > summary::-webkit-details-marker, .catalog-positions > summary::-webkit-details-marker { display: none; }
.location-type-section > summary::after, .catalog-positions > summary::after { content: '›'; margin-left: auto; padding-inline: 4px; color: var(--muted); font-size: 22px; line-height: 1; }
.location-type-section[open] > summary::after, .catalog-positions[open] > summary::after { transform: rotate(90deg); }
.location-type-section > summary:focus-visible, .catalog-positions > summary:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.catalog-positions > summary h2 { margin: 0; font-size: var(--fs-md); font-weight: 600; }
.location-type-section h3 { margin: 0; font-size: var(--fs-md); font-weight: 600; }
.location-type-section > summary h4 { margin: 0; font-size: var(--fs-md); font-weight: 600; }
.location-type-section > summary > span { min-width: 24px; padding: 2px 7px; border-radius: 12px; background: var(--panel); color: var(--muted); font-size: var(--fs-xs); text-align: center; }
.location-level-card { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.location-level-card:hover { border-color: var(--accent); }
.location-level-card strong, .location-level-card small { display: block; overflow-wrap: anywhere; }
.location-level-card small { color: var(--muted); font-size: var(--fs-xs); margin-top: 4px; }
.location-level-photo { width: 52px; height: 52px; border-radius: var(--radius-sm); overflow: hidden; background: var(--soft); }
.location-level-photo img { width: 100%; height: 100%; object-fit: cover; }
.location-level-photo .noimg { display: grid; place-items: center; width: 100%; height: 100%; }
.place-content-card { padding: 0; border: 1px solid var(--line); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.place-content-card .thumb { display: block; width: 100%; overflow: hidden; }
.place-content-card .thumb .noimg { height: 100%; }
.place-content-card .card-body { width: 100%; }
.place-content-card small { color: var(--muted); font-size: var(--fs-xs); }
.place-content-grid { gap: 12px; }
.place-content-grid .item-card { cursor: pointer; }
.place-content-grid [role="button"]:focus-visible, .place-content-card:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }

/* Общий компактный стандарт превью позиции и места. */
#items.grid, .location-level-list, .place-content-grid { grid-template-columns: repeat(auto-fill, minmax(min(253px, 100%), 1fr)); gap: 9px; }
.card.inventory-card { display: grid; grid-template-columns: 57px minmax(0, 1fr); align-items: center; gap: 11px; min-width: 0; min-height: 86px; padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); color: var(--text); box-shadow: none; text-align: left; cursor: pointer; }
.card.inventory-card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: none; }
.inventory-card-photo { display: block; width: 57px; height: 57px; overflow: hidden; border-radius: 6px; background: var(--soft); }
.inventory-card-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.inventory-card-photo .noimg { display: grid; place-items: center; width: 100%; height: 100%; }
.inventory-card-photo .noimg .ic { width: 29px; height: 29px; }
.inventory-card-body { display: grid; min-width: 0; gap: 3px; }
.inventory-card-title { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 14.3px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.inventory-card-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12.1px; line-height: 1.3; }
.inventory-card-footer { display: flex; justify-content: space-between; gap: 7px; min-width: 0; color: var(--muted); font-size: 12.1px; line-height: 1.3; }
.inventory-card-footer > :first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inventory-card-footer > :last-child { flex: none; white-space: nowrap; color: var(--text); }
.inventory-card-category .category-tag { display: flex; align-items: center; min-width: 0; gap: 4px; }
.inventory-card-category .category-tag > :last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inventory-card-category .category-dot { width: 8px; height: 8px; flex-basis: 8px; margin-inline: 0; }
.inventory-card:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
#locationLevelMore { margin-top: 12px; }

/* Навигация и компактная карточка позиции */
.workspace-nav { gap: 6px; align-items: center; }
.workspace-nav button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 0 12px; border: 0; border-radius: 8px; font: inherit; white-space: nowrap; }
.workspace-nav button > span { display: inline-flex; }
.workspace-nav .ic { width: 17px; height: 17px; }
.workspace-nav button:hover { background: var(--soft); color: var(--text); }
.workspace-nav button.active, .workspace-nav button[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.workspace-nav button:focus-visible, .directory-all:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.directory-all { width: 100%; min-height: 40px; padding: 8px 10px; border: 0; border-radius: var(--radius-sm); background: var(--soft); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.directory-all:hover { background: var(--accent-soft); }
#viewDialog .item-summary { grid-template-columns: minmax(0, 1fr); gap: 12px; }
#viewDialog .stock-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: center; gap: 12px; width: 100%; min-height: 70px; padding: 14px 16px; border: 1px solid transparent; border-radius: var(--radius-md); font: inherit; color: var(--text); cursor: pointer; text-align: center; }
#viewDialog .stock-summary.stock-unchecked { background: #fff3bf; border-color: #f1da80; }
#viewDialog .stock-summary.stock-checked { background: #e4f3cb; border-color: #c3dda0; }
#viewDialog .stock-summary:hover { filter: brightness(.98); }
#viewDialog .stock-summary:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 3px; }
.stock-summary .stock-recount { color: var(--accent-ink); font-size: var(--fs-sm); }
.stock-value { font-size: 22px; line-height: 1.2; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stock-value small { font-size: 14px; font-weight: 400; color: var(--muted); }
#viewDialog .condition-comparison { grid-template-columns: repeat(2, minmax(0, 1fr)); align-self: stretch; background: var(--bg); border: 0; border-radius: var(--radius-md); }
#viewDialog .assessment-row { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 8px; min-width: 0; padding: 12px; }
#viewDialog .assessment-row + .assessment-row { border-top: 0; border-left: 1px solid #dce2e8; }
#viewDialog .assessment-row .cond-buttons { width: min(100%, 220px); max-width: none; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
#viewDialog .assessment-row .cond-btn { height: 36px; min-height: 36px; font-size: 14px; }
#viewDialog .assessment-author { grid-column: 1; }
#viewDialog .assessment-row > .cond-draft { grid-column: 1; }
#viewDialog .cond-draft-actions { flex-wrap: wrap; }
.item-notes { margin-top: 12px; padding: 14px; border-radius: var(--radius-md); background: var(--bg); }
.item-notes h3 { margin: 0 0 10px; font-size: var(--fs-sm); font-weight: 600; }
.item-note { display: grid; gap: 4px; min-width: 0; }
.item-note + .item-note { margin-top: 10px; padding-top: 10px; border-top: 1px solid #dce2e8; }
.item-note .cond-note { font-size: var(--fs-md); }
@media (max-width: 600px) {
  .workspace-nav { gap: 3px; }
  .workspace-nav button { flex: 1 1 0; min-width: 0; padding: 0 3px; gap: 4px; font-size: 12px; }
  .workspace-nav .ic { width: 15px; height: 15px; }
  #dataToggle { display: inline-flex; }
  #settingsView.is-open { display: block; width: 100%; padding: 12px; margin-top: 12px; border-radius: var(--radius-md); background: var(--panel); }
  #viewDialog .stock-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 12px 8px; }
  .stock-value { font-size: 20px; }
  .stock-summary .stock-recount { font-size: 12px; }
  #viewDialog .assessment-row { padding: 10px 8px; }
  #viewDialog .assessment-row .cond-btn { height: 40px; min-height: 40px; font-size: 15px; }
}

/* Информация о позиции: остаток → состояние → описание → служебные данные. */
#viewDialog .item-information { display: grid; gap: 14px; margin-top: 16px; min-width: 0; }
#viewDialog .item-information .item-summary { gap: 14px; }
#viewDialog .stock-summary { min-height: 76px; padding: 16px 20px; }
#viewDialog .stock-summary > .stat-label { text-align: left; color: #48515b; font-size: 14px; }
#viewDialog .stock-summary > .stock-value { font-size: 26px; }
#viewDialog .stock-summary > .stock-recount { text-align: right; font-size: 14px; }
.condition-section { min-width: 0; overflow: hidden; border: 1px solid #e5e9ed; border-radius: var(--radius-md); background: var(--panel); }
.information-heading { display: flex; align-items: baseline; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; padding: 14px 16px; border-bottom: 1px solid #e5e9ed; }
.information-heading h3 { margin: 0; font-size: 15px; font-weight: 600; }
.information-heading > span { color: var(--muted); font-size: 12px; }
#viewDialog .condition-section .condition-comparison { background: transparent; border-radius: 0; }
#viewDialog .condition-section .assessment-row { padding: 16px; gap: 12px; }
.assessment-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.assessment-heading h4 { margin: 0; font-size: 14px; font-weight: 600; }
.assessment-score { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
#viewDialog .condition-section .cond-buttons { width: 100%; max-width: 280px; gap: 6px; }
#viewDialog .condition-section .cond-btn { min-height: 40px; height: 40px; font-size: 15px; border-radius: 6px; }
#viewDialog .condition-section .assessment-author { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: 12px; line-height: 1.5; }
.assessment-person { color: var(--text); }
.assessment-comment { display: grid; gap: 6px; min-width: 0; padding-top: 10px; border-top: 1px solid #e5e9ed; }
.assessment-comment .cond-note { font-size: 14px; line-height: 1.55; }
#viewDialog .item-information .item-notes { margin: 0; padding: 16px; border: 1px solid #e5e9ed; background: var(--panel); }
.item-information .item-notes h3 { font-size: 15px; margin-bottom: 8px; }
.item-information .item-notes .cond-note { line-height: 1.6; font-size: 14px; }
#viewDialog .item-information .item-details { margin: 0; border: 1px solid #e5e9ed; border-radius: var(--radius-md); overflow: hidden; }
#viewDialog .item-information .item-details::before { display: none; }
#viewDialog .item-information .item-details > summary { min-height: 48px; padding: 14px 40px 14px 16px; background: var(--panel); font-size: 14px; }
#viewDialog .item-information .item-details[open] > summary { margin-bottom: 0; border-bottom: 1px solid #e5e9ed; }
#viewDialog .item-information .item-extras, #viewDialog .item-information #history { padding: 12px 16px 16px; }
@media (max-width: 600px) {
  #viewDialog .item-information { gap: 12px; }
  #viewDialog .stock-summary { min-height: 72px; gap: 8px; padding: 12px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  #viewDialog .stock-summary > .stat-label { font-size: 12px; }
  #viewDialog .stock-summary > .stock-value { font-size: 22px; }
  #viewDialog .stock-summary > .stock-recount { font-size: 12px; }
  .stock-value small { font-size: 12px; }
  #viewDialog .condition-section .condition-comparison { grid-template-columns: minmax(0, 1fr); }
  #viewDialog .condition-section .assessment-row { padding: 14px; }
  #viewDialog .condition-section .assessment-row + .assessment-row { border-left: 0; border-top: 1px solid #e5e9ed; }
  #viewDialog .condition-section .cond-buttons { max-width: none; gap: 8px; }
  #viewDialog .condition-section .cond-btn { min-height: 44px; height: 44px; font-size: 16px; }
  #viewDialog .cond-draft-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #viewDialog .cond-draft-actions .btn { min-height: 44px; }
  #viewDialog .item-information .item-notes { padding: 14px; }
}
@media (max-width: 380px) {
  .item-audit { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}

@media (min-width: 901px) {
  #viewDialog .condition-section .cond-buttons, #formConditionButtons { width: 70%; max-width: none; gap: 6px; }
  #viewDialog .condition-section .cond-btn, #formConditionButtons .cond-btn { min-height: 36px; height: 36px; font-size: 13.3px; border-radius: 6px; }
  .serial-detail-photo { width: 144px; }
}
@media (max-width: 900px) {
  #viewDialog .condition-section .cond-buttons, #formConditionButtons { width: 70%; max-width: none; gap: 5px; }
  #viewDialog .condition-section .cond-btn, #formConditionButtons .cond-btn { min-height: 31px; height: 31px; font-size: 12px; border-radius: 5px; }
}

/* Общий стандарт модальных окон; специальные фото- и числовые контролы сохраняют свой формат. */
.dlg { --h: 44px; --h-icon: 44px; --gap: 20px; --modal-space: 20px; }
:is(#viewDialog, #placeViewDialog, #scanDialog, .dlg) .dlg-head { min-height: 68px; padding: 16px var(--modal-space); gap: 12px; flex-shrink: 0; }
:is(#viewDialog, #placeViewDialog, #scanDialog, .dlg) .dlg-head h2 { min-width: 0; margin: 0; font-size: 20px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
:is(#viewDialog, #placeViewDialog, #scanDialog, .dlg) .dlg-body { padding: var(--modal-space); }
.dlg .dlg-body.stack { gap: 16px; }
:is(#viewDialog, #placeViewDialog, #scanDialog, .dlg) .btn { min-width: 0; min-height: 44px; height: auto; padding: 10px 14px; border-radius: 8px; font-size: 14px; line-height: 1.4; white-space: normal; overflow-wrap: anywhere; }
:is(#viewDialog, #placeViewDialog, #scanDialog, .dlg) .btn:is([data-close], [value="cancel"], [data-edit]) { padding: 10px 14px; font-size: 14px; line-height: 1.4; }
.dlg .dlg-head .btn { flex: none; }
:is(#itemForm, #locForm) .btn.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-on); }
:is(#itemForm, #locForm) .btn.btn-primary:hover { background: var(--accent-hover); }
:is(#viewDialog, #placeViewDialog, #scanDialog, .dlg) .field { gap: 8px; }
:is(#viewDialog, #placeViewDialog, #scanDialog, .dlg) .field > span:first-child,
:is(#viewDialog, #placeViewDialog, #scanDialog, .dlg) .field > label:first-child { font-size: 13px; font-weight: 400; line-height: 1.4; color: var(--muted); }
.dlg .field :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]):not([type="file"]), select) { height: 44px; padding-block: 0; border-radius: 8px; background-color: var(--panel); font-size: 16px; line-height: 1.4; }
.dlg .field textarea { min-height: 96px; height: auto; padding: 10px 12px; border-radius: 8px; background: var(--panel); font-size: 16px; line-height: 1.5; }
.dlg .field :is(input, textarea)::placeholder { color: var(--muted); opacity: .75; }
.dlg .field :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea):focus { border-color: var(--accent-ink); box-shadow: 0 0 0 3px rgb(127 199 255 / 20%); }
:is(#viewDialog, #placeViewDialog, #scanDialog, .dlg) .btn:focus-visible, .dlg .icon-btn:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.dlg .hint { font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.dlg .place-row { min-height: 44px; padding: 10px 14px; border-radius: 8px; font-size: 14px; line-height: 1.4; }
.dlg .swatch { width: 44px; height: 44px; }
:is(#viewDialog, #placeViewDialog, #scanDialog, .dlg) .dlg-foot { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; padding: 16px var(--modal-space); flex-shrink: 0; }
.dlg .dlg-foot > .btn { flex: 1 1 0; }
.dlg .dlg-foot > .spacer { display: none; }
.dlg .dlg-foot > .hint { flex-basis: 100%; margin: 0; }
#countForm .btn.count-step { padding: 0; min-height: 56px; font-size: 26px; }
.dlg .confirm-text { font-size: 16px; line-height: 1.55; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .dlg { --modal-space: 16px; --gap: 16px; }
  :is(#viewDialog, #placeViewDialog, #scanDialog, .dlg) .dlg-head { padding-block: 16px; }
  :is(#viewDialog, #placeViewDialog, #scanDialog, .dlg) .dlg-foot { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  :is(#locForm, #catForm) .dlg-foot > .btn-ghost-danger { flex-basis: 100%; }
  .dlg .form-grid .fields { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .dlg .form-grid .span-2 { grid-column: 1; }
}
