/* Свод – базовые стили. Цвета – только через токены. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #586070;  /* темнее прежнего #6b7280 – читается без напряжения (аудит 15.10.2026) */
  --border: #e3e6eb;
  --accent: #2f6fed;
  --danger: #c0392b;
  --warn: #b7791f;
  --ok: #2f855a;
  --pill-gray-bg: #eef0f3;  --pill-gray: #4b5563;
  --pill-blue-bg: #e7efff;  --pill-blue: #2453b3;
  --pill-amber-bg: #fdf3e1; --pill-amber: #8a5a12;
  --pill-green-bg: #e5f4ea; --pill-green: #23683f;
  --pill-red-bg: #fbe9e7;   --pill-red: #a3301f;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
}
/* Крупный шрифт – кнопки «А−» / «А+» в шапке (static/js/size.js); все размеры в rem растут вместе с ним */
:root[data-size="large"] { font-size: 17px; }
:root[data-size="xlarge"] { font-size: 19px; }
.font-size { display: inline-flex; gap: 2px; white-space: nowrap; }
.font-size button { font-weight: 600; padding: 2px 6px; border: 1px solid var(--border); border-radius: 6px; }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
.muted { color: var(--muted); }
.error { color: var(--danger); }

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 16px; height: 52px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); }
.nav { display: flex; gap: 16px; flex: 1; overflow-x: auto; }
.nav a, .nav .soon { white-space: nowrap; color: var(--muted); padding: 4px 0; }
.nav a.active { color: var(--text); border-bottom: 2px solid var(--accent); }
.nav .soon { opacity: .5; cursor: default; }
.nav-toggle { display: none; font-size: 1rem; white-space: nowrap; }
/* Г4: до 900 px – компактное меню по кнопке «≡ Меню» вместо обрезанной строки с прокруткой. */
@media (max-width: 900px) {
  .topbar { position: relative; }
  .nav-toggle { display: inline-block; }
  .nav { display: none; }
  .topbar.nav-open .nav { display: flex; flex-direction: column; gap: 0; position: absolute; top: 52px; left: 0; right: 0;
    z-index: 30; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: 0 6px 20px rgba(0, 0, 0, .08);
    padding: 4px 16px; overflow: visible; }
  .topbar.nav-open .nav a { padding: 12px 0; border-bottom: 1px solid var(--border); }
  .topbar.nav-open .nav a.active { border-bottom: 1px solid var(--border); color: var(--accent); }
  .user { margin-left: auto; }
}
.user { display: flex; align-items: center; gap: 12px; color: var(--muted); white-space: nowrap; }
.user form { margin: 0; }

.page { max-width: 1200px; margin: 0 auto; padding: 24px 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px; margin-top: 16px;
}

button { font: inherit; padding: 8px 16px; border-radius: var(--radius); border: 0; background: var(--accent); color: #fff; cursor: pointer; }
button.link { background: none; color: var(--accent); padding: 0; }
input { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); width: 100%; }
label { display: block; margin: 12px 0; color: var(--muted); }

.login { max-width: 400px; margin: 10vh auto 0; }
.register { max-width: 820px; margin: 6vh auto 0; }
.steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 12px 0 20px; counter-reset: step; }
.steps li { flex: 1; padding: 6px 10px; border-radius: var(--radius); background: var(--bg); color: var(--muted); counter-increment: step; }
.steps li::before { content: counter(step) ". "; }
.steps li.current { background: var(--accent); color: #fff; }
.steps li.done { background: var(--pill-green-bg); color: var(--pill-green); }
.enroll { display: grid; grid-template-columns: 1fr 260px; gap: 24px; align-items: start; }
.enroll h3 { font-size: 1rem; margin: 16px 0 6px; }
.qr svg { width: 100%; height: auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.secret { word-break: break-all; font-size: 1rem; }
.codes { columns: 2; font-size: 1.15rem; }
.inline-check { display: flex; gap: 8px; align-items: center; color: var(--text); }
@media (max-width: 700px) { .enroll { grid-template-columns: 1fr; } .qr { max-width: 260px; } }
@media print { .topbar, form, button { display: none !important; } .codes { font-size: 1.3rem; } }
.messages { list-style: none; padding: 0; }
.messages li { padding: 8px 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.messages .undo-form { display: inline; margin-left: 8px; }

[x-cloak] { display: none !important; }
.small { font-size: .85rem; }
.late { color: var(--warn); font-weight: 600; }
input[type="checkbox"] { width: 16px; height: 16px; margin: 0; }

/* «Сегодня» */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.segmented a { padding: 6px 14px; color: var(--muted); background: var(--surface); }
.segmented a.active { background: var(--accent); color: #fff; }

.block { margin-top: 24px; }
.block h2 { font-size: 1rem; margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.block-overdue h2 { color: var(--warn); }
.count { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 11px; background: var(--border);
  color: var(--text); text-align: center; font-size: .8rem; }
.rows { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.row { display: grid; grid-template-columns: 24px minmax(160px, 1.2fr) 3fr 150px; gap: 12px; align-items: center;
  padding: 10px 12px; border-top: 1px solid var(--border); }
.row:first-child { border-top: 0; }
.row.is-overdue { box-shadow: inset 3px 0 0 var(--warn); }
.row .check { margin: 0; display: flex; }
.org { font-weight: 600; }
.tracks { display: flex; flex-direction: column; gap: 6px; }
.track { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.track-name { min-width: 110px; }
.when { text-align: right; }

.pill { padding: 2px 8px; border-radius: 10px; font-size: .87rem; white-space: nowrap; }
.pill-gray { background: var(--pill-gray-bg); color: var(--pill-gray); }
.pill-blue { background: var(--pill-blue-bg); color: var(--pill-blue); }
.pill-amber { background: var(--pill-amber-bg); color: var(--pill-amber); }
.pill-green { background: var(--pill-green-bg); color: var(--pill-green); }
.pill-red { background: var(--pill-red-bg); color: var(--pill-red); }

button.step { padding: 3px 10px; font-size: .85rem; background: var(--surface); color: var(--accent);
  border: 1px solid var(--accent); }
button.step:hover { background: var(--accent); color: #fff; }
button.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.done { color: var(--ok); font-weight: 700; }

.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; padding: 0 6px; color: var(--muted); border-radius: 6px; }
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { background: var(--border); }
.menu-list { position: absolute; z-index: 10; left: 0; top: 24px; min-width: 220px; max-width: calc(100vw - 32px); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0, 0, 0, .08);
  display: flex; flex-direction: column; padding: 4px; }
.menu-list button { background: none; color: var(--text); text-align: left; padding: 6px 10px; }
.menu-list button:hover { background: var(--bg); }
.menu.align-right .menu-list { left: auto; right: 0; }  /* у правого края экрана – раскрывается влево (Г3) */
.menu-list button { min-height: 40px; }

.bulkbar { position: sticky; top: 0; z-index: 20; display: flex; gap: 12px; align-items: center; padding: 10px 12px;
  margin-top: 16px; background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); }
.empty { color: var(--muted); }

/* Реестр и ввод сумм */
.page-wide { max-width: none; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
select { font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); max-width: min(360px, 100%); }
.grid-wrap { margin-top: 16px; overflow: auto; max-height: calc(100vh - 190px); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); }
.grid { border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.grid th, .grid td { padding: 6px 8px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); white-space: nowrap; }
.grid thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); font-weight: 600; text-align: center; }
.grid .sticky-col { position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left; }
.grid thead .sticky-col { z-index: 3; }
.org-cell { font-weight: 600; min-width: 170px; }
.cell { text-align: center; cursor: pointer; min-width: 52px; }
/* Аудит 15.10.2026: ячейка реестра словами и суммой, как в Excel; точки – дополнение для цвета */
.grid td.cell { min-width: 84px; padding: 4px 6px; line-height: 1.25; }
.cell-state { display: block; font-size: .87rem; white-space: nowrap; }
.cell.is-done .cell-state { color: var(--ok); font-weight: 600; }
.cell.is-late .cell-state { color: var(--warn); font-weight: 600; }
.cell-sum { display: block; font-size: .87rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-marks { display: block; }
.cell-note { font-size: .75rem; margin-left: 2px; }
.grid tfoot .totals td, .grid tfoot .totals th { border-top: 2px solid var(--border); text-align: center; background: var(--surface); }
.cell:hover, .cell:focus { background: var(--bg); outline: none; }
.cell.is-late { box-shadow: inset 0 -3px 0 var(--warn); }
.cell.is-done { background: #f3faf5; }
.cell.is-future { opacity: .55; }
.cell.is-none { background: repeating-linear-gradient(45deg, transparent 0 6px, var(--bg) 6px 12px); cursor: default; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 2px; vertical-align: middle; }
.dot-gray { background: #c7ccd4; }
.dot-blue { background: var(--accent); }
.dot-amber { background: #e0a43a; }
.dot-green { background: var(--ok); }
.dot-red { background: var(--danger); }
.sums-link { margin-left: 4px; font-weight: 400; }
.legend { margin-top: 8px; }
.num { text-align: right; }
.sums-grid td { padding: 3px 6px; }
input.amount { width: 110px; padding: 4px 6px; text-align: right; font-variant-numeric: tabular-nums; }
input.amount.saved { border-color: var(--ok); background: var(--pill-green-bg); }
input.amount.invalid { border-color: var(--danger); background: var(--pill-red-bg); }
input.amount[readonly] { background: var(--bg); border-color: transparent; color: var(--muted); }

.event-row { grid-template-columns: minmax(200px, 2fr) 2fr 150px; }
.new-event summary { cursor: pointer; }
.new-event-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; margin-top: 8px; }
.new-event-form .wide { grid-column: 1 / -1; }
.new-event-form label { margin: 8px 0; }
.new-event-form select { width: 100%; max-width: none; }

.journal-form { display: grid; grid-template-columns: 160px 1fr; gap: 8px; }
.journal-form textarea { grid-column: 1 / -1; }
.journal-form button { justify-self: start; }
.journal-row { grid-template-columns: minmax(200px, 1fr) 3fr; cursor: default; }

.notice { border-color: var(--accent); background: var(--pill-blue-bg); }
.block-approval h2 { color: var(--accent); display: flex; align-items: center; gap: 12px; }
.approval-row { grid-template-columns: 24px minmax(180px, 1fr) 2fr auto; }
.approval-actions { display: flex; gap: 8px; }

.summary-cell { min-width: 130px; line-height: 1.6; }

/* Карточка организации */
.tabs { display: flex; gap: 4px; margin-top: 16px; border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.row-compact { grid-template-columns: minmax(160px, 1fr) 3fr; cursor: pointer; }
.row-compact:hover { background: var(--bg); }
.card h3 { margin: 0 0 8px; font-size: 1rem; }
.accruals { width: 100%; }
.accruals td, .accruals th { border-bottom: 1px solid var(--border); }
.accruals tfoot th { font-weight: 600; }
.list-table td { white-space: normal; }
.org a, .org-cell a { color: var(--text); }
.org a:hover, .org-cell a:hover { color: var(--accent); }

/* Панель справа */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .25); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); z-index: 50; overflow-y: auto;
  background: var(--surface); box-shadow: -8px 0 30px rgba(0, 0, 0, .12); padding: 16px 20px; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.drawer section { padding: 12px 0; border-bottom: 1px solid var(--border); }
.drawer h3 { font-size: .95rem; margin: 0 0 8px; }
.drawer .track { margin-bottom: 6px; }
/* Поиск (Д7.1, Д4) */
.egrul-warning { color: var(--danger); font-weight: 600; }
.egrul-full { margin-top: 10px; }
.egrul-full > summary { cursor: pointer; color: var(--accent); font-size: .9rem; }
.egrul-full table { margin-top: 6px; }
.egrul-full th { text-align: left; padding-top: 8px; font-weight: 600; }
.egrul-actions { margin-top: 8px; }
.details-link { color: inherit; text-decoration: underline dotted; }
.org-filters { margin: 12px 0; flex-wrap: wrap; }
.org-filters input[type=search] { flex: 1 1 260px; width: auto; }
.search-open { font-size: 1.1rem; }
.search-input { font-size: 1.05rem; }
.search-drawer section { padding: 8px 0; }
.search-hit { display: block; padding: 8px; border-radius: var(--radius); color: var(--text); }
.search-hit:hover, .search-hit:focus { background: var(--pill-blue-bg); outline: none; }
/* «Сегодня»: группы по виду (Г9) */
details.group { border-top: 1px solid var(--border); }
details.group:first-of-type { border-top: 0; }
details.group > summary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 16px; cursor: pointer;
  background: var(--bg); list-style: none; }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::before { content: "▸"; color: var(--muted); }
details.group[open] > summary::before { content: "▾"; }
.group-check { width: auto; margin: 0; }
.sums-button { margin-left: auto; }
/* Карточка клиента: «Обзор» и заметки (Д1, Д2) */
.overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 16px; }
.overview .card { margin-top: 16px; }
.overview-wide { grid-column: 1 / -1; }
.overview h3 { margin-top: 0; }
.note-hint { color: var(--pill-amber); cursor: help; }
.drawer .pinned-notes { padding: 8px; border-radius: var(--radius); margin: 8px 0; }
.pinned-notes { background: var(--pill-amber-bg); border-color: var(--pill-amber-bg); }
.note { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.note.is-pinned { background: var(--pill-amber-bg); padding: 8px; border-radius: var(--radius); }
.contact { padding: 6px 0; border-bottom: 1px dashed var(--border); }
form.inline { display: inline; }
.inline-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 12px; align-items: end; }
.inline-form .wide { grid-column: 1 / -1; }
.quick-edit summary { cursor: pointer; color: var(--accent); font-size: .9rem; margin-top: 8px; }
.attr-edit { display: inline-block; }
.attr-edit[open] { display: block; }
.attr-edit > summary { display: inline; margin: 0 0 0 4px; list-style: none; }
.attr-edit > summary::-webkit-details-marker { display: none; }
.attr-edit[open] > form { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: end; margin: 6px 0; }
.attr-bool { display: inline-flex; gap: 6px; }
button.copy { font-size: .8rem; margin-left: 6px; }
/* Сроки действия ЭП и доверенностей (Д6) */
.term { font-size: .85rem; margin-left: 6px; white-space: nowrap; }
.term-late { color: var(--danger); font-weight: 600; }
.term-soon { color: var(--warn); font-weight: 600; }
.term-ok { color: var(--muted); }
/* Явное сохранение в панели и короткие сообщения внизу экрана (1.7а) */
.save-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.save-bar button.save { padding: 6px 14px; }
.save-state { font-size: .85rem; font-weight: 400; color: var(--muted); }
.save-state.ok { color: var(--ok); }
.save-state.fail { color: var(--danger); }
.drawer-close { min-width: 44px; min-height: 44px; font-size: 1.2rem; }
textarea.saved { border-color: var(--ok); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: var(--radius); background: var(--text); color: var(--surface);
  box-shadow: 0 4px 16px rgba(15, 23, 42, .2); }
.mini { border-collapse: collapse; }
.mini td, .mini th { padding: 4px 6px; text-align: left; font-weight: 400; vertical-align: top;
  border-bottom: 1px solid var(--border); }
.mini > tbody > tr:last-child > td, .mini > tr:last-child > td { border-bottom: 0; }
/* Справка «подпись – значение» (реквизиты, особенности клиента): подпись фиксированной ширины, серым */
.kv { width: 100%; table-layout: fixed; }
.kv td:first-child { width: 40%; color: var(--muted); overflow-wrap: break-word; hyphens: auto; }
.kv td + td { overflow-wrap: break-word; }
.matrix-wrap { overflow-x: auto; }
.matrix th { font-size: .8rem; vertical-align: bottom; white-space: nowrap; }
.matrix input.amount { width: 92px; }
.recon { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; margin-top: 2px; }
.diff-neg { color: var(--accent); font-weight: 600; }
textarea { font: inherit; width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); }
.history { list-style: none; padding: 0; margin: 0; }
.history li { padding: 4px 0; border-bottom: 1px dashed var(--border); }

@media (max-width: 800px) {
  .row { grid-template-columns: 24px 1fr; }
  .tracks, .when { grid-column: 2; }
  .when { text-align: left; }
  /* У событий и строк карточки нет колонки с галочкой – всё в одну колонку. */
  .event-row, .row-compact { grid-template-columns: 1fr; }
  .event-row > *, .row-compact > * { grid-column: 1; }
}

@media (max-width: 640px) {
  .topbar { gap: 12px; }
  .user span { display: none; }
  .kv td:first-child { width: 46%; }
  .user .font-size { display: none; }  /* на телефоне размер текста – в настройках самого телефона, в шапке нет места */
}

/* 3.1: подписи этапов у точек реестра, текущий период, итог в вводе сумм */
.track-mark { display: inline-flex; align-items: center; font-size: .72rem; color: var(--muted); margin: 0 1px; white-space: nowrap; }
.track-mark .dot { margin: 0 1px 0 0; }
.grid th.is-current { background: var(--pill-blue-bg); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.sums-total th, .sums-total td { font-weight: 600; border-top: 2px solid var(--border); background: var(--surface); position: sticky; bottom: 0; }

/* 3.2: экран «Команда» */
.team-table th, .team-table td { padding: 6px 10px; }
.team-table td.num, .team-table th.num { text-align: right; white-space: nowrap; }
.team-unassigned td { background: var(--pill-amber-bg); }
.team-total th, .team-total td { font-weight: 600; border-top: 2px solid var(--border); }

/* 3.4: горячие клавиши */
.row.is-focused { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
kbd { display: inline-block; min-width: 1.4em; padding: 1px 5px; border: 1px solid var(--border); border-bottom-width: 2px;
      border-radius: 4px; background: var(--bg); font: inherit; font-size: .8rem; text-align: center; }
.keys th { text-align: left; padding-top: 12px; }
.keys td:first-child { white-space: nowrap; padding-right: 12px; }

/* 3.5: «Справка» */
.help { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 0 16px; }
.help .card { margin-top: 16px; }
.help h2 { margin: 0 0 8px; font-size: 1.15rem; }
.help details { border-top: 1px solid var(--border); padding: 8px 0; }
.help details:first-of-type { border-top: 0; }
.help summary { cursor: pointer; color: var(--accent); }
.help details[open] summary { font-weight: 600; color: var(--text); }
.help ol { margin: 8px 0 0; padding-left: 20px; line-height: 1.5; }
.help li { margin-bottom: 4px; }

/* 3.7: мастер «Новый клиент» */
.wizard h2 { font-size: 1.1rem; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.step-no { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff;
           align-items: center; justify-content: center; font-size: .9rem; }
.questions { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 10px 16px; }
.questions label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.questions .wide { grid-column: 1 / -1; margin: 6px 0 0; }
.preview-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 8px 16px; }
.preview-groups ul { margin: 4px 0 0; padding-left: 18px; }
.wizard-submit { margin: 16px 0 32px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.error-box { border-left: 3px solid var(--danger); }
.button-link { display: inline-block; padding: 6px 12px; border-radius: var(--radius); background: var(--accent); color: #fff; }

/* 3.8: конструктор правил */
.rules h2 { font-size: 1.1rem; margin: 0 0 8px; }
.rules-table td { vertical-align: top; padding: 4px 6px; }
.rules-table select, .rules-table input { max-width: 100%; }
.deadline, .condition { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; margin: 2px 0; }
.condition { padding: 4px 0; }
.choice-values { display: inline-flex; flex-wrap: wrap; gap: 2px 10px; align-items: center; }
.skip-list { display: flex; flex-wrap: wrap; gap: 4px 14px; }
pre.json { white-space: pre-wrap; font-size: .8rem; max-height: 400px; overflow: auto; }
.rule-row { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: flex-end; padding: 10px 0; border-top: 1px solid var(--border); }
.rule-row:first-of-type { border-top: 0; }
.rule-row label { display: flex; flex-direction: column; gap: 2px; font-size: .85rem; }
.rule-deadline { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.deadline > span, .condition > span { display: inline-flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; max-width: 100%; }
.deadline select, .deadline input, .condition select, .condition input, .rule-row select, .rule-row input { max-width: 100%; min-width: 0; }
.rule-deadline > *, .rule-row > label { min-width: 0; max-width: 100%; }
.rule-deadline, .deadline, .condition { min-width: 0; max-width: 100%; }
.deadline > span > select, .condition > span > select, .deadline > select, .condition > select { flex: 0 1 auto; font-size: .9rem; }

/* Этап 4: раздел «Отчёты» – список, таблицы с итогами, диаграммы на SVG, печать */
.report-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 8px; }
.report-card { display: flex; flex-direction: column; gap: 6px; margin-top: 0; color: var(--text); }
.report-card:hover { border-color: var(--accent); }
.report-tools { display: flex; gap: 16px; align-items: center; }
.report-filters { margin-top: 12px; }
.report-filters .inline-check { margin: 0; }
.report-page .card h2 { font-size: 1.05rem; margin: 0 0 8px; }
.report-wrap { max-height: none; margin-top: 8px; }
.report-table td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.report-table td.num .small { font-weight: 400; }
.report-total th, .report-total td { font-weight: 600; background: var(--bg); }
.nowrap { white-space: nowrap; }
.chart { width: 100%; max-width: 760px; height: auto; display: block; }
.chart .bar-0, .chart-legend .bar-0 { fill: var(--accent); background: var(--accent); }
.chart .bar-1, .chart-legend .bar-1 { fill: #b9c9ee; background: #b9c9ee; }
.chart .bar-2, .chart-legend .bar-2 { fill: var(--warn); background: var(--warn); }
.chart .bar:hover { opacity: .8; }
.chart-grid { stroke: var(--border); stroke-dasharray: 3 3; }
.chart-zero { stroke: var(--muted); }
.chart-axis, .chart-label { fill: var(--muted); font-size: .75rem; }
.chart-legend { display: flex; gap: 16px; margin: 4px 0 0; color: var(--muted); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.print-only { display: none; }
@media print {
  .no-print, .nav-toggle, #drawer, .toast { display: none !important; }
  .print-only { display: block; }
  body { background: #fff; }
  .page { max-width: none; padding: 0; }
  .card { border: 0; padding: 0; margin-top: 12px; }
  .grid-wrap { overflow: visible; max-height: none; border: 0; }
  .grid thead th, .grid .sticky-col { position: static; }
  .grid th, .grid td { padding: 2px 4px; font-size: 9pt; }
  a { color: inherit; }
}
.recon-table td.recon-advice, .recon-table td.recon-review { white-space: normal; min-width: 240px; max-width: 420px; }
.recon-advice p { margin: 0 0 4px; }
.recon-form { display: flex; gap: 6px; margin-top: 4px; }
.recon-form input { padding: 4px 6px; font-size: .85rem; }
.recon-row.is-reviewed td, .recon-row.is-reviewed th { background: #f3faf5; }
/* Ж3: требования ФНС/СФР – красная метка и сроки этапов */
.row.is-highlight { box-shadow: inset 4px 0 0 var(--danger); }
.stages { margin-top: 2px; }
.stage-current { font-weight: 600; }
.report-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 16px; }
.report-table td.wrap { white-space: normal; min-width: 260px; max-width: 480px; }
.report-table tr.is-highlight th { box-shadow: inset 4px 0 0 var(--danger); }
/* Ж2, Ж5: «Требует внимания» и панель руководителя */
.attention-list { list-style: none; padding: 0; margin: 8px 0 0; }
.attention-list li { padding: 6px 0; border-top: 1px dashed var(--border); }
.attention-list li:first-child { border-top: 0; }
.attention-block summary { cursor: pointer; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 8px; }
.kpi { display: flex; flex-direction: column; gap: 4px; margin-top: 0; color: var(--text); }
.kpi:hover { border-color: var(--accent); }
.kpi-label { color: var(--muted); font-size: .9rem; }
.kpi-value { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-warn { box-shadow: inset 4px 0 0 var(--warn); }
.kpi-danger { box-shadow: inset 4px 0 0 var(--danger); }
.chart-wrap { overflow-x: auto; }
/* Ж1.6: календарь сроков */
.month-cal { border-collapse: collapse; width: 100%; min-width: 640px; table-layout: fixed; }
.month-cal th { padding: 6px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); }
.month-cal td { border: 1px solid var(--border); vertical-align: top; height: 92px; padding: 0; }
.month-cal td.out { opacity: .45; }
.month-cal td.off { background: var(--bg); }
.month-cal td.peak { box-shadow: inset 0 0 0 2px var(--warn); }
.month-cal td.is-today .cal-num { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 6px; }
.month-cal td.chosen { background: var(--pill-blue-bg); }
.cal-day { display: flex; flex-direction: column; gap: 2px; padding: 4px 6px; height: 100%; color: var(--text); font-size: .8rem; }
.cal-num { font-weight: 600; align-self: flex-start; }
.cal-pay { color: var(--pill-amber); }
.cal-ev { color: var(--pill-blue); }
.month-input { width: auto; padding: 5px 8px; }
/* Ж4: конструктор отчётов */
.builder { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.builder-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.builder-row label { margin: 0; display: flex; flex-direction: column; gap: 2px; font-size: .85rem; }
.builder-row input[type=date] { width: auto; padding: 5px 8px; }
.builder-cols { border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 6px 12px; margin: 4px 0 0; }
.builder-cols .inline-check { margin: 0; }
.report-new { border-style: dashed; }
.saved-list { margin: 0; padding-left: 18px; }
.saved-list li { padding: 3px 0; }
/* Запросы клиенту (В5) */
.requests { list-style: none; margin: 0; padding: 0; }
.requests li { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.requests li > span:first-child { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; }
.requests li.done > span:first-child { text-decoration: line-through; color: var(--muted); }
.request-actions { display: inline-flex; gap: 8px; align-items: center; }
.request-form { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.request-form textarea { width: 100%; box-sizing: border-box; }
/* Массовые действия в списке организаций (В6) */
.check-col { width: 28px; text-align: center; }
.org-bulkbar { flex-wrap: wrap; }
.menu-up { position: relative; }
.menu-up > summary { cursor: pointer; list-style: none; padding: 4px 10px; border: 1px solid var(--accent); border-radius: var(--radius); color: var(--accent); }
.menu-up > summary::-webkit-details-marker { display: none; }
.menu-up .bulk-form { position: absolute; top: calc(100% + 8px); left: 0; z-index: 30; background: var(--surface, var(--bg));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column;
  gap: 6px; min-width: 260px; max-width: calc(100vw - 32px); box-shadow: 0 4px 16px rgba(0, 0, 0, .15); }

/* «Налоги за срок» */
.date-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.date-chips .chip { padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font-size: .9rem; }
.date-chips .chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.date-chips .chip.overdue:not(.active) { border-color: var(--danger, #c0392b); color: var(--danger, #c0392b); }
.notices-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.notices-grid td { padding: 3px 6px; }
.notices-grid .group-head { border-bottom: 2px solid var(--accent); }
.notices-grid td.state { white-space: nowrap; border-right: 2px solid var(--border); }
.notices-grid td.state .pill { font-size: .85rem; }
.notices-grid input.amount.has-hint::placeholder { color: var(--muted); font-style: italic; opacity: 1; }
.notices-grid .hint-value { color: var(--muted); font-style: italic; }
/* Сумма подставлена системой из проведённого уведомления 1С (Д2): синяя полоска слева; правка человеком её снимает */
.notices-grid .from-onec { box-shadow: inset 3px 0 0 var(--accent); }
.notices-grid input.amount.from-onec { background: var(--pill-blue-bg); }
.notices-grid td.calc { color: var(--muted); background: var(--bg, transparent); }
.notices-grid td.src input.amount { background: var(--pill-blue-bg); }
.notices-grid td.pay { white-space: nowrap; }
.notices-grid td.pay button { padding: 2px 8px; }

/* --- уведомления --------------------------------------------------------------------------- */
.bell { position: relative; text-decoration: none; }
.bell-badge { position: absolute; top: -6px; right: -10px; min-width: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--danger); color: #fff; font-size: .7rem; line-height: 16px; text-align: center; }
.notify-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.notify-settings { display: grid; gap: 16px; }
@media (max-width: 800px) { .notify-grid { grid-template-columns: 1fr; } }
.notice-item { padding: 8px 0; border-bottom: 1px solid var(--border); }
.notice-item:last-child { border-bottom: 0; }
.notice-item.is-new { font-weight: 600; }
.notice-item.is-important { border-left: 3px solid var(--danger); padding-left: 8px; }
.device-row { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 4px 0; }
.copy-field { width: 100%; max-width: 100%; font-size: .8rem; }
.jobs-banner { border-left: 4px solid var(--danger); }
.jobs-banner.is-ok { border-left-color: var(--ok); }

/* --- В2: меню из 5 пунктов, «Помощники ▾» и «Ещё ▾» ------------------------------------------ */
.nav { overflow: visible; align-items: center; }
.nav-group { position: relative; }
.nav-group > summary { list-style: none; cursor: pointer; white-space: nowrap; color: var(--muted); padding: 4px 0; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary.active { color: var(--text); border-bottom: 2px solid var(--accent); }
.nav-list { position: absolute; top: calc(100% + 8px); left: -12px; z-index: 40; min-width: 220px; display: flex;
  flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .08); padding: 4px 0; }
.nav-list a { padding: 8px 12px; color: var(--text); }
.nav-list a:hover { background: var(--bg, rgba(0, 0, 0, .04)); }
.nav-list a.active { color: var(--accent); border-bottom: 0; font-weight: 600; }
@media (max-width: 900px) {
  .topbar.nav-open .nav-group > summary { padding: 12px 0; border-bottom: 1px solid var(--border); }
  .topbar.nav-open .nav-list { position: static; box-shadow: none; border: 0; padding: 0 0 0 12px; min-width: 0; }
  .topbar.nav-open .nav-list a { padding: 10px 0; border-bottom: 1px solid var(--border); }
}

/* --- 4.1/В4: цвет точки – фаза статуса (одинаково во всех наборах) -------------------------- */
.dot.phase-todo { background: #c7ccd4; }
.dot.phase-in_work { background: var(--accent); }
.dot.phase-waiting { background: #e0a43a; }
.dot.phase-done { background: var(--ok); }
.dot.phase-skipped { background: transparent; box-shadow: inset 0 0 0 1.5px #c7ccd4; }
.legend { margin: 8px 0; }
/* В7: «Вернуть» – поле причины в строке, без окна браузера */
.return-menu > summary.button-like { list-style: none; cursor: pointer; display: inline-block; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.return-menu > summary::-webkit-details-marker { display: none; }
.return-box { min-width: 280px; padding: 10px; display: grid; gap: 8px; }
.return-box textarea { width: 100%; }

/* Памятка «Как сделать?» в панели задачи (аудит 15.10.2026) */
details.howto { margin: 8px 0; padding: 8px 10px; border-radius: var(--radius); background: var(--pill-blue-bg); }
details.howto summary { cursor: pointer; color: var(--accent); font-weight: 600; }
details.howto div { margin-top: 6px; line-height: 1.45; }
.from-onec-legend { box-shadow: inset 3px 0 0 var(--accent); padding-left: 6px; }

/* Журнал ошибок и «Сообщить о проблеме» (план 16.10.2026, пп. 9–10) */
pre.trace { max-height: 320px; overflow: auto; white-space: pre-wrap; font-size: .75rem; background: var(--bg);
  padding: 8px; border-radius: var(--radius); }
.page-foot { max-width: 1200px; margin: 0 auto 16px; padding: 0 16px; font-size: .85rem; color: var(--muted); }
.page-foot summary { cursor: pointer; color: var(--accent); display: inline; }
.page-foot form { display: flex; flex-direction: column; gap: 8px; max-width: 560px; margin-top: 8px; }

/* Чтение из 1С: кнопка на месте данных, шкала прогресса, индикатор в шапке (план 16.10.2026, п. 1а) */
.onec-refresh form { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.onec-job { padding: 8px 10px; border-radius: var(--radius); background: var(--bg); max-width: 640px; }
.onec-job.is-active { background: var(--pill-blue-bg); }
.onec-job-line { display: flex; justify-content: space-between; gap: 12px; font-size: .9rem; }
.progress { height: 8px; border-radius: 999px; background: var(--surface); overflow: hidden; margin: 4px 0; }
.progress > span { display: block; height: 100%; background: var(--accent); transition: width 1.5s linear; }
.onec-header summary { white-space: nowrap; color: var(--accent); font-weight: 600; }
.onec-header .nav-list a { white-space: normal; min-width: 240px; }
.onec-refresh .onec-bad, .onec-job .onec-bad { color: var(--danger); font-weight: 600; }
.onec-job .onec-ok { color: var(--ok); }
.onec-refresh.compact, .onec-job.compact { display: inline; padding: 0; background: none; }
.onec-refresh.compact form { display: inline; }

/* «Доктор» (план 16.10.2026, п. 12) */
.doctor-mark { display: inline-block; width: 1.2em; font-weight: 700; }
.doctor-ok .doctor-mark { color: var(--ok); }
.doctor-warn .doctor-mark { color: var(--warn); }
.doctor-bad .doctor-mark, .doctor-bad td:first-child { color: var(--danger); }
.doctor-info .doctor-mark { color: var(--muted); }
.doctor-fix { display: inline; margin-left: 6px; }
/* Загрузка отчётов 1С файлами (план 16.10.2026, п. 2) */
.onec-upload { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 8px 0 12px; }
.onec-pairs { margin: 4px 0; padding-left: 18px; }
.onec-pairs li { margin: 2px 0; }
.onec-pairs form.inline { display: inline; margin-left: 6px; }
