:root {
  --ink: #17202a;
  --muted: #687385;
  --line: #dfe4ea;
  --surface: #ffffff;
  --canvas: #f4f6f8;
  --accent: #2067e8;
  --accent-dark: #164fae;
  --danger: #b72d2d;
  --warning: #9a6400;
  --success: #117a47;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
/* Отступ под фиксированной панелью действий считается от её настоящей высоты
   (--action-bar-height ставит app.js): состав кнопок менялся дважды за день, и
   подобранное на глаз значение оставило последнюю карточку под панелью —
   поле «Новая цена» у неё стало недоступно (жалоба Ole 2026-08-14). */
body { margin: 0; min-height: 100vh; padding-bottom: calc(var(--action-bar-height, 92px) + 20px); }
button, input, select, textarea { font: inherit; }
button { min-height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; background: var(--surface); color: var(--ink); cursor: pointer; }
button:hover { border-color: #aeb8c4; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #99baf7; outline-offset: 2px; }
button.primary { background: var(--accent); border-color: var(--accent); color: white; font-weight: 650; }
button.primary:hover { background: var(--accent-dark); }
button:disabled { opacity: .45; cursor: not-allowed; }
input, select, textarea { min-height: 42px; max-width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: white; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.topbar { height: 62px; padding: 10px max(16px, env(safe-area-inset-left)); display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar strong { display: block; font-size: 18px; }
.topbar span { color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.status-pill { border-radius: 999px; padding: 6px 10px; background: #edf2f7; }
.status-pill.ok { background: #ddf5e8; color: var(--success); }
.status-pill.warn { background: #fff1ce; color: var(--warning); }
.status-pill.danger { background: #ffe4e4; color: var(--danger); }
.icon-button { min-width: 32px; width: 32px; min-height: 32px; height: 32px; padding: 0; border-radius: 50%; font-weight: 750; color: var(--accent); }
.readonly-banner { background: #fff1ce; color: #6b4800; padding: 9px 16px; text-align: center; font-size: 13px; }
.tabs { display: flex; gap: 4px; padding: 10px 16px 0; max-width: 1280px; margin: auto; overflow-x: auto; }
.tabs, .filters { scrollbar-width: none; }
.tabs::-webkit-scrollbar, .filters::-webkit-scrollbar { display: none; }
.tab { border: 0; background: transparent; border-radius: 8px 8px 0 0; color: var(--muted); white-space: nowrap; }
.tab.active { color: var(--accent); background: var(--surface); box-shadow: inset 0 -2px var(--accent); }
.tab-link { display: grid; place-items: center; text-decoration: none; padding: 8px 14px; }
.back-link { color: var(--accent); text-decoration: none; font-weight: 650; }
main { max-width: 1280px; margin: auto; padding: 12px 16px 32px; }
.panel { display: none; }
.panel.active { display: block; }
.toolbar { display: grid; grid-template-columns: auto minmax(260px, 1fr); gap: 10px 16px; align-items: center; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.segmented { display: flex; padding: 3px; border-radius: 12px; background: #edf1f5; }
.segmented button { min-height: 36px; border: 0; background: transparent; padding: 6px 13px; }
.segmented button.active { background: white; color: var(--accent); box-shadow: 0 1px 5px #1f293722; }
.search { position: relative; display: block; }
.search span { position: absolute; left: 12px; top: 8px; font-size: 22px; color: var(--muted); }
.search input { width: 100%; padding-left: 38px; }
.filters { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.filter-select { display: inline-flex; align-items: center; gap: 6px; }
.filter-select select { padding: 4px 6px; }
.filters label { display: flex; align-items: center; gap: 7px; color: var(--ink); }
.filters input { min-height: 0; }
.summary-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; color: var(--muted); font-size: 13px; }
.summary-row span { background: #e9edf2; border-radius: 999px; padding: 5px 9px; }
.brand-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.brand-chips .chip { background: #e9edf2; border: 1px solid transparent; border-radius: 999px; padding: 6px 11px; font-size: 13px; color: var(--muted); cursor: pointer; }
.brand-chips .chip.active { background: #1f6feb; border-color: #1f6feb; color: #fff; }
.brand-chips .chip small { opacity: .7; }
.step-picker { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.step-picker select { padding: 6px 4px; }
.select-all-row { display: flex; align-items: center; gap: 8px; margin: 0 0 8px 2px; font-size: 14px; color: var(--muted); cursor: pointer; }
.select-all-row input { width: 18px; height: 18px; }
.catalog { display: grid; gap: 8px; }
.product-row { display: grid; grid-template-columns: 34px minmax(260px, 2fr) 118px 116px 172px 116px; gap: 10px 14px; align-items: center; min-width: 0; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.product-row.review { border-left: 4px solid #e3a321; }
.product-title { min-width: 0; }
/* Название не обрезаем нигде: «HUAWEI PURA 90S PRO 12+…» у трёх соседних позиций
   с разными ценами выглядело одинаково, и понять, что за модель, было нельзя. */
.product-title strong { display: block; overflow-wrap: anywhere; line-height: 1.3; }
.product-title small { display: block; margin-top: 3px; color: var(--muted); }
.cell-label { display: block; color: var(--muted); font-size: 11px; }
/* Остаток и резерв — одной строкой: в узкой колонке они переносились по слову
   и растягивали карточку вчетверо. */
.stock-cell { display: flex; align-items: baseline; gap: 10px; }
.stock-cell .cell-label { display: inline; }
.price-cell b { font-variant-numeric: tabular-nums; }
.draft-price { width: 100%; min-width: 86px; }
.show-state { min-height: 34px; padding: 6px 8px; font-size: 12px; color: var(--muted); text-align: left; }
.show-state.on { color: var(--success); }
.both-row { grid-template-columns: 34px minmax(220px, 1fr) minmax(460px, 2fr); }
.both-prices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.context-price { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 9px; border: 1px solid var(--line); border-radius: 10px; }
.context-price > span { color: var(--muted); font-size: 12px; }
.context-price .price-cell { display: grid; grid-template-columns: 86px 1fr; gap: 8px; align-items: center; }
.context-price.missing { color: var(--muted); align-content: center; }
.action-bar { position: fixed; z-index: 25; bottom: 0; left: 0; right: 0; min-height: 72px; padding: 10px max(16px, calc((100vw - 1248px) / 2)); padding-bottom: max(10px, env(safe-area-inset-bottom)); background: #ffffffee; backdrop-filter: blur(12px); border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; box-shadow: 0 -8px 28px #17202a12; }
.action-bar > div { display: flex; gap: 7px; }
.section-heading { display: flex; align-items: start; justify-content: space-between; margin: 8px 0 14px; }
.section-heading h1 { margin: 0; font-size: 23px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); }
.card { padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.row-card { display: flex; gap: 12px; align-items: end; }
.row-card label { flex: 1; }
.price-preview { min-height: 360px; max-height: 62vh; overflow: auto; padding: 16px; background: #101820; color: #f6f7f9; border-radius: var(--radius); white-space: pre-wrap; font: 14px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
.publication-actions { display: flex; justify-content: end; gap: 8px; flex-wrap: wrap; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; min-width: 0; }
.setting-card, .form-grid, .form-grid > *, .inline-admin { min-width: 0; }
.setting-card h2 { margin: 0 0 4px; font-size: 17px; }
.setting-card p { color: var(--muted); margin: 0 0 12px; }
.settings-form { display: grid; gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.form-grid fieldset { display: flex; flex-wrap: wrap; gap: 12px; max-width: 100%; border: 1px solid var(--line); border-radius: 10px; }
.form-grid legend { color: var(--muted); font-size: 12px; }
.check { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 7px; color: var(--ink); }
.check input { min-height: 0; }
.wide-field { grid-column: 1 / -1; }
.wide-field textarea { width: 100%; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.inline-admin { display: grid; grid-template-columns: 140px minmax(120px, 1fr) auto auto auto; gap: 8px; align-items: center; margin-top: 8px; }
.stack { display: grid; gap: 12px; }
.wide { width: 100%; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.history-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.history-item > div small, .history-item > small { display: block; color: var(--muted); margin-top: 3px; }
.history-item > p { grid-column: 1 / -1; margin: 0; color: var(--danger); overflow-wrap: anywhere; }
.audit-row { display: grid; grid-template-columns: 165px minmax(160px, 1fr) minmax(100px, auto); gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.audit-row span { color: var(--muted); }
.login-page { display: grid; place-items: center; padding: 20px; }
.login-card { width: min(410px, 100%); padding: 28px; background: white; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 18px 70px #17202a18; }
.login-card h1 { margin: 12px 0 4px; }
.brand-mark { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 14px; background: var(--accent); color: white; font-weight: 800; }
.muted { color: var(--muted); }
.alert { padding: 10px 12px; border-radius: 10px; margin: 10px 0; }
.alert.danger { background: #ffe4e4; color: var(--danger); }
.hidden { display: none !important; }
dialog { width: min(760px, calc(100% - 24px)); max-height: 90vh; border: 0; padding: 0; border-radius: 18px; box-shadow: 0 30px 100px #0005; }
dialog::backdrop { background: #17202a88; backdrop-filter: blur(2px); }
.dialog-shell { padding: 18px; overflow: auto; max-height: 90vh; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-heading h2 { margin: 0; }
.dialog-heading button { border: 0; font-size: 24px; }
.dialog-actions { display: flex; justify-content: end; gap: 8px; margin-top: 14px; }
.diff-list { display: grid; gap: 7px; max-height: 54vh; overflow: auto; }
.diff-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.diff-row .arrow { color: var(--muted); }
.action-status { color: var(--muted, #6b7785); }
.action-status:not(:empty) { display: inline; }
.toast { position: fixed; z-index: 50; right: 16px; bottom: 92px; max-width: min(430px, calc(100% - 32px)); background: #17202a; color: white; padding: 11px 14px; border-radius: 10px; opacity: 0; pointer-events: none; transform: translateY(10px); transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.test-page { padding-bottom: 32px; }
.test-main { display: grid; gap: 12px; max-width: 960px; }
.test-scope { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; }
.test-scope h1, .test-status-card h2, .test-history-card h2 { margin: 0 0 6px; }
.test-scope p, .test-scope ul { color: var(--muted); }
.test-scope p { margin: 0; }
.test-scope ul { grid-column: 1 / -1; margin: 8px 0 0; padding-left: 20px; }
.test-controls { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.test-catalog { display: grid; gap: 8px; max-height: 48vh; overflow: auto; }
.test-product { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; min-height: 70px; text-align: left; padding: 12px; }
.test-product.selected { border: 2px solid var(--accent); background: #edf4ff; }
.test-product b, .test-product small { display: block; }
.test-product small { color: var(--muted); margin-top: 3px; }
.test-product > span:last-child { text-align: right; }
.test-runner { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, 240px) auto; gap: 12px; align-items: end; position: sticky; bottom: 8px; z-index: 10; box-shadow: 0 12px 36px #17202a1f; }
.test-runner small { display: block; color: var(--muted); margin-top: 4px; }
.test-note { background: #e8f1ff; color: var(--accent-dark); }
.test-result { display: grid; gap: 8px; }
.test-result p { margin: 0; color: var(--danger); }

@media (max-width: 760px) {
  .tabs { padding-inline: 8px; }
  main { padding: 8px; }
  /* Телефон: шапка со всеми фильтрами занимала больше половины экрана, и на список
     оставалась одна карточка (Ole 2026-08-14: «сделай красиво и удобно»). Ужимаем
     всё вспомогательное и не липнем — при прокрутке список получает весь экран. */
  .toolbar { grid-template-columns: 1fr; padding: 8px; gap: 8px; position: static; }
  .toolbar .segmented button { min-height: 32px; padding: 5px 10px; }
  .search input { min-height: 38px; }
  .filters { font-size: 13px; }
  /* Счётчики дублируют чипы брендов («Все N») и строку выбора — на узком экране это
     был отдельный ряд ради цифры, которая уже видна дважды. */
  #catalogSummary { display: none; }
  .brand-chips { flex-wrap: nowrap; overflow-x: auto; margin-top: 8px; padding-bottom: 2px; }
  .brand-chips .chip { white-space: nowrap; }
  .select-all-row { margin: 8px 0 6px 2px; }
  .toolbar, .card, .setting-card { min-width: 0; max-width: 100%; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; }
  /* Полоса прокручивается, а не переносится: перенос дал четыре ряда (119 px)
     и с экрана ушёл сам список. Поэтому порядок контролов = порядок важности. */
  .filters { grid-column: 1; gap: 8px 12px; overflow-x: auto; flex-wrap: nowrap; }
  .filters label { white-space: nowrap; }
  /* Телефон: сначала читаемое имя, потом факты, потом ввод. Имя переносится и не
     обрезается — «HUAWEI PURA 90S PRO 12+…» у трёх соседних позиций выглядело
     одинаково при разных ценах, и понять, где какая модель, было нельзя
     (Ole 2026-08-14: «тут не вариант читать, что за модель»). */
  .product-row { grid-template-columns: 26px minmax(0, 1fr) auto; grid-template-areas: "check title show" "check stock price" "check draft draft"; align-items: start; gap: 5px 10px; padding: 10px 12px; }
  .product-row > input { grid-area: check; margin-top: 2px; width: 22px; height: 22px; }
  .product-title { grid-area: title; }
  .product-title strong { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; line-height: 1.3; font-size: 15px; }
  /* Подпись теперь несёт только то, чего нет в названии (см. subtitle в app.js),
     поэтому её видно и на телефоне — но мелко и одной строкой. */
  .product-title small { font-size: 12px; margin-top: 2px; }
  .product-row .stock-cell { grid-area: stock; display: flex; align-items: baseline; gap: 6px; color: var(--muted); font-size: 13px; }
  .product-row .stock-cell b { color: var(--ink); font-size: 15px; }
  .product-row .price-cell { display: flex; align-items: baseline; gap: 6px; }
  .product-row .current-price { grid-area: price; justify-content: end; }
  .product-row .current-price b { font-size: 16px; }
  /* Подпись над полем не нужна: то же самое написано в самом поле-подсказке,
     а лишняя строка стоит четверти карточки на телефоне. */
  .product-row .draft-cell { grid-area: draft; display: grid; grid-template-columns: 1fr; margin-top: 2px; }
  .product-row .draft-cell .cell-label { display: none; }
  .product-row .draft-price { min-height: 40px; }
  .product-row .cell-label { display: inline; font-size: 12px; }
  .product-row .show-state { grid-area: show; text-align: right; align-self: start; min-height: 28px; padding: 4px 8px; font-size: 12px; white-space: nowrap; }
  .both-row { grid-template-columns: 32px minmax(0, 1fr); grid-template-areas: "check title" "prices prices"; }
  .both-row .both-prices { grid-area: prices; grid-template-columns: 1fr; }
  .both-row .context-price .price-cell { grid-area: auto; }
  .both-row .context-price .show-state { grid-area: auto; text-align: left; }
  .desktop-only { display: none; }
  .action-bar { min-height: 116px; align-items: stretch; flex-direction: column; padding-inline: 10px; }
  /* Узкий экран: «Выбрать все» и шаг в первом ряду, проценты во втором,
     действие — во всю ширину. */
  /* Два ряда вместо четырёх: мелкое действие в верхнем, основное — во всю ширину. */
  .action-bar { min-height: 116px; gap: 8px; padding-top: 8px; }
  .action-bar > span { font-size: 13px; }
  .action-bar > div { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .action-bar button { min-height: 40px; padding-inline: 4px; font-size: 13px; white-space: nowrap; }
  /* Подпись главной кнопки должна умещаться в половину ряда: на 390 px «Проверить
     и сохранить» при 15px обрезалось по краю. */
  .action-bar .primary { font-size: 13.5px; padding-inline: 2px; }
  /* Порядок задаёт разметка: шаг, −%, +%, «Выбрать все» — первый ряд;
     «Вернуть в прайс» и «Проверить и сохранить» — по половине второго. */
  #toggleSelected, .action-bar .primary { grid-column: span 2; }
  .step-picker { justify-content: center; gap: 4px; }
  .step-picker select { flex: 1; min-height: 40px; }
  .action-bar button { padding-inline: 8px; }
  .settings-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .wide-field { grid-column: auto; }
  .inline-admin { grid-template-columns: 1fr; }
  .row-card { align-items: stretch; flex-direction: column; }
  .publication-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .publication-actions .primary { grid-column: 1 / -1; }
  .diff-row { grid-template-columns: 1fr auto; }
  .diff-row .name { grid-column: 1 / -1; }
  .audit-row { grid-template-columns: 1fr; gap: 2px; }
  .test-scope { grid-template-columns: 1fr; }
  .test-scope ul { grid-column: auto; }
  .test-controls, .test-runner { grid-template-columns: 1fr; }
  .test-product { grid-template-columns: 1fr; gap: 6px; min-height: 104px; }
  .test-product b { overflow-wrap: anywhere; }
  .test-product > span:last-child { display: flex; justify-content: space-between; gap: 12px; text-align: left; }
  .test-runner { bottom: 4px; }
}
