:root {
  color-scheme: light;
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f0f2f5;
  --line: #d9dde3; --line-strong: #b6bdc7;
  --text: #1c2430; --muted: #566173;
  --on-accent: #ffffff; --accent: #1f5fbf; --accent-dark: #184c99; --accent-soft: #e8f0fc;
  --ok: #1a6b34; --ok-bg: #e3f4e8; --bad: #b3261e; --bad-bg: #fdeceb;
  --tile-good-bg: #e4f2e8; --tile-bad-bg: #f8e3e3; --tile-flat-bg: #eceff4;
  --chip-bg: #ffffff; --chip-good: var(--ok); --chip-bad: var(--bad);
  --warn: #8a5a00; --warn-bg: #fff4d6; --off: #566173; --off-bg: #eceef1; --disabled: #8b94a1;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 15px; --fs-lg: 18px; --fs-xl: 24px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --r: 6px; --r-lg: 8px; --fs-brand: 16px; --anchor-gap: 200px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); font: var(--fs-md)/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { font-size: var(--fs-xl); margin: 0 0 var(--s4); line-height: 1.25; overflow-wrap: anywhere; }
h2 { font-size: var(--fs-lg); margin: 0 0 var(--s3); }
h3 { font-size: var(--fs-md); font-weight: 600; margin: var(--s4) 0 var(--s2); }
.wrap, footer { width: 100%; max-width: 1200px; margin: 0 auto; padding-left: var(--s5); padding-right: var(--s5); }
.main { flex: 1; padding-top: var(--s5); padding-bottom: var(--s6); }
footer { font-size: var(--fs-xs); color: var(--muted); padding-bottom: var(--s5); text-align: center; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar__in { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s4); min-height: 52px; }
.brand { font-size: var(--fs-brand); font-weight: 600; text-decoration: none; color: var(--text); }
.menu { display: flex; flex-wrap: wrap; gap: var(--s1); }
.menu a, .menu__off { padding: var(--s2) var(--s3); border-bottom: 2px solid transparent; text-decoration: none; color: var(--text); }
.menu a[aria-current="page"] { border-bottom-color: var(--accent); font-weight: 600; }
.menu__off { color: var(--disabled); cursor: not-allowed; }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.who { color: var(--muted); overflow-wrap: anywhere; }
.inline { display: inline; margin: 0; }
.context { background: var(--accent-soft); border-bottom: 1px solid var(--line); }
.context__in { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s1) var(--s5); padding-top: var(--s2); padding-bottom: var(--s2); }
.seller { font-size: var(--fs-lg); font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.seller-none { font-weight: 600; }
.seller + .context__why, .seller-none + .context__why { border-left: 2px solid var(--line-strong); padding-left: var(--s3); }
.context__why { color: var(--muted); font-size: var(--fs-sm); }
.back { font-size: var(--fs-sm); margin: 0 0 var(--s3); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s5); margin-bottom: var(--s4); }
.card--ok { border-left: 4px solid var(--ok); }
.card--bad { border-left: 4px solid var(--bad); }
.card--warn { border-left: 4px solid var(--warn); }
.card > :last-child { margin-bottom: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.page-head h1 { margin: 0; }
.narrow { max-width: 860px; }
.auth { max-width: 380px; margin: var(--s6) auto 0; }
.auth:has(.card--bad) { max-width: 560px; }

.btn { display: inline-block; padding: 9px 18px; border: 0; border-radius: var(--r); background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; text-align: center; }
.btn:hover { background: var(--accent-dark); }
.btn--ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: var(--surface); color: var(--bad); border: 1px solid var(--bad); }
.btn--danger:hover { background: var(--bad-bg); }
.form--danger { margin-top: 24px; }
.btn--sm { padding: 5px 12px; font-size: var(--fs-sm); }
.btn[disabled] { opacity: .6; cursor: default; }
.auth .form .btn { width: 100%; }
.state p:has(.btn) { display: flex; flex-wrap: wrap; gap: var(--s2); }

.form { display: flex; flex-direction: column; gap: var(--s4); }
.form--row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s2); }
.form--row .field { flex: 1; min-width: 200px; }
.form--row .field--market { flex: 0 0 180px; min-width: 140px; }
.field { display: block; font-size: var(--fs-sm); font-weight: 600; }
.field label:not(.btn), .field__label { display: block; margin-bottom: var(--s1); font-size: var(--fs-sm); font-weight: 600; }
input[type=text], input[type=password], input:not([type]), select { display: block; width: 100%; height: 38px; padding: 0 var(--s3); border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); color: var(--text); font: inherit; font-weight: 400; }
.form--row > input { flex: 1; width: auto; min-width: 160px; }
.pw { position: relative; display: block; }
.pw input { padding-right: 40px; }
.pw__toggle { position: absolute; right: 4px; top: 5px; width: 28px; height: 28px; padding: 0; border: 0; border-radius: var(--r); background: url("/static/eye.svg") center / 20px no-repeat; cursor: pointer; }
.pw__toggle[aria-pressed="true"] { background-image: url("/static/eye-off.svg"); }
.field__error { margin: var(--s1) 0 0; font-size: var(--fs-sm); font-weight: 600; color: var(--bad); }
.field--bad input, .field--bad select { border-color: var(--bad); border-width: 2px; }
.hint { margin: var(--s2) 0 0; font-size: var(--fs-sm); color: var(--muted); font-weight: 400; }
.hints { margin: 0 0 var(--s2); padding-left: var(--s5); color: var(--muted); font-size: var(--fs-sm); }
.hints li { margin-bottom: var(--s2); }
.file { padding: var(--s4); border: 1.5px dashed var(--line-strong); border-radius: var(--r-lg); background: var(--surface-2); }
.file input[type=file] { width: 100%; font: inherit; }
.file ::file-selector-button { margin-right: var(--s3); padding: 5px 12px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; }
.file__chosen { margin: var(--s2) 0 0; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.js .file input[type=file] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.js .file { position: relative; }
.file:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.progress progress { display: block; width: 100%; height: 10px; accent-color: var(--accent); }
.progress__text { margin: var(--s2) 0 0; min-height: 1.5em; font-size: var(--fs-sm); }
/* Место под полосу занято заранее (виден лишь скрипт-режим): кнопка не прыгает при отправке. */
.js .progress[hidden] { display: block !important; visibility: hidden; }
#upload { scroll-margin-top: var(--s5); }
.upload[aria-busy="true"] .file { opacity: .6; }

.files { list-style: none; margin: 0 0 var(--s3); padding: 0; }
/* Блок, а не flex: длинный текст переносится рядом с плашкой, а не уходит под неё. */
.files li { padding: var(--s1) 0; overflow-wrap: anywhere; }
.files li > span { margin-right: var(--s2); }
.files li > span:first-child { flex: 0 0 auto; min-width: 96px; max-width: 100%; white-space: normal; text-align: center; }
.next { font-weight: 600; margin: var(--s3) 0; }
.totals { font-weight: 600; font-variant-numeric: tabular-nums; margin: 0 0 var(--s3); }
.note { color: var(--muted); font-size: var(--fs-sm); }
.empty { color: var(--muted); text-align: center; padding: var(--s5) 0; }
.msg { padding: var(--s3) var(--s4); border-radius: var(--r); border-left: 4px solid; margin: 0 0 var(--s4); overflow-wrap: anywhere; }
.msg.bad { color: var(--bad); background: var(--bad-bg); border-color: var(--bad); }
.msg.ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok); }
.msg.warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); margin: 0 0 var(--s4); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th { background: var(--surface-2); font-weight: 600; text-align: left; white-space: nowrap; }
th, td { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child > td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.stages { min-width: 760px; }
td a { font-weight: 600; overflow-wrap: anywhere; }
.row-bad { background: var(--bad-bg); }
.row-warn { background: var(--warn-bg); }
.row-info { background: none; }
ul.attention { list-style: none; margin: var(--s2) 0; padding: 0; }
ul.attention li { margin: var(--s2) 0; }
ul.attention .where { display: block; font-size: var(--fs-sm); color: var(--muted, inherit); }
table.stages tr[id] { scroll-margin-top: var(--anchor-gap); }
tr:target, .row-bad:target, .row-warn:target { background: var(--accent-soft); outline: 2px solid var(--accent); outline-offset: -2px; }
table.sellers { table-layout: fixed; min-width: 640px; }
table.sellers .col-name { width: 32%; }
table.sellers .col-state { width: 38%; }
table.sellers .col-rename { width: 30%; }
table.sellers td { overflow-wrap: anywhere; }
table.sellers tr.entity-row td { background: var(--surface-2, var(--accent-soft)); border-top: 2px solid var(--line-strong); }
.entity-name { font-size: var(--fs-lg); overflow-wrap: anywhere; }
.entity-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--s2) var(--s4); margin-top: var(--s1); }
.entity-actions form { margin: 0; }
.entity .form--row .field { min-width: 160px; }
table.sellers span.ok, table.sellers span.bad, table.sellers span.warn, table.sellers span.off { white-space: normal; }
.row-links { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); margin-top: var(--s1); }
.rename summary { cursor: pointer; color: var(--accent); }
.rename form { margin-top: var(--s2); }

span.ok, span.bad, span.warn, span.off, span.info, .st { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; margin-left: var(--s2); }
.files li > span, .table-wrap td > span { margin-left: 0; }
span.ok, .st { color: var(--ok); background: var(--ok-bg); }
span.bad, tr.bad .st { color: var(--bad); background: var(--bad-bg); }
span.warn { color: var(--warn); background: var(--warn-bg); }
span.info { color: var(--accent); background: var(--accent-soft); }
tr.warn .st { color: var(--warn); background: var(--warn-bg); }
span.off, tr.off .st { color: var(--off); background: var(--off-bg); }
tr.bad .st, tr.off .st, tr.warn .st { margin-left: 0; }
table.uploads .st { white-space: normal; }
details.remarks > summary { cursor: pointer; color: var(--warn); font-weight: 600; }
details.remarks > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
details.remarks ul { list-style: none; margin: var(--s2) 0 0; padding: 0; }
details.remarks li { margin-bottom: var(--s2); overflow-wrap: anywhere; white-space: normal; }
.st { margin-left: 0; }
h2 > span.ok, h2 > span.bad, h2 > span.warn, h2 > span.off, h2 > span.info { white-space: normal; vertical-align: middle; }
.week__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2) var(--s3); overflow-wrap: anywhere; }
.week__head > span { margin-left: 0; }
.week__tools { margin: 0 0 var(--s3); }
.week-fold > summary { cursor: pointer; margin-bottom: var(--s3); }
.week-fold > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.week-fold > summary h2 { display: inline-flex; margin: 0; vertical-align: baseline; }
.week-fold:not([open]) > summary { margin-bottom: 0; }
.legend li { display: flex; gap: var(--s3); align-items: baseline; }
.legend li > span:first-child { flex: 0 0 auto; min-width: 190px; max-width: 100%; text-align: left; }
.legend-fold > summary { cursor: pointer; }
.legend-fold > summary h2 { display: inline; margin: 0; }

/* Узкий экран: строка этапа и строка таблицы под ним — карточка, подпись у каждого значения. */
@media screen and (max-width: 768px) {
  .table-wrap:has(table.stages), .table-wrap:has(table.found), .table-wrap:has(table.cards) { overflow-x: visible; border: 0; }
  table.stages, table.found, table.cards { min-width: 0; }
  table.stages thead, table.found thead, table.cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.stages, table.stages tbody, table.stages tr, table.stages td,
  table.found, table.found tbody, table.found tr, table.found td,
  table.cards, table.cards tbody, table.cards tr, table.cards th, table.cards td { display: block; width: auto; }
  table.stages tr, table.found tr, table.cards tr { margin-bottom: var(--s3); padding: var(--s2) var(--s3); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
  table.stages tr.row-bad { background: var(--bad-bg); }
  table.stages tr.row-warn { background: var(--warn-bg); }
  table.cards th, table.cards td { padding: var(--s1) 0; border-bottom: 0; overflow-wrap: anywhere; white-space: normal; text-align: left; background: none; }
  table.cards td.fname { font-weight: 600; }
  table.uploads tr.explain { margin-top: 0; border-top: 0; border-radius: 0 0 var(--r-lg) var(--r-lg); margin-bottom: var(--s3); }
  table.uploads tr:has(+ tr.explain) { border-bottom: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; margin-bottom: 0; }
  table.cards td.fname[data-label]::before { content: none; }
  table.cards th[data-label]::before, table.cards td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-weight: 600; }
  table.stages td, table.found td { padding: var(--s1) 0; border-bottom: 0; overflow-wrap: anywhere; white-space: normal; text-align: left; }
  table.stages td:empty, table.found td:empty, table.cards td:empty { display: none; }
  table.stages td::before, table.found td::before { content: attr(data-label) ": "; color: var(--muted); font-weight: 600; }
  /* Номер и название — заголовок карточки на одной строке, без подписей. */
  table.stages td[data-label="№"], table.stages td.stage__name { display: inline; font-weight: 600; }
  table.stages td[data-label="№"]::before, table.stages td.stage__name::before { content: none; }
  table.stages td[data-label="№"]::after { content: ". "; }
  table.stages td.stage__status { margin-top: var(--s1); }
  .table-wrap table.found td:last-child:not(.num), .table-wrap table.cards td:last-child:not(.num) { min-width: 0; }
}
@media (max-width: 900px) {
  .menu { order: 3; flex: 1 0 100%; }
}
@media (max-width: 640px) {
  .wrap, footer { padding-left: var(--s4); padding-right: var(--s4); }
  h1 { font-size: 20px; }
  .card { padding: var(--s4); }
  .menu a, .menu__off { flex: 1 0 45%; }
  .form--row { flex-direction: column; align-items: stretch; }
  .form--row > input { flex: none; }
  .form--row .btn, .form .btn, .state p:has(.btn) .btn { width: 100%; }
  .legend li { flex-direction: column; gap: var(--s1); }
  /* Узкий экран: строка селлера — карточка, чтобы «Переименовать» не пряталось за прокруткой. */
  table.sellers { min-width: 0; }
  table.sellers thead { display: none; }
  table.sellers tr, table.sellers td { display: block; width: auto; }
  table.sellers td { border-bottom: 0; padding-bottom: var(--s1); }
  table.sellers tr { border-bottom: 1px solid var(--line); padding: var(--s2) 0; }
  .table-wrap td:last-child:not(.num) { min-width: 0; }
}
.table-wrap td:last-child:not(.num) { min-width: 220px; }
/* Таблицы этапов «Проверки»: длинный текст («Что не так») переносится, таблица не шире карточки.
   Только в табличном виде: на ≤ 768 px строки уже карточки. */
@media (min-width: 769px) {
  table.found td:not(.num) { white-space: normal; overflow-wrap: anywhere; }
  .table-wrap table.found td:last-child:not(.num) { min-width: 160px; }
  table.found td.code { white-space: nowrap; overflow-wrap: normal; }  /* баркод и артикул не рвём */
}
table.uploads { table-layout: auto; }
table.uploads td, table.uploads th { min-width: 0; }
table.uploads td.fname { min-width: 160px; }
table.uploads .fname__name { overflow-wrap: anywhere; }
table.uploads .fmeta { display: block; color: var(--muted); font-size: var(--fs-sm); margin-top: var(--s1); white-space: normal; }
table.uploads td[colspan] { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
table.uploads tr:has(+ tr.explain) > td { border-bottom: 0; }
.week--compact p { margin: 0; overflow-wrap: anywhere; }
.week--compact a { margin-left: var(--s2); }
/* Печать: свёрнутые недели раскрываются. */
@media print {
  details.week-fold::details-content, details.more::details-content { content-visibility: visible; display: block; }
  details.week-fold:not([open]) > :not(summary) { display: block; }
  details.more:not([open]) > :not(summary) { display: block; }
}

details.more > summary { cursor: pointer; color: var(--accent); margin: 0 0 var(--s3); }
ul.note { padding-left: var(--s5, 1.25rem); }
.nowrap { white-space: nowrap; }
table.stages .todo { display: block; margin-top: var(--s1); }
.checks-wait [hidden] { display: none; }
.check { display: flex; align-items: center; gap: var(--s2); font-weight: 400; margin-bottom: var(--s2); }
fieldset.field { border: 0; padding: 0; margin: 0; }
.secret { display: inline-block; padding: var(--s2) var(--s3); font-size: 1.25rem; letter-spacing: 0.05em; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); user-select: all; overflow-wrap: anywhere; }
.row-off td { color: var(--muted); }
.auth .card > .hint:first-of-type { margin-bottom: var(--s4); }
table.compare tbody th { background: none; font-weight: 400; white-space: normal; }
table.compare tr.row-bad th { font-weight: 600; }
@media screen and (max-width: 768px) {
  table.compare tbody th { font-weight: 600; }
  table.compare tr.row-bad { background: var(--bad-bg); }
}
table.compare .why { display: block; margin-top: var(--s1); font-size: var(--fs-sm); font-weight: 400; color: var(--muted, inherit); }
