:root {
  --bg: oklch(97.4% 0.004 250);
  --surface: oklch(100% 0 0);
  --surface-2: oklch(96.2% 0.006 250);
  --line: oklch(91% 0.008 250);
  --line-strong: oklch(82% 0.012 250);
  --ink: oklch(24% 0.02 260);
  --ink-2: oklch(43% 0.018 260);
  --ink-3: oklch(52% 0.014 260);
  /* смысловые цвета: кобальт — выбор, фокус и главное действие; дальше по качеству — хорошо → спокойно → внимание → плохо.
     Красный danger — только ошибки ввода и сбои. Каждый цвет ходит с подписью или знаком, не один. */
  --accent: oklch(49% 0.16 262);
  --accent-strong: oklch(41% 0.15 262);
  --accent-soft: oklch(95.5% 0.028 262);
  --good: oklch(50% 0.12 160);        /* полный аналог, отличие в плюс, готово */
  --good-soft: oklch(95.5% 0.04 160);
  --calm: oklch(50% 0.065 220);       /* близкий аналог: годится, но не один в один */
  --warn: oklch(51% 0.11 68);         /* другая форма, отличие без знака, досверить, уточнить */
  --warn-soft: oklch(95.5% 0.045 82);
  --warn-line: oklch(80% 0.08 70);
  --bad: oklch(46% 0.16 35);          /* другой монтаж, отличие в минус, нет аналога, нет DALI, не хватает остатка */
  --bad-soft: oklch(95.5% 0.03 35);
  --bad-line: oklch(78% 0.09 35);
  --danger: oklch(51% 0.18 25);
  --top: 52px;
  --colsh: 34px; /* высота шапки колонок ведомости */
  --stick: calc(var(--top) + var(--colsh)); /* под липкой обвязкой: отсюда липнут подписи лесенки */
  /* ведомость: ширина и колонки общие для шапки, списка и итогов — суммы стоят под своими брендами */
  --sheet: 1760px;
  --gutter: 20px;
  --edge: max(var(--gutter), calc((100% - var(--sheet)) / 2 + var(--gutter)));
  --cols: minmax(260px, 1.25fr) minmax(0, 1fr) minmax(0, 1fr);
  --r: 6px;
  color-scheme: light;
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.42;
  color: var(--ink);
  background: var(--bg);
  accent-color: var(--accent);
  caret-color: var(--accent);
  scrollbar-color: var(--line-strong) transparent;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--stick) + 36px); /* + липкая подпись лесенки */ scroll-padding-bottom: calc(var(--tot-h, 96px) + 8px); }
body { margin: 0; background: var(--bg); min-height: 100dvh; }
/* Короткая ведомость: .sheet растягивается, липкие итоги стоят у низа окна, а не посреди экрана. */
#screen-results:not([hidden]) { min-height: 100dvh; display: flex; flex-direction: column; }
#screen-results .sheet { flex: 1; width: 100%; }
p, h1, h2, h3, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
::selection { background: var(--accent-soft); color: var(--ink); }
a { color: var(--accent); text-underline-offset: 2px; text-decoration-thickness: 1px; }
b, .num, input, table { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.muted { color: var(--ink-2); }
.error { color: var(--danger); font-size: 13px; overflow-wrap: anywhere; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ic { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.ic.ext { width: 12px; height: 12px; margin-left: 3px; vertical-align: -1px; opacity: .7; }
.chev { transition: transform .18s cubic-bezier(.2, .8, .2, 1); }
.chev.up { transform: rotate(180deg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
kbd { font: 600 11px/1 inherit; font-family: inherit; padding: 2px 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--surface); color: var(--ink); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; font-size: 13px;
  cursor: pointer; white-space: nowrap; transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { background: var(--line); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.primary[aria-busy="true"] { cursor: progress; }
.btn.ghost { border-color: transparent; background: none; color: var(--ink-2); }
.btn.ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn.small { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn.quiet { border-color: transparent; color: var(--ink-2); }
.btn.quiet:hover { color: var(--danger); background: oklch(96% 0.02 25); }

input:where(:not([type=radio], [type=file])) {
  height: 30px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 5px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
input:not([type=radio]):focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--ink-3); }
input[aria-invalid="true"] { border-color: var(--danger) !important; box-shadow: 0 0 0 3px oklch(95% 0.03 25) !important; }
input[type=radio] { width: 15px; height: 15px; margin: 0; cursor: pointer; }

/* ---------- screens ---------- */
.center { min-height: calc(100dvh - var(--top)); display: grid; place-items: center; padding: 24px 16px; }
#screen-login.center { min-height: 100dvh; }
.wordmark { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; }

.login { width: min(340px, 100%); display: grid; gap: 14px; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 1px 2px oklch(24% 0.02 260 / .04), 0 8px 24px -12px oklch(24% 0.02 260 / .12); }
.login h1 { font-size: 20px; }
.login .muted { margin-top: -8px; font-size: 13px; }
.login .btn { height: 36px; }
.field { display: grid; gap: 5px; font-size: 12.5px; color: var(--ink-2); }
.field input { height: 36px; font-size: 14px; }
.hint { font-size: 12px; color: var(--ink-3); }

.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top);
  display: flex; align-items: center; gap: 14px; padding: 0 var(--edge);
  background: color-mix(in oklch, var(--surface) 94%, transparent); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.spacer { flex: 1; }
.file-chip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: var(--ink-2); padding: 3px 8px; background: var(--surface-2); border-radius: 4px; }
.file-chip:empty { display: none; }
.counts { display: flex; gap: 4px; font-size: 13px; }
.counts a { color: var(--ink-2); text-decoration: none; padding: 4px 8px; border-radius: 5px; white-space: nowrap; }
.counts a:hover { background: var(--surface-2); color: var(--ink); }
.counts b { color: var(--ink); font-weight: 600; margin-left: 2px; }
.counts a.warn b { color: var(--warn); background: var(--warn-soft); padding: 0 5px; border-radius: 4px; } /* есть спорные — сюда смотреть */

/* upload */
.drop {
  width: min(560px, 100%); display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 56px 24px; border: 1.5px dashed var(--line-strong); border-radius: 12px; background: var(--surface);
  cursor: pointer; transition: border-color .15s, background-color .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { font-size: 16px; font-weight: 600; }
.drop .muted { font-size: 13px; }
.drop .link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.drop-icon { width: 28px; height: 28px; color: var(--ink-2); margin-bottom: 6px; }
.drop .error { margin-top: 8px; }
/* касание: главное — выбрать файл; перетаскивание — только там, где есть мышь */
.t-tap { display: none; }
@media (hover: none) and (pointer: coarse) { .drop .t-drag { display: none; } .drop .t-tap { display: inline; } }
.progress-act { display: flex; flex-wrap: wrap; gap: 8px; }

.progress { width: min(420px, 100%); display: grid; gap: 18px; }
.progress-file { font-weight: 600; overflow-wrap: anywhere; }
.steps { display: grid; gap: 2px; counter-reset: s; }
.steps li { display: flex; align-items: center; gap: 12px; padding: 8px 0; color: var(--ink-3); transition: color .2s; }
.steps .dot { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center; flex: none; transition: background-color .2s, border-color .2s; }
.steps .dot .ic { width: 13px; height: 13px; opacity: 0; color: var(--surface); }
.steps li.active { color: var(--ink); font-weight: 600; }
.steps li.active .dot { border-color: var(--accent); border-width: 2px; animation: pulse 1.1s ease-out infinite; }
.steps li.done { color: var(--ink); }
.steps li.done .dot { background: var(--good); border-color: var(--good); }
.steps li.done .ic { opacity: 1; }
.steps li.failed { color: var(--danger); }
.steps li.failed .dot { border-color: var(--danger); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 oklch(49% 0.16 262 / .35); } 100% { box-shadow: 0 0 0 7px oklch(49% 0.16 262 / 0); } }

/* ---------- results ---------- */
.sheet { max-width: var(--sheet); margin: 0 auto; padding: 0 var(--gutter) 28px; }
.cols-head, .pos-grid { display: grid; grid-template-columns: var(--cols); }
.cols-head {
  position: sticky; top: var(--top); z-index: 10; background: var(--bg); height: var(--colsh); align-items: end;
  font-size: 12px; font-weight: 600; color: var(--ink-2); padding-bottom: 6px;
}
.cols-head span { padding: 0 16px; }
#pos-list { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: clip; }

/* ponytail: без content-visibility — с ним WebKit не доводил переходы к позиции и сбивал прокрутку после выбора;
   ввод держит sums(id) (152 позиции, Pixel 7 CPU×4: ввод до 21 мс). Тормозит на 500+ строках — виртуализация списка. */
.pos { border-top: 1px solid var(--line); }
.pos:first-child { border-top: 0; }
.pos:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pos-grid > * { padding: 12px 16px; min-width: 0; }
.pick { container: pick / inline-size; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }

.ref { font-size: 12px; overflow-wrap: anywhere; } /* имена файлов проектировщиков — без пробелов, через «_» */
.src { container: src / inline-size; display: flex; flex-direction: column; gap: 6px; }
.src-text { font-weight: 500; overflow-wrap: anywhere; }
.specs { display: flex; flex-wrap: wrap; gap: 4px; font-size: 12px; }
.specs li { padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--ink); }
.specs li.soft { background: none; box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--ink-2); overflow-wrap: anywhere; }
.specs li.soft small { font-size: 11px; color: var(--ink-3); }
.ask { font-size: 12.5px; color: var(--warn); font-weight: 500; }
.notes { font-size: 12px; line-height: 1.35; color: var(--ink-2); display: grid; gap: 2px; }
.notes li { padding-left: 12px; position: relative; }
.notes li::before { content: ""; position: absolute; left: 2px; top: .62em; width: 5px; height: 1px; background: var(--ink-3); }
.src-act { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: auto; padding-top: 2px; }
.src-act [data-do=remove] { margin-left: auto; }
.qty { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); margin-right: 4px; }
.qty input { width: 72px; text-align: right; }
.sr-mobile { display: none; }

.pick-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-name { font-size: 12px; font-weight: 600; color: var(--ink-2); display: none; }
.rung { flex: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650; color: var(--ink); }
.gauge { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.gauge i { width: 4px; border-radius: 1px; background: var(--line); }
.gauge i:nth-child(1) { height: 5px; } .gauge i:nth-child(2) { height: 7px; } .gauge i:nth-child(3) { height: 9.5px; } .gauge i:nth-child(4) { height: 12px; }
.gauge i.on { background: var(--ink-2); }
/* цвет по качеству: полный — хорошо, близкий — спокойно, другая форма — внимание, другой монтаж — плохо */
.r1 { --rung: var(--good); } .r2 { --rung: var(--calm); } .r3 { --rung: var(--warn); } .r4 { --rung: var(--bad); }
.rung { color: var(--rung); }
.gauge i.on { background: var(--rung); }

/* узкая колонка бренда: фото | имя, ниже пометки и цена; шире 360 px — цена справа от имени */
.pick-main { flex: 1; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 10px; align-items: start; align-content: start; } /* цена сразу под пометками: без пустоты, когда соседняя колонка выше */
.pick-main .marks { grid-column: 1 / -1; }
.pick-main .price { grid-column: 1 / -1; }
@container pick (min-width: 360px) {
  .pick-main { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto 1fr; }
  .pick-main .marks { grid-column: 2 / -1; }
  .pick-main .price { grid-column: 3; grid-row: 1; display: grid; justify-items: end; gap: 3px; padding-top: 0; }
  .price-meta .base { display: block; text-align: right; margin: 0; }
}
.thumb { display: inline-block; width: 40px; height: 40px; flex: none; object-fit: contain; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.thumb.sm { width: 36px; height: 36px; }
.noimg { background: repeating-linear-gradient(135deg, var(--surface-2) 0 4px, var(--surface) 4px 8px); }
.pick-id { min-width: 0; display: grid; gap: 2px; }
.name { color: var(--ink); font-weight: 600; font-size: 13.5px; text-decoration: none; overflow-wrap: anywhere; }
a.name:hover { color: var(--accent); text-decoration: underline; }
.sku { font-size: 12px; }

.marks { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; font-size: 12px; }
.marks:empty { display: none; }
.marks .same { padding: 1px 2px; }
.diff, .flag, .nodata { padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
.marks .flags { display: contents; }
.marks .diff, .marks .flag.wrap { white-space: normal; max-width: 100%; overflow-wrap: anywhere; }
/* отличие: без знака — внимание; в плюс (поток выше, ватт меньше, IP выше…) — хорошо; в минус — плохо. Знак есть и в подписи */
.diff { background: var(--warn-soft); color: var(--warn); font-weight: 500; }
.diff.plus { background: var(--good-soft); color: var(--good); }
.diff.minus { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.flag { box-shadow: inset 0 0 0 1px var(--warn-line); color: var(--warn); font-weight: 500; }
.flag.bad { box-shadow: inset 0 0 0 1px var(--bad-line); color: var(--bad); font-weight: 600; }
.nodata { color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line-strong); }

.price { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 2px; }
.price label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.price input { width: 112px; text-align: right; }
.price-meta { font-size: 13px; white-space: nowrap; }
.price-meta .base { font-size: 12px; margin-right: 2px; }
.price-meta b { font-weight: 600; }

.pick.empty { justify-content: flex-start; align-items: flex-start; }
.none { color: var(--ink-2); font-weight: 500; padding: 6px 10px; border: 1px dashed var(--line-strong); border-radius: 5px; }
.none.miss { color: var(--bad); border-color: var(--bad-line); } /* аналога нет — бренд не предложить; «не берём» — выбор менеджера, нейтрально */

.removed { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--surface-2); }
.removed-line { flex: 1; min-width: 0; display: flex; gap: 8px; align-items: baseline; }
.removed-text { color: var(--ink-3); text-decoration: line-through; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 11.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }

/* ladder: таблица, пока осям хватает места; уже ~1150 px или оси не влезают — карточки (класс cards, fitLadder в app.js) */
.ladder { border-top: 1px solid var(--line); background: var(--surface-2); padding: 6px 16px 14px; display: grid; gap: 10px; }
.ld-brand { min-width: 0; }
/* таблица: бренд в шапке таблицы, заголовок h3 — для диктора; шапка таблицы липнет под обвязкой ведомости.
   Без overflow-x (иначе шапка не липнет): таблицу, которая не влезает, fitLadder переводит в карточки. */
.ld-brand h3 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ld-brand h3.shown { position: static; width: auto; height: auto; overflow: visible; clip-path: none; font-size: 12.5px; font-weight: 650; margin: 8px 0 4px; }
.ld thead th { position: sticky; top: var(--stick); z-index: 1; background: var(--surface); border-bottom: 0; box-shadow: inset 0 -1px var(--line); }
.ld th.th-brand { color: var(--ink); font-size: 12.5px; font-weight: 650; }
.ld th.ax-category { width: 9.5em; }
.ld { width: 100%; border-collapse: collapse; font-size: 12.5px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.ld th { text-align: left; vertical-align: bottom; font-weight: 600; font-size: 11.5px; color: var(--ink-2); padding: 7px 8px; border-bottom: 1px solid var(--line); }
.ld td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ld tbody tr:last-child td { border-bottom: 0; }
.ld tbody tr:not(.src-row) { cursor: pointer; transition: background-color .12s; }
.ld tbody tr:not(.src-row):hover { background: var(--surface-2); }
.ld tr.sel, .ld tr.sel:hover { background: var(--accent-soft); }
.ld .src-row { background: var(--surface-2); color: var(--ink-2); }
.ld .src-row .c-name { font-weight: 600; }
.ld .c-pick { width: 30px; padding-right: 0; vertical-align: middle; }
.ld .c-img { width: 52px; } .ld th:nth-child(4) { width: 22%; }
.ld .c-rung { white-space: nowrap; }
.ld .c-name label { display: block; font-weight: 600; color: var(--ink); cursor: pointer; overflow-wrap: anywhere; }
.ld .c-name .muted { display: block; font-size: 11.5px; }
.ld .c-name .marks { margin-top: 3px; font-size: 11.5px; }
.ld .ax small { display: block; font-size: 11px; font-weight: 600; }
.ld .ax.diff { background: none; color: var(--warn); font-weight: 500; padding: 7px 8px; border-radius: 0; white-space: normal; }
.ld .ax.diff.plus { color: var(--good); }
.ld .ax.diff.minus { color: var(--bad); font-weight: 600; }
.ld .ax.no_data { color: var(--ink-3); }
.ld .ax .orig { display: block; font-size: 11px; font-weight: 400; color: var(--ink-3); }
.ld .c-price, .ld .c-stock { text-align: right; white-space: nowrap; }
.ld th:nth-last-child(-n+2) { text-align: right; }
.ld .c-same { display: none; }

/* карточки (класс cards — fitLadder в app.js): бренды рядом, если каждому хватает ~320 px */
.ladder.cards { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 10px 16px; }
.cards .ld, .cards .ld tbody { display: block; }
.cards .ld thead { display: none; }
.cards .ld-brand h3 { position: sticky; top: var(--stick); z-index: 1; width: auto; height: auto; overflow: visible; clip-path: none; white-space: normal;
  font-size: 12.5px; font-weight: 650; margin: 0; padding: 8px 0 4px; background: var(--surface-2); }
.cards .ld tr { display: flex; flex-wrap: wrap; gap: 6px 8px; padding: 10px; border-bottom: 1px solid var(--line); }
.cards .ld tbody tr:last-child { border-bottom: 0; }
.cards .ld td { display: block; padding: 0; border: 0; }
.cards .ld td:empty { display: none; }
.cards .ld .c-pick { width: auto; padding-top: 2px; }
.cards .ld .c-img { order: 1; width: auto; }
/* имя — в строке со ступенью, если ему остаётся ≥160 px, иначе своей строкой; оси — всегда с новой строки (::after) */
.cards .ld .c-name { order: 2; flex: 1 1 max(calc(100% - 200px), 160px); min-width: 0; }
.cards .ld tr:not(.src-row):has(.ax)::after { content: ""; order: 3; flex-basis: 100%; margin-top: -6px; }
.cards .ld .c-rung { order: 1; padding-top: 1px; }
.cards .ld .ax, .cards .ld .c-stock, .cards .ld .c-price { order: 4; flex: 1 1 auto; min-width: min(100%, 72px); max-width: 100%; /* ширина по содержимому, ряд добивается растяжением */ text-align: left; white-space: normal; overflow-wrap: break-word; font-size: 12px; }
.cards .ld .ax.diff { padding: 0; }
.cards .ld td[data-l]::before { content: attr(data-l); display: block; font-size: 10.5px; font-weight: 600; color: var(--ink-3); }
/* карточка кандидата: отличия, «нет данных», склад и цена; совпавшие оси — одной строкой */
.cards .ld tr:not(.src-row) .ax.match:not(.soft) { display: none; }
.cards .ld .c-same { display: block; order: 5; flex-basis: 100%; font-size: 12px; color: var(--ink-2); }
.cards .ld .c-same:empty { display: none; }
/* исходник — сплошной строкой «ось значение», а не сеткой */
.cards .ld .src-row { gap: 2px 12px; }
.cards .ld .src-row .c-name { flex-basis: 100%; }
.cards .ld .src-row .ax { flex: 0 1 auto; min-width: 0; }
.cards .ld .src-row td[data-l]::before { display: inline; margin-right: 4px; font-size: 11px; }

/* side blocks */
.blocks { margin-top: 32px; max-width: 900px; } /* D-034: остался один блок — «Спорные» */
.side-block h2 { font-size: 15px; font-weight: 650; display: flex; gap: 8px; align-items: baseline; }
.side-block > .muted { font-size: 12.5px; margin: 4px 0 8px; max-width: 60ch; }
.plain-list .item { padding: 10px 0; border-top: 1px solid var(--line); display: grid; gap: 3px; }
.plain-list .item p { overflow-wrap: anywhere; }
.plain-list .item a { font-size: 12.5px; }
.empty { padding: 28px 16px; color: var(--ink-2); }
.keys { font-size: 12px; margin-top: 28px; }
.keys kbd { margin: 0 1px; }

/* totals */
.totals {
  position: sticky; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: var(--cols); align-items: end; gap: 8px 0;
  padding: 8px var(--edge); background: color-mix(in oklch, var(--surface) 96%, transparent); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); box-shadow: 0 -6px 16px -12px oklch(24% 0.02 260 / .18);
}
.tot { display: grid; line-height: 1.25; padding-inline: 16px; grid-row: 1; }
[data-tot=innolux] { grid-column: 2; }
[data-tot=navigator] { grid-column: 3; padding-inline-end: calc(var(--act-w, 0px) + 24px); } /* кнопка стоит в этой же ячейке: текст итога переносится до неё (--act-w — app.js) */
.tot-brand { font-size: 11.5px; font-weight: 600; color: var(--ink-2); }
.tot-sum { font-size: 16px; font-weight: 650; }
.tot-meta { font-size: 11.5px; }
.tot-note { font-size: 11.5px; max-width: 48ch; line-height: 1.3; grid-column: 1; grid-row: 1; padding-inline: 16px; }
/* кнопка у правого края ведомости; сообщение над ней, не шире её — ничего не сдвигает */
.tot-act { grid-column: 3; grid-row: 1; justify-self: end; width: min-content; display: grid; justify-items: end; gap: 2px; }
.tot-act .btn { height: 38px; padding: 0 18px; font-size: 13.5px; }
.gen-msg { font-size: 12.5px; color: var(--ink-2); text-align: right; }
.gen-msg:empty { display: none; }
.gen-msg.error { color: var(--danger); }
.gen-msg.ok { color: var(--good); }
.tot-meta .warn { color: var(--warn); font-weight: 550; }

/* ---------- narrow ---------- */
@media (max-width: 1100px) {
  :root { --cols: minmax(220px, 0.8fr) minmax(0, 1fr) minmax(0, 1fr); }
}
/* планшет: имя файла важнее названия сервиса — видно ~27 знаков и на 761 px */
@media (max-width: 1000px) { #screen-results .topbar .wordmark { display: none; } }
/* до ~1300 px колонка Navigator уже суммы с пометкой и кнопки: итоги подряд, кнопка своей колонкой у правого края */
@media (max-width: 1300px) {
  .totals { grid-template-columns: auto auto minmax(0, 1fr) auto; column-gap: 12px; }
  [data-tot=innolux] { grid-column: 1; }
  [data-tot=navigator] { grid-column: 2; padding-inline-end: 16px; }
  .tot-note { grid-column: 3; padding-inline: 8px 0; }
  .tot-act { grid-column: 4; }
}

/* ведомость стопкой (телефон, планшет в портрете до 960 px): исходник сверху, под ним лесенка и бренды.
   Низкий широкий экран (телефон в альбомной) остаётся в три колонки — иначе от аналогов виден один край. */
@media (max-width: 599px), (max-width: 960px) and (min-height: 501px) {
  :root { --stick: var(--top); } /* шапки колонок нет — подписи лесенки липнут сразу под шапкой */
  .cols-head { display: none; }
  #pos-list { margin-top: 12px; }
  /* лесенка раскрывается сразу под кнопкой, до выбранных вариантов */
  .pos:not(.removed) { display: grid; grid-template-columns: 1fr; }
  .pos-grid { display: contents; }
  .ladder { order: 1; }
  .pick { order: 2; border-left: 0; border-top: 1px solid var(--line); }
  .src-act { flex-wrap: nowrap; }
  .brand-name { display: inline; }
  .pick-head .rung { margin-left: auto; }
}

/* телефон: шапка не липнет и укладывается в две строки, ведомость на всю ширину */
@media (max-width: 760px) {
  :root { --stick: 0px; }
  html { scroll-padding-top: 36px; }
  .topbar { position: static; height: auto; flex-wrap: wrap; gap: 4px 8px; padding: 6px 12px; }
  .topbar .spacer { display: none; }
  .topbar .wordmark { flex: 1; }
  #screen-results .topbar .wordmark { display: none; }
  .file-chip { flex: 1 1 0; max-width: none; }
  .counts { order: 6; flex: 1 1 100%; gap: 0; margin: 0 -8px; }
  .topbar .btn.ghost { padding: 0 8px; }
  .sheet { padding: 0 8px 20px; }
  .pos-grid > * { padding: 12px; }
  .thumb { width: 36px; height: 36px; }
  .src-act [data-do=remove] { flex: none; width: 44px; padding: 0; }
  .removed { padding: 10px 12px; }
  .ladder { padding: 4px 12px 12px; }
  .blocks { margin-top: 24px; }
}
/* iPhone SE: подпись «Кол-во» только для экранного диктора — ряд кол-во · лесенка · удалить не рвётся */
@media (max-width: 380px) {
  .qty > span:first-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .qty input { width: 68px; }
}

@media (min-width: 600px) and (max-width: 760px) { .counts { order: 0; flex: 0 1 auto; margin: 0; } } /* шапка в одну строку */
/* планшет в портрете: исходник на всю ширину, бренды рядом */
@media (min-width: 600px) and (max-width: 960px) and (min-height: 501px) {
  .pos:not(.removed) { grid-template-columns: 1fr 1fr; }
  .src, .ladder { grid-column: 1 / -1; }
  .pick + .pick { border-left: 1px solid var(--line); }
}

/* высокий планшет 600–760 в портрете: итоги целиком, подпись о цене — строкой под суммами, а не узкой колонкой */
@media (min-width: 600px) and (max-width: 760px) and (min-height: 901px) {
  .tot-note { grid-column: 1 / -1; grid-row: 2; padding-inline: 0; max-width: none; }
}

/* низкий экран (альбомный телефон): обвязка не липнет */
@media (max-height: 500px) {
  :root { --stick: 0px; }
  html { scroll-padding-top: 36px; }
  .topbar, .cols-head { position: static; }
}

/* компактные итоги (телефон, низкий планшет, альбомный телефон): видна одна строка «бренд · сумма | кнопка»,
   неполный итог помечен в ней же; «N поз.» и полная подпись о цене висят ниже края экрана
   (bottom < 0, --tot-tail считает app.js) и видны в конце страницы. Высокий планшет 600–760 — итоги целиком. */
@media (max-width: 599px), (max-width: 760px) and (max-height: 900px), (max-height: 500px) {
  .totals { grid-template-columns: auto 1fr auto; gap: 0 8px; padding: 6px 12px 8px; bottom: calc(-1 * var(--tot-tail, 0px)); }
  .tot, .tot-act { display: contents; }
  .tot-brand { grid-column: 1; align-self: baseline; }
  .tot-sum { grid-column: 2; font-size: 13.5px; align-self: baseline; }
  .tot-sum[data-miss]:not([data-miss=""])::after { content: attr(data-miss) " без цены или кол-ва"; display: block; font-size: 11px; font-weight: 550; color: var(--warn); }
  [data-tot=innolux] .tot-brand, [data-tot=innolux] .tot-sum { grid-row: 2; }
  [data-tot=navigator] .tot-brand, [data-tot=navigator] .tot-sum { grid-row: 3; }
  .tot-act .btn { grid-column: 3; grid-row: 2 / span 2; height: 44px; padding: 0 12px; white-space: normal; line-height: 1.15; max-width: 132px; }
  .gen-msg { grid-column: 1 / -1; grid-row: 1; max-width: none; text-align: left; margin-bottom: 4px; }
  .gen-msg:empty { display: none; }
  .tot-meta { grid-column: 1 / -1; }
  [data-tot=innolux] .tot-meta { grid-row: 4; margin-top: calc(8px + env(safe-area-inset-bottom)); }
  [data-tot=navigator] .tot-meta { grid-row: 5; }
  [data-tot=innolux] .tot-meta::before { content: "Innolux: "; }
  [data-tot=navigator] .tot-meta::before { content: "Navigator: "; }
  .tot-note { grid-column: 1 / -1; grid-row: 6; margin-top: 4px; font-size: 11px; }
}

/* касание: цели не меньше 44 px, поля 16 px (иначе Safari на iPhone зумит страницу при фокусе) */
@media (pointer: coarse) {
  .btn, .btn.small, .login .btn, .tot-act .btn { height: 44px; }
  .btn.small { padding: 0 12px; }
  input:not([type=radio]):not([type=file]) { height: 44px; font-size: 16px; }
  .qty input { width: 80px; }
  .price input { width: 124px; }
  input[type=radio] { width: 22px; height: 22px; }
  .counts a { display: inline-block; padding: 13px 10px; }
  .src-act { gap: 8px; }
  .topbar { gap: 4px 12px; }
  a.name { padding-block: 8px; }
  /* зона ссылки растит свою строку, а не заходит на название и оси: касание названия выбирает вариант */
  .ld .c-name .muted a { display: inline-block; padding: 8px; margin: 0 -8px; }
  .ld .c-name label { padding-block: 4px; }
  .plain-list .item a { display: inline-block; padding-block: 10px; }
  /* пока открыта экранная клавиатура (класс kb — app.js) и фокус в поле, итоги не липнут и не закрывают поля */
  body.kb:has(#pos-list input:not([type=radio]):focus) .totals { position: static; }
}

/* подпись «Удалить» на касании — только если в колонке исходника есть место; иначе иконка в ряду с количеством */
@media (pointer: coarse) { @container src (min-width: 360px) {
  .sr-mobile { display: inline; }
  .src-act [data-do=remove] { width: auto; min-width: 44px; padding: 0 10px; } /* с подписью — по ширине текста */
} }
@media (pointer: coarse) and (min-width: 761px) { .sr-mobile { display: inline; } } /* ряд переносится — подпись не мешает */
/* подсказка клавиш — пока есть клавиатура, при любой ширине (масштаб 200%, узкое окно) */
@media (hover: none) and (pointer: coarse) { .keys { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation: none !important; }
}
