/* Портал ВЭД. Рабочий инструмент: плотные таблицы, спокойный цвет.
   Палитра — фисташка и бежевый (образец 19.11.2026): тёплый бумажный фон, шалфейная панель вкладок, тёмно-зелёный текст;
   заголовок доски — антиквой. План на графиках — песочный, факт — шалфейный. */
@font-face {
  font-family: Onest;
  src: url("fonts/onest-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: Onest;
  src: url("fonts/onest-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f3f0e6;
  --surface: #fbfaf5;
  --ink: #2e4038;
  --muted: #4d5b53; /* подписи и пояснения: 6,6:1 к панели — мелкий текст читается увереннее */
  --line: #e0dacb;
  --line-soft: #ebe6da;
  --line-strong: #8f8670; /* рамка полей и кнопок-контуров: 3,4:1 к панели, 3,0:1 к фону */
  --navy: #4e6b5c;      /* тёмная шалфейная: выбранный переключатель, шапка окна правки */
  --navy-2: #617c6b;    /* панель вкладок: белый текст на ней — контраст 4,6:1 */
  --signal: #4e7360;    /* кнопки, ссылки, факт */
  --plan: #dccb9e;
  --plan-edge: #9c8550;
  --ok: #3f6b4f;
  --ok-bg: #e2ece1;
  --bad: #a3402c;
  --bad-bg: #f5e2da;
  --warn: #855f12;
  --warn-bg: #f2e7c9;
  --serif: Lora, "Iowan Old Style", Georgia, "Times New Roman", serif;
  --mono: "Cascadia Mono", Consolas, "SFMono-Regular", monospace;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(46 64 56 / 6%), 0 6px 18px rgb(46 64 56 / 6%);
}

* { box-sizing: border-box; }
html { font-size: 16px; } /* основа 16 px: таблицы и подписи — 14 px, примечания и фильтры — 13 px (12 px — нижняя граница) */
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.45 Onest, "Segoe UI", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--muted); }

/* ── шапка: название, свежесть данных, профиль; ниже — панель вкладок ── */
.top { padding: 18px 24px 4px; }
.top-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.brand { color: var(--muted); text-decoration: none; font-weight: 700; font-size: 0.8rem; letter-spacing: 0.14em; text-transform: uppercase; }
.fresh { margin: 0 0 0 auto; font-size: 0.85rem; color: var(--muted); }
.fresh b { color: var(--ink); font-weight: 600; }
.me { display: flex; align-items: center; gap: 10px; font-size: 0.875rem; font-weight: 600; color: var(--ink); }
.me:empty { display: none; }
.me .btn { padding: 6px 12px; min-height: 36px; }
.login { max-width: 400px; margin: 48px auto; display: flex; flex-direction: column; gap: 14px; }
.login h2 { margin: 0; }
.login .btn { align-self: flex-start; min-width: 140px; }
.login .note { margin: 0; font-size: 0.875rem; color: var(--muted); }
.tabs { display: inline-flex; gap: 4px; margin-top: 14px; padding: 5px; background: var(--navy-2); border-radius: 14px; box-shadow: var(--shadow); flex-wrap: wrap; max-width: 100%; }
.tabs-main, .tabs-more { display: flex; gap: 2px; flex-wrap: wrap; }
.tabs-more { padding-left: 6px; margin-left: 4px; border-left: 1px solid rgb(255 255 255 / 25%); }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #fff;
  text-decoration: none;
  padding: 8px 14px;
  min-height: 40px;
  border-radius: 10px;
  font-weight: 500;
  transition: background-color 0.15s, color 0.15s;
}
.tab svg { width: 17px; height: 17px; flex: none; }
.tab:hover { background: rgb(255 255 255 / 14%); }
.tab.on { color: var(--ink); background: var(--surface); box-shadow: 0 1px 3px rgb(46 64 56 / 18%); }
.tab:focus-visible { outline-color: #fff; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--plan); color: var(--ink); font-size: 0.75rem; font-weight: 700; text-align: center; }

/* ── доска ─────────────────────────────────────────── */
main { padding: 22px 24px 48px; }
main[aria-busy="true"] { opacity: 0.55; }
.board-h { display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 14px; }
h1 { font-family: var(--serif); font-size: 2.3rem; line-height: 1.1; margin: 0; font-weight: 500; letter-spacing: -0.01em; }
h2 { font-size: 1.12rem; margin: 0 0 10px; font-weight: 650; }
h3 { font-size: 0.95rem; margin: 16px 0 6px; color: var(--muted); font-weight: 600; }
.section-h { margin: 28px 0 10px; }
.sub { margin: 0; color: var(--muted); max-width: 70ch; }
.hint { color: var(--muted); font-size: 0.875rem; margin: 6px 0 10px; max-width: 110ch; }
.empty { color: var(--muted); padding: 12px 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.empty-state { max-width: 760px; }
/* блоки «Аналитики» — друг под другом на всю ширину: на широком экране по два в ряд они разной высоты и оставляют пустоты */
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.grid .panel { margin: 0; min-width: 0; }

/* фильтры */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 16px; }
.toolbar.inline { margin: 0; }
.fld { display: flex; flex-direction: column; gap: 3px; font-size: 0.875rem; color: var(--muted); }
.fld.wide { width: 100%; }
.fld input, .fld select, .fld textarea {
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 6px 9px;
  min-height: 36px;
}
.fld textarea { resize: vertical; line-height: 1.5; }
.seg { border: 0; padding: 0; margin: 0; display: flex; gap: 0; align-items: center; }
.seg legend { font-size: 0.875rem; color: var(--muted); padding: 0 0 3px; }
.seg label { border: 1px solid var(--line-strong); background: var(--surface); padding: 6px 12px; min-height: 36px; display: flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.seg label:first-of-type { border-radius: var(--radius) 0 0 var(--radius); }
.seg label:last-of-type { border-radius: 0 var(--radius) var(--radius) 0; }
.seg label + label { border-left: 0; }
.seg label:has(input:checked) { background: var(--navy); color: #fff; border-color: var(--navy); }
.seg input { accent-color: var(--plan); }
/* «Сегодня» на «Аналитике» — как кнопка переключателя: нажата — тёмная, как выбранная разбивка */
.tb-today { font: inherit; min-height: 36px; padding: 6px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap; }
.tb-today:hover { border-color: var(--navy-2); }
.tb-today[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.tb-today:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

.btn {
  font: inherit;
  font-weight: 600;
  background: var(--signal);
  color: #fff;
  border: 0;
  border-radius: var(--radius);
  padding: 8px 16px;
  min-height: 38px;
  cursor: pointer;
}
.btn:hover { background: #3f5f4f; }
.btn.ghost { background: transparent; color: var(--signal); border: 1px solid var(--line-strong); }

/* итоги */
.stats { display: flex; flex-wrap: wrap; gap: 0; margin: 4px 0 12px; }
.stat { padding: 2px 22px 2px 0; margin-right: 22px; border-right: 1px solid var(--line-soft); }
.stat:last-child { border-right: 0; }
.stat-v { font-size: 1.55rem; font-weight: 650; line-height: 1.2; }
.stats.big .stat-v { font-size: 1.55rem; }
.stat.small .stat-v { font-size: 1.55rem; }
.stat.note-v .stat-v { font-size: 1rem; font-weight: 600; line-height: 1.4; max-width: 16ch; } /* текст вместо числа («Нет наступившего плана») — не кричит */
.stat-l { font-size: 0.875rem; color: var(--muted); }
.stat-n { font-size: 0.8125rem; color: var(--muted); }
.stat-l::first-letter { text-transform: uppercase; }
.stat.zero .stat-v { color: var(--muted); font-weight: 500; } /* ноль бледнее — взгляд идёт к проблемам */
.stat.warn .stat-v { color: var(--warn); }
.stat.bad .stat-v { color: var(--bad); }

/* график план/факт */
.chart { position: relative; margin: 4px 0 6px; min-width: 0; overflow-x: auto; } /* на узком экране график листается вбок в своей рамке */
.chart svg { display: block; }
/* «Аналитика»: таблица блока свёрнута — видны цифры и график; раскрывается строкой «По фабрикам» (стрелка и «Показать таблицу») */
.fold { margin-top: 16px; }
.fold > summary { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 10px; background: #f6f3ea; color: var(--ink); cursor: pointer; list-style: none; transition: background-color 0.15s ease-out; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: ""; flex: none; width: 7px; height: 7px; border-right: 2px solid var(--signal); border-bottom: 2px solid var(--signal); rotate: -45deg; transition: rotate 0.15s ease-out; }
.fold[open] > summary::before { rotate: 45deg; translate: 0 -2px; }
.fold > summary:hover { background: #eee9dc; }
.fold > summary:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.fold-t { font-weight: 650; font-size: 1rem; }
.fold-n { color: var(--muted); font-size: 0.875rem; }
.fold-act { margin-left: auto; color: var(--signal); font-size: 0.875rem; font-weight: 600; }
.fold-hide, .fold[open] .fold-show { display: none; }
.fold[open] .fold-hide { display: inline; }
.fold > .tbl { margin-top: 8px; }
@media (prefers-reduced-motion: reduce) { .fold > summary, .fold > summary::before { transition: none; } }

/* Наведение на месяц: его столбцы — как есть, остальные бледнеют; полоса месяца чуть подсвечена; карточка с цифрами рядом */
.pf-g { outline: none; }
.pf-hit { fill: transparent; transition: fill 0.15s ease-out; }
.chart .b-plan, .chart .b-fact { transition: opacity 0.15s ease-out; }
.chart.hovering .pf-g:not(.on) .b-plan, .chart.hovering .pf-g:not(.on) .b-fact { opacity: 0.35; }
.pf-g.on .pf-hit { fill: rgb(78 115 96 / 8%); }
.pf-g.on text { fill: var(--ink); font-weight: 650; }
.pf-g:focus-visible .pf-hit { stroke: var(--signal); stroke-width: 2; }
.chart-tip { position: absolute; top: 0; z-index: 3; pointer-events: none; display: grid; gap: 4px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 20px rgb(46 64 56 / 16%); font-size: 0.875rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart-tip[hidden] { display: none; }
.chart-swipe { display: none; margin-left: auto; }
/* Номер партии — всегда целиком (колонки с full); в «Сверке ЧЗ» «Фабрика» (часто «Не найдено» или пусто) — узкая */
tbody td.full, tbody td.mono.full { max-width: none; } /* сильнее правила для td.mono ниже */
.tbl[data-id^="cz-"] tbody td:nth-child(3) { max-width: 170px; }
.chart-tip-h { color: var(--ink); font-size: 0.95rem; margin-bottom: 2px; }
.chart-tip b { color: var(--ink); font-weight: 650; }
.chart-tip .key { margin: 0 8px 0 0; vertical-align: -1px; }
@media (prefers-reduced-motion: reduce) { .pf-hit, .chart .b-plan, .chart .b-fact { transition: none; } }
.chart text { font-size: 13px; fill: var(--muted); font-family: inherit; }
.b-plan { fill: var(--plan); stroke: var(--plan-edge); stroke-width: 0.6; }
.b-fact { fill: var(--signal); }
.chart figcaption { font-size: 0.875rem; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.key { width: 12px; height: 12px; display: inline-block; border-radius: 2px; }
.key-plan { background: var(--plan); border: 1px solid var(--plan-edge); }
.key-fact { background: var(--signal); margin-left: 10px; }

/* таблица */
.tbl { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: clip; box-shadow: var(--shadow); }
.panel .tbl { box-shadow: none; border-radius: 8px; }
.tbl-scroll { position: relative; overflow: auto; max-height: 70vh; } /* position — скрытые подписи (.sr) в ячейках позиционируются внутри прокрутки и не расширяют страницу */
table { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 0.875rem; }
thead { position: sticky; top: 0; z-index: 2; }
thead th { background: #f0ece0; text-align: left; font-weight: 600; border-bottom: 1px solid var(--line); padding: 0; white-space: nowrap; }
thead th button { all: unset; display: block; padding: 8px 10px 6px; cursor: pointer; width: 100%; box-sizing: border-box; }
thead th button:focus-visible { outline: 2px solid var(--signal); outline-offset: -2px; }
thead th button[aria-sort="ascending"]::after { content: " ▲"; color: var(--signal); font-size: 0.7em; }
thead th button[aria-sort="descending"]::after { content: " ▼"; color: var(--signal); font-size: 0.7em; }
th.num, td.num { text-align: right; }
.tbl-filters td { min-width: 76px; background: #f0ece0; padding: 0 4px 6px; border-bottom: 1px solid var(--line); } /* min-width: узкая колонка не уже поля фильтра, «фильтр» читается целиком */
/* только поле поиска в ячейке — не галочки во всплывающем списке */
/* ширину колонки задают данные, а не поле фильтра: у поля нет своей ширины, оно растягивается по ячейке */
.tbl-filters td > input { box-sizing: border-box; width: 0; min-width: 100%; height: 30px; font: inherit; font-size: 0.8125rem; border: 1px solid var(--line-strong); border-radius: 4px; padding: 3px 6px; background: #fff; }
tbody td { padding: 6px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
tbody tr:hover td { background: #f4f1e6; }
tbody td.mono { max-width: 200px; } /* коды и номера; длинное имя поставщика без кода — с многоточием */
.row-late td, .row-bad td { background: #fbf0eb; }
.row-warn td { background: #faf4e2; }
.row-shift td { background: #f6edcf; }
.tbl-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 10px; font-size: 0.8125rem; color: var(--muted); border-top: 1px solid var(--line-soft); }
.tbl-foot .btn { min-height: 32px; padding: 4px 12px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; background: var(--line-soft); font-size: 0.8125rem; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.muted-pill { background: transparent; border: 1px dashed var(--line-strong); color: var(--muted); } /* «факт в 1С не ведётся» — не оценка, а пометка */
.shift { display: inline-block; font-size: 0.8125rem; color: var(--warn); }

/* оплаты */
.notices ul, .log { margin: 0; padding-left: 18px; }
.notices li, .log li { margin: 3px 0; }
.note { all: unset; cursor: pointer; color: var(--signal); max-width: 260px; display: inline-block; }
.note:hover { text-decoration: underline; }
.note-edit { display: flex; gap: 6px; }
.note-edit input { font: inherit; min-width: 220px; border: 1px solid var(--line); border-radius: 4px; padding: 3px 6px; }
.note-edit .btn { min-height: 30px; padding: 2px 10px; }

/* протоколы */
.split { display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: 16px; align-items: start; }
.plist { list-style: none; margin: 0; padding: 0; }
.plist button { all: unset; box-sizing: border-box; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; width: 100%; padding: 9px 10px; border-radius: var(--radius); cursor: pointer; }
.plist button:hover { background: #f4f1e6; }
.plist button.on { background: #e6ece3; }
.plist .muted { width: 100%; font-size: 0.8125rem; }
.p-date { font-weight: 650; }
.pform { display: flex; flex-direction: column; gap: 12px; }
.pform .row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.err { color: var(--bad); margin: 0; min-height: 1em; }

.toast { position: fixed; right: 20px; bottom: 76px; background: var(--navy); color: #fff; padding: 10px 16px; border-radius: var(--radius); z-index: 10; max-width: 420px; }
.toast.bad { background: var(--bad); }

@media (max-width: 760px) {
  .top, main { padding-left: 16px; padding-right: 16px; }
  .fresh { margin-left: 0; width: 100%; order: 3; }
  .tabs-more { padding-left: 0; margin-left: 0; border-left: 0; }
  .split { grid-template-columns: 1fr; }
  h1 { font-size: 1.7rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* правка записей */
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-h h2 { margin: 0; }
.section-h.panel-h { margin: 28px 0 6px; }
.rowbtn { all: unset; box-sizing: border-box; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 1px 8px 1px 6px; margin-right: 6px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--signal); font-weight: 600; font-size: 0.8125rem; font-family: Onest, system-ui, sans-serif; }
.rowbtn svg { width: 14px; height: 14px; }
.rowbtn:hover { color: #fff; background: var(--signal); border-color: var(--signal); }
.rowbtn:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.editor { border: 0; border-radius: 10px; padding: 0; width: min(880px, calc(100vw - 32px)); max-height: calc(100vh - 48px); color: var(--ink); }
.editor::backdrop { background: rgb(46 64 56 / 40%); }
.ed-form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.ed-form header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; background: var(--navy); color: #fff; }
.ed-form header h2 { margin: 0; }
.ed-form .x { all: unset; cursor: pointer; font-size: 1.6rem; line-height: 1; padding: 4px 8px; border-radius: 4px; }
.ed-form .x:focus-visible { outline: 2px solid #fff; }
.ed-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px 16px; padding: 16px 20px; overflow: auto; }
.ed-fields .fld:has(textarea) { grid-column: 1 / -1; }
.chk { display: flex; align-items: center; gap: 8px; min-height: 36px; font-size: 0.92rem; }
.chk input { width: 18px; height: 18px; accent-color: var(--signal); }
.hist { padding: 0 20px 8px; font-size: 0.85rem; }
.hist ul { margin: 6px 0 0; padding-left: 18px; }
.ed-form .err { padding: 0 20px; }
.ed-form footer { display: flex; gap: 10px; align-items: center; padding: 12px 20px; border-top: 1px solid var(--line); }
.ed-form footer span { flex: 1; }
.btn.danger { color: var(--bad); border-color: #e3bcae; }
/* «Удалить протокол»: светло-красная кнопка с корзиной. Наведение — крышка приподнимается; первое нажатие — кнопка краснеет,
   вздрагивает и крышка открыта («Точно удалить?»); второе — корзина «проглатывает» и протокол удаляется */
.btn.del { display: inline-flex; align-items: center; gap: 8px; background: var(--bad-bg); color: var(--bad); border: 1px solid #e3bcae; transition: background-color 0.15s ease-out, color 0.15s ease-out; }
.btn.del:hover { background: #f0d3c7; }
.btn.del:active { transform: scale(0.97); }
.btn.del:focus-visible { outline: 2px solid var(--bad); outline-offset: 2px; }
.btn.del.sure { background: var(--bad); color: #fff; border-color: var(--bad); animation: bin-shake 0.3s ease-out; }
.btn.del:disabled { cursor: progress; }
.bin { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.bin-lid { transform-box: fill-box; transform-origin: 0% 100%; transition: transform 0.2s ease-out; }
.btn.del:hover .bin-lid { transform: translateY(-1px) rotate(-14deg); }
.btn.del.sure .bin-lid { transform: translateY(-2px) rotate(-30deg); }
.btn.del.going .bin-lid { transform: none; }
.btn.del.going .bin { animation: bin-gulp 0.25s ease-in forwards; }
@keyframes bin-shake { 0%, 100% { translate: 0; } 25% { translate: -3px; } 50% { translate: 3px; } 75% { translate: -1px; } }
@keyframes bin-gulp { 50% { transform: translateY(2px) scale(0.85); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .bin-lid, .btn.del { transition: none; }
  .btn.del.sure, .btn.del.going .bin { animation: none; }
}

/* таблица: строка состояния сверху, закреплённая первая колонка, пустой результат, новая запись */
.tbl-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 6px 10px; min-height: 40px; font-size: 0.8125rem; color: var(--muted); border-bottom: 1px solid var(--line-soft); }
.tbl-bar .btn, .tbl-empty .btn { min-height: 30px; padding: 3px 12px; font-size: 0.82rem; }
.tbl-note { color: var(--warn); font-weight: 600; }
.tbl-foot:has(.tbl-more[hidden]) { display: none; }
thead th:first-child, .tbl-filters td:first-child, tbody td:first-child { position: sticky; left: 0; box-shadow: 1px 0 0 var(--line); }
thead th:first-child, .tbl-filters td:first-child { z-index: 3; }
tbody td:first-child { z-index: 1; }
tbody tr:not([class*="row-"]) td:first-child { background: var(--surface); }
tbody tr:hover td:first-child { background: #f4f1e6; }
.tbl-empty td { white-space: normal; padding: 20px 14px; color: var(--muted); position: static; box-shadow: none; }
tr.row-new td { background: #dcebd9; transition: background-color 0.4s; }
.src { font-size: 0.875rem; color: var(--muted); margin: 2px 0 10px; }
.src b { color: var(--ink); font-weight: 600; }

/* Номер партии в уведомлении — кнопка-ссылка: щелчок фильтрует таблицу оплат */
.linkbtn { all: unset; cursor: pointer; color: var(--signal); text-decoration: underline; text-underline-offset: 2px; }
.linkbtn:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.sub-h { font-size: 1rem; margin: 18px 0 6px; }
.editor.wide { width: min(1240px, calc(100vw - 32px)); }
.editor.wide .ed-form > :not(header) { margin: 10px 20px 0; }
.editor.wide .tbl { overflow: auto; min-height: 0; margin-bottom: 16px; }
.p-search { margin-bottom: 10px; }
.hist .pre { white-space: pre-wrap; margin: 4px 0 10px; padding: 8px 10px; background: #f4f1e6; border-radius: 6px; }
.fld-err { color: #a3442b; font-size: 0.875rem; min-height: 0; }
.fld-err:empty { display: none; }
[aria-invalid="true"] { border-color: #a3442b !important; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }

/* Копия ползунка прокрутки вправо-влево — прилипает к низу окна, пока настоящий ползунок таблицы ниже края экрана */
.tbl-end { height: 0; }
.tbl-hbar { position: sticky; bottom: 0; z-index: 4; overflow-x: auto; overflow-y: hidden; height: 16px; background: var(--surface); border-top: 1px solid var(--line); }
.tbl-hbar > div { height: 1px; }
.tbl-hbar[hidden] { display: none; }
.tbl-scroll, .tbl-hbar { scrollbar-color: #8fa596 #ece8dc; }

/* Длинные списки (не таблицы) листаются внутри своего блока — страница не растягивается */
.p-list { max-height: 70vh; overflow-y: auto; }
.notices-scroll { max-height: 50vh; overflow-y: auto; }
.log { max-height: 50vh; overflow-y: auto; }
.p-list, .notices-scroll, .log { scrollbar-color: #8fa596 #ece8dc; }

/* Выбор менеджера фабрики — в стиле портала: поле, стрелка и само раскрывающееся меню
   (Chrome 135+ рисует меню по этим правилам; другие браузеры — обычный список в тех же цветах) */
select.pick, select.pick::picker(select), .fld select, .fld select::picker(select) { appearance: base-select; }
select.pick { font: inherit; font-size: 0.88rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 2px 10px; min-width: 220px; min-height: 30px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
select.pick:hover { border-color: var(--navy-2); }
/* чужая фабрика: менеджера видно, сменить нельзя — без рамки и стрелки, как обычный текст */
select.pick:disabled { border-color: transparent; background: transparent; cursor: default; opacity: 1; color: var(--ink); }
select.pick:disabled::picker-icon { display: none; }
select.pick:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
select.pick:has(option[value=""]:checked) { color: var(--muted); border-style: dashed; }
select.pick::picker-icon, .fld select::picker-icon { content: ""; width: 6px; height: 6px; margin: 0 4px 3px 0; border-right: 1.6px solid var(--navy-2); border-bottom: 1.6px solid var(--navy-2); rotate: 45deg; transition: rotate 0.15s ease-out; }
select.pick:open::picker-icon, .fld select:open::picker-icon { rotate: 225deg; }
.fld select { display: inline-flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; }
select.pick::picker(select), .fld select::picker(select) { max-height: 60vh; overflow-y: auto; scrollbar-color: #8fa596 #ece8dc; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: 0 10px 30px rgb(46 64 56 / 18%); padding: 4px; margin-top: 4px; }
select.pick option, .fld select option { padding: 7px 10px; border-radius: 6px; font-size: 0.88rem; color: var(--ink); }
select.pick option:hover, select.pick option:focus-visible, .fld select option:hover, .fld select option:focus-visible { background: #e6ece3; }
select.pick option:checked, .fld select option:checked { background: var(--navy-2); color: #fff; font-weight: 600; }
select.pick option::checkmark, .fld select option::checkmark { display: none; }
@media (prefers-reduced-motion: reduce) { select::picker-icon { transition: none; } }
/* меню-списки не сжимаются до ширины «Все»: в фильтрах — удобная ширина, в форме — на всю ячейку */
.toolbar .fld select { min-width: 190px; }
.ed-fields .fld select { width: 100%; }
.guide-link { font-size: 0.85rem; font-weight: 600; color: var(--signal); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }

/* Счётчик-кнопка: щелчок открывает список того, что за цифрой */
.stat-pop { font: inherit; color: inherit; text-align: left; background: none; border-top: 0; border-bottom: 0; border-left: 0; cursor: pointer; border-radius: 6px; }
.stat-pop > span { display: block; }
.stat-pop .stat-l { text-decoration: underline dotted; text-underline-offset: 3px; }
.stat-pop:hover .stat-v, .stat-pop:hover .stat-l { color: var(--signal); }
.stat-pop.warn:hover .stat-v { color: var(--warn); }
.stat-pop.bad:hover .stat-v { color: var(--bad); }
.stat-pop:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }
tbody td.wrap { white-space: normal; min-width: 280px; max-width: 420px; }

/* Выбор нескольких значений: кнопка со сводкой выбранного, под ней — список с галочками (popover у кнопки) */
/* список привязан к своей кнопке: имя якоря одно на все блоки, anchor-scope держит его внутри блока (встроенные style запрещает CSP) */
.ms { anchor-scope: --ms; }
.ms-f { display: flex; flex-direction: column; gap: 3px; font-size: 0.875rem; color: var(--muted); }
.ms-btn {
  anchor-name: --ms;
  position: relative;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 6px 32px 6px 10px;
  min-height: 36px;
  min-width: 190px;
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.ms-btn::after { content: ""; position: absolute; right: 13px; top: 50%; width: 6px; height: 6px; border-right: 1.6px solid var(--navy-2); border-bottom: 1.6px solid var(--navy-2); translate: 0 -70%; rotate: 45deg; }
.ms-btn:hover { border-color: var(--navy-2); }
.ms-btn.on { border-color: var(--signal); background: #e6ece3; font-weight: 600; }
.tbl-filters .ms-btn { width: 100%; min-width: 90px; height: 30px; min-height: 0; padding: 3px 24px 3px 6px; font-size: 0.8125rem; border-radius: 4px; background: #fff; }
.tbl-filters .ms-btn.on { background: #e6ece3; }
.tbl-filters .ms-btn::after { right: 9px; }
.ms-pop {
  position-anchor: --ms;
  inset: auto;
  position-area: bottom span-right;
  position-try-fallbacks: flip-block, flip-inline;
  margin: 4px 0;
  padding: 6px;
  min-width: 230px;
  max-width: 380px;
  font-size: 0.88rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgb(46 64 56 / 18%);
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
}
.ms-list { display: flex; flex-direction: column; max-height: min(40vh, 320px); overflow-y: auto; scrollbar-color: #8fa596 #ece8dc; }
.ms-opt { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 4px 8px; border-radius: 6px; cursor: pointer; }
.ms-opt:hover { background: #e6ece3; }
.ms-opt[hidden] { display: none; }
.ms-opt input { width: 16px; height: 16px; margin: 0; accent-color: var(--signal); flex: none; }
.ms-q { width: 100%; margin-bottom: 6px; font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
.ms-top { display: flex; gap: 6px; margin-bottom: 6px; }
.ms-top .ms-q { margin: 0; flex: 1; min-width: 0; }
.ms-clear { flex: none; min-height: 32px; padding: 3px 10px; font-size: 0.82rem; margin-left: auto; }
.tbl-xlsx { margin-left: auto; }

/* «Главное за период»: цифра — кнопка перехода к блоку; заголовок блока получает фокус без рамки */
h2[tabindex="-1"]:focus { outline: none; } /* заголовок блока получает фокус только при переходе из сводки — без рамки */
.toolbar .ms-btn { width: 140px; min-width: 0; max-width: none; } /* постоянная ширина: выбор не сдвигает соседние фильтры */
.toolbar input[type="date"] { width: 148px; } /* панель «Аналитики» на 1366 — в одну строку */
.toolbar .tb-reset { align-self: flex-end; min-height: 36px; }

/* Оплаты: сводная для финансов — компактная таблица сумм и долей, «Всего» отделено линией; итог над каждой таблицей */
.fin-scroll { overflow-x: auto; }
.fin-t { width: auto; font-size: 0.92rem; }
.fin-t th, .fin-t td { padding: 7px 14px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.fin-t thead th { background: none; padding: 4px 14px 6px; font-size: 0.875rem; color: var(--muted); font-weight: 600; }
.fin-t tbody th { text-align: left; font-weight: 500; }
.fin-t th:first-child { padding-left: 0; }
.fin-total th, .fin-total td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }
.fin-t td.muted { font-size: 0.875rem; }
.fin-bad { color: var(--bad); }
.pay-sec { margin-top: 26px; }
.pay-sec .sub-h { font-size: 1.12rem; margin-bottom: 2px; }
.pay-sec .hint { margin: 2px 0 6px; }
.pay-sum { margin: 0 0 8px; font-size: 0.9rem; }
.pay-sum b { font-weight: 650; }
.tbl-bar .tbl-xlsx { min-height: 30px; padding: 3px 12px; font-size: 0.82rem; }

/* Телефон: переключатель из трёх-четырёх кнопок (период оплат) переносится по строкам, а не распирает страницу */
@media (max-width: 760px) {
  .toolbar .seg { flex-wrap: wrap; gap: 4px; }
  .toolbar .seg label { border-left: 1px solid var(--line-strong); border-radius: var(--radius); }
}

/* «Как считается»: метод расчёта и источник свёрнуты под блоком — доска читается с первого взгляда */
.how { margin: 4px 0 10px; font-size: 0.875rem; color: var(--muted); max-width: 110ch; }
.how summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--signal); font-weight: 500; list-style: none; min-height: 28px; }
.how summary::-webkit-details-marker { display: none; }
.how summary::after { content: ""; width: 5px; height: 5px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; rotate: 45deg; translate: 0 -2px; transition: rotate 0.15s ease-out; }
.how[open] summary::after { rotate: 225deg; translate: 0 2px; }
.how summary:hover { text-decoration: underline; text-underline-offset: 3px; }
.how-b { padding: 4px 0 2px 12px; border-left: 2px solid var(--line); }
.how-b p { margin: 4px 0; }
.panel > .how:last-child { margin-bottom: 0; }

/* Переносы оплат — свёрнуто, заголовок со счётчиком; внутри компактная таблица */
.notices > summary { cursor: pointer; list-style: none; }
.notices > summary::-webkit-details-marker { display: none; }
.notices > summary h2 { display: inline; margin: 0; }
.notices > summary::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 10px; border-right: 1.6px solid var(--navy-2); border-bottom: 1.6px solid var(--navy-2); rotate: 45deg; translate: 0 -3px; }
.notices[open] > summary::after { rotate: 225deg; translate: 0 1px; }
.notices[open] > summary { margin-bottom: 6px; }
.notices-t { width: auto; font-size: 0.86rem; }
.notices-t th, .notices-t td { padding: 4px 16px 4px 0; text-align: left; border-bottom: 1px solid var(--line-soft); white-space: nowrap; font-weight: 400; }
.notices-t thead th { color: var(--muted); font-size: 0.8125rem; background: none; }
.fin-t td.fin-pct { color: var(--muted); }
.stat-groups { display: flex; flex-wrap: wrap; gap: 4px 40px; }
.stat-groups h3 { margin: 4px 0 4px; }

@media (max-width: 760px) {
  /* всплывающий список фильтра — снизу экрана во всю ширину */
  .ms-pop { position: fixed; position-area: none; inset: auto 0 0 0; margin: 0; max-width: none; width: 100%; border-radius: 14px 14px 0 0; max-height: 75dvh; overflow-y: auto; }
  .ms-list { max-height: 50dvh; }
  /* вкладки — одной строкой с прокруткой вбок */
  .tabs { flex-wrap: nowrap; overflow-x: auto; }
  .tabs-main, .tabs-more { flex-wrap: nowrap; }
  .tab { white-space: nowrap; }
  /* сводная оплат: первая колонка закреплена, числа прокручиваются */
  .fin-t th:first-child { position: sticky; left: 0; background: var(--surface); white-space: normal; min-width: 130px; }
}

/* «Главное за период» на «Аналитике» — ключевые цифры одной строкой на 1366 px */
.summary .stat { padding-right: 16px; margin-right: 16px; }
.summary .stat-v { font-size: 1.35rem; }
.grid > .panel { scroll-margin-top: 16px; } /* переход из «Главного»: заголовок блока виден целиком */
.summary .stat-pop { display: flex; flex-direction: column; justify-content: flex-start; } /* цифры шапки — на одной линии */

/* Кнопка «Наверх» — в правом нижнем углу, появляется после первого экрана прокрутки (уведомления — над ней) */
.to-top { position: fixed; right: 20px; bottom: 20px; z-index: 9; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px 0 12px; font: inherit; font-weight: 600; color: #fff; background: var(--navy); border: 0; border-radius: 22px; box-shadow: 0 4px 14px rgb(46 64 56 / 25%); cursor: pointer; }
.to-top[hidden] { display: none; }
.to-top svg { width: 18px; height: 18px; }
.to-top:hover { background: var(--signal); }
.to-top:focus-visible { outline: 2px solid var(--navy); outline-offset: 3px; }
@media (max-width: 760px) { .to-top { right: 16px; bottom: 16px; } }

/* Число в таблице — кнопка: щелчок открывает список, что за ним стоит */
.cellbtn { all: unset; box-sizing: border-box; display: inline-block; min-width: 24px; min-height: 24px; padding: 2px 6px; text-align: center; cursor: pointer; color: var(--signal); font-weight: 600; text-decoration: underline dotted; text-underline-offset: 3px; border-radius: 3px; }
.crumb { margin: 0 0 4px; font-size: 0.875rem; color: var(--muted); }
.note-line { margin: 0 0 10px; color: var(--warn); }
.cellbtn:hover { text-decoration-style: solid; }
.cellbtn:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

/* «Аналитика»: без пустот на широком экране.
   «Главное» — цифры поровну на всю ширину; в блоке — цифры и пояснение слева, график справа;
   у блоков без графика — пояснение справа от цифр; короткая таблица «Загрузки» — с пояснением рядом */
.summary .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.summary .stat:last-child { border-right: 0; margin-right: 0; }
/* план и факт: цифры 2×2 слева, график справа (одной высоты), пояснение — под ними на всю ширину */
.blk-pf > .stats { display: grid; grid-template-columns: repeat(2, minmax(0, max-content)); gap: 10px 0; }
.blk-pf > .stats .stat:nth-child(2n) { border-right: 0; }
@media (min-width: 1200px) {
  .blk-pf { display: grid; grid-template-columns: minmax(380px, 1fr) minmax(0, 2.2fr); grid-template-areas: "stats chart" "about about"; gap: 4px 36px; align-items: center; }
  .blk-pf > .stats { grid-area: stats; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .blk-pf > .chart { grid-area: chart; margin: 0; }
  .blk-pf > .blk-about { grid-area: about; }
  .blk-top { display: grid; gap: 4px 36px; align-items: start; }
  .blk-top.blk-text { grid-template-columns: max-content minmax(0, 1fr); }
  .blk-text .stats { margin-bottom: 0; }
  .blk-text .src:first-child, .blk-text .hint:first-child { margin-top: 2px; }
  .blk-split { display: grid; grid-template-columns: minmax(0, max-content) minmax(280px, 1fr); gap: 28px; align-items: start; }
  .blk-side .hint { margin-top: 0; }
}

/* Телефон: счётчики — по два в ряд, без висящих разделителей (после правил «Главного», чтобы перекрыть их) */
@media (max-width: 760px) {
  .stats { display: flex; flex-wrap: wrap; gap: 10px 16px; }
  .stat { flex: 1 1 140px; } /* по два в ряд; длинная сумма — на свою строку */
  /* строка свёрнутой таблицы — в одну строку: стрелка и число хватает, «Показать таблицу» лишнее */
  /* панель фильтров — по два поля в ряд: на первом экране остаются цифры, а не одни фильтры */
  .toolbar:not(.inline) { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
  .toolbar:not(.inline) .seg, .toolbar:not(.inline) .tb-reset { grid-column: 1 / -1; }
  .toolbar:not(.inline) .ms-btn, .toolbar:not(.inline) input[type="date"] { width: 100%; }
  .fold-act { display: none; }
  .chart-swipe { display: inline; }
  .fold-t, .fold-n { white-space: nowrap; }
  .stat, .summary .stat { border-right: 0; margin-right: 0; padding-right: 0; }
}

/* Версия выпуска внизу портала: дописывает сервер (lib/app-version.js) */
.app-version { margin: 8px 24px 24px; font-size: 12px; color: var(--muted); }
@media print { .app-version { display: none; } }
