:root {
  --gap: 24px;
  --pad: 24px;
  --inner: 16px;
  /* Типографика (просьба 21.11: «очень разношёрстно»): четыре стиля на весь сайт, жирность только 400 и 600.
     Крупный — Oswald: h1 и главные числа; заголовок — h2; текст — всё остальное (h3 — текст жирным);
     мелкий — подписи, источники, заголовки таблиц, оси. Других размеров нет; логотип и значок «i» — не текст. */
  --font-text: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Oswald", system-ui, sans-serif;
  --fs-display: 28px;
  --fs-head: 19px;
  --fs-body: 17px;
  --fs-small: 14px;
  /* Отступы — только по шкале 4, 8, 12, 16, 24, 32 (просьба 21.11): между блоками страницы — --gap, поля карточки —
     --pad, между элементами карточки — --inner; подпись и поле — 8. Поля ввода — по сетке колонок --field-s
     (числа и даты), 2 колонки — --field-m (названия, списки), длинное — на всю строку. */
  --field-s: 160px;
  --field-m: calc(2 * var(--field-s) + 16px);
  --radius: 14px;
  --brand: #C40034;
  --brand-dark: #9E002A;
  --cream: #FBF4EA;
  --bg: #f7f4ef;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6b66;
  --line: #e2e1dc;
  --accent: #C40034;
  --neg: #b42318;
  --neg-bg: #fdecea;
  --warn: #9a5b00;
  --warn-bg: #fff4e0;
  --ok: #2e7d32;
  --ok-bg: #e8f5e9;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #161615;
  --surface: #1f1f1d;
  --text: #ecebe6;
  --muted: #a3a29c;
  --line: #34332f;
  --accent: #ff7a95;
  --neg: #ff8a80;
  --neg-bg: #3a1d1a;
  --warn: #f2b45a;
  --warn-bg: #352812;
  --ok: #81c784;
  --ok-bg: #1b2e1c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-body)/1.5 var(--font-text);
}
a { color: var(--accent); }
h1 { font: 600 var(--fs-display)/1.15 var(--font-display); margin: 0; }
h2 { font-size: var(--fs-head); font-weight: 600; line-height: 1.3; margin: 0; }
h3, h4 { font-size: var(--fs-body); font-weight: 600; line-height: 1.35; }
b, strong { font-weight: 600; }
small { font-size: var(--fs-small); }
.muted { color: var(--muted); }
.lead { color: var(--muted); margin: 0; max-width: 80ch; }
details.howto { color: var(--muted); max-width: 80ch; font-size: var(--fs-small); }
details.howto summary { color: var(--muted); font-size: var(--fs-small); }
details.howto p { margin: 8px 0 0; }
.desc { color: var(--muted); margin: 0; max-width: 980px; }
code { font-size: var(--fs-small); }

/* Тема: светлая по умолчанию, тёмная — html[data-theme=dark] (переключатель в шапке, cookie «theme»). */

/* --- Шапка: малиновая полоса бренда (лого, производство, месяц, тема) + вкладки на светлом фоне --- */
.skip { position: absolute; left: -999px; top: 8px; z-index: 10; padding: 8px 12px; border-radius: 8px;
  background: var(--surface); color: var(--text); }
.skip:focus { left: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0; }
.top { position: sticky; top: 0; z-index: 2; background: var(--bg); }
.top-inner { background: var(--brand); color: var(--cream); padding: 10px max(32px, calc((100% - 1800px) / 2 + 32px));
  display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.brand { display: inline-flex; flex-direction: column; align-items: stretch; text-decoration: none; color: var(--cream); line-height: 1; }
.brand-name {
  font: 800 28px/1 "Big Shoulders Display", "Oswald", "Arial Narrow", sans-serif;
  letter-spacing: .14em;
  color: transparent;
  -webkit-text-stroke: 1.2px var(--cream);
}
.brand-sub {
  display: flex; align-items: center; gap: 8px; margin-top: 4px;
  font: 600 10px/1 "Oswald", "Arial Narrow", sans-serif; letter-spacing: .32em;
}
.brand-sub::before, .brand-sub::after { content: ""; flex: 1; height: 2px; background: currentColor; }
/* Меню разделов: одно на весь сайт. Активный раздел — кремовая «таблетка» на малиновом. */
.main-nav { display: flex; align-items: center; gap: 4px; min-width: 0; }
.main-nav a { padding: 8px 12px; border-radius: 999px; color: var(--cream); text-decoration: none; font-weight: 400;
  font-size: var(--fs-body); white-space: nowrap; }
.main-nav a:hover { background: var(--brand-dark); }
.main-nav a.active { background: var(--cream); color: var(--brand); font-weight: 600; }
/* Правая группа шапки — от левого края: месяц, а где его нет (заказы, изделия) — кнопка или меню у имени. */
.period, a.enter, .more { margin-left: auto; }
.period ~ a.enter, .period ~ .more, a.enter ~ .more { margin-left: 0; }
select, button, input[type=file] { font: inherit; }
select, button { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
button { background: var(--brand); color: var(--cream); border: 0; cursor: pointer; font-weight: 600; }
button:hover { background: var(--brand-dark); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; }
.top-inner :focus-visible { outline-color: var(--cream); }
.more-menu :focus-visible { outline-color: color-mix(in srgb, var(--brand) 45%, transparent); }
/* Планшет: без задержки двойного касания на ссылках и кнопках. */
a, button, summary, select, label, input[type=date] { touch-action: manipulation; }
h1, h2, .callout-title { text-wrap: balance; }
.top select { background: var(--brand-dark); color: var(--cream); border-color: transparent; padding: 8px 12px; min-height: 40px; }
/* «Внести данные» — главная кнопка сайта: кремовая на малиновом, на странице ввода — нажата. */
a.enter { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 10px; min-height: 40px;
  background: var(--cream); color: var(--brand); text-decoration: none; font-weight: 600; white-space: nowrap; }
a.enter:hover { background: #fff; }
a.enter.active { background: var(--brand-dark); color: var(--cream); box-shadow: inset 0 0 0 1.5px var(--cream); }
/* Меню у имени: изделия, пользователи, разделы системы, тема, выход. Без JS — <details>, JS закрывает по клику мимо. */
.more { position: relative; }
.more summary { list-style: none; display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 40px;
  height: 40px; padding: 0 16px 0 12px; border-radius: 999px; border: 1.5px solid var(--cream); color: var(--cream);
  font-weight: 600; cursor: pointer; }
/* Слово «Меню» — где хватает места: на широком экране и на планшете (там разделы — своей строкой); иначе только ☰ */
/* 1341–1399 px: шапка в одну строку помещается только без слова «Меню» (нужно ≈ 1311 px, со словом ≈ 1370). */
@media (max-width: 700px), (min-width: 1341px) and (max-width: 1399px) { .more summary { padding: 0; } .more-label { display: none; } }
.more summary::-webkit-details-marker { display: none; }
.more summary:hover, .more[open] summary { background: var(--brand-dark); }
.more[open] > summary { margin: 0; }
.more-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 5; min-width: 250px; padding: 8px;
  display: flex; flex-direction: column; gap: 4px; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .18); }
.more-menu > * { margin: 0; }
.more-menu a, .more-menu button.link { padding: 8px 12px; border-radius: 8px; color: var(--text); text-decoration: none;
  text-align: left; font-size: var(--fs-body); width: 100%; }
.more-menu a:hover, .more-menu a.active, .more-menu button.link:hover { background: var(--bg); }
.more-who { display: flex; flex-direction: column; padding: 8px 12px 8px; border-bottom: 1px solid var(--line); }
.more-who span { color: var(--muted); font-size: var(--fs-small); }
.more-menu .theme-switch { display: flex; align-items: center; gap: 4px; padding: 4px 12px; border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line); margin: 4px 0; }
.more-menu .theme-switch span { margin-right: auto; color: var(--muted); font-size: var(--fs-small); }
.more-menu .theme-switch:last-child { border-bottom: 0; margin-bottom: 0; }
.theme-switch button { display: inline-flex; padding: 8px 8px; border-radius: 999px; background: transparent; color: var(--text); }
.theme-switch button:hover { background: var(--bg); }
.theme-switch button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
/* Вторая строка шапки: вкладки раздела слева, производство справа. */
.top-tabs { border-bottom: 1px solid var(--line); background: var(--surface); }
.tabs-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0 24px; max-width: 1800px; margin: 0 auto; padding: 0 32px;
  min-height: 52px; }
.tabs { display: flex; align-items: stretch; gap: 32px; align-self: stretch; min-width: 0; max-width: 100%; overflow-x: auto;
  scrollbar-width: none; }
.tabs a { display: flex; align-items: center; padding: 12px 0 8px; border-bottom: 3px solid transparent; text-decoration: none;
  color: var(--muted); font-weight: 400; font-size: var(--fs-body); white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--brand); font-weight: 600; }
.prod-switch { display: inline-flex; gap: 4px; padding: 4px; margin: 8px 0 8px auto; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); }
.prod-switch a { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: 9px; color: var(--text);
  text-decoration: none; font-weight: 400; white-space: nowrap; }
.prod-switch a:hover { background: var(--surface); }
.prod-switch a.active { background: var(--text); color: var(--bg); font-weight: 600; }
.prod-switch .key { width: 10px; height: 10px; margin: 0; }

.foot { max-width: 1800px; margin: 0 auto; padding: 16px 32px 40px; border-top: 1px solid var(--line); color: var(--muted);
  font-size: var(--fs-small); }

.wrap { max-width: 1800px; margin: 0 auto; padding: var(--gap) 32px 48px; display: flex; flex-direction: column; gap: var(--gap); }
.wrap > * { margin: 0; }
.overview { display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--pad); margin: 0; display: flex; flex-direction: column; gap: var(--inner); min-width: 0; }
.card > * { margin: 0; }
.card[id], .alerts[id] { scroll-margin-top: 200px; }  /* ссылка на раздел (#check, #crew) не прячется под шапкой
   с вкладками раздела (≈ 190 px) */
.card > h2 + .desc, .card > h2 + .legend { margin-top: calc(8px - var(--inner)); }
.card > button, .card > form > button { align-self: flex-start; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 560px), 1fr)); gap: var(--gap); }
.card.empty { align-items: center; text-align: center; padding: 48px var(--pad); }
.flash { padding: 12px 16px; border-radius: 10px; margin: 0; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--neg-bg); color: var(--neg); }

/* --- Пояснение за кнопкой «i» (partials/info.html): окно поверх страницы, текст коротко и по пунктам --- */
.info-btn { display: inline-grid; place-items: center; width: 26px; height: 26px; margin: 0 0 0 8px; padding: 0;
  vertical-align: 2px; border: 1.5px solid var(--muted); border-radius: 50%; background: transparent; color: var(--muted);
  font: italic 700 15px/1 Georgia, "Times New Roman", serif; letter-spacing: 0; text-transform: none; cursor: pointer;
  position: relative; touch-action: manipulation; }
.info-btn::after { content: ""; position: absolute; inset: -9px; } /* палец попадает с запасом: 44 px */
.info-btn:hover, .info-btn:focus-visible { border-color: var(--text); color: var(--text); }
.info-btn:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.info-pop { display: block; max-width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto;
  margin: auto; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  color: var(--text); box-shadow: 0 18px 48px rgb(0 0 0 / .22); font: 400 var(--fs-body)/1.5 var(--font-text);
  letter-spacing: normal; text-align: left; text-transform: none; text-wrap: pretty; white-space: normal;
  overscroll-behavior: contain; } /* внутри h1/h2 не наследовать их шрифт и text-wrap: balance */
.info-pop:not(:popover-open) { display: none; }
@supports not selector(:popover-open) { .info-pop { display: block; margin: 8px 0; box-shadow: none; } .info-close { display: none; } }
.info-pop::backdrop { background: rgb(0 0 0 / .28); }
.info-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.info-head b { font-size: var(--fs-head); line-height: 1.3; }
.info-close { flex: none; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: transparent;
  color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; } /* «×» — значок, не текст */
.info-close:hover, .info-close:focus-visible { background: var(--bg); color: var(--text); }
.info-body { display: grid; gap: 12px; padding: 12px 16px 16px; }
.info-body p, .info-body ul, .info-body ol, .info-body dl { margin: 0; }
.info-body ul, .info-body ol { padding-left: 16px; display: grid; gap: 4px; }
.info-body dt { font-weight: 600; }
.info-body dt:not(:first-child) { margin-top: 12px; }
.info-body dd { margin: 0; }
.info-body .formula { padding: 8px 12px; border-radius: 8px; background: var(--bg); font-variant-numeric: tabular-nums; }

/* --- Калькуляция --- */
.cost-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--field-m)), var(--field-m))); gap: 24px 16px; }  /* колонки — по две колонки сетки полей */
.cost-field { display: flex; flex-direction: column; gap: 8px; font-size: var(--fs-small); color: var(--text); }
.cost-field small { font-size: var(--fs-small); line-height: 1.35; }
.cost-field .vat { display: flex; gap: 8px; align-items: center; font-size: var(--fs-small); cursor: pointer; }
.cost-field .vat input { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
/* Статья расходов — две суммы, с НДС и без (поля рядом в той же колонке). */
.cost-field.split { border: 0; padding: 0; margin: 0; min-width: 0; }
/* Состав комплекта: строки «изделие — штук». */
.kit-parts { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.kit-parts legend { padding: 0; margin-bottom: 8px; font-size: var(--fs-small); color: var(--muted); }
.cost-field.split legend { padding: 0; margin-bottom: 8px; }
.split-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.split-pair label { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.split-pair input { min-width: 0; width: 100%; }
.cost-form h3 { font-size: var(--fs-body); margin: 0; }
.cost-table tr.sub td { border-top: 0; padding-top: 0; font-size: var(--fs-small); white-space: normal; }
.cost-table th.group { text-align: center; padding-bottom: 4px; }  /* «Статьи, сум» и «Итого» над колонками */
.cost-table tr.incomplete td { border-bottom-color: transparent; }
.cost-table tr:target td { background: color-mix(in srgb, var(--brand) 10%, transparent); }
/* «Из чего складывается» в карточке позиции (просьба 29.11: «стильная таблица»): группы статей — полосой фона с
   цветом группы как на «Графиках себестоимости», статьи — с отступом, доля — полоской и процентом, период данных —
   меткой (этот месяц — заливка, прошлый — рамка, не внесено — жёлтая с ⚠, не зависит от месяца — пунктир). */
.cost-card th { border-bottom: 2px solid var(--line); vertical-align: bottom; }
.cost-card td { padding: 12px; vertical-align: top; }
.cost-card tr.group td { font-weight: 600; background: var(--bg); border-top: 1px solid var(--line); }
.cost-card tr.part td:first-child { padding-left: 32px; }
.cost-card tr.part:hover td { background: var(--bg); }
.cost-card td.sum { font-weight: 600; }
.cost-card tr.part td.sum { font-weight: 400; }
.cost-card .cv-swatch { margin-right: 8px; }
.cost-card td.name { white-space: normal; width: 40%; min-width: 320px; }
.cost-card .how { display: block; margin-top: 4px; font-size: var(--fs-small); font-weight: 400; color: var(--muted); }
.cost-card td.when-cell { white-space: normal; min-width: 160px; max-width: 220px; }
.cost-card tfoot tr.total td { font-size: var(--fs-head); border-top: 2px solid var(--text); border-bottom: 0; padding: 16px 12px; }
.cost-card tfoot tr.total td.when-cell { font-size: var(--fs-small); font-weight: 400; }
.when { display: inline-block; padding: 4px 8px; border-radius: 999px; border: 1px solid transparent; font-size: var(--fs-small);
  font-weight: 600; line-height: 1.2; white-space: nowrap; }
.when-this { background: var(--line); color: var(--text); }
.when-prev { border-color: var(--muted); color: var(--text); }
.when-carried { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.when-fixed { border: 1px dashed var(--line); color: var(--muted); }
.when-none { color: var(--muted); padding-left: 0; }
.when-note { display: block; margin-top: 4px; font-size: var(--fs-small); color: var(--muted); font-weight: 400; }
.share { display: inline-flex; align-items: center; gap: 8px; }
.share-track { display: inline-block; width: 48px; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.share-bar { display: block; height: 100%; }
.share-num { min-width: 40px; text-align: right; font-size: var(--fs-small); color: var(--muted); font-weight: 400; }
.pack-rows { display: grid; gap: 12px; }
.pack-row { display: grid; grid-template-columns: minmax(var(--field-s), var(--field-m)) var(--field-s) var(--field-s) var(--field-s) auto;
  justify-content: start; gap: 16px; align-items: center; }
.pack-row input { text-align: right; font-variant-numeric: tabular-nums; }
.pack-row .vat { display: flex; gap: 8px; align-items: center; font-size: var(--fs-small); cursor: pointer; }
.pack-row .vat input { width: 18px; height: 18px; accent-color: var(--brand); }
.vat-line { display: flex; gap: 8px; align-items: center; font-size: var(--fs-small); cursor: pointer; }
.route-stages { display: flex; flex-wrap: wrap; gap: 24px; }
.route-stages label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.route-stages input { width: 22px; height: 22px; accent-color: var(--brand); }
.route-stages .fixed { color: var(--muted); cursor: default; }
.vat-line input { width: 18px; height: 18px; accent-color: var(--brand); }
.pack-head { color: var(--muted); font-size: var(--fs-small); }
.pack-cap { display: none; }
.pack-note { grid-column: 1 / -1; }
.pack-calc { margin: 0; font-size: var(--fs-small); }
.pack-flags { display: grid; gap: 4px; }

/* --- Вход --- */
.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--brand); }
.login { display: flex; flex-direction: column; align-items: center; gap: 32px; padding: 24px 16px; width: min(100%, 420px); }
.login-brand { display: flex; flex-direction: column; color: var(--cream); line-height: 1; }
.login-brand .brand-name { font-size: 44px; }
.login-brand .brand-sub { font-size: 13px; }
.login-card { width: 100%; }
.login-card label { display: flex; flex-direction: column; gap: 8px; color: var(--muted); font-size: var(--fs-small); }
.login-card button { align-self: stretch !important; }

/* --- Главные цифры месяца: одна строка без рамок, группировка отступами --- */
.page-head { display: flex; flex-direction: column; gap: 8px; }
.page-head > * { margin: 0; }
.source { color: var(--muted); font-size: var(--fs-small); margin: 0; }
/* Выбор изделия на калькуляции — главный элемент страницы: малиновая плашка, крупный жирный список. */
.product-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; width: fit-content; max-width: 100%;
  margin: 8px 0 !important; padding: 12px 16px; border-radius: var(--radius); background: var(--brand); color: var(--cream);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--brand) 30%, transparent); }
.product-pick label { font: 600 var(--fs-head)/1.2 var(--font-text); }
.product-pick select { appearance: none; -webkit-appearance: none; max-width: 100%; min-width: min(420px, 100%); min-height: 58px;
  padding: 8px 56px 8px 16px; border: 0; border-radius: 10px; color: var(--brand); font: 600 var(--fs-display)/1.15 var(--font-display);
  cursor: pointer; background: var(--cream) no-repeat right 18px center / 20px
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4 7l6 6 6-6' fill='none' stroke='%23C40034' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.product-pick select:hover { background-color: #fff; }
.product-pick select:focus, .product-pick select:focus-visible { outline: 3px solid var(--cream); outline-offset: 3px; }
.product-pick option, .product-pick optgroup { color: #1d1d1b; background: #fff; font: 400 var(--fs-body)/1.5 var(--font-text); }
.product-pick button { background: var(--cream); color: var(--brand); font-size: var(--fs-head); }
.kpis { display: flex; flex-wrap: wrap; gap: 16px 44px; margin: 0; padding-bottom: var(--gap); border-bottom: 1px solid var(--line); }
.kpi { display: flex; flex-direction: column; min-width: 0; max-width: 240px; }
.kpi b { order: -1; font: 600 var(--fs-display)/1.1 var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi > span { font-size: var(--fs-small); line-height: 1.35; color: var(--text); }
.kpi small { color: var(--muted); font-size: var(--fs-small); line-height: 1.35; }
.kpi.alarm b, .kpi.alarm span { color: var(--neg); }
a.kpi { text-decoration: none; color: inherit; }
a.kpi:hover span { text-decoration: underline; }

/* Замечания: полоса статуса слева, без заливки; первые три — сразу, остальные — «ещё N». */
.alerts { border-left: 4px solid var(--st-warning); padding: 4px 0 4px 16px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.alerts > * { margin: 0; }
.alerts h2 { font-size: var(--fs-body); color: var(--warn); }
.alerts ul { margin: 0; padding-left: 16px; display: flex; flex-direction: column; gap: 4px; }
.alerts details summary { color: var(--muted); }
.alerts details[open] > summary { margin-bottom: 4px; }

.stats { display: flex; gap: 12px 36px; flex-wrap: wrap; margin: 0; }
.stats > div { display: flex; flex-direction: column; }
.stats span { color: var(--text); font-size: var(--fs-small); }
.stats b { order: -1; font: 600 var(--fs-display)/1.1 var(--font-display); font-variant-numeric: tabular-nums; }

.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-body); }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-weight: 600; color: var(--muted); font-size: var(--fs-small); }
table.num td, table.num th { text-align: right; font-variant-numeric: tabular-nums; }
table.num td:first-child, table.num th:first-child, table.num .t { text-align: left; }
td.l { text-align: left !important; white-space: normal; }
td.r { text-align: right; }
tr.sub td { color: var(--muted); }
tr.total td { font-weight: 600; border-top: 2px solid var(--line); }
tr.bad td { background: var(--neg-bg); }
tr.muted td { color: var(--muted); }
.neg { color: var(--neg); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }
.card h3.sep { border-top: 1px solid var(--line); padding-top: var(--pad); }
.hand { border-bottom: 1px dashed var(--warn); cursor: help; }

details { margin: 0; }
details[open] > summary { margin-bottom: 12px; }
summary { cursor: pointer; color: var(--accent); }

.upload { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.upload label { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
a.button { display: inline-flex; align-items: center; padding: 8px 16px; border-radius: 10px; background: var(--brand);
  color: var(--cream); text-decoration: none; font-weight: 600; }
a.button:hover { background: var(--brand-dark); }

/* --- Ввод данных --- */
.subtabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; }
.subtabs a { padding: 8px 16px; text-decoration: none; color: var(--muted); border-radius: 999px; font-weight: 400;
  border: 1.5px solid var(--line); }
.subtabs a.active { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }
.subtabs a:not(.active):hover { color: var(--text); border-color: var(--muted); }
/* Поля формы — сетка колонок по --field-s: число и дата — колонка, название и список — две, длинное — вся строка. */
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--field-s), var(--field-s))); gap: 16px;
  align-items: end; }
.fields > label, .fields > fieldset { display: flex; flex-direction: column; gap: 8px; font-size: var(--fs-small); color: var(--muted); }
.fields > label:has(> select, > input:not([inputmode]):not([type=date]):not([type=number])), .fields > p { grid-column: span 2; }
.fields > label:has(.w-l) { grid-column: span 2; }
.fields > label:has(.w-s, .w-m) { grid-column: span 1; }
.fields > label.grow, .fields > fieldset, .fields > .wide { grid-column: 1 / -1; }
.fields > button, .fields > a { justify-self: start; }
.fields .w-s, .fields .w-m { width: 100% !important; }
@media (max-width: 700px) { .fields { grid-template-columns: 1fr 1fr; } }  /* телефон: число — пол-строки, название — строка */
input:not([type=radio]):not([type=checkbox]):not([type=file]), .fields select {
  font: inherit; padding: 8px 12px; border-radius: 10px; border: 1.5px solid var(--line);
  background: var(--bg); color: var(--text); min-height: 48px; width: 100%;
}
/* Safari (планшет) рисует системный список мелким и без рамки — свой вид и стрелка из токенов темы. */
.fields select { appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 18px center, right 12px center; background-size: 6px 6px; background-repeat: no-repeat; }
input:focus, select:focus { outline: 3px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
.entry-table { width: auto; min-width: min(100%, 720px); display: block; max-width: 100%; overflow-x: auto; }
.entry-table input { text-align: right; font-variant-numeric: tabular-nums; max-width: var(--field-s); }
.entry-table td.t input { text-align: left; max-width: none; }
.w-s, .w-m { width: var(--field-s) !important; }
.w-l { min-width: var(--field-m); }
.seg { border: 0; padding: 0; margin: 0; }
.seg legend { padding: 0; margin-bottom: 8px; }
.seg-opts { display: flex; }
.seg label { display: inline-flex; }
.seg input { position: absolute; opacity: 0; }
.seg span { padding: 12px 16px; border: 1.5px solid var(--line); background: var(--bg); color: var(--text); cursor: pointer; font-size: var(--fs-body); }
.seg label:first-child span { border-radius: 10px 0 0 10px; }
.seg label:last-child span { border-radius: 0 10px 10px 0; border-left: 0; }
.seg input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--cream); font-weight: 600; }
.seg input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--brand) 35%, transparent); }
button.big { font-size: var(--fs-head); padding: 12px 24px; }
button.secondary { background: var(--surface); color: var(--accent); border: 1.5px solid var(--accent); }
button.secondary:hover { background: var(--bg); }
button.link { background: none; color: var(--accent); padding: 0; font-weight: 400; text-decoration: underline; }
button.link:hover { background: none; }
button:disabled { opacity: .6; cursor: wait; }
.msg-box { border-radius: 12px; padding: 12px 16px; }
.msg-box ul { margin: 8px 0 0; padding-left: 24px; }
.msg-box.err { background: var(--neg-bg); color: var(--neg); }
.msg-box.warn { background: var(--warn-bg); color: var(--text); }
.msg-box.warn b { color: var(--warn); }
.confirm { display: flex; gap: 12px; align-items: center; margin-top: 12px; font-weight: 600; cursor: pointer; }
.confirm input { width: 22px; height: 22px; accent-color: var(--brand); }
.badge { background: var(--warn-bg); color: var(--warn); padding: 8px 12px; border-radius: 10px; margin: 0; font-size: var(--fs-small); }
.hint { font-weight: 600; }
.hint:empty { display: none; }
.hint.neg, .neg { color: var(--neg); }
.ok-text { color: var(--ok); }
.small { font-size: var(--fs-small); }
table.excel { font-size: var(--fs-body); }
table.excel td, table.excel th { padding: 8px 8px; }
table.excel th.c { text-align: center; border-bottom: 0; }
table.num tr th.rh { text-align: right; }
table.excel tfoot td { background: var(--bg); }
tr.current td { background: color-mix(in srgb, var(--brand) 10%, transparent); }
tr.warn-row td { background: var(--warn-bg); }


/* --- Внести данные: день, загрузка Excel, плитки дня; форма участка — карточка на изделие (макет — shveya.pen) --- */
.day-pick { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin: 0; }
.day-pick label { display: flex; flex-direction: column; gap: 8px; font-size: var(--fs-small); color: var(--muted); }
.day-pick label { width: var(--field-s); }
.day-pick button { min-height: 48px; }
.upload-card { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.upload-text { display: flex; flex-direction: column; gap: 8px; flex: 1 1 420px; min-width: 0; }
.upload-text > * { margin: 0; }
.day-tasks { display: flex; flex-direction: column; gap: var(--inner); margin: 0; }
.day-tasks > * { margin: 0; }
.day-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; }
.tiles, .rare { list-style: none; margin: 0; padding: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: var(--inner); }
.tile { display: flex; flex-direction: column; gap: 12px; height: 100%; padding: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1.5px solid var(--text); color: var(--text); text-decoration: none; }
.tile.done { border-color: var(--line); }
.tile:hover { background: var(--bg); }
.tile-name { font-size: var(--fs-head); font-weight: 600; }
.tile-what { color: var(--muted); font-size: var(--fs-small); }
.tile-status { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 8px 12px; border-radius: 8px;
  background: var(--bg); font-size: var(--fs-small); }
.tile-status svg { flex: none; color: var(--muted); }
.tile.done .tile-status { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.tile.done .tile-status svg { color: var(--ok); }
.rare { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.rare li + li { border-top: 1px solid var(--line); }
.rare a { display: flex; flex-direction: column; gap: 4px; padding: 16px 16px; color: var(--text); text-decoration: none; }
.rare a:hover { background: var(--bg); }
.rare a b { font-size: var(--fs-body); }
a.back { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); text-decoration: none; font-weight: 400; }
a.back:hover { text-decoration: underline; }
.size-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: var(--inner); }
fieldset.size-card { margin: 0; min-width: 0; padding: 12px 16px 16px; border: 1px solid var(--line); border-radius: 12px;
  display: flex; flex-direction: column; gap: 12px; }
fieldset.size-card > * { margin: 0; }
.size-card legend { padding: 0 4px; font-size: var(--fs-head); font-weight: 600; }
.size-have { color: var(--muted); }
.size-have b { color: var(--text); font-size: var(--fs-body); }
.size-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.size-fields label { display: flex; flex-direction: column; gap: 8px; font-size: var(--fs-small); color: var(--muted); }
.size-fields label.main { color: var(--text); font-weight: 600; }
.size-fields label.main input { border: 2px solid var(--text); font-size: var(--fs-head); font-weight: 600; min-height: 56px; }
.size-fields input { text-align: right; font-variant-numeric: tabular-nums; }
.size-fields small { font-size: var(--fs-small); font-weight: 400; }
.size-left { padding: 8px 12px; border-radius: 8px; background: var(--bg); color: var(--muted); }
.size-left b { color: var(--text); font-variant-numeric: tabular-nums; }
.size-left b.neg { color: var(--neg); }
.size-why summary { color: var(--muted); font-size: var(--fs-small); }
.size-why p { margin: 0; color: var(--muted); font-size: var(--fs-small); }
details.sheet > summary { list-style: none; display: flex; flex-direction: column; gap: 4px; }
details.sheet > summary::-webkit-details-marker { display: none; }
details.sheet > summary h2::before { content: "▸"; display: inline-block; width: 1.1em; color: var(--muted); }
details.sheet[open] > summary h2::before { content: "▾"; }
details.sheet > summary h2 { color: var(--text); }
details.sheet > summary .desc { color: var(--muted); }
@media (max-width: 700px) {
  .size-fields { grid-template-columns: 1fr; }
  .upload-card .upload { width: 100%; }
}

/* --- Картина: графики. Цвета — по роли (последовательная синяя шкала, нейтральный «лежит»), тёмная тема — свои ступени. --- */
:root {
  --viz-1: #2a78d6; --viz-wait: #c3c2b7; --viz-stuck: #fab219; --viz-grid: #e1e0d9;
  --h1: #cde2fb; --h2: #9ec5f4; --h3: #6da7ec; --h4: #3987e5; --h5: #256abf; --h6: #184f95; --h7: #0d366b;
  --h-ink-light: #0b0b0b; --h-ink-dark: #ffffff;
}
:root[data-theme="dark"] {
  --viz-1: #3987e5; --viz-wait: #5a5a55; --viz-stuck: #fab219; --viz-grid: #2c2c2a;
  --h1: #104281; --h2: #184f95; --h3: #1c5cab; --h4: #256abf; --h5: #3987e5; --h6: #6da7ec; --h7: #9ec5f4;
}
.viz h3 { font-size: var(--fs-body); margin: 0 0 8px; }
.tm-heads { display: flex; gap: 12px; font-size: var(--fs-body); color: var(--muted); }
.card > .tm-heads + .treemap { margin-top: calc(8px - var(--inner)); }
.tm-heads b { color: var(--text); }
.treemap { width: 100%; height: auto; display: block; }
.treemap .tile { cursor: default; outline: none; }
.treemap .tile:hover > rect:first-of-type, .treemap .tile:focus > rect:first-of-type { filter: brightness(1.06) saturate(1.1); }
.treemap .tile:focus > rect:first-of-type { stroke: var(--text); stroke-width: 3; }
.treemap text { font-family: var(--font-text); }
.treemap .on-light text { fill: #1d1d1b; }
.treemap .on-dark text { fill: #ffffff; }
.treemap .tl { font-weight: 600; }
.treemap .tv { font-weight: 600; }
.treemap .ts { opacity: .85; }
.swatch { display: inline-block; width: 16px; height: 16px; border-radius: 4px; margin-right: 8px; vertical-align: -2px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }


.legend { display: flex; gap: 8px 16px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: var(--fs-small); }
.key { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-right: -10px; vertical-align: -2px; }
.key.done { background: var(--viz-1); }
.key.wait { background: var(--viz-wait); }
.key.stuck { background: var(--viz-stuck); }
.bar-line { display: flex; align-items: center; gap: 12px; min-height: 22px; font-variant-numeric: tabular-nums; }
.bar-line .bar { height: 18px; border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-line.thin .bar { height: 10px; }
.bar-line.thin span { font-size: var(--fs-small); color: var(--muted); }
.bar-line.thin span.warn { color: var(--warn); }
.bar.done { background: var(--viz-1); }
.bar.wait { background: var(--viz-wait); }
.bar.stuck { background: var(--viz-stuck); }

table.heat { border-collapse: separate; border-spacing: 2px; width: 100%; table-layout: fixed; }
table.heat th:first-child { width: 130px; }
table.heat th { font-size: var(--fs-small); padding: 4px 8px; border: 0; text-align: center; }
table.heat tbody th { text-align: left; color: var(--text); font-weight: 400; }
table.heat td { height: 40px; text-align: center; border: 0; border-radius: 4px; font-size: var(--fs-small);
  font-variant-numeric: tabular-nums; background: var(--bg); }
table.heat td.h1 { background: var(--h1); color: var(--h-ink-light); }
table.heat td.h2 { background: var(--h2); color: var(--h-ink-light); }
table.heat td.h3 { background: var(--h3); color: var(--h-ink-light); }
table.heat td.h4 { background: var(--h4); color: var(--h-ink-dark); }
table.heat td.h5 { background: var(--h5); color: var(--h-ink-dark); }
table.heat td.h6 { background: var(--h6); color: var(--h-ink-dark); }
table.heat td.h7 { background: var(--h7); color: var(--h-ink-dark); }
[data-theme="dark"] table.heat td:is(.h1, .h2, .h3, .h4, .h5) { color: var(--h-ink-dark); }
[data-theme="dark"] table.heat td:is(.h6, .h7) { color: var(--h-ink-light); }

/* --- Люди: выработка по дням (та же синяя шкала h1…h7, что у тепловой карты) --- */
table.staff-heat { min-width: 1100px; }
table.staff-heat th:first-child { width: 300px; }
table.staff-heat th.r, table.staff-heat td.r { width: 96px; text-align: right; background: none; color: var(--text); }
table.staff-heat th.r:last-child { width: 150px; }
table.staff-heat td { height: 34px; font-size: var(--fs-small); }
table.staff-heat tbody th { white-space: normal; font-size: var(--fs-small); line-height: 1.25; }
table.staff-heat tr.group th { text-align: left; padding: 12px 8px 4px; font-size: var(--fs-body); color: var(--text); font-weight: 600; }
table.staff-heat tr.sum th, table.staff-heat tr.sum td { font-weight: 600; background: none; color: var(--text); }
table caption { caption-side: top; text-align: left; font-weight: 600; padding: 0 0 8px; }

.supply-row { display: grid; grid-template-columns: minmax(150px, 220px) 1fr 90px; gap: 12px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--viz-grid); }
.supply-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.supply-rolls { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* --- Материалы: категориальные слоты 1–2 (проверены на CVD), статусы — свои. --- */
:root { --mat-micro: #2a78d6; --mat-poly: #eb6834; --st-warning: #fab219; --st-critical: #d03b3b; }
:root[data-theme="dark"] { --mat-micro: #3987e5; --mat-poly: #d95926; }
.key.micro { background: var(--mat-micro); }
.key.poly { background: var(--mat-poly); }
.key.neg { background: var(--st-critical); }
td .key, th .key { margin-right: 8px; }
h2 .key { margin-right: 8px; }

/* --- Участки: путь каждого изделия — строка на изделие, клетка на участок (макет — shveya.pen) --- */
.lanes { display: flex; flex-direction: column; min-width: 900px; }
.lanes-row { display: grid; grid-template-columns: 190px repeat(var(--cols), minmax(0, 1fr)); gap: 8px 32px;
  align-items: start; padding: 16px 0; border-top: 1px solid var(--line); }
.lanes-head { padding: 8px 0; color: var(--muted); font-size: var(--fs-small); font-weight: 600; }
.lane-name { display: flex; flex-direction: column; gap: 4px; padding-top: 4px; }
.lane-name b { margin-bottom: 4px; }
.lane-name b { display: flex; align-items: center; gap: 8px; font-size: var(--fs-body); }
.lane-name .key { margin: 0; flex: none; }
.lane-name .muted { font-size: var(--fs-small); }
.cell { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 12px 12px; border-radius: 10px;
  background: var(--bg); border: 1.5px solid transparent; min-width: 0; }
.cell + .cell::before { content: ""; position: absolute; left: -19px; top: 26px; width: 8px; height: 8px;
  border-top: 2px solid var(--line); border-right: 2px solid var(--line); transform: rotate(45deg); }
.cell.hot { background: var(--warn-bg); border-color: var(--warn); }
.cell.neg-cell { border-color: var(--neg); }
.cell-done { font: 600 var(--fs-display)/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.cell-pace { color: var(--muted); font-size: var(--fs-small); }
.cell-lie { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--line); font-size: var(--fs-small); }
.cell-lie .track { height: 8px; }
.cell-lie .warn, .cell-lie .neg { font-size: var(--fs-small); }
.cell-lie .muted { font-size: var(--fs-small); }
@media (max-width: 700px) {
  /* Телефон: название изделия — строкой над клетками, клетки прокручиваются вбок, название остаётся на месте. */
  .lanes { min-width: 0; width: max-content; }
  .lanes-row { grid-template-columns: repeat(var(--cols), 160px); gap: 8px 16px; }
  .lanes-head span:first-child { display: none; }
  .lane-name { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 4px 12px;
    position: sticky; left: 0; width: min(100vw - 64px, 100%); }
  .lane-name b { width: 100%; }
  .cell + .cell::before { left: -14px; }
}

/* --- Фильтр по типу товара --- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters-label { color: var(--muted); font-size: var(--fs-small); margin-right: 4px; }
.filters-sep { width: 1px; height: 28px; background: var(--line); margin: 0 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--text); text-decoration: none; font-size: var(--fs-body); min-height: 40px; }
.chip:hover { border-color: var(--muted); }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.chip .key { margin-right: 0; }
.filter-note { color: var(--muted); font-size: var(--fs-small); margin: 0; }

/* --- Сводка: путь за месяц, где лежат штуки, заказы, ткань, готовая продукция (макет — shveya.pen) --- */
.grid-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: var(--gap); }
.grid-main > :only-child { grid-column: 1 / -1; }
.grid-main > .alerts { align-self: start; }
.card ol.path { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px 40px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.step { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 12px 0; min-width: 0; }
.step + .step:not(.wip)::before { content: ""; position: absolute; left: -25px; top: 50%; width: 9px; height: 9px;
  border-top: 2px solid var(--line); border-right: 2px solid var(--line); transform: translateY(-50%) rotate(45deg); }
.step-label { color: var(--muted); font-size: var(--fs-small); }
.step-value { font: 600 var(--fs-display)/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.step-by { margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-small); }
.step-by div { display: flex; justify-content: space-between; gap: 12px; }
.step-by dt { color: var(--muted); display: flex; align-items: center; gap: 8px; }
.step-by dd { margin: 0; font-variant-numeric: tabular-nums; }
.step-by .key, .order-top .key, .ot-head .key, .fabric-row .key { margin: 0 8px 0 0; width: 10px; height: 10px; }
.step.final { background: var(--ok-bg); border-radius: 12px; padding: 12px 16px; }
.step.final .step-label { color: var(--ok); font-weight: 600; }
.step.wip { border-left: 1px solid var(--line); padding-left: 24px; }
.step-note { color: var(--muted); font-size: var(--fs-small); }
.callout { display: flex; gap: 16px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; background: var(--warn-bg); }
.callout > div { display: flex; flex-direction: column; gap: 4px; }
.callout p { margin: 0; }
.callout-icon { color: var(--warn); flex: none; margin-top: 4px; }
.callout-title { font-weight: 600; font-size: var(--fs-head); }
.card ul.piles { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.pile { display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; grid-template-areas: "name bar qty" "name parts qty";
  gap: 4px 16px; align-items: center; }
.pile-name { grid-area: name; font-weight: 600; }
.pile-bar { grid-area: bar; display: flex; height: 14px; border-radius: 4px; background: var(--bg); overflow: hidden; }
.pile-bar .bar, .track .bar { height: 100%; border-radius: 4px; }
.pile-parts { grid-area: parts; color: var(--muted); font-size: var(--fs-small); }
.pile-qty { grid-area: qty; display: flex; flex-direction: column; align-items: flex-end; text-align: right;
  font-variant-numeric: tabular-nums; }
.pile-qty small { color: var(--muted); font-size: var(--fs-small); }
.pile-qty small.warn { color: var(--warn); }
.card ul.order-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
/* Заказы наверху «Сводки»: плитка на заказ — процент крупно, готово, сколько дней до завершения, срок. */
.card ul.order-tiles:not(.checklist) { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.order-tile { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--line);
  border-radius: var(--radius); position: relative; }
/* вся плитка — ссылка на заказ (звонок 26.11: нажимали на плитку, а открывался только номер) */
.order-tile .order-code::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.order-tile:hover { border-color: var(--muted); }
.order-tile:has(.order-code:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.ot-head { display: flex; gap: 8px 12px; align-items: baseline; flex-wrap: wrap; }
.ot-pct { margin: 0; display: flex; gap: 8px; align-items: baseline; }
.ot-pct b { font: 600 var(--fs-display)/1 var(--font-display); font-variant-numeric: tabular-nums; }
.ot-facts { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.ot-facts > div { display: flex; justify-content: space-between; gap: 12px; }
.ot-facts dt { color: var(--muted); font-size: var(--fs-small); }
.ot-facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.order-row { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.order-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.order-code { font: 600 var(--fs-display)/1.1 var(--font-display); color: var(--text); text-decoration: none; }
.order-code:hover { text-decoration: underline; }
.order-done { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.order-pct { font: 600 var(--fs-display)/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.track { display: flex; height: 10px; border-radius: 4px; background: var(--bg); overflow: hidden; }
.order-hint { margin: 0; color: var(--muted); font-size: var(--fs-small); }
.fabric-row { display: flex; flex-direction: column; gap: 4px; padding-top: 12px; border-top: 1px solid var(--line); }
.fabric-row p { margin: 0; font-size: var(--fs-small); }
.fabric-left b { font: 600 var(--fs-display)/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.day-bars { display: flex; align-items: flex-end; gap: 8px; min-width: 520px; padding-top: 4px; }
.day-col { flex: 1 1 0; display: flex; flex-direction: column; gap: 4px; min-width: 26px; }
.day-total, .day-label { font-size: var(--fs-small); color: var(--muted); text-align: center; font-variant-numeric: tabular-nums;
  white-space: nowrap; }
.day-stack { display: flex; flex-direction: column; gap: 1px; border-radius: 4px 4px 0 0; overflow: hidden; }
.day-stack .seg.micro { background: var(--mat-micro); }
.day-stack .seg.poly { background: var(--mat-poly); }
.stats.stack { flex-direction: column; gap: 16px; }
@media (max-width: 1000px) {
  .grid-main { grid-template-columns: 1fr; }
  .step + .step:not(.wip)::before { display: none; }
  .step.wip { border-left: 0; padding-left: 0; }
}
@media (max-width: 700px) {
  .card ol.path { grid-template-columns: 1fr; gap: 4px; }
  .step.final { padding: 8px 12px; }
  .pile { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name qty" "bar bar" "parts parts"; }
}

/* --- Разделы системы --- */
.module-group { display: flex; flex-direction: column; gap: 12px; }
.module-group > h2 { margin: 0; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: var(--gap); }
.module-card { text-decoration: none; color: var(--text); gap: 12px; }
.module-card:hover { border-color: var(--muted); border-top-color: var(--brand); }
.module-card h3 { font-size: var(--fs-head); margin: 0; }
.module-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.status { display: inline-flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 999px; font-size: var(--fs-small);
  font-weight: 600; white-space: nowrap; }
.status.ready { background: var(--ok-bg); color: var(--ok); }
.status.partial { background: var(--warn-bg); color: var(--warn); }
.status.stub { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.crumbs { color: var(--muted); font-size: var(--fs-small); margin: 0 0 8px; }
.checklist { margin: 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.checklist li { padding-left: 24px; position: relative; }
.checklist li::before { content: "•"; position: absolute; left: 8px; color: var(--muted); }
.checklist.done li::before { content: "✓"; left: 4px; color: var(--ok); font-weight: 600; }
.card ul:not(.checklist), .card ol { margin: 0; padding-left: 24px; display: flex; flex-direction: column; gap: 8px; }
.links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; }

/* Планшет и узкий ноутбук (до 1340 px — например, экран 1920 при масштабе 150 %, 1280 px): меню разделов — своей
   строкой под логотипом, прокручивается вбок. Шире всё в одну строку; было до 1180 — и в 1181–1310 кнопка «Меню»
   уезжала одна на вторую строку (аудит 27.11). */
@media (max-width: 1340px) {
  .tabs { gap: 24px; }
  .prod-switch a { padding: 4px 8px; }
  .main-nav { order: 10; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; width: calc(100% + 28px); }
}
@media (max-width: 700px) {
  .period { order: 2; margin-left: auto; }
  .more, a.enter ~ .more { order: 3; margin-left: auto; }
  .period ~ .more, .period ~ a.enter ~ .more { margin-left: 0; }
  a.enter { order: 4; flex: 1 1 100%; justify-content: center; margin-left: 0; }
  :root { --gap: 16px; --pad: 16px; --inner: 12px; --fs-display: 24px; --fs-body: 16px; }
  .top-inner { padding: 8px 16px; gap: 12px 12px; }
  .wrap, .foot { padding-left: 16px; padding-right: 16px; }
  .top { position: static; }  /* на телефоне шапка не съедает экран: прокручивается вместе со страницей */
  .period { margin-left: auto; }
  .brand-name { font-size: 22px; }
  .tabs-row { padding: 0 16px; flex-wrap: wrap; }
  .tabs { overflow-x: auto; gap: 24px; width: 100%; }
  .prod-switch { margin: 0 0 12px; width: 100%; }
  .main-nav { margin: 0 -6px; width: calc(100% + 12px); flex-wrap: wrap; overflow: visible; }  /* все разделы видны */
  .main-nav a { padding: 8px 12px; }
  .prod-switch a { flex: 1; justify-content: center; padding: 4px 8px; }
  a.enter { padding: 8px 12px; }
  .kpis { gap: 12px 32px; }
}

/* Картина себестоимости (/cost/visual). Статьи — категориальные слоты 3, 7, 5, 6 палитры в этом порядке (смежные
   пары проверены валидатором в обеих темах; синий и оранжевый заняты материалами, жёлтый — статусом); участки
   работы — порядковая синяя шкала по маршруту; налоги — штриховка. Точные числа — таблица на /cost. */
:root {
  --cv-fabric: #1baf7a; --cv-labour: #6250d6; --cv-materials: #e87ba4; --cv-overhead: #008300;
  --cv-o1: #86b6ef; --cv-o2: #5598e7; --cv-o3: #2a78d6; --cv-o4: #1c5cab; --cv-o5: #104281;
}
:root[data-theme="dark"] {
  --cv-fabric: #199e70; --cv-labour: #9085e9; --cv-materials: #d55181; --cv-overhead: #008300;
  --cv-o1: #184f95; --cv-o2: #256abf; --cv-o3: #3987e5; --cv-o4: #6da7ec; --cv-o5: #9ec5f4;
}
.card ul.cv-legend { display: flex; flex-direction: row; flex-wrap: wrap; gap: 8px 16px; list-style: none; margin: 0;
  padding: 0; font-size: var(--fs-small); color: var(--muted); }
.cv-legend li { display: flex; align-items: center; gap: 8px; }
.cv-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.cv-chart, .cv-missing { display: flex; flex-direction: column; gap: 16px; }
.cv-row { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 4px 16px; align-items: start; }
.cv-name { display: flex; align-items: center; gap: 8px; min-height: 28px; line-height: 1.3; }
.cv-name .key { margin-right: 0; flex: none; }
.cv-cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cv-cell p { margin: 0; }
.cv-track { position: relative; height: 28px; }
.cv-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--viz-grid); }
.cv-bar { position: relative; display: flex; height: 100%; }
.cv-bar .cv-seg { height: 100%; border-right: 2px solid var(--surface); }
.cv-bar .cv-seg:has(+ .cv-total) { border-radius: 0 4px 4px 0; }
.cv-total { align-self: center; padding-left: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cv-axis .cv-track { height: 18px; }
.cv-tick { position: absolute; top: 0; transform: translateX(-50%); font-size: var(--fs-small); color: var(--muted);
  white-space: nowrap; font-variant-numeric: tabular-nums; }
.cv-tick:first-child { transform: none; }
.cv-unknown, .cv-note { font-size: var(--fs-small); color: var(--muted); }
.cv-note b { color: var(--text); font-weight: 600; }
.cv-fabric { background: var(--cv-fabric); }
.cv-labour { background: var(--cv-labour); }
.cv-materials { background: var(--cv-materials); }
.cv-overhead { background: var(--cv-overhead); }
.cv-cut { background: var(--cv-o1); }
.cv-overlock { background: var(--cv-o2); }
.cv-single { background: var(--cv-o3); }
.cv-cleaning { background: var(--cv-o4); }
.cv-packing { background: var(--cv-o5); }
.cv-salaries { background: var(--cv-labour); }  /* оклады — не участок: цвет статьи «Зарплата» */
.cv-tax { background: var(--viz-wait); }  /* налоги с зарплаты — не участок, нейтральный серый */
.cv-bullet, .cv-count { height: 14px; margin-top: 8px; background: var(--bg); border-radius: 0 4px 4px 0; }
.cv-bullet .cv-seg, .cv-count .cv-seg { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; }
.cv-need { background: var(--viz-wait); }
.cv-norm { position: absolute; top: -5px; bottom: -5px; width: 2px; margin-left: -1px; background: var(--text); }
.cv-defaults { display: flex; flex-direction: column; margin: 0; }
.cv-defaults > div { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px;
  padding: 8px 0; border-bottom: 1px solid var(--line); }
.cv-defaults dt { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cv-defaults dt small { color: var(--muted); font-size: var(--fs-small); }
.cv-defaults dd { margin: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cv-sum { display: flex; flex-direction: column; gap: var(--inner); }
.cv-sum p { margin: 0; font-variant-numeric: tabular-nums; }
.cv-result { font: 600 var(--fs-display)/1.1 var(--font-display); }
.cv-result small { font: 400 var(--fs-small)/1.35 var(--font-text); color: var(--muted); }
@media (max-width: 640px) {
  .pack-head { display: none; }
  .pack-row { grid-template-columns: 1fr 1fr; align-items: end; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .pack-name, .pack-row .vat, .pack-flags { grid-column: 1 / -1; }
  .filters .filters-sep { display: none; }  /* месяцы «Кассы» по годам переносятся: разделитель повисает в конце строки */
  .pack-cap { display: block; font-size: var(--fs-small); color: var(--muted); margin-bottom: 4px; }
  .cv-row { grid-template-columns: 1fr; }
  .cv-axis > span:first-child { display: none; }
  /* Выбор позиции на телефоне: названия наборов длинные («Набор полотенец 70×140, 2 шт») — на всю ширину. */
  .product-pick { width: 100%; padding: 12px 12px; }
  .product-pick select { width: 100%; min-width: 0; min-height: 52px; padding: 8px 42px 8px 12px;
    background-position: right 14px center; background-size: 16px; }
}

/* Роли: собственник смотрит сайт глазами роли — заметная, но не тревожная полоса (не статус). */
.preview-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 16px;
  padding: 8px 32px; background: var(--text); color: var(--bg); font-size: var(--fs-small); }
.preview-bar button.link { color: var(--bg); font-weight: 600; }
form.inline { display: flex; gap: 8px; align-items: center; }
form.inline input { min-height: 40px; padding: 4px 8px; font-size: var(--fs-body); }
.entry-form fieldset.plan { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.entry-form fieldset.plan legend { padding: 0; margin-bottom: 8px; color: var(--muted); font-size: var(--fs-small); }
/* Позиции номенклатуры на «Изделиях»: каждая — своя форма внутри карточки, через линию. */
.position-form { display: flex; flex-direction: column; gap: var(--inner); border-top: 1px solid var(--line);
  padding-top: var(--pad); }
.position-form > * { margin: 0; }
.position-form h3 { font-size: var(--fs-body); font-weight: 600; }
tr.pos-row td:first-child { padding-left: 24px; }
table.roles td:not(.t), table.roles th:not(.t) { text-align: center; }
table.roles td.t, table.roles th { white-space: normal; }
table.roles td.t { min-width: 240px; }
small.block { display: block; margin-top: 4px; }

/* --- «Схема учёта»: участки цепочкой слева направо, на стрелках — сдано и принято; места сверки — номера в кружках --- */
.card ol.sc-chain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: row; align-items: stretch;
  min-width: min-content; position: relative; }  /* скрытые подписи (.sr-only) — внутри прокрутки, страница не шире экрана */
.sc-node { flex: 1 1 0; min-width: 140px; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
  display: flex; flex-direction: column; gap: 8px; background: var(--surface); }
.sc-node > * { margin: 0; }
.sc-node h3 { font-size: var(--fs-body); font-weight: 600; }
.sc-big { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-small); color: var(--muted); }
.sc-big b { font: 600 var(--fs-display)/1.1 var(--font-display); color: var(--text); font-variant-numeric: tabular-nums; }
.sc-who { font-size: var(--fs-small); color: var(--muted); }
.sc-facts { margin: 0; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.sc-facts div { display: flex; flex-direction: column; gap: 1px; }
.sc-facts dt { color: var(--muted); font-size: var(--fs-small); }
.sc-facts dd { margin: 0; font-size: var(--fs-body); font-variant-numeric: tabular-nums; }
.sc-arrow { flex: 0 0 84px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px;
  padding: 0 4px; font-size: var(--fs-small); line-height: 1.3; text-align: center; }
.sc-arrow b { display: block; font-variant-numeric: tabular-nums; }
.sc-line { display: block; width: 100%; height: 2px; background: var(--muted); position: relative; margin: 4px 0 4px; }
.sc-line::after { content: ""; position: absolute; right: -2px; top: -5px; border: 6px solid transparent;
  border-left: 9px solid var(--muted); border-right: 0; }
.sc-mark { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px;
  padding: 0 4px; border-radius: 10px; border: 1px solid var(--muted); color: var(--muted); font-size: var(--fs-small);
  font-weight: 600; line-height: 1; vertical-align: 1px; }
.card ol.sc-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--inner); }
.sc-points > li { display: flex; gap: 16px; align-items: flex-start; border-top: 1px solid var(--line); padding-top: var(--inner); }
.sc-points > li:first-child { border-top: 0; padding-top: 0; }
.sc-points > li > .sc-mark { min-width: 28px; height: 28px; border-radius: 14px; font-size: var(--fs-small); flex: none; }
.sc-point { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.sc-point > * { margin: 0; }
.sc-point h3 { font-size: var(--fs-body); font-weight: 600; text-wrap: balance; }
.sc-point ul { padding-left: 16px; display: flex; flex-direction: column; gap: 4px; }
.sc-status { font-size: var(--fs-small); font-weight: 400; margin-left: 8px; color: var(--muted); white-space: nowrap; }
.sc-status.warn { color: var(--warn); }
.sc-status.ok { color: var(--ok); }
table.sc-plan { font-size: var(--fs-body); }
table.sc-plan td, table.sc-plan th { white-space: normal; vertical-align: top; }
table.sc-plan tbody th { color: var(--text); font-size: var(--fs-body); white-space: nowrap; }
table.sc-plan td { min-width: 220px; }
.sc-list { display: flex; flex-direction: column; gap: 8px; }
.sc-list > * { margin: 0; }
.sc-list h3 { font-size: var(--fs-body); font-weight: 600; }
.sc-list ul { padding-left: 16px; display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 760px) {
  .card ol.sc-chain { flex-direction: column; min-width: 0; }
  .sc-node { min-width: 0; }
  .sc-facts { flex-flow: row wrap; gap: 8px 24px; }
  .sc-arrow { flex: none; flex-flow: row wrap; justify-content: center; padding: 8px 0; gap: 4px 12px; }
  .sc-arrow b { display: inline; }
  .sc-line { width: 2px; height: 22px; margin: 0; flex: none; }
  .sc-line::after { right: -5px; top: auto; bottom: -2px; border: 6px solid transparent; border-top: 9px solid var(--muted);
    border-bottom: 0; }
  table.sc-plan td { min-width: 180px; }
}

/* --- «Куда нужны люди»: на «Участках» — таблица участков (люди сейчас против нужных), на «Сводке» — коротко, через
   линию под «Где лежат штуки». Подпись под числом — мелко и тихо. --- */
table.crew-table th, table.crew-table td { padding: 8px 8px; }
table.crew-table thead th { white-space: normal; vertical-align: bottom; }
table.crew-table tbody th { color: var(--text); font-size: var(--fs-body); }
table.crew-table td.t { white-space: normal; min-width: 6.5em; }
table.overhead-table td { white-space: normal; } /* формулы общих расходов длинные: на телефоне переносятся */
table.crew-table small { display: block; margin-top: 4px; color: var(--muted); font-size: var(--fs-small); font-weight: 400;
  white-space: normal; }
table.crew-table small span { white-space: nowrap; }  /* «36, 36, 40» переносится только целиком */
.crew-brief { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: var(--inner);
  scroll-margin-top: 200px; }  /* ссылка «Сколько людей нужно» не прячет блок под шапкой */
.crew-brief > * { margin: 0; }
.crew-brief h3 { font-size: var(--fs-body); font-weight: 600; }

/* Списки «Сводки» без маркеров и отступа — после общего правила для списков в карточках (`.card ul`). */
.card ul.piles, .card ul.order-list { padding: 0; }
/* Формула Excel остатка — за «из журнала»: на виду слово, формула — по нажатию */
.formula-src summary { cursor: pointer; color: var(--muted); }
.formula-src code { display: block; padding-top: 4px; word-break: break-all; }
/* Свежесть данных: за какие рабочие дни ещё ничего не внесено (partials/stale.html) — та же плашка, что вывод про затор */
.callout.stale p { margin: 0; }
/* «Табель фабрики»: люди участка — свёрнуты, открываются по участку */
details.people-group { border-top: 1px solid var(--line); }
details.people-group > summary { cursor: pointer; padding: 12px 0; display: flex; gap: 8px; align-items: baseline; }
details.people-group[open] > summary { padding-bottom: 8px; }
/* Замечание: что сделать — своей строкой, ссылка туда и «Проверено» рядом; проверенные — внизу, без жёлтой полосы */
.alerts li .todo { display: block; color: var(--muted); }
.alert-acts { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin-left: 8px; }
.alert-check { display: inline; margin: 0; }
.alert-check button.link { font-size: var(--fs-small); color: var(--muted); padding: 0; }
.alert-check button.link:hover { color: var(--text); }
.alerts.calm { border-left-color: var(--line); }
.alerts.calm h2 { color: var(--muted); }
/* «Скачать в Excel» — тихая ссылка под заголовком страницы */
.page-head .export { margin: 0; font-size: var(--fs-small); }
.page-head .export a { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.page-head .export a:hover { color: var(--text); }
/* «Что нового»: плашка над страницей, пока последнюю запись не открыли или не скрыли */
.news-bar { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px;
  padding: 12px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.news-bar p, .news-bar form { margin: 0; }
.news-bar button.link { color: var(--muted); }
/* «Как пользоваться»: дела по ролям и словарь */
.help-role ol, .help-role ul, .news-entry ul { margin: 0; padding-left: 24px; display: flex; flex-direction: column; gap: 8px; }
.help-role h3 { margin: 0; }
.glossary-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; }
.glossary dl { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.glossary dt { font-weight: 600; }
.glossary dd { margin: 0; color: var(--muted); }
.news-bar button.link:hover, details.people-group > summary:hover, .formula-src summary:hover { color: var(--text); }

.print-btn { align-self: flex-start; justify-self: start; }

/* Печать (звонок 24.11: рейтинг вывешивают на фабрике): только заголовок и таблицы — без шапки, меню, форм, кнопок и
   колонок `.no-print` (заработок в рейтинге, звонок 27.11),
   чёрным по белому, таблицы во всю ширину, строка не рвётся между страницами. */
@media print {
  header.top, .preview-bar, .news-bar, footer.foot, .filters, .export, .info-btn, .print-btn, form.entry-form,
  .stale, .no-print { display: none !important; }
  :root, :root[data-theme="dark"] { --bg: #fff; --surface: #fff; --text: #000; --muted: #333; --line: #999; }
  body { background: var(--surface); color: var(--text); }
  .card { border: 0; box-shadow: none; padding: 0; break-inside: avoid-page; }
  .scroll { overflow: visible; }
  tr { break-inside: avoid; }
}
