: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;
  --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 > :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--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; }
.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"); }
.hint { margin: var(--s2) 0 0; font-size: var(--fs-sm); color: var(--muted); font-weight: 400; }
.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; }
.files li { display: flex; gap: var(--s2); align-items: baseline; padding: var(--s1) 0; overflow-wrap: anywhere; }
.files li > span:first-child { flex: 0 0 auto; min-width: 96px; 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); }
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 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, .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.off, tr.off .st { color: var(--off); background: var(--off-bg); }
tr.bad .st, tr.off .st { margin-left: 0; }
.st { margin-left: 0; }
h2 > span.ok, h2 > span.bad, h2 > span.warn, h2 > span.off { 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__head small { margin-left: auto; font-size: var(--fs-sm); font-weight: 400; }
.legend li { display: flex; gap: var(--s3); align-items: baseline; }
.legend li > span:first-child { flex: 0 0 auto; min-width: 190px; text-align: left; }

@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; }
