/* ЮгСтройИнвест — согласование реестров счетов.
   Палитра и пластика взяты из образца, вёрстка переработана под адаптив:
   таблица живёт на десктопе, на узких экранах те же данные показываются карточками. */

:root {
  --bg: #f4f4ef;
  --surface: #ffffff;
  --surface-soft: #f8f8f4;
  --line: #e6e7e2;
  --line-strong: #d9dcd5;
  --text: #1c252c;
  --muted: #6d777c;
  --blue: #115c8d;
  --blue-deep: #0b4b76;
  --blue-soft: #eaf3f8;
  --green: #557a46;
  --green-soft: #edf4e8;
  --amber: #9b6c13;
  --amber-soft: #fff5dc;
  --red: #9b4d47;
  --red-soft: #faeceb;
  --shadow: 0 14px 40px rgba(26, 45, 55, 0.07);
  --shadow-soft: 0 7px 22px rgba(26, 45, 55, 0.06);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  /* Один отступ от края экрана на всё приложение: шапка и содержимое
     считают его из одной переменной, поэтому логотип и «Архив реестров»
     всегда стоят ровно над краями плиток и карточки счетов. */
  --gutter: 28px;
  --shell-max: 1920px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
a { color: var(--blue); }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* Шапка и содержимое — одна колонка: одинаковый отступ от края и общая
   максимальная ширина. На экранах шире --shell-max отступ растёт с обеих
   сторон, поэтому края не расходятся и на широком мониторе. */
.topbar, .main-content {
  padding-left:  max(var(--gutter), calc((100% - var(--shell-max)) / 2 + var(--gutter)));
  padding-right: max(var(--gutter), calc((100% - var(--shell-max)) / 2 + var(--gutter)));
}

/* ─────────────────────────── Шапка ─────────────────────────── */

.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 12px;
  padding-bottom: 12px;
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; flex: 0 0 auto; }
/* Логотип обрезан вплотную по буквам — высоту задаём по самим буквам,
   поэтому левый край картинки и есть левый край логотипа. */
.brand-logo { height: 38px; width: auto; display: block; }

/* Меню прижато вправо: реестр → архив → настройки, следом «Выйти». */
.top-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
/* Пилюли — только у переключателей разделов; «Архив реестров» открывает
   окно, а не вид, и остаётся ссылкой. */
.top-nav button[data-view] {
  border: 0; background: transparent; color: #56636a;
  font-weight: 650; font-size: 13px; padding: 9px 14px; border-radius: 999px;
}
.top-nav button[data-view]:hover { background: var(--surface-soft); color: var(--text); }
.top-nav button[data-view].active { background: var(--blue-soft); color: var(--blue-deep); }

.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-link { border: 0; background: transparent; color: var(--blue-deep); font-weight: 650; padding: 10px 10px; font-size: 13px; }
.topbar-link:hover { color: var(--blue); }

.logout-button {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-soft); border: 1px solid var(--line);
  border-radius: 999px; padding: 9px 15px;
  color: #455158; font-size: 13px; font-weight: 650;
}
.logout-button svg {
  width: 17px; height: 17px; flex: 0 0 auto;
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.logout-button:hover { background: var(--red-soft); border-color: #efd6d3; color: var(--red); }

/* ─────────────────────────── Общее ─────────────────────────── */

.main-content { padding-top: 26px; padding-bottom: 40px; width: 100%; flex: 1; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--blue); font-weight: 760; }
h1 { margin: 0; font-size: 30px; line-height: 1.1; letter-spacing: -.035em; font-weight: 720; }

.secondary-button, .primary-button {
  min-height: 44px; border-radius: 13px; padding: 0 16px; font-weight: 680;
  border: 1px solid var(--line-strong); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.secondary-button { background: var(--surface); color: #455158; }
.secondary-button:hover { background: #fbfbf8; border-color: #cfd4cc; }
.primary-button { background: var(--blue-deep); color: #fff; border-color: var(--blue-deep); }
.primary-button:hover { background: var(--blue); }
.primary-button:disabled, .secondary-button:disabled { cursor: default; opacity: .5; }
.danger-button { background: #8e4944; color: #fff; border-color: #8e4944; }
.danger-button:hover { background: #7d403c; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  border-radius: 999px; padding: 6px 11px; font-size: 12px; font-weight: 700;
  background: var(--surface-soft); color: #55616a; border: 1px solid var(--line);
}
.badge.city { background: var(--blue-soft); color: var(--blue-deep); border-color: #d7e8f0; }
.badge.pending { background: var(--amber-soft); color: var(--amber); border-color: #f0e1b6; }
.badge.approved { background: var(--green-soft); color: var(--green); border-color: #dce9d4; }
.badge.rejected { background: var(--red-soft); color: var(--red); border-color: #efd6d3; }

.field-label { display: block; font-size: 11px; font-weight: 700; color: #5d686e; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .05em; }
.text-input, .select-input, .textarea-input {
  width: 100%; min-height: 44px; padding: 10px 13px;
  border: 1px solid var(--line-strong); border-radius: 11px;
  background: #fff; color: var(--text); font-size: 13px; outline: 0;
}
.textarea-input { min-height: 92px; resize: vertical; line-height: 1.4; }
.text-input:focus, .select-input:focus, .textarea-input:focus { border-color: #9bb7c8; box-shadow: 0 0 0 3px #eaf3f8; }
.text-input.invalid, .textarea-input.invalid { border-color: #d3a19c; box-shadow: 0 0 0 3px #faeceb; }
.hint { margin: 6px 0 0; font-size: 11px; color: var(--muted); line-height: 1.45; }
.error-text { margin: 8px 0 0; font-size: 12px; color: #9a4945; font-weight: 620; }

/* ─────────────────────────── Вход ─────────────────────────── */

.login-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #e7f1f6 0%, var(--bg) 60%);
}
.login-card {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-xl); box-shadow: var(--shadow); padding: 34px 30px 28px;
}
.login-card .brand { justify-content: center; margin-bottom: 22px; }
.login-card .brand-logo { height: 46px; }
.login-card h1 { font-size: 22px; text-align: center; margin: 0 0 22px; }
.login-form { display: grid; gap: 14px; }
.login-form .primary-button { width: 100%; min-height: 48px; margin-top: 4px; }

/* ─────────────────────── Реестр: шапка ─────────────────────── */

/* Без горизонтальных отступов: заголовок реестра и поиск стоят ровно
   по краям плиток и карточки счетов. */
.hero-panel { display: flex; justify-content: space-between; align-items: flex-end; gap: 22px; padding: 4px 0 20px; flex-wrap: wrap; }
.hero-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hero-meta { margin: 9px 0 0; color: var(--muted); font-size: 13px; }
.hero-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search-box {
  width: 300px; max-width: 100%; height: 44px; display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 13px;
  padding: 0 13px; box-shadow: 0 2px 8px rgba(26, 45, 55, .02);
}
.search-icon { width: 14px; height: 14px; border: 2px solid #8a9499; border-radius: 50%; position: relative; flex: 0 0 auto; }
.search-icon:after { content: ""; position: absolute; width: 6px; height: 2px; background: #8a9499; transform: rotate(45deg); right: -5px; bottom: -2px; border-radius: 2px; }
/* Обновление данных: кнопка и время последнего обновления под ней. */
.refresh-box { display: grid; gap: 4px; justify-items: start; }
.refresh-button {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-md);
  background: var(--surface); color: var(--blue-deep);
  font-size: 12px; font-weight: 700; white-space: nowrap;
  transition: border-color .15s ease-out, background-color .15s ease-out;
}
.refresh-button:hover:not(:disabled) { border-color: #b9d2dd; background: var(--blue-soft); }
.refresh-button:disabled { color: #9aa4a9; background: var(--surface-soft); }
.refresh-button svg {
  width: 16px; height: 16px; flex: 0 0 auto;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.refresh-button.busy svg { animation: refresh-spin 1s linear infinite; }
@keyframes refresh-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .refresh-button.busy svg { animation: none; } }
.refresh-time { font-size: 10px; color: var(--muted); padding-left: 2px; }

.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; }
.search-box input::placeholder { color: #9aa2a6; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card {
  padding: 17px 19px 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: 0 4px 20px rgba(26, 45, 55, .035);
}
.stat-card.accent-card { background: #f0f6f8; border-color: #dce9ee; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 620; }
.stat-value { margin-top: 8px; font-size: 23px; font-weight: 740; letter-spacing: -.03em; overflow-wrap: anywhere; }
.stat-note { margin-top: 5px; color: #8b9498; font-size: 11px; }

.registry-card, .summary-card, .panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl);
  box-shadow: var(--shadow); overflow: hidden;
}
.registry-card-head, .panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 22px 17px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.registry-card-head h2, .panel-head h2 { margin: 0; font-size: 17px; font-weight: 720; letter-spacing: -.02em; }
.registry-card-head p, .panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.legend { display: flex; gap: 14px; align-items: center; color: var(--muted); font-size: 11px; flex-wrap: wrap; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; }
.legend-dot.pending { background: #d7ad50; }
.legend-dot.approved { background: #73935e; }
.legend-dot.rejected { background: #b8756f; }

/* ───────────────────── Реестр: таблица ─────────────────────── */

.table-wrap { overflow-x: auto; }
.registry-table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; min-width: 1240px; }
.registry-table thead th {
  padding: 13px 12px; background: #f8f8f5;
  color: #606b70; font-size: 10px; line-height: 1.25; font-weight: 700;
  text-align: left; text-transform: uppercase; letter-spacing: .055em;
  border-bottom: 1px solid var(--line);
}
.registry-table thead th span { text-transform: none; letter-spacing: 0; font-weight: 600; display: block; }
.registry-table tbody td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 12px; }
/* Строка кликабельна целиком — открывает карточку счёта. */
.registry-table tbody tr.invoice-row { cursor: pointer; }
.registry-table tbody tr.invoice-row:hover td { background: #fcfcfa; }
.comment-field { cursor: auto; }
.registry-table tbody tr.invoice-row.is-approved td { background: #fdfefc; }
.registry-table tbody tr.invoice-row.is-rejected td { background: #fdfaf9; }
.registry-table tbody tr:last-child td { border-bottom: 0; }
.col-number { width: 48px; }
.col-details { width: 145px; }
.col-action { width: 180px; }
.col-comment { width: 225px; }
.row-number { color: #8a9499; font-weight: 700; }
.cell-title { color: var(--blue-deep); font-weight: 670; line-height: 1.35; overflow-wrap: anywhere; }
.cell-meta { margin-top: 4px; color: #8a9499; font-size: 10px; }
.cell-text { line-height: 1.38; color: #2d393f; overflow-wrap: anywhere; }
.purpose-link { color: var(--blue); font-weight: 620; text-decoration: none; }
.purpose-link:hover { text-decoration: underline; }
.cell-date { white-space: nowrap; color: #566267; }
.cell-money { white-space: nowrap; font-weight: 730; font-variant-numeric: tabular-nums; }

.details-button {
  width: 100%; min-height: 38px; border: 1px solid #cfe1e9; background: #eaf5f8; color: var(--blue-deep);
  border-radius: 10px; font-weight: 720; font-size: 11px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px;
}
.details-button:hover { background: #e1f0f4; }
.details-button:after { content: "⌄"; font-size: 15px; transform: translateY(-1px); transition: .2s ease; }
.details-button.expanded:after { transform: rotate(180deg) translateY(-1px); }

.action-menu { position: relative; }
.action-trigger {
  width: 100%; min-height: 38px; border-radius: 999px; padding: 0 12px;
  border: 1px solid transparent; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 11px; font-weight: 720;
}
.action-trigger:after { content: ""; width: 6px; height: 6px; border-right: 1.7px solid currentColor; border-bottom: 1.7px solid currentColor; transform: rotate(45deg) translateY(-2px); opacity: .75; }
.action-trigger[disabled]:after { display: none; }
.action-trigger.status-pending { background: var(--amber-soft); color: var(--amber); border-color: #f0e1b6; }
.action-trigger.status-approved { background: var(--green-soft); color: var(--green); border-color: #dbe8d5; }
.action-trigger.status-rejected { background: var(--red-soft); color: var(--red); border-color: #efd6d3; }
.action-trigger.status-locked { background: #f1f2ef; color: #747d81; border-color: #e3e5df; cursor: default; }
.action-dropdown {
  display: none; position: fixed; min-width: 225px; padding: 7px;
  background: #fff; border: 1px solid var(--line); border-radius: 13px;
  box-shadow: 0 16px 38px rgba(19, 39, 51, .15); z-index: 100;
}
.action-dropdown.open { display: block; }
.action-option {
  width: 100%; min-height: 38px; border: 0; border-radius: 9px; background: transparent;
  text-align: left; padding: 0 11px; color: #3e4b52; font-size: 12px; font-weight: 630;
}
.action-option:hover { background: #f4f5f1; }
.action-option.approve { color: #4b7040; }
.action-option.reject { color: #9a4945; }
/* Отказ без причины запрещён — пункт выглядит недоступным, но клик по нему
   не молчит, а подсказывает заполнить комментарий. */
.action-option.reject.needs-comment { color: #b6a3a1; }
.comment-field.invalid { border-color: #d3a19c; box-shadow: 0 0 0 3px #faeceb; }

.comment-field {
  width: 100%; min-height: 54px; max-height: 120px; resize: vertical;
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 10px;
  color: #3e4a50; background: #fff; outline: 0; line-height: 1.35; font-size: 11px;
}
.comment-field:focus { border-color: #9bb7c8; box-shadow: 0 0 0 3px #eaf3f8; }
.comment-field:disabled { background: #fafaf7; color: #697478; opacity: 1; }

.detail-row td { padding: 0 !important; background: #f4f8f9 !important; }
.detail-panel {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1px;
  background: #dfeaed; border-bottom: 1px solid #dfeaed;
}
.detail-block { background: #f1f7f8; padding: 17px; }
.detail-block-title { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: #75858d; font-weight: 730; margin-bottom: 11px; }
.detail-list { display: grid; gap: 9px; }
.detail-item { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px; font-size: 11px; line-height: 1.3; }
.detail-item span:first-child { color: #78858b; }
.detail-item span:last-child { color: #35434a; font-weight: 600; overflow-wrap: anywhere; }
.detail-source { display: inline-flex; align-items: center; gap: 7px; color: var(--blue-deep); background: #e5f0f4; border-radius: 999px; padding: 6px 9px; font-size: 10px; font-weight: 680; }
.open-invoice-button { min-height: 36px; padding: 0 12px; border: 1px solid #b9d2dd; background: #fff; color: var(--blue-deep); border-radius: 9px; font-weight: 680; font-size: 10px; }
.open-invoice-button:hover { background: #f7fbfc; }
.detail-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* «Посмотреть счет» — открывает скан из 1С. Ссылка, а не кнопка, чтобы
   работало «открыть в новой вкладке» средствами браузера. */
.view-invoice-button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 36px; padding: 0 14px;
  border: 1px solid #b9d2dd; border-radius: 9px;
  background: var(--blue-soft); color: var(--blue-deep);
  font-weight: 700; font-size: 10px; text-decoration: none; white-space: nowrap;
  transition: background-color .15s ease-out, border-color .15s ease-out;
}
.view-invoice-button:hover { background: #dcecf5; }
.view-invoice-button.compact { margin-top: 8px; min-height: 28px; padding: 0 10px; }
.view-invoice-button.primary { min-height: 40px; padding: 0 18px; font-size: 11px; }
.view-invoice-button[disabled] {
  background: var(--surface-soft); border-color: var(--line-strong); color: #9aa4a9;
  cursor: default;
}

/* ─────────── Реестр: карточки для узких экранов ─────────── */

.invoice-cards { display: none; padding: 14px; gap: 12px; grid-template-columns: 1fr; }
.invoice-card { border: 1px solid var(--line); border-radius: var(--radius-md); background: #fff; overflow: hidden; cursor: pointer; }
.invoice-card.is-approved { background: #fcfefb; }
.invoice-card.is-rejected { background: #fefaf9; }
.invoice-card-head { display: flex; justify-content: space-between; gap: 12px; padding: 14px 15px 12px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.invoice-card-head .num { font-size: 11px; color: #8a9499; font-weight: 700; }
.invoice-card-head .title { margin-top: 3px; font-size: 13px; font-weight: 700; color: var(--blue-deep); line-height: 1.3; overflow-wrap: anywhere; }
.invoice-card-body { padding: 12px 15px; display: grid; gap: 9px; }
.card-line { display: grid; grid-template-columns: minmax(96px, 40%) minmax(0, 1fr); gap: 10px; font-size: 12px; line-height: 1.35; }
.card-line span:first-child { color: #78858b; }
.card-line span:last-child { color: #2d393f; font-weight: 620; overflow-wrap: anywhere; }
.card-line.total span:last-child { font-weight: 760; }
.invoice-card-foot { padding: 0 15px 14px; display: grid; gap: 9px; }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.card-actions button { min-height: 40px; border-radius: 11px; font-size: 12px; font-weight: 700; border: 1px solid var(--line-strong); }
.card-actions .approve { background: var(--green-soft); color: var(--green); border-color: #dbe8d5; }
.card-actions .reject { background: var(--red-soft); color: var(--red); border-color: #efd6d3; }
.card-extra { padding: 0 15px 14px; }

.empty-state { padding: 52px 20px; text-align: center; }
.empty-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; margin: 0 auto 13px; background: #edf2f3; color: #75858d; font-weight: 760; }
.empty-state h3 { margin: 0; font-size: 16px; }
.empty-state p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }

.summary-card { margin-top: 16px; }
.summary-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; padding: 20px 22px 17px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.summary-head h2 { margin: 6px 0 0; font-size: 17px; font-weight: 720; }
.summary-total { text-align: right; }
.summary-total strong { font-size: 22px; letter-spacing: -.03em; }
.summary-total span { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }
.registry-bulk-actions {
  display: flex; justify-content: flex-end; align-items: center; gap: 12px;
  padding: 18px 22px 20px; border-top: 1px solid var(--line); background: #fbfbf8; flex-wrap: wrap;
}
.registry-bulk-actions button { min-width: 190px; }
.bulk-reject-button { color: var(--red); border-color: #e6c9c6; }
.bulk-reject-button:hover { background: var(--red-soft); border-color: #ddb8b4; }

/* Принудительное согласование: янтарный, как и всё «внимание, это обход».
   Намеренно не зелёный — чтобы не читалось как обычное «Согласовать». */
.bulk-force-button { color: var(--amber); border-color: #f0e1b6; }
.bulk-force-button:hover { background: var(--amber-soft); border-color: #e6d3a4; }


/* ─────────────────────────── Настройки ─────────────────────────── */

.settings-head { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.settings-head .icon {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: 0 0 auto;
  background: linear-gradient(140deg, var(--blue-deep), #3a86ad); color: #fff; font-size: 19px;
  box-shadow: 0 8px 18px rgba(11, 75, 118, .22);
}
.settings-head h1 { font-size: 24px; }
.settings-head p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

.settings-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.settings-tabs button {
  display: flex; align-items: center; gap: 10px; padding: 12px 15px; margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent; background: transparent; color: #667177; text-align: left;
}
.settings-tabs button:hover { color: var(--text); border-bottom-color: var(--line-strong); }
.settings-tabs button.active { color: var(--text); border-bottom-color: var(--blue); }
.settings-tabs .tab-ico {
  width: 18px; height: 18px; flex: 0 0 auto; opacity: .8;
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.settings-tabs button.active .tab-ico { opacity: 1; color: var(--blue); }
.settings-tabs .tab-label { font-size: 13px; font-weight: 700; display: block; }

.panel { max-width: 980px; margin-bottom: 18px; }
.panel-body { padding: 20px 22px 22px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 15px; }
.form-row { display: grid; gap: 0; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.checkbox-row { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 620; color: #404c53; }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--blue-deep); }

.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table thead th {
  padding: 11px 14px; background: var(--surface-soft); color: #606b70;
  font-size: 10px; font-weight: 700; text-align: left; text-transform: uppercase; letter-spacing: .055em;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.data-table tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #fbfbf8; }
.data-table .right { text-align: right; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto;
  background: linear-gradient(140deg, var(--blue-deep), #3a86ad); color: #fff; font-weight: 750; font-size: 11px;
}
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell b { font-weight: 640; font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: var(--muted); }
.icon-action {
  width: 32px; height: 32px; border-radius: 9px; border: 1px solid transparent; background: transparent;
  color: #8d979c; display: inline-grid; place-items: center; font-size: 14px;
}
.icon-action:hover { background: var(--surface-soft); color: var(--blue-deep); border-color: var(--line); }
.icon-action.danger:hover { color: #9a4945; background: #faeceb; border-color: #efd6d3; }

.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.perm-group { border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.perm-group h4 { margin: 0; padding: 11px 14px; background: var(--surface-soft); font-size: 12px; font-weight: 730; border-bottom: 1px solid var(--line); }
.perm-item { display: flex; gap: 11px; padding: 11px 14px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.perm-item:last-child { border-bottom: 0; }
.perm-item input { width: 17px; height: 17px; margin-top: 2px; accent-color: var(--blue-deep); flex: 0 0 auto; }
.perm-item b { display: block; font-size: 12.5px; font-weight: 660; }
.perm-item span { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

.field-editor { display: grid; gap: 10px; }
.field-row {
  display: grid; grid-template-columns: 22px minmax(140px, 1.4fr) minmax(120px, 1fr) 120px 120px 92px 36px;
  gap: 9px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-md); background: #fdfdfb;
}
.field-row .drag { display: grid; gap: 2px; justify-items: center; }
.field-row .drag .move {
  width: 22px; height: 17px; padding: 0; line-height: 1; font-size: 8px;
  border: 1px solid var(--line); background: #fff; border-radius: 5px; color: #7d878c;
}
.field-row .drag .move:hover:not(:disabled) { background: var(--surface-soft); color: var(--blue-deep); }
.field-row .drag .move:disabled { opacity: .3; cursor: default; }
.field-row input, .field-row select { min-height: 38px; padding: 8px 10px; font-size: 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; outline: 0; width: 100%; }
.field-row .key { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.field-head { display: grid; grid-template-columns: 22px minmax(140px, 1.4fr) minmax(120px, 1fr) 120px 120px 92px 36px; gap: 9px; padding: 0 10px; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: #7d878c; font-weight: 700; }
.suggest-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.suggest-chip {
  border: 1px dashed #bcd3de; background: #f2f9fb; color: var(--blue-deep); border-radius: 999px;
  padding: 7px 12px; font-size: 11px; font-weight: 650;
}
.suggest-chip:hover { background: #e6f2f6; }
.suggest-chip[disabled] { opacity: .45; cursor: default; }

.log-list { display: grid; gap: 8px; }
.log-item { display: grid; grid-template-columns: 96px 1fr auto; gap: 12px; align-items: center; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-md); font-size: 12px; }
.log-item .when { color: var(--muted); font-size: 11px; }
.log-item.ok { border-left: 3px solid #73935e; }
.log-item.error { border-left: 3px solid #b8756f; }
.log-item.skipped { border-left: 3px solid #d7ad50; }

/* ─────────────────────────── Модалки ─────────────────────────── */

.modal { display: none; position: fixed; inset: 0; z-index: 200; align-items: center; justify-content: center; padding: 18px; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 31, 37, .42); backdrop-filter: blur(4px); }
.modal-dialog {
  position: relative; width: min(720px, 96vw); max-height: 90vh; overflow: auto;
  background: #fff; border-radius: 24px; border: 1px solid rgba(255, 255, 255, .6);
  box-shadow: 0 30px 100px rgba(15, 29, 38, .28);
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 20px 22px 17px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 6px 0 0; font-size: 20px; letter-spacing: -.025em; }
.modal-body { padding: 20px 22px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 22px 22px; flex-wrap: wrap; }
.icon-button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: #f8f8f5; font-size: 22px; line-height: 1; color: #677279; flex: 0 0 auto; }
.icon-button:hover { background: #f0f1ed; }

.archive-dialog { width: min(780px, 96vw); }
.archive-toolbar { padding: 14px 22px 4px; display: flex; gap: 10px; }
.archive-toolbar .select-input { flex: 1; min-width: 0; }
.archive-bulk { display: flex; align-items: center; gap: 14px; padding: 12px 22px 0; }
.archive-bulk .checkbox-row { font-size: 12px; font-weight: 660; }
.archive-selected { font-size: 12px; color: var(--muted); margin-right: auto; }
.archive-bulk-delete { min-height: 36px; padding: 0 13px; font-size: 12.5px; }
.archive-bulk-delete:disabled { cursor: default; opacity: .45; }
.archive-pick { display: grid; place-items: center; padding-left: 10px; }
.archive-pick input { width: 17px; height: 17px; accent-color: var(--blue-deep); }
.archive-empty { padding: 32px 12px 36px; text-align: center; color: var(--muted); font-size: 12px; }
.archive-list { padding: 10px 12px 16px; }
/* Строка архива = кнопка открытия + корзина рядом. Подсветка наведения живёт
   на строке целиком, чтобы корзина не «выпадала» из неё своим фоном. */
/* Флекс, а не грид: набор ячеек в строке зависит от прав (отметка и корзина
   есть только у тех, кому можно удалять), и колонки пришлось бы считать дважды. */
.archive-row { display: flex; align-items: center; gap: 2px; border-radius: 14px; padding-right: 6px; }
.archive-row .archive-item { flex: 1; min-width: 0; }
.archive-row:hover { background: #f6f7f3; }
.archive-row.active { background: #eef4f6; }
.archive-item { width: 100%; border: 0; background: transparent; display: grid; grid-template-columns: 1fr auto; gap: 14px; text-align: left; padding: 14px 12px; border-radius: 14px; }
/* Корзина видна всегда, а не по наведению: на телефоне наведения нет,
   да и искать скрытую кнопку удаления неудобно. Спокойный серый до наведения. */
.archive-delete { flex: 0 0 auto; color: #b6bec2; }
.archive-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.archive-badge { min-width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue-deep); font-weight: 760; font-size: 12px; flex: 0 0 auto; }
.archive-title { font-size: 13px; font-weight: 720; color: #2a373d; display: block; }
.archive-meta { margin-top: 4px; font-size: 10px; color: #849095; display: block; }
.archive-side { text-align: right; align-self: center; }
.archive-amount { font-size: 13px; font-weight: 730; display: block; }
.archive-state { margin-top: 4px; font-size: 10px; color: #748087; display: block; }

/* Страница счёта — раскладка формы «Счет на оплату» из 1С. */
.invoice-page { display: grid; gap: 18px; }
.inv-page-head { display: grid; gap: 12px; }
.inv-back {
  justify-self: start;
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 0 18px 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-md);
  background: var(--surface); color: var(--blue-deep);
  font-size: 13px; font-weight: 700; text-decoration: none;
  transition: border-color .15s ease-out, background-color .15s ease-out;
}
.inv-back:hover { border-color: #b9d2dd; background: var(--blue-soft); }
.inv-back svg {
  width: 20px; height: 20px; flex: 0 0 auto;
  fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}
.inv-page-title h1 { margin: 0; font-size: 24px; line-height: 1.25; overflow-wrap: anywhere; }
.inv-page-badges { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.inv-page-amount { font-size: 17px; font-weight: 740; }
.inv-decided { margin: 8px 0 0; color: var(--muted); font-size: 11px; }
.inv-card {
  display: grid; gap: 20px; padding: 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}
.inv-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 26px; }
.inv-col { margin: 0; display: grid; gap: 7px; align-content: start; }
.inv-field { display: grid; grid-template-columns: 148px 1fr; gap: 12px; align-items: baseline; }
.inv-field dt { color: var(--muted); font-size: 10px; line-height: 1.35; }
.inv-field dd {
  margin: 0; padding: 6px 10px; min-height: 30px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px;
  font-size: 11px; line-height: 1.35; font-weight: 620; color: #2a373d; overflow-wrap: anywhere;
}
.inv-lines-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.inv-lines-head h4 { margin: 0; font-size: 13px; color: var(--blue-deep); }
.inv-lines-head span { color: #849095; font-size: 10px; }
.inv-lines-wrap { overflow-x: auto; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }
.inv-lines { width: 100%; min-width: 560px; border-collapse: collapse; }
.inv-lines th, .inv-lines td { padding: 9px 11px; font-size: 11px; text-align: left; border-bottom: 1px solid var(--line); }
.inv-lines th {
  background: var(--surface-soft); color: #606b70; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .055em;
}
.inv-lines tbody tr:hover td { background: #fcfcfa; }
.inv-lines .inv-line-num { width: 44px; color: #8a9499; font-weight: 700; }
.inv-lines .inv-line-sum { text-align: right; white-space: nowrap; }
.inv-lines-empty td { color: #8a9499; text-align: center; padding: 18px 11px; }
.inv-lines tfoot td { border-bottom: 0; background: var(--surface-soft); font-weight: 730; font-size: 11px; }
.inv-lines tfoot td:first-child { color: var(--muted); text-align: right; }
.inv-files { display: grid; gap: 8px; }
.inv-file {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-soft); text-decoration: none; color: inherit;
  transition: border-color .15s ease-out, background-color .15s ease-out;
}
.inv-file:hover { border-color: #b9d2dd; background: var(--blue-soft); }
.inv-file-icon {
  width: 20px; height: 20px; flex: 0 0 auto;
  fill: none; stroke: var(--blue); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.inv-file-body { display: grid; gap: 3px; min-width: 0; }
.inv-file-name { font-size: 11px; font-weight: 650; color: var(--blue-deep); overflow-wrap: anywhere; }
.inv-file-meta { font-size: 10px; color: #849095; }
.inv-files-empty { margin: 0; color: #8a9499; font-size: 11px; }

.inv-comment { display: grid; gap: 5px; }
.inv-comment span { color: var(--muted); font-size: 10px; }
.inv-comment p {
  margin: 0; padding: 9px 11px; min-height: 40px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px;
  font-size: 11px; line-height: 1.45; overflow-wrap: anywhere;
}
.inv-comment-field { min-height: 72px; }
.inv-actions { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 4px; }
.inv-actions button { min-width: 180px; }

.confirm-dialog { width: min(460px, 96vw); padding: 26px; text-align: center; overflow: visible; }
.confirm-icon { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; margin: 0 auto 14px; background: var(--blue-soft); color: var(--blue-deep); font-size: 20px; font-weight: 800; }
.confirm-dialog h2 { margin: 0; font-size: 19px; }
.confirm-dialog p { margin: 9px auto 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; max-width: 360px; }
.confirm-comment { margin-top: 18px; text-align: left; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }

.toast-stack { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 300; max-width: calc(100vw - 36px); }
.toast { min-width: 260px; max-width: 390px; padding: 13px 15px; border-radius: 13px; background: #21343e; color: #fff; box-shadow: 0 16px 40px rgba(15, 29, 38, .24); font-size: 11.5px; line-height: 1.4; animation: toastIn .22s ease both; }
.toast strong { display: block; font-size: 12.5px; margin-bottom: 3px; }
.toast.success { background: #496642; }
.toast.warning { background: #8d6821; }
.toast.error { background: #8e4944; }
@keyframes toastIn { from { transform: translateY(7px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.loading-veil { padding: 60px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.spinner { width: 22px; height: 22px; border: 2.5px solid #d8e2e6; border-top-color: var(--blue-deep); border-radius: 50%; margin: 0 auto 12px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────────────────────── Адаптив ─────────────────────────── */

@media (max-width: 1280px) {
  :root { --gutter: 20px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1080px) {
  .field-row, .field-head { grid-template-columns: 22px minmax(120px, 1fr) 108px 104px 78px 36px; }
  .field-row .key-cell, .field-head .key-cell { display: none; }
}

@media (max-width: 900px) {
  .table-wrap { display: none; }
  .invoice-cards { display: grid; }
  .hero-panel { align-items: stretch; }
  .hero-toolbar { width: 100%; }
  .search-box { flex: 1 1 200px; width: auto; }
  .registry-bulk-actions button { flex: 1 1 160px; min-width: 0; }
  .summary-head { align-items: flex-start; }
  .summary-total { text-align: left; }
  .inv-fields { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  :root { --gutter: 14px; }
  .topbar { min-height: 0; gap: 10px; padding-top: 10px; padding-bottom: 10px; }
  .brand-logo { height: 30px; }
  /* Меню уезжает во вторую строку целиком, поэтому вправо в первой строке
     «Выйти» прижимает уже она сама, а не меню. */
  .top-nav { order: 3; width: 100%; margin-left: 0; }
  .top-nav button { flex: 1; text-align: center; }
  .topbar-actions { gap: 8px; margin-left: auto; }
  .logout-button span { display: none; }
  .logout-button { padding: 9px 11px; }
  .main-content { padding-top: 18px; padding-bottom: 32px; }
  h1 { font-size: 24px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 19px; }
  .registry-card, .summary-card, .panel { border-radius: var(--radius-lg); }
  .registry-card-head, .panel-head, .summary-head, .registry-bulk-actions { padding-left: 16px; padding-right: 16px; }
  .panel-body { padding: 16px; }
  .modal { padding: 10px; }
  .modal-dialog { border-radius: 18px; max-height: 94vh; }
  .field-row, .field-head { grid-template-columns: 1fr 1fr; }
  .field-head { display: none; }
  .field-row .drag { display: none; }
  .data-table thead th, .data-table tbody td { padding: 10px 11px; }
  /* Отметка и корзина отъедают ширину у названия реестра — на телефоне
     ужимаем всё, что можно, иначе название ломается на три строки. */
  .archive-toolbar { flex-wrap: wrap; }
  .archive-toolbar .select-input { flex: 1 0 100%; }
  .archive-bulk { flex-wrap: wrap; gap: 8px 10px; padding-left: 16px; padding-right: 16px; }
  .archive-bulk-delete { flex: 1 0 100%; }
  .archive-list { padding-left: 6px; padding-right: 6px; }
  .archive-row { padding-right: 2px; }
  .archive-item { padding: 12px 6px; gap: 8px; }
  .archive-main { gap: 8px; }
  .archive-badge { min-width: 36px; height: 36px; border-radius: 10px; font-size: 11px; }
  .archive-pick { padding-left: 4px; }
  .archive-delete { width: 28px; height: 28px; }
}

@media (max-width: 460px) {
  /* Три пункта в строке: чуть мельче и без переносов, иначе «Реестр счетов»
     и «Архив реестров» ломаются на две строки. */
  .top-nav button { font-size: 12px; padding-left: 6px; padding-right: 6px; white-space: nowrap; }
  .stats-grid { grid-template-columns: 1fr; }
  .card-actions { grid-template-columns: 1fr; }
  .confirm-actions { grid-template-columns: 1fr; }
  .detail-item, .card-line { grid-template-columns: 1fr; gap: 3px; }
  .inv-field { grid-template-columns: 1fr; gap: 3px; }
  .inv-card { padding: 16px 14px 20px; }
  .inv-page-title h1 { font-size: 19px; }
  .inv-actions button { min-width: 0; flex: 1 1 100%; }
}

/* Ярлык «Копия» (.copy-badge) живёт только в стилях копии — в боевой
   версии его нет намеренно, чтобы шапки двух приложений не путались. */

/* ═══════════════════════════ Цепочка согласования ═══════════════════════════ */

/* ── Колокольчик в шапке ── */

.bell-button {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  background: var(--surface-soft); border: 1px solid var(--line);
  border-radius: 999px; color: #455158;
}
.bell-button svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.bell-button:hover { background: var(--blue-soft); border-color: #d7e8f0; color: var(--blue-deep); }
.bell-button.has-unread { background: var(--amber-soft); border-color: #f0e1b6; color: var(--amber); }

/* Счётчик сидит на кнопке, поэтому у кнопки position: relative. */
.bell-count {
  position: absolute; top: -3px; right: -3px;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 760; line-height: 1;
  border: 2px solid var(--bg);
}

/* ── Список уведомлений ── */

.notify-dialog { width: min(620px, 96vw); }
.notify-toolbar { padding: 12px 22px 0; display: flex; justify-content: flex-end; }
.notify-list { padding: 12px 14px 16px; max-height: 60vh; overflow-y: auto; }
.notify-empty { padding: 28px 8px; text-align: center; color: var(--muted); font-size: 13px; }

.notify-item {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left;
  padding: 12px 14px; border-radius: var(--radius-md); border: 1px solid transparent;
  background: transparent;
}
.notify-item + .notify-item { margin-top: 2px; }
.notify-item:hover { background: var(--surface-soft); border-color: var(--line); }
.notify-item.unread { background: #fbf8ef; border-color: #f0e1b6; }

.notify-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--amber); margin-top: 6px; flex: 0 0 auto; }
.notify-item:not(.unread) .notify-dot { background: var(--line-strong); }
.notify-body { min-width: 0; flex: 1; }
.notify-body b { display: block; font-size: 13px; font-weight: 700; }
.notify-body span { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.notify-body time { display: block; font-size: 11px; color: #98a1a5; margin-top: 5px; }

/* ── Панель цепочки под таблицей счетов ── */

.chain-card { margin-top: 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-xl); box-shadow: var(--shadow); overflow: hidden; }

.chain-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 22px 17px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.chain-head h2 { margin: 0; font-size: 17px; font-weight: 720; letter-spacing: -.02em; }
.chain-head-side { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Строка «сейчас ваша очередь» / «ждём такого-то» — единственное место,
   где видно, можно ли вообще нажимать кнопки решения. */
.chain-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 22px; font-size: 13px; border-bottom: 1px solid var(--line);
  background: var(--surface-soft); color: #455158;
}
.chain-banner.mine { background: var(--amber-soft); color: var(--amber); }
.chain-banner.done { background: var(--green-soft); color: var(--green); }
.chain-banner b { font-weight: 730; }

.chain-steps { padding: 6px 12px 14px; }

.chain-step {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 10px; border-radius: var(--radius-md);
}
.chain-step + .chain-step { border-top: 1px solid var(--line); border-radius: 0; }
.chain-step.is-active { background: #fbf8ef; }

.chain-num {
  width: 30px; height: 30px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 740;
  background: var(--surface-soft); color: #6d777c; border: 1px solid var(--line);
}
.chain-step.is-active   .chain-num { background: var(--amber-soft); color: var(--amber); border-color: #f0e1b6; }
.chain-step.is-approved .chain-num { background: var(--green-soft); color: var(--green); border-color: #dce9d4; }
.chain-step.is-rejected .chain-num { background: var(--red-soft);   color: var(--red);   border-color: #efd6d3; }
.chain-step.is-mixed    .chain-num { background: var(--blue-soft);  color: var(--blue-deep); border-color: #d7e8f0; }
/* Шаг обойдён принудительным согласованием — тот же янтарь, что у кнопки. */
.chain-step.is-forced   .chain-num { background: var(--amber-soft); color: var(--amber); border-color: #f0e1b6; }

.chain-who { min-width: 0; }
.chain-who b { display: block; font-size: 13px; font-weight: 700; }
.chain-who span { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }
.chain-side { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.chain-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.chain-time b { color: var(--text); font-weight: 700; }

.chain-foot {
  display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap;
  padding: 14px 22px 18px; border-top: 1px solid var(--line); background: #fbfbf8;
}

/* Развёрнутая история по счёту — внутри карточки счёта и на его странице. */
.chain-log { margin-top: 10px; border-top: 1px dashed var(--line-strong); padding-top: 10px; }
.chain-log-row { display: flex; gap: 10px; align-items: baseline; font-size: 12px; padding: 4px 0; flex-wrap: wrap; }
.chain-log-row .pos { color: var(--muted); font-weight: 700; min-width: 18px; }
.chain-log-row .who { font-weight: 660; }
.chain-log-row .when { color: var(--muted); margin-left: auto; white-space: nowrap; }
.chain-log-row .why { width: 100%; color: var(--muted); padding-left: 28px; }

/* Отметка решения в колонке «Действие», когда очередь не наша. */
.vote-mark {
  display: inline-flex; flex-direction: column; gap: 2px;
  font-size: 12px; line-height: 1.25;
}
.vote-mark b { font-weight: 700; }
.vote-mark.approved b { color: var(--green); }
.vote-mark.rejected b { color: var(--red); }
/* Пропуск и обход — не решения, поэтому ни зелёного, ни красного. */
.vote-mark.neutral b { color: var(--muted); font-weight: 640; }
.vote-mark span { color: var(--muted); font-size: 11px; }

/* ── Редактор цепочки в настройках ── */

.chain-editor { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.chain-edit-row {
  display: grid; grid-template-columns: 30px 1fr auto auto; gap: 10px; align-items: center;
  padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-soft);
}
.chain-edit-row .select-input { min-height: 40px; }
.chain-edit-row .move-box { display: flex; gap: 4px; }
.chain-edit-row .move {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: #fff; color: #6d777c; font-size: 10px;
}
.chain-edit-row .move:disabled { opacity: .35; }
.chain-empty { padding: 18px 2px; color: var(--muted); font-size: 13px; }

/* Цепь согласования привязана к городу, и таких цепей несколько. Каждая —
   отдельная карточка: в сплошном списке не видно, где кончается один город
   и начинается другой. Правится по одной, открытая подсвечена рамкой. */
.chain-city-card {
  border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 12px 14px 14px; margin-bottom: 12px; background: var(--surface);
}
.chain-city-card.editing { border-color: var(--blue-deep); box-shadow: 0 0 0 3px var(--blue-soft); }
.chain-city-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 6px;
}
.chain-city-title { font-size: 14px; font-weight: 730; color: var(--ink); }
.chain-city-note { color: var(--muted); font-size: 12px; }
.chain-card-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.chain-city-card .chain-empty { padding: 10px 2px; }
.chain-city-card .field-label { display: block; margin-bottom: 6px; }
.chain-city-card .chain-editor + .secondary-button.small { margin-top: 10px; }

/* Готовая цепь показывается простым нумерованным списком: на чтение
   выпадающие списки не нужны и только шумят. */
.chain-view-list { margin: 2px 0 0; padding-left: 22px; }
.chain-view-list li { font-size: 13px; color: var(--ink); padding: 2px 0; }
.chain-view-list li::marker { color: var(--muted); font-size: 12px; }

.secondary-button.small { padding: 6px 12px; font-size: 12px; min-height: 32px; }

@media (max-width: 720px) {
  .chain-head, .chain-banner, .chain-foot { padding-left: 16px; padding-right: 16px; }
  .chain-step { grid-template-columns: 28px 1fr; }
  .chain-side { grid-column: 1 / -1; justify-content: flex-start; padding-left: 40px; }
  .chain-foot .secondary-button, .chain-foot .primary-button { width: 100%; }
  /* На узком экране строка не влезает в один ряд: номер и выбор человека
     сверху, стрелки и «убрать» — вторым рядом. Раскладываем явно, иначе
     четвёртый элемент уезжает в первую колонку и крестик оказывается слева. */
  .chain-edit-row { grid-template-columns: 26px 1fr auto; row-gap: 8px; }
  .chain-edit-row .select-input  { grid-column: 2 / -1; }
  .chain-edit-row .move-box      { grid-column: 2 / 3; grid-row: 2; }
  .chain-edit-row .icon-action   { grid-column: 3 / 4; grid-row: 2; justify-self: end; }

  /* Подпись города переносим под название, чтобы не рвать его на слоги. */
  .chain-city-head { flex-wrap: wrap; }
  .chain-city-head .chain-city-note { flex: 1 0 100%; order: 3; }

  .notify-list { max-height: 68vh; }
}

@media (max-width: 460px) {
  .bell-button { width: 36px; height: 36px; }
}

/* Причина вместо кнопок решения, когда очередь ещё не наша.
   Стоит ровно там, где эти кнопки ищут. */
.bulk-note {
  margin: 0; margin-right: auto;
  font-size: 13px; color: var(--amber); font-weight: 640; line-height: 1.4;
}
.chain-banner.stuck { background: var(--red-soft); color: var(--red); }

@media (max-width: 720px) {
  .bulk-note { margin-right: 0; width: 100%; }
}

/* ⚠️ У .primary-button / .secondary-button задан display: inline-flex, а он
   специфичнее браузерного правила [hidden] { display: none } — без этой строки
   скрытые через hidden кнопки продолжали бы показываться. */
.primary-button[hidden], .secondary-button[hidden], .bulk-note[hidden] { display: none; }
