@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #F8F7F5;
  --surface: #FFFFFF;
  --text: #141414;
  --text-muted: #6B6B6B;
  --border: #E5E4E1;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --radius: 12px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; }

/* ── Header ── */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(248, 247, 245, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
}
.header-left { display: flex; align-items: center; gap: 28px; }
.wordmark {
  font-size: 15px; font-weight: 600; letter-spacing: -0.3px;
  color: var(--text); text-decoration: none;
}
.nav { display: flex; gap: 16px; }
.nav-link {
  font-size: 13px; color: var(--text-muted); text-decoration: none;
  padding: 4px 0; border-bottom: 1px solid transparent;
  transition: color 150ms, border-color 150ms;
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--text); border-bottom-color: var(--accent); }

.header-right { display: flex; align-items: center; gap: 16px; }
.updated-at { font-size: 13px; color: var(--text-muted); }

.btn-primary {
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 7px 14px;
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background 150ms;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.btn-sm {
  font-family: inherit; font-size: 12px; font-weight: 500;
  border-radius: 5px; padding: 5px 11px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); transition: all 150ms;
}
.btn-sm:hover { border-color: var(--text-muted); }
.btn-sm:disabled { opacity: 0.5; cursor: default; }

/* Сочетание .btn-primary.btn-sm — компактный primary-стиль (например,
   «Применить в Bitrix» в строке approved-черновика на /drafts). */
.btn-primary.btn-sm {
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  font-size: 12px; padding: 5px 11px; border-radius: 5px;
}
.btn-primary.btn-sm:hover {
  background: var(--accent-hover); border-color: var(--accent-hover);
}
.btn-primary.btn-sm:disabled { opacity: 0.6; }

.text-muted { color: var(--text-muted); }

/* ── Layout ── */
.main { padding: 24px; max-width: 1400px; margin: 0 auto; }
.section-title {
  font-size: 12px; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 12px;
}
.back-link {
  display: inline-block; font-size: 13px; color: var(--text-muted);
  text-decoration: none; margin-bottom: 16px;
}
.back-link:hover { color: var(--text); }

/* ── Sync progress ── */
.sync-progress-wrap { display: none; padding: 0 24px; margin-bottom: 4px; }
.sync-progress-wrap.visible { display: block; }
.sync-progress-track {
  width: 100%; height: 3px;
  background: var(--border); border-radius: 99px;
  overflow: hidden; margin-top: 4px;
}
.sync-progress-fill {
  height: 100%; width: 0%; background: var(--accent);
  border-radius: 99px; transition: width 400ms ease;
}
.sync-progress-label {
  display: block; font-size: 12px; color: var(--text-muted);
  padding: 4px 0;
}

/* ── KPI cards ── */
.kpi-row {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px; margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  text-decoration: none; color: var(--text); display: block;
}
.kpi-link { transition: border-color 150ms, transform 150ms; cursor: pointer; }
.kpi-link:hover { border-color: var(--accent); transform: translateY(-1px); }
.kpi-value {
  font-size: 28px; font-weight: 600; letter-spacing: -0.5px;
  color: var(--text);
}
.kpi-decisions .kpi-value { font-size: 22px; }
.kpi-label {
  font-size: 12px; color: var(--text-muted); margin-top: 4px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.kpi-progress {
  height: 3px; background: var(--border);
  border-radius: 99px; overflow: hidden; margin-top: 10px;
}
.kpi-progress-fill {
  height: 100%; width: 0%; background: var(--accent);
  border-radius: 99px; transition: width 400ms ease;
}

/* ── Panel ── */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.dash-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 800px) { .dash-grid { grid-template-columns: 1fr; } }

.dash-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dash-table th {
  text-align: left; font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); padding: 8px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.dash-table th:first-child, .dash-table td:first-child { padding-left: 0; }
.dash-table th:last-child, .dash-table td:last-child { padding-right: 0; }
.dash-table th.th-right { text-align: right; }
.dash-table td {
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.dash-table tr:last-child td { border-bottom: none; }
.dash-table td.td-right { text-align: right; font-variant-numeric: tabular-nums; }
.dash-table tr.row-link { cursor: pointer; transition: background 100ms; }
.dash-table tr.row-link:hover { background: #FAFAF9; }
.row-sub {
  font-family: ui-monospace, monospace; font-size: 11px;
  color: var(--text-muted); margin-top: 2px;
}

/* ── Filters ── */
.filters-section { margin-bottom: 16px; }
.search-wrap { position: relative; margin-bottom: 10px; }
.search-input {
  width: 100%; font-family: inherit; font-size: 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; background: var(--surface); outline: none;
  transition: border-color 150ms;
}
.search-input:focus { border-color: var(--accent); }

.filters-row { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-select {
  font-family: inherit; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 10px; background: var(--surface); color: var(--text);
  outline: none; cursor: pointer; flex: 1; min-width: 160px;
  transition: border-color 150ms;
}
.filter-select:focus { border-color: var(--accent); }

/* ── Chips ── */
.chips-row {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px;
}
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 100px; padding: 3px 4px 3px 10px;
  font-size: 12px; color: var(--text);
}
.chip-x {
  border: none; background: transparent; cursor: pointer;
  font-size: 14px; line-height: 1; color: var(--text-muted);
  padding: 0 6px; border-radius: 100px;
}
.chip-x:hover { color: var(--text); background: var(--bg); }
.chip-clear-all {
  border: none; background: transparent; cursor: pointer;
  font-size: 12px; color: var(--accent); font-family: inherit;
  padding: 3px 8px;
}
.chip-clear-all:hover { text-decoration: underline; }

/* ── Bulk action bar ── */
.bulk-bar {
  position: sticky; top: 56px; z-index: 50;
  display: none;
  background: #141414; color: #fff;
  border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 12px;
  align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  flex-wrap: wrap;
}
.bulk-bar.visible { display: flex; }
.bulk-bar-left { display: flex; align-items: center; gap: 12px; }
.bulk-bar-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bulk-count { font-size: 13px; font-weight: 500; }
.bulk-link {
  color: #93C5FD; font-size: 12px; text-decoration: none; border-bottom: 1px dashed #93C5FD;
}
.bulk-link:hover { color: #fff; border-bottom-color: #fff; }
.bulk-bar .btn-sm { background: rgba(255,255,255,0.08); color: #fff; border-color: rgba(255,255,255,0.15); }
.bulk-bar .btn-sm:hover { background: rgba(255,255,255,0.16); border-color: rgba(255,255,255,0.32); }
.bulk-bar .bulk-clear { background: transparent; border-color: transparent; color: #ccc; }
.bulk-bar .bulk-clear:hover { color: #fff; }

/* ── Articles table ── */
.table-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.table-count { font-size: 13px; color: var(--text-muted); }

.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: auto; margin-bottom: 12px;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { position: sticky; top: 0; z-index: 10; }
thead th {
  background: var(--bg); border-bottom: 1px solid var(--border);
  padding: 10px 12px; text-align: left; font-size: 11px;
  font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); white-space: nowrap;
}
thead th.th-right { text-align: right; }
thead th.th-checkbox, td.td-checkbox { width: 36px; padding: 10px 8px; }
tbody tr {
  border-bottom: 1px solid var(--border); transition: background 100ms;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #FAFAF9; }
td {
  padding: 10px 12px; vertical-align: middle;
  max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
td.td-right { text-align: right; font-variant-numeric: tabular-nums; }
td a { color: var(--text); text-decoration: none; border-bottom: 1px solid transparent; }
td a:hover { border-bottom-color: var(--text-muted); }

td.decision-cell { white-space: nowrap; }
.row-undo {
  border: none; background: transparent; cursor: pointer;
  color: var(--text-muted); font-size: 14px; padding: 0 2px 0 6px;
}
.row-undo:hover { color: var(--text); }

.pagination { display: flex; gap: 8px; justify-content: center; padding: 8px 0 24px; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 100px;
  font-size: 11px; font-weight: 500; white-space: nowrap;
}
.badge-green  { background: #DCFCE7; color: #15803D; }
.badge-red    { background: #FEE2E2; color: #B91C1C; }
.badge-amber  { background: #FEF3C7; color: #92400E; }
.badge-gray   { background: #F3F4F6; color: #6B7280; }
.badge-blue   { background: #DBEAFE; color: #1D4ED8; }
.badge-purple { background: #EDE9FE; color: #6D28D9; }
.badge-orange { background: #FFEDD5; color: #C2410C; }

/* ── Empty / loading ── */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--text-muted); font-size: 13px;
}

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #141414; color: #fff;
  padding: 10px 20px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  opacity: 0; transition: opacity 200ms, transform 200ms;
  pointer-events: none; z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Article detail ── */
.article-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 12px;
}
.article-title {
  font-size: 22px; font-weight: 600; line-height: 1.3;
  letter-spacing: -0.4px; color: var(--text);
}
.article-meta {
  font-size: 12px; color: var(--text-muted); margin-bottom: 16px;
  display: flex; gap: 12px; flex-wrap: wrap;
}
.article-meta span + span::before { content: '·'; padding-right: 12px; opacity: 0.6; }

.detail-grid {
  display: grid; grid-template-columns: 2fr 1fr; gap: 16px;
}
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

.issue-card {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 8px; background: #FAFAF9;
  display: flex; gap: 10px; align-items: flex-start;
}
.issue-card.severity-error   { background: #FEF2F2; border-color: #FCA5A5; }
.issue-card.severity-warning { background: #FFFBEB; border-color: #FCD34D; }
.issue-card.severity-info    { background: #EFF6FF; border-color: #BFDBFE; }
.issue-message { flex: 1; font-size: 13px; }
.issue-type {
  font-family: ui-monospace, monospace; font-size: 11px;
  color: var(--text-muted); margin-top: 4px;
}
.issue-context {
  font-family: ui-monospace, monospace; font-size: 11px;
  color: var(--text-muted); margin-top: 4px;
  word-break: break-all; white-space: normal;
}
.issue-action {
  flex-shrink: 0; align-self: center;
  display: flex; align-items: center; gap: 6px;
  max-width: 280px; text-align: right;
}
.issue-action .settings-hint { font-size: 12px; line-height: 1.3; }

/* Жизненный цикл статьи: вертикальный список «кнопка + подсказка». */
.lifecycle-options {
  display: flex; flex-direction: column; gap: 10px; margin-top: 12px;
}
.lifecycle-option {
  display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 12px;
}
.lifecycle-option button { justify-self: start; width: 100%; }
.lifecycle-hint {
  font-size: 12px; line-height: 1.35; color: var(--text-muted);
}

.draft-group { margin-bottom: 14px; }
.draft-group:last-child { margin-bottom: 0; }
.draft-group-header {
  font-size: 13px; color: var(--text); margin: 4px 0 6px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.draft-group-header .settings-hint { font-size: 12px; }

.detail-html {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px; background: var(--surface); max-height: 500px;
  overflow: auto; font-size: 13px;
}
.detail-html img { max-width: 100%; height: auto; }

.kv-list { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.kv-list .k { color: var(--text-muted); font-size: 12px; }
.kv-list .v { color: var(--text); word-break: break-word; }

/* ── Decision history ── */
.decision-history { margin-top: 14px; font-size: 13px; }
.decision-history summary {
  cursor: pointer; color: var(--text-muted); font-size: 12px;
  list-style: none; padding: 6px 0;
}
.decision-history summary::-webkit-details-marker { display: none; }
.decision-history summary:hover { color: var(--text); }
.history-list {
  margin-top: 8px; display: flex; flex-direction: column; gap: 8px;
}
.history-item {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; background: #FAFAF9;
}
.history-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }

/* ── Settings ── */
.settings-row { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.settings-label { flex: 0 0 200px; font-size: 13px; color: var(--text-muted); }
.pricing-input {
  flex: 1; font-family: inherit; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 10px; background: var(--surface); outline: none;
  transition: border-color 150ms;
}
.pricing-input:focus { border-color: var(--accent); }
.settings-actions { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.settings-hint { font-size: 12px; color: var(--text-muted); }

.checks-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-top: 10px; }
@media (max-width: 700px) { .checks-list { grid-template-columns: 1fr; } }
.check-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: #FAFAF9;
}
.check-label { font-size: 13px; color: var(--text); }
.check-key {
  font-family: ui-monospace, monospace; font-size: 11px;
  color: var(--text-muted); display: block; margin-top: 2px;
}

.toggle-switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.toggle-switch input { display: none; }
.toggle-track {
  width: 32px; height: 18px; background: #D1D5DB;
  border-radius: 100px; transition: background 150ms; position: relative;
}
.toggle-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; background: #fff;
  border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 150ms;
}
.toggle-switch input:checked + .toggle-track { background: var(--accent); }
.toggle-switch input:checked + .toggle-track .toggle-thumb { transform: translateX(14px); }

/* ── Bulk-bar fix group ── */
.bulk-bar { flex-wrap: wrap; row-gap: 8px; }
.bulk-bar-fix {
  display: none; align-items: center; gap: 8px; flex-basis: 100%;
  border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px;
}
.bulk-bar.visible .bulk-bar-fix { display: flex; }
.bulk-fix-label { font-weight: 600; font-size: 13px; color: var(--text-muted); }
#bulk-fix-btn { background: var(--accent); color: #fff; border: none; }
#bulk-fix-btn:hover { background: #1d4ed8; }
#bulk-fix-btn:disabled { background: #cbd5e1; cursor: not-allowed; }
.fix-progress { margin-top: 12px; }

/* ── Drafts page ── */
.draft-card {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-top: 8px; background: #fff;
}
.draft-card:first-of-type { margin-top: 0; }
.draft-summary { font-size: 13px; color: var(--text); margin: 6px 0; }
.draft-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.row-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Diff view in draft preview modal ── */
.modal-card-wide { max-width: 1100px; width: 95vw; max-height: 90vh; overflow: auto; }
.diff-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0;
}
.diff-col { display: flex; flex-direction: column; min-width: 0; }
.diff-col-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); margin-bottom: 4px;
}
.diff-pre {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 6px;
  padding: 10px; max-height: 50vh; overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
}
.edit-textarea {
  width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.45;
}

/* ── Modals ── */
.modal-root {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
}
.modal-root[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative; background: var(--surface);
  border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  padding: 22px; width: min(560px, 92vw);
  max-height: 88vh; overflow: auto;
}
.modal-title {
  font-size: 16px; font-weight: 600; margin-bottom: 12px;
  letter-spacing: -0.2px;
}
.modal-card p { margin-bottom: 10px; font-size: 13px; line-height: 1.5; }
.modal-actions {
  display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px;
}
.modal-field { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.modal-field label { font-size: 12px; color: var(--text-muted); }
.radio-group {
  display: flex; flex-direction: column; gap: 8px; margin: 8px 0;
}
.radio-group label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #FAFAF9;
}
.radio-group code {
  font-family: ui-monospace, monospace; font-size: 12px;
  color: var(--text-muted); padding: 1px 6px;
  background: var(--bg); border-radius: 4px;
}

.merge-results {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-top: 8px; max-height: 240px; overflow: auto;
}
.merge-results:empty { display: none; }
.merge-result {
  padding: 8px 10px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 100ms;
}
.merge-result:last-child { border-bottom: none; }
.merge-result:hover { background: #FAFAF9; }
.merge-result.selected { background: #EFF6FF; border-color: #BFDBFE; }
.merge-result-name { font-size: 13px; color: var(--text); }
.merge-result-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── Stage 1.5: Links page ── */
.links-page { display: flex; flex-direction: column; gap: 14px; }
.links-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap;
}
.links-summary { font-size: 13px; color: var(--text-muted); }
.links-progress { margin-top: 4px; }
.links-progress-track {
  height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden;
  border: 1px solid var(--border);
}
.links-progress-fill {
  height: 100%; background: var(--accent); width: 0%;
  transition: width 600ms ease;
}
.links-progress-meta {
  font-size: 12px; color: var(--text-muted); margin-top: 6px;
}

.links-tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--border);
  margin-top: 4px;
}
.links-tab {
  background: transparent; border: none; padding: 8px 14px;
  font: inherit; font-size: 13px; cursor: pointer;
  color: var(--text-muted); border-bottom: 2px solid transparent;
}
.links-tab:hover { color: var(--text); }
.links-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }
.tab-count {
  display: inline-block; min-width: 20px; padding: 1px 6px;
  font-size: 11px; background: var(--bg); border-radius: 10px;
  color: var(--text-muted); margin-left: 4px;
}
.links-tab.active .tab-count { background: #DBEAFE; color: var(--accent); }

.links-filters { display: flex; gap: 8px; align-items: center; }

#links-table tbody tr { cursor: pointer; }
#links-table tbody tr:hover { background: #FAFAF9; }

.link-dot {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 500; line-height: 1.4;
}
.link-dot-ok      { background: #D1FAE5; color: #065F46; }
.link-dot-broken  { background: #FEE2E2; color: #991B1B; }
.link-dot-redirect{ background: #FEF3C7; color: #92400E; }
.link-dot-warn    { background: #FED7AA; color: #9A3412; }
.link-dot-muted   { background: var(--bg);  color: var(--text-muted); }

.redirect-hop {
  font-family: ui-monospace, monospace; font-size: 12px;
  padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 4px; margin-top: 6px; word-break: break-all;
}

/* article_detail link rows: цветные точки слева */
.link-row-status::before {
  content: ''; display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-right: 6px; vertical-align: middle;
}
.link-row-status.s-ok::before      { background: #10B981; }
.link-row-status.s-broken::before  { background: #DC2626; }
.link-row-status.s-redirect::before{ background: #F59E0B; }
.link-row-status.s-warn::before    { background: #F97316; }
.link-row-status.s-muted::before   { background: #94A3B8; }

/* ───────── Stage 1.7 — Apply UI ───────── */
.badge-purple { background: #EDE9FE; color: #5B21B6; }
.badge-amber  { background: #FEF3C7; color: #92400E; }

.protect-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}
.protect-label { font-size: 13px; color: var(--text); flex: 1; }

.bitrix-token-row {
  display: flex; align-items: center; gap: 10px;
}
.bitrix-token-mask {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--text);
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.bitrix-token-mask.text-muted { color: var(--text-muted); }

.kpi-applied-today { background: #ECFDF5; }
.bulk-bar-apply {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.12);
  margin-top: 8px;
}

/* Apply job page */
.job-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.job-header h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 4px 0;
}
.job-header .job-meta {
  color: var(--text-muted);
  font-size: 13px;
}
.job-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.job-progress {
  margin: 16px 0;
}
.job-progress-track {
  width: 100%;
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.job-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}
.job-progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.job-counters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 16px 0;
}
.job-counter {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.job-counter .v {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.1;
}
.job-counter .l {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.job-counter.applied .v { color: #10B981; }
.job-counter.failed  .v { color: #DC2626; }
.job-counter.skipped .v { color: #92400E; }

.job-log-table { width: 100%; }
.job-log-table td.kind-applied  { color: #10B981; }
.job-log-table td.kind-failed   { color: #DC2626; }
.job-log-table td.kind-skipped  { color: #92400E; }
.job-log-table td.kind-rolled_back { color: #5B21B6; }

/* Human-readable preview blocks for /changes modal */
.schema-fields { margin: 4px 0 8px 0; padding-left: 22px; font-size: 13px; line-height: 1.7; }
.schema-fields li { margin: 2px 0; }
.schema-fields code { background: #F3F4F6; padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.replacements-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.replacements-table th,
.replacements-table td { padding: 6px 8px; border-bottom: 1px solid #E5E7EB; text-align: left; vertical-align: top; }
.replacements-table th { background: #F9FAFB; font-weight: 500; color: #374151; }
.replacements-table code { word-break: break-all; font-size: 12px; }
.raw-diff-toggle > summary { user-select: none; }
.raw-diff-toggle > summary:hover { color: #2563EB; }
