/* Единая дизайн-система интерфейса. Инлайн-стили и скрипты запрещены (CSP default-src 'self',
   тесты test_no_inline_styles_or_scripts), поэтому весь внешний вид и поведение — здесь. Порядок: токены, каркас, меню, типографика, кнопки и формы,
   таблицы, карточки и показатели, бейджи и сообщения, графики, частные блоки, адаптив. */

:root {
  color-scheme: light;
  --bg: #f4f3f8;
  --surface: #ffffff;
  --surface-2: #f9f8fc;
  --ink: #1d1a2e;
  --ink-2: #4f4b66;
  --muted: #736f88;
  --line: #e4e1ed;
  --line-strong: #cdc9db;
  --accent: #5a3fd0;
  --accent-hover: #4a31b8;
  --accent-ink: #ffffff;
  --accent-soft: #efebfd;
  --side-bg: #1e1936;
  --side-ink: #cfcae6;
  --side-muted: #918bb0;
  --side-hover: #2b2449;
  --side-active: #ffffff;
  --good: #0c6f45;  --good-bg: #e1f4e9;  --good-line: #a9dfc1;
  --warn: #8f5400;  --warn-bg: #fdf0d6;  --warn-line: #f1d08e;
  --bad: #b3261e;   --bad-bg: #fdeae8;   --bad-line: #f5c2bd;
  --info: #1e59b3;  --info-bg: #e5eefc;  --info-line: #b9d0f5;
  --s1: #2a78d6;  --s2: #eb6834;  --s3: #1baf7a;  --s4: #eda100;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(29, 26, 46, .06);
  --sidebar-w: 244px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #131120;
    --surface: #1c192b;
    --surface-2: #221f33;
    --ink: #ecebf4;
    --ink-2: #c5c1d8;
    --muted: #9c98b3;
    --line: #322e47;
    --line-strong: #46415f;
    --accent: #a393f7;
    --accent-hover: #b8abfa;
    --accent-ink: #171427;
    --accent-soft: #2a2447;
    --side-bg: #0f0d1a;
    --side-hover: #1f1b33;
    --good: #6fd3a2;  --good-bg: #12301f;  --good-line: #1f5237;
    --warn: #efbd5f;  --warn-bg: #33250a;  --warn-line: #5c4414;
    --bad: #f39189;   --bad-bg: #3a1614;   --bad-line: #6a2a25;
    --info: #8fb8f7;  --info-bg: #14233f;  --info-line: #25416f;
    --s1: #3987e5;  --s2: #d95926;  --s3: #199e70;  --s4: #c98500;
    --shadow: none;
  }
}

/* --- каркас ------------------------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); background: var(--bg); color: var(--ink); }
body.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.page { min-width: 0; display: flex; flex-direction: column; }
main { width: 100%; max-width: 760px; margin: 0; padding: 20px 28px 56px; }
main.wide { max-width: 1680px; }
body.guest main { max-width: 440px; margin: 48px auto; padding: 0 16px; }
.guest-header { display: flex; align-items: center; gap: 12px; padding: 14px 24px;
                background: var(--surface); border-bottom: 1px solid var(--line); }
.guest-header form { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px;
             border-radius: var(--radius-sm); z-index: 50; }
.skip-link:focus { left: 8px; }
[hidden] { display: none !important; }

/* --- боковое меню ------------------------------------------------------------------------------ */
.sidebar { background: var(--side-bg); color: var(--side-ink); display: flex; flex-direction: column;
           position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 16px 12px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 12px; color: #fff;
         text-decoration: none; font-weight: 650; line-height: 1.2; letter-spacing: -.01em; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; flex: none;
              background: linear-gradient(135deg, #8a6ff0 0 50%, #f2b84b 50% 100%); }
.menu { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.menu a { display: block; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--side-ink);
          text-decoration: none; }
.menu a:hover { background: var(--side-hover); color: #fff; }
.menu-home { font-weight: 600; }
.menu-group > summary { list-style: none; cursor: pointer; padding: 7px 10px; border-radius: var(--radius-sm);
                        font-weight: 600; display: flex; justify-content: space-between; align-items: center;
                        user-select: none; }
.menu-group > summary::-webkit-details-marker { display: none; }
.menu-group > summary::after { content: ""; width: 7px; height: 7px; border-right: 1.5px solid var(--side-muted);
                               border-bottom: 1.5px solid var(--side-muted); transform: rotate(-45deg);
                               transition: transform .15s; margin-right: 4px; }
.menu-group[open] > summary::after { transform: rotate(45deg); }
.menu-group > summary:hover { background: var(--side-hover); color: #fff; }
.menu-group.is-active > summary { color: #fff; }
.menu-group ul { list-style: none; margin: 2px 0 6px 10px; padding: 0 0 0 8px;
                 border-left: 1px solid rgba(255, 255, 255, .12); }
.menu-group li a { font-size: 14px; padding: 6px 10px; }
.menu a.is-active { background: var(--accent); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { .menu a.is-active { background: #4d37b3; } }
.sidebar-user { display: flex; justify-content: space-between; align-items: center; gap: 8px;
                padding: 10px; border-top: 1px solid rgba(255, 255, 255, .12); font-size: 14px; }
.sidebar-user .user-name { color: var(--side-muted); overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .link-button { color: var(--side-ink); }
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.nav-button, .nav-backdrop { display: none; }

/* --- верхняя строка: хлебные крошки и вкладки раздела ------------------------------------------- */
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 28px 0; min-height: 44px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.crumbs > * + *::before { content: "›"; margin-right: 6px; color: var(--line-strong); }
.crumbs a { color: var(--ink-2); }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; }
.section-tabs { display: none; }

/* --- типографика -------------------------------------------------------------------------------- */
h1 { font-size: 26px; line-height: 1.2; margin: 6px 0 14px; letter-spacing: -.02em; font-weight: 680; }
h2 { font-size: 18px; line-height: 1.3; margin: 24px 0 10px; letter-spacing: -.01em; }
h3 { font-size: 15px; margin: 18px 0 8px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
p { margin: 0 0 12px; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.muted { color: var(--muted); font-size: 13px; }
.helptext { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
code { font-size: 13px; word-break: break-all; }
pre.value { margin: 0; white-space: pre-wrap; font-size: 13px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
             gap: 12px 24px; margin-bottom: 8px; }
.page-head h1 { margin-bottom: 4px; }
.page-head .actions { margin: 6px 0 0; }

/* --- кнопки ------------------------------------------------------------------------------------- */
button, .btn, .actions > a {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 14px; font-weight: 550; line-height: 1.2; cursor: pointer;
  padding: 8px 14px; border-radius: var(--radius-sm); text-decoration: none;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong);
  transition: background .12s, border-color .12s;
}
button:hover, .btn:hover, .actions > a:hover { background: var(--surface-2); border-color: var(--muted); color: var(--ink); }
button { margin-top: 14px; }
.btn-primary, .actions > a.btn-primary, form:not(.toolbar):not(.inline-fields):not(.inline) > button[type=submit]:not(.btn-danger):not(.link-button):not(.btn-quiet) {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.btn-primary:hover, .actions > a.btn-primary:hover, form:not(.toolbar):not(.inline-fields):not(.inline) > button[type=submit]:not(.btn-danger):not(.link-button):not(.btn-quiet):hover {
  background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink);
}
/* кнопка обычной формы стоит на своей строке, а не рядом с последним полем */
.card > form:not(.toolbar):not(.inline-fields):not(.inline):not(.actions) > button,
main > form:not(.toolbar):not(.inline-fields):not(.inline):not(.actions) > button { display: flex; width: fit-content; }
button.btn-danger, .btn-danger { color: var(--bad); border-color: var(--bad-line); background: var(--surface); }
button.btn-danger:hover, .btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.link-button, button.link-button { background: none; border: none; color: var(--accent); padding: 0; margin: 0;
                                   font-weight: 500; }
.link-button:hover { background: none; text-decoration: underline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.actions button { margin-top: 0; }
.export-links { display: flex; gap: 12px; align-items: center; margin: 8px 0; font-size: 13px; }

/* --- формы -------------------------------------------------------------------------------------- */
label { display: block; margin: 12px 0 4px; font-weight: 550; font-size: 14px; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=date],
input[type=datetime-local], input[type=email], input[type=url], input[type=file], select, textarea {
  width: 100%; max-width: 520px; padding: 8px 10px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
textarea { max-width: 720px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; vertical-align: -3px; }
label.inline { display: inline; margin: 0; }
form.inline { display: inline; }
form.inline button { margin-top: 0; }
.inline-fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-fields button { margin-top: 0; }
.inline-fields input, .inline-fields select { width: auto; min-width: 0; }
.errors, .errorlist { color: var(--bad); }
.errorlist { list-style: none; padding: 0; margin: 4px 0; font-size: 14px; }

/* панель фильтров над таблицей */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin: 12px 0;
           padding: 12px 14px; background: var(--surface); border: 1px solid var(--line);
           border-radius: var(--radius); box-shadow: var(--shadow); }
.toolbar label { margin: 0; font-size: 12px; color: var(--muted); font-weight: 600; }
.toolbar .field { display: flex; flex-direction: column; gap: 3px; }
.toolbar .field.check { flex-direction: row; align-items: center; padding-bottom: 8px; }
.toolbar .field.check label { font-size: 14px; color: var(--ink); font-weight: 500; }
.toolbar input, .toolbar select { width: auto; min-width: 120px; padding: 7px 10px; }
.toolbar input[type=search] { min-width: 240px; }
.toolbar input[type=checkbox] { min-width: 0; }
.toolbar button { margin-top: 0; }
.toolbar > a:not(.btn) { padding-bottom: 8px; font-size: 14px; }
.result-line { display: flex; flex-wrap: wrap; gap: 4px 20px; align-items: center; justify-content: space-between;
               margin: 8px 0; }
.result-line p { margin: 0; }

/* --- таблицы ------------------------------------------------------------------------------------ */
.table-wrap { overflow: auto; max-height: 78vh; background: var(--surface); border: 1px solid var(--line);
              border-radius: var(--radius); box-shadow: var(--shadow); }
.card .table-wrap { box-shadow: none; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
table.data th, table.data td { border-bottom: 1px solid var(--line); padding: 8px 12px; text-align: left;
                               vertical-align: top; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--ink-2);
                      font-weight: 600; font-size: 13px; white-space: nowrap;
                      border-bottom: 1px solid var(--line-strong); }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data tr.negative td { background: var(--bad-bg); }
table.data tr.negative:hover td { background: var(--bad-bg); }
table.data tr.negative td.num.ff { color: var(--bad); font-weight: 650; }
table.data tr.info td { color: var(--muted); font-style: italic; }
table.data tr.total td { font-weight: 650; background: var(--surface-2); }
table.data form { display: inline; }
table.data button { margin-top: 0; padding: 5px 10px; font-size: 13px; }
table.data input[type=number], table.data input[type=text], table.data select { padding: 5px 8px; min-width: 70px; }
table.data td.num input[type=number] { width: 96px; text-align: right; }
th.sortable { padding: 0; }
th.sortable a { display: flex; align-items: center; gap: 4px; padding: 8px 12px; color: inherit; text-decoration: none; }
th.sortable.num a { justify-content: flex-end; }
th.sortable a:hover { color: var(--accent); background: var(--accent-soft); }
th.sortable .sort-mark { font-size: 11px; color: var(--line-strong); }
th.sortable.is-sorted a { color: var(--accent); }
th.sortable.is-sorted .sort-mark { color: var(--accent); font-size: 13px; }
td .sub { display: block; color: var(--muted); font-size: 12.5px; }
.pagination { margin: 14px 0; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; font-size: 14px; }
.pagination .btn { padding: 6px 12px; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

/* --- карточки, факты, показатели ---------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 18px 20px; box-shadow: var(--shadow); }
.card + .card, .card + h2, .table-wrap + .card, .kpis + .card { margin-top: 16px; }
main > .card { margin-bottom: 16px; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; margin: 0 0 12px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 14px 0; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; }
.kpi .muted { font-size: 13px; }
.kpi strong { font-size: 26px; line-height: 1.2; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi strong a { text-decoration: none; }
.kpi > span:last-child { font-size: 13px; color: var(--ink-2); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 16px 0; }
.grid-2 > .card { margin: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin: 16px 0; }
.grid-3 > .card { margin: 0; }
.dashboard > .card + .card { margin-top: 16px; }
.counters { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; margin-bottom: 12px; }
.counters button { margin-top: 0; }
.counter-alert { color: var(--bad); font-weight: 600; }
.chip { display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 999px; font-size: 14px;
        text-decoration: none; background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink-2); }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip-alert { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); font-weight: 600; }
ul.warnings { color: var(--warn); padding-left: 20px; }
.subnav { display: flex; flex-wrap: wrap; gap: 16px; margin: 8px 0 16px; }

/* шапка карточки SKU: общая для экономики, остатков и планирования */
.sku-head { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; margin: 4px 0 2px; }
.sku-head h1 { margin: 0; }
.sku-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; color: var(--ink-2);
            font-size: 14px; margin-bottom: 10px; }
.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--line-strong); margin: 8px 0 18px; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--ink-2); font-weight: 550; font-size: 14px;
          border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.tabs a:hover { background: var(--accent-soft); color: var(--accent); }
.tabs a.is-active { color: var(--accent); border-bottom-color: var(--accent); }

/* --- бейджи и сообщения ------------------------------------------------------------------------- */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
         line-height: 1.6; vertical-align: middle; white-space: nowrap; text-decoration: none;
         background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink-2); }
.badge-good { background: var(--good-bg); border-color: var(--good-line); color: var(--good); }
.badge-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.badge-bad, .badge-alert { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
.badge-info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }
.badge-muted { color: var(--muted); }
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.message { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 8px;
           background: var(--info-bg); border: 1px solid var(--info-line); color: var(--info); }
.message.success { background: var(--good-bg); border-color: var(--good-line); color: var(--good); }
.message.warning { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.message.error { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
.negative { color: var(--bad); }

/* --- графики ------------------------------------------------------------------------------------ */
.chart { margin: 0; }
.chart-title { font-weight: 650; font-size: 15px; margin-bottom: 6px; }
.chart-unit { color: var(--muted); font-weight: 400; }
.chart-plot svg { display: block; width: 100%; max-width: 680px; height: auto; overflow: visible; }
.chart-hbars .chart-plot svg { max-width: 540px; }
.chart-empty, .chart-note { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.chart-empty { padding: 28px 0; text-align: center; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; list-style: none; padding: 0; margin: 0 0 6px;
                font-size: 13px; color: var(--ink-2); }
.chart-legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.chart .grid { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart .grid-zero { stroke: var(--line-strong); }
.chart .tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .tick-y { text-anchor: end; dominant-baseline: middle; }
.chart .tick-x { text-anchor: middle; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; }
.chart .cross { stroke: var(--line-strong); stroke-width: 1; visibility: hidden; }
.chart .col:hover .cross { visibility: visible; }
.chart .bar-label { fill: var(--ink); font-size: 13px; text-anchor: end; }
.chart a .bar-label { fill: var(--accent); }
.chart .bar-value { fill: var(--ink-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.chart .bar-row:hover .bar { opacity: .82; }
.s1 { --c: var(--s1); } .s2 { --c: var(--s2); } .s3 { --c: var(--s3); } .s4 { --c: var(--s4); }
.st-good { --c: var(--good); } .st-warn { --c: #d9940a; } .st-bad { --c: #d6453d; }
.st-info { --c: var(--s1); } .st-muted { --c: var(--line-strong); }
.chart .line { stroke: var(--c); }
.band { fill: var(--c); opacity: .14; stroke: none; }
.chart .dot, .chart .bar { fill: var(--c); }
.chart-legend .swatch { background: var(--c); }
.chart-table { margin-top: 8px; font-size: 13px; }
.chart-table summary { cursor: pointer; color: var(--muted); }
.chart-table .table-wrap { max-height: 260px; margin-top: 6px; }

/* --- частные блоки ------------------------------------------------------------------------------ */
.chat-message { padding: 10px 14px; border-radius: var(--radius); margin: 10px 0; background: var(--surface-2);
                border: 1px solid var(--line); max-width: 780px; }
.chat-message p { margin: 4px 0 0; }
.chat-user { background: var(--accent-soft); border-color: transparent; margin-left: auto; }
.thumb { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); }

/* --- адаптив ------------------------------------------------------------------------------------ */
@media (max-width: 960px) {
  body.app { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 300px); z-index: 30;
             transform: translateX(-102%); transition: transform .18s ease; }
  .nav-toggle:checked ~ .sidebar { transform: none; }
  .nav-toggle:checked ~ .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 20;
                                        background: rgba(15, 13, 26, .5); }
  .nav-button { display: inline-flex; align-items: center; padding: 7px 12px; margin: 0; cursor: pointer;
                border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
                background: var(--surface); font-weight: 600; font-size: 14px; }
  .nav-toggle:focus-visible ~ .page .nav-button { outline: 2px solid var(--accent); }
  .topbar { padding: 10px 16px 0; }
  main { padding: 14px 16px 40px; }
  .section-tabs { display: flex; gap: 4px; overflow-x: auto; padding: 10px 16px 0; }
  .section-tabs a { flex: none; padding: 6px 12px; border-radius: 999px; font-size: 13px; text-decoration: none;
                    color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); }
  .section-tabs a.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
  h1 { font-size: 22px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .toolbar input[type=search] { min-width: 0; width: 100%; }
  .toolbar .field { flex: 1 1 140px; }
  .toolbar input:not([type=checkbox]), .toolbar select { width: 100%; }
  .toolbar .field.check { flex: 1 1 100%; padding-bottom: 0; }
  dl.facts { grid-template-columns: 1fr; gap: 0; }
  dl.facts dd { margin-bottom: 8px; }
  .table-wrap { max-height: none; }
  table.data thead th { position: static; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .sidebar, .topbar, .section-tabs, .toolbar, .export-links, .pagination, .actions { display: none !important; }
  body.app { display: block; }
  .table-wrap { max-height: none; overflow: visible; border: none; }
}

/* --- цены акции: строка-гипотеза над SKU --------------------------------------------------- */
table.data tr.hypothesis td { border-bottom: none; padding-bottom: 2px; font-size: 13px; color: var(--ink-2);
                              border-left: 3px solid var(--accent); }
table.data tr.hypothesis:hover td { background: none; }
.lines-form .actions { margin-top: 14px; }

/* план закупки: ссылка «снять все / отметить» в заголовке колонки отметок */
table.data th.marks { white-space: nowrap; font-weight: 500; font-size: 12px; }

/* новая партия: поле поиска SKU во всю ширину колонки */
table.batch-lines td:first-child { width: 70%; }
table.batch-lines input[list] { width: 100%; max-width: none; }

/* карточка партии: добавление позиции */
form.add-line input[list] { min-width: 360px; }
form.add-line input[type=number] { width: 110px; }

/* лист выкупа: фото, товар со ссылкой и комментарием, строка отметки заказа под товаром */
table.sheet th.sheet-photo, table.sheet td.sheet-photo { width: 88px; vertical-align: top; }
table.sheet td.sheet-title { min-width: 280px; max-width: 560px; vertical-align: top; }
table.sheet td.sheet-title .btn { margin-left: 8px; }
table.sheet .china-comment { margin-top: 6px; padding: 6px 8px; font-size: 13px; color: var(--ink-2);
                             background: var(--surface-2); border-radius: var(--radius-sm); white-space: normal;
                             overflow-wrap: anywhere; }
table.sheet tbody.sheet-item td { vertical-align: top; }
table.sheet tr.sheet-edit td { border-bottom: 2px solid var(--line-strong); padding-top: 0; }
table.sheet tr.sheet-edit .inline-fields { gap: 6px 10px; }
.btn-small, a.btn-small { padding: 3px 8px; font-size: 12px; }

/* товары: список и редактирование SKU */
img.thumb-small { width: 40px; height: 40px; }
.sku-edit { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.sku-edit-photo img.photo-large { width: 240px; height: 240px; object-fit: contain; border-radius: var(--radius-sm);
                                  border: 1px solid var(--line); background: var(--surface-2); }
.sku-facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 12px 0 0; font-size: 13px; }
.sku-facts dt { color: var(--muted); }
.sku-facts dd { margin: 0; }
.sku-edit-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 18px; }
.sku-edit-form > div:has(textarea) { grid-column: 1 / -1; }
.sku-edit-form > button { grid-column: 1 / -1; }
@media (max-width: 760px) { .sku-edit { grid-template-columns: 1fr; } }

/* лист выкупа: заголовок фабрики с полем «Фабрика → ТК» */
.factory-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
                margin-top: 24px; }
.factory-head h2 { margin: 0; }
.factory-head form button { margin-top: 0; }
/* партия: строка, по которой всё пришло */
table.data tr.arrived td { background: var(--good-bg); }

/* партия: правка количества и удаление позиции черновика */
table.data td.line-actions { white-space: nowrap; }
table.data td.line-actions .inline-fields { display: inline-flex; flex-wrap: nowrap; }
table.data td.line-actions input[type=number] { width: 90px; }
.kpis > .card + .card { margin-top: 0; }
.batch-summary .kpi strong { font-size: 22px; }
label.check-line { display: inline-flex; align-items: center; gap: 6px; margin: 12px 0 4px; font-weight: 500; }
td label.check-line { margin: 0; white-space: nowrap; }
th.has-tip a, span.has-tip { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
table.data.plan tr.group-head td { background: var(--surface-2); padding: 10px 12px; border-top: 1px solid var(--line-strong); }
table.data.plan tr.group-head .btn { margin-left: 8px; }
table.data.plan input[type=number] { width: 84px; }
.days.late { color: var(--bad); font-weight: 600; }
.days.tight { color: var(--warn); font-weight: 600; }
.plan-bar { position: sticky; bottom: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  justify-content: space-between; margin-top: 12px; padding: 10px 14px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm, 8px); background: var(--surface); box-shadow: var(--shadow); }
svg.sparkline { display: block; }
svg.sparkline .spark-bar { fill: var(--accent); }
svg.sparkline .spark-none { fill: transparent; }
svg.sparkline .spark-oos { fill: var(--bad); }
table.data td form.inline-fields { display: inline-flex; flex-wrap: nowrap; }
table.data td input[type=number] { width: 80px; }
table.data td form.inline-fields input[type=number] { width: 70px; }
/* The factory group's own checkbox: a submit button of the plan form (no JavaScript, typed numbers are kept) */
table.data button.group-check, button.group-check { display: inline-block; box-sizing: border-box; width: 16px; min-width: 0; height: 16px; min-height: 0; padding: 0; margin: 0;
  border: 1.5px solid var(--line-strong); border-radius: 3px; background: var(--surface); vertical-align: middle;
  position: relative; cursor: pointer; box-shadow: none; }
table.data button.group-check.on, button.group-check.on { background: var(--accent); border-color: var(--accent); }
table.data button.group-check.on::after, button.group-check.on::after { content: ""; position: absolute; left: 4px; top: 0; width: 5px; height: 10px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
table.data button.group-check:hover, button.group-check:hover { border-color: var(--accent); }
table.data button.link-button, button.link-button { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent); text-decoration: underline;
  font: inherit; font-size: 12px; cursor: pointer; box-shadow: none; }
button.default-submit { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); border: 0; }
button.link-button:hover { background: none; color: var(--accent); }
table.data button.group-check:not(.on):hover, button.group-check:not(.on):hover { background: var(--surface); }

/* --- главная: утренний экран --- */
.dashboard > .block-title { margin: 20px 0 0; }
.dashboard h3 { margin: 16px 0 6px; }
.dashboard details.more { margin-top: 8px; }
.dashboard details.more > summary, .dashboard details.service > summary { cursor: pointer; }
.dashboard details.service > summary { font-size: 18px; font-weight: 650; }
.dashboard details.service[open] > summary { margin-bottom: 12px; }
.kpi.negative strong, .kpi.negative .muted { color: var(--bad); }
