/* Аудит Директа — «заключение аудитора»: спокойная бумага, серифный вердикт,
   светофор серьёзности. Жёлтая метка — единственный брендовый акцент. */

:root {
  --paper: #f4f4f2;
  --card: #ffffff;
  --ink: #1a1d21;
  --ink-2: #565d66;
  --ink-3: #8c939c;
  --line: #e7e8e6;
  --line-soft: #f0f1ef;
  --brand: #ffcc00;

  --sev-critical: #d03b3b; --sev-critical-text: #9e2b2b; --sev-critical-tint: #fbecec;
  --sev-high:     #ec835a; --sev-high-text:     #a04416; --sev-high-tint:     #fdf0ea;
  --sev-medium:   #fab219; --sev-medium-text:   #8a6207; --sev-medium-tint:   #fdf4dd;
  --sev-low:      #8c939c; --sev-low-text:      #4c545e; --sev-low-tint:      #eff1f3;
  --good:         #0ca30c; --good-text:         #0b6e0b; --good-tint:         #e9f6e9;
  --info-tint: #eaf1f8; --info-text: #2a5b8f;

  --serif: "PT Serif", Georgia, "Times New Roman", serif;
  --sans: "Golos Text", -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(26, 29, 33, 0.05);
  --check: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M6 12.6 10 16.4 18 7.6' stroke='%231A1D21' stroke-width='2.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  background: var(--paper);
  color: var(--ink);
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }

/* ---------- шапка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 12px 28px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--serif); font-size: 1.08rem; font-weight: 700;
  text-decoration: none;
}
.topbar-right { display: flex; align-items: center; gap: 22px; }
.topbar nav { display: flex; gap: 20px; }
.topbar nav a { color: var(--ink-2); text-decoration: none; font-size: 0.92rem; transition: color 0.15s; }
.topbar nav a:hover { color: var(--ink); }
.topbar nav a.active { color: var(--ink); font-weight: 600; }

/* хлебные крошки: «Клиенты › Клиент › Отчёт №N» */
.crumbs { font-size: 0.86rem; color: var(--ink-3); margin: 0 0 10px; }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.crumbs .sep { margin: 0 7px; }

.container { max-width: 1080px; margin: 32px auto 64px; padding: 0 20px; }

/* появление страницы — один спокойный такт */
@media (prefers-reduced-motion: no-preference) {
  .container > * { animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) backwards; }
  .container > *:nth-child(2) { animation-delay: 0.06s; }
  .container > *:nth-child(3) { animation-delay: 0.12s; }
  .container > *:nth-child(4) { animation-delay: 0.18s; }
  .container > *:nth-child(n+5) { animation-delay: 0.24s; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
}

/* ---------- типографика ---------- */
h1 { font-family: var(--serif); font-size: 1.9rem; line-height: 1.25; margin: 0 0 6px; }
h2 { font-family: var(--serif); font-size: 1.25rem; margin: 0 0 12px; }
.eyebrow {
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-3); margin: 0 0 6px;
}
.muted { color: var(--ink-2); font-weight: 400; }
.small { font-size: 0.86rem; }
.error { color: var(--sev-critical-text); }

/* ---------- карточки, формы, кнопки ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 24px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }

label { display: block; margin: 12px 0; font-size: 0.92rem; color: var(--ink-2); }
label input, label select, label textarea { display: block; margin-top: 5px; width: 100%; }
input, select, textarea {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 0.95rem; color: var(--ink); background: var(--card);
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--ink-2); outline: none;
  box-shadow: 0 0 0 3px rgba(26, 29, 33, 0.07);
}

button, .button {
  display: inline-block; padding: 10px 18px; border: 0; border-radius: 8px;
  background: var(--ink); color: #fff; font: inherit; font-size: 0.95rem;
  font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.15s, transform 0.1s, border-color 0.15s, color 0.15s;
}
button:hover, .button:hover { background: #33383f; }
button:active, .button:active { transform: translateY(1px); }
.button.ghost, button.ghost {
  background: transparent; color: var(--ink); border: 1px solid var(--line);
}
.button.ghost:hover, button.ghost:hover { background: var(--line-soft); border-color: var(--ink-3); }
.button.compact { padding: 8px 14px; font-size: 0.9rem; }
.button.danger, button.danger { background: var(--sev-critical); }
.button.danger:hover, button.danger:hover { background: #b83232; }
.danger-ghost { color: var(--sev-critical-text) !important; }
.danger-ghost:hover { background: var(--sev-critical-tint) !important; border-color: var(--sev-critical) !important; }
button.wide { width: 100%; margin-top: 8px; }

/* ---------- модальные окна ---------- */
dialog.modal {
  border: 0; border-radius: 14px; padding: 26px 28px;
  width: min(430px, calc(100vw - 32px));
  background: var(--card); color: var(--ink);
  box-shadow: 0 24px 64px rgba(26, 29, 33, 0.25);
}
dialog.modal::backdrop {
  background: rgba(26, 29, 33, 0.38);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
dialog.modal[open] { animation: modal-in 0.22s cubic-bezier(0.2, 0.7, 0.3, 1); }
dialog.modal[open]::backdrop { animation: fade-in 0.22s ease; }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
}
@keyframes fade-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  dialog.modal[open], dialog.modal[open]::backdrop { animation: none; }
}
dialog.modal h2 { margin-bottom: 8px; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px;
}
.modal-confirm { width: min(390px, calc(100vw - 32px)); }

/* ---------- таблицы ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
td { font-variant-numeric: tabular-nums; }
th { color: var(--ink-3); font-weight: 600; font-size: 0.8rem; letter-spacing: 0.02em; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink-2); }
th.sortable::after { content: '↕'; margin-left: 4px; opacity: 0.4; }
th.sortable.sort-asc::after { content: '↑'; opacity: 1; }
th.sortable.sort-desc::after { content: '↓'; opacity: 1; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
.table-scroll { overflow-x: auto; }

/* широкая таблица кампаний: компактнее, заголовки и числа не переносятся */
.campaigns-table { font-size: 0.9rem; }
.campaigns-table th, .campaigns-table td { padding: 9px 5px; }
.campaigns-table th { white-space: nowrap; font-size: 0.78rem; }
.campaigns-table th.sortable::after { margin-left: 2px; }
.campaigns-table td.num { white-space: nowrap; }
.campaigns-table td:first-child { min-width: 160px; }
.audits-table tbody tr { transition: background 0.12s; }
.audits-table tbody tr:hover { background: #fafaf8; }
.audits-table tbody tr.row-clickable { cursor: pointer; }
.audits-table tbody tr.row-clickable:hover { background: var(--line-soft); }

/* ---------- бейджи ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none; }

.status-pending   { background: var(--sev-low-tint); color: var(--sev-low-text); }
.status-planned   { background: var(--line-soft); color: var(--ink-2); border: 1px dashed var(--ink-3); }
.status-planned::before { content: none; }
.row-planned td { color: var(--ink-2); }
.status-fetching, .status-analyzing { background: var(--info-tint); color: var(--info-text); }
.status-done      { background: var(--good-tint); color: var(--good-text); }
.status-failed    { background: var(--sev-critical-tint); color: var(--sev-critical-text); }
.status-pending::before, .status-fetching::before, .status-analyzing::before,
.status-done::before, .status-failed::before { content: none; }

.schedule-badge { background: var(--info-tint); color: var(--info-text); font-weight: 500; }
.schedule-badge::before { content: none; }

.sev-critical { background: var(--sev-critical-tint); color: var(--sev-critical-text); }
.sev-critical::before { background: var(--sev-critical); }
.sev-high     { background: var(--sev-high-tint); color: var(--sev-high-text); }
.sev-high::before { background: var(--sev-high); }
.sev-medium   { background: var(--sev-medium-tint); color: var(--sev-medium-text); }
.sev-medium::before { background: var(--sev-medium); }
.sev-low      { background: var(--sev-low-tint); color: var(--sev-low-text); }
.sev-low::before { background: var(--sev-low); }

/* ---------- клиенты ---------- */
.page-head { margin-bottom: 22px; }
.client-card { padding: 20px 24px 14px; transition: border-color 0.15s; }
.client-card:hover { border-color: #d9dbd7; }
.client-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap; margin-bottom: 10px;
}
.client-id { display: flex; align-items: center; gap: 14px; min-width: 0; }
.client-id h2 { margin: 0; }
.client-id p { margin: 1px 0 0; }
.row-link { color: var(--ink); font-weight: 500; }
.client-link { color: inherit; text-decoration: none; }
.client-link:hover { text-decoration: underline; text-decoration-color: var(--ink-3); text-underline-offset: 3px; }
.check-yes { color: var(--good-text); font-weight: 600; }
.check-no { color: var(--ink-3); }
.no-audits { margin: 4px 0 10px; }

td.row-actions { text-align: right; white-space: nowrap; }

.sev-dots { display: inline-flex; gap: 12px; flex-wrap: wrap; }
.sev-dot {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.88rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.sev-dot i { width: 9px; height: 9px; border-radius: 50%; }
.ok-note { color: var(--good-text); font-weight: 500; font-size: 0.9rem; }

.empty-state { text-align: center; padding: 52px 24px; }
.empty-state h2 { margin-bottom: 6px; }
.empty-state p { max-width: 380px; margin: 0 auto 20px; }
.empty-mark {
  display: grid; place-items: center;
  width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 14px;
  background: var(--brand); color: var(--ink);
  font-family: var(--serif); font-size: 1.6rem; font-weight: 700;
}

/* ---------- вход ---------- */
.login-page .topbar { display: none; }
.login-page .container { max-width: 420px; margin-top: max(48px, 12vh); }
.auth-hero { text-align: center; margin-bottom: 24px; }
.auth-hero p { margin: 6px 0 0; }
.auth-mark {
  display: inline-block; width: 48px; height: 48px; border-radius: 13px;
  margin-bottom: 14px;
  background: var(--brand) var(--check) center / 30px no-repeat;
}
.auth-card { padding: 24px 26px; }

/* ---------- новый аудит ---------- */
.period-options { display: grid; gap: 8px; margin: 14px 0; }
.period-option {
  display: flex; align-items: center; gap: 10px; margin: 0;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.period-option:hover { border-color: var(--ink-3); }
.period-option:has(input:checked) { border-color: var(--ink); background: var(--line-soft); }
.period-option input { width: auto; margin: 0; }
.dates { display: flex; gap: 12px; margin: 4px 0 14px; }
.dates label { flex: 1; margin: 0; }

/* ---------- расписание аудитов ---------- */
.schedule-summary {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap;
}
.schedule-summary h2 { margin-bottom: 4px; }
.schedule-summary p { margin: 0; }
.modal-schedule { width: min(560px, calc(100vw - 32px)); }
.schedule-form .schedule-toggle { display: inline-flex; margin: 10px 0 14px; }
.schedule-controls { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.schedule-controls label { flex: 1 1 160px; max-width: 240px; margin: 0; font-size: 0.9rem; }
.schedule-delete { margin-top: 12px; }

/* ---------- статус аудита ---------- */
.progress-track {
  height: 6px; border-radius: 999px; background: var(--line-soft);
  overflow: hidden; margin: 18px 0 10px; position: relative;
}
.progress-track::after {
  content: ""; position: absolute; inset: 0; width: 40%; border-radius: 999px;
  background: var(--ink); animation: slide 1.4s ease-in-out infinite;
}
@keyframes slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(280%); }
}
@media (prefers-reduced-motion: reduce) {
  .progress-track::after { animation: none; width: 100%; opacity: 0.25; }
}

/* ---------- отчёт: заголовок ---------- */
.report-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 22px; }
.report-head .meta { color: var(--ink-2); font-size: 0.92rem; margin: 4px 0 0; }
.report-actions { display: flex; gap: 10px; flex: none; }

/* ---------- вердикт ---------- */
.verdict { padding: 26px 28px; }
.verdict-title { font-family: var(--serif); font-size: 1.7rem; font-weight: 700; margin: 0 0 8px; }
.verdict-title::before {
  content: ""; display: inline-block; width: 12px; height: 12px;
  border-radius: 50%; margin-right: 12px;
}
.verdict.tone-critical .verdict-title::before { background: var(--sev-critical); }
.verdict.tone-serious  .verdict-title::before { background: var(--sev-high); }
.verdict.tone-warning  .verdict-title::before { background: var(--sev-medium); }
.verdict.tone-good     .verdict-title::before { background: var(--good); }
.verdict-note { margin: 0 0 18px; max-width: 620px; color: var(--ink-2); }

/* светофор серьёзности: сегменты с зазором 2px, подписи в легенде */
.sev-meter { display: flex; gap: 2px; height: 14px; border-radius: 7px; overflow: hidden; }
.sev-meter span { min-width: 14px; }
.sev-meter .seg-critical { background: var(--sev-critical); }
.sev-meter .seg-high     { background: var(--sev-high); }
.sev-meter .seg-medium   { background: var(--sev-medium); }
.sev-meter .seg-low      { background: var(--sev-low); }
.sev-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px; font-size: 0.88rem; color: var(--ink-2); }
.sev-legend .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px;
}
.sev-legend b { color: var(--ink); }

/* «начните с этого»: топ-3 находки по серьёзности */
.verdict-top { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.verdict-top-label { margin: 0 0 6px; font-size: 0.82rem; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); }
.verdict-top ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.verdict-top li { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.verdict-top .dot { flex: none; width: 8px; height: 8px; border-radius: 50%;
  position: relative; top: -1px; }
.verdict-top a { font-weight: 600; text-decoration: none; white-space: nowrap; }
.verdict-top a:hover { text-decoration: underline; text-underline-offset: 3px; }
.verdict-top .obj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* сетка равных плиток; разделитель рисуется в межколоночном зазоре,
   у первой плитки ряда он выходит за край и срезается overflow'ом */
.verdict-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 18px 32px; margin-top: 22px; padding-top: 18px;
  border-top: 1px solid var(--line-soft); overflow: hidden;
}
.stat { position: relative; min-width: 0; }
.stat::before {
  content: ""; position: absolute; left: -16px; top: 3px; bottom: 3px;
  width: 1px; background: var(--line-soft);
}
.stat .value { font-family: var(--serif); font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat .label { font-size: 0.82rem; color: var(--ink-3); }

/* ---------- фильтры и навигация по блокам ---------- */
.filters {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 14px 18px;
}
.chip {
  padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--ink-2); font: inherit; font-size: 0.88rem;
  cursor: pointer; transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--ink-3); background: var(--card); }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip b { font-weight: 600; }
.filters select { margin-left: auto; max-width: 280px; }
.filters .filter-label { color: var(--ink-3); font-size: 0.88rem; }

.toc { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 22px; }
.toc a {
  text-decoration: none; font-size: 0.88rem; color: var(--ink-2);
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  transition: border-color 0.15s, color 0.15s;
}
.toc a:hover { color: var(--ink); border-color: var(--ink-3); }
.toc a .n { color: var(--ink-3); }

/* ---------- находки ---------- */
.report-block { scroll-margin-top: 80px; }
.report-block h2 { display: flex; align-items: baseline; gap: 10px; }
.report-block h2 .count { font-family: var(--sans); font-size: 0.85rem; font-weight: 400; color: var(--ink-3); }

.finding {
  border-left: 3px solid var(--sev-low);
  padding: 4px 0 4px 16px; margin: 18px 0;
  scroll-margin-top: 80px;
}
/* длинная серия находок одного правила: показываем первые 5 */
.finding-group[data-collapsed] .finding:nth-of-type(n+6) { display: none; }
.show-more {
  background: transparent; color: var(--ink-2); border: 1px dashed var(--line);
  padding: 7px 14px; font-size: 0.88rem; border-radius: 8px; margin: 0 0 14px 19px;
}
.show-more:hover { background: var(--line-soft); color: var(--ink); border-color: var(--ink-3); }
.finding[data-severity="critical"] { border-left-color: var(--sev-critical); }
.finding[data-severity="high"]     { border-left-color: var(--sev-high); }
.finding[data-severity="medium"]   { border-left-color: var(--sev-medium); }

.finding-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.finding-head .object {
  font-weight: 600; max-width: min(540px, 100%);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.finding-head .rule-code {
  margin-left: auto; font-size: 0.8rem; color: var(--ink-3); cursor: default;
}
.finding .message { margin: 8px 0 0; max-width: 720px; overflow-wrap: anywhere; }
.recommendation {
  display: flex; gap: 10px; margin: 10px 0 0; padding: 12px 14px;
  background: var(--line-soft); border-radius: 8px;
  font-size: 0.92rem; max-width: 720px;
}
.recommendation .rec-label { flex: none; }
.recommendation .rec-text { color: var(--ink-2); }
.recommendation .rec-text b { color: var(--ink); font-weight: 600; }

/* пустое состояние */
.all-good { text-align: center; padding: 44px 24px; }
.all-good .icon {
  width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 50%;
  background: var(--good-tint); color: var(--good-text);
  display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
}
.all-good h2 { margin-bottom: 6px; }

/* ---------- данные аккаунта ---------- */
.note {
  display: flex; gap: 8px; padding: 10px 14px; border-radius: 8px;
  background: var(--info-tint); color: var(--info-text); font-size: 0.88rem;
  margin: 12px 0;
}

/* ---------- правила аудита (M7) ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.page-head .muted { max-width: 640px; }
.client-head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.rules-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.rule-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rule-title-row .rule-code { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 0.78rem; color: var(--ink-3); }

.builtin-rules { display: grid; }
.rules-block-label {
  margin: 20px 0 2px; font-size: 0.76rem; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3);
}
.rules-block-label:first-child { margin-top: 8px; }
.rules-foot { display: flex; justify-content: flex-end; margin-top: 16px; }
.builtin-rule {
  display: flex; gap: 12px; align-items: flex-start; margin: 0;
  padding: 12px 4px; border-bottom: 1px solid var(--line-soft);
  color: var(--ink); cursor: pointer;
}
.builtin-rule:last-child { border-bottom: 0; }
.builtin-rule > input[type=checkbox] { width: auto; margin-top: 4px; flex: none; }
.builtin-rule-body { display: grid; gap: 4px; }
.builtin-rule:has(input:not(:checked)) .builtin-rule-body { opacity: 0.5; }

.rule-sentence { color: var(--ink-2); font-size: 0.92rem; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.param-input {
  width: 88px; padding: 4px 8px; font-size: 0.92rem;
  font-variant-numeric: tabular-nums; text-align: right;
}

.custom-rules { display: grid; }
.custom-rule {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  padding: 12px 4px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap;
}
.custom-rule:last-child { border-bottom: 0; }
.custom-rule.rule-off .custom-rule-main { opacity: 0.5; }
.custom-rule-main p { margin: 4px 0 0; }
.custom-rule-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.custom-rule-actions form { margin: 0; }

/* конструктор */
.form-errors { border-color: var(--sev-critical); background: var(--sev-critical-tint); color: var(--sev-critical-text); }
.form-errors ul { margin: 8px 0 0; padding-left: 20px; }
.rule-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.rule-form-grid .span2 { grid-column: span 2; }
.check-label { display: flex; align-items: center; gap: 8px; }
.check-label input { width: auto; margin: 0; }

.cond-group {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; margin: 12px 0;
}
.cond-group-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.cond-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.cond-if { flex: none; width: 18px; }
.cond-row:first-child .cond-if { visibility: hidden; }
.cond-field { max-width: 300px; }
.cond-op { max-width: 150px; }
.cond-value { max-width: 200px; }
.cond-del {
  background: transparent; color: var(--ink-3); border: 0; padding: 4px 8px;
  font-size: 1.1rem; line-height: 1;
}
.cond-del:hover { background: var(--sev-critical-tint); color: var(--sev-critical-text); border-radius: 6px; }

.form-actions { display: flex; gap: 10px; margin: 4px 0 24px; }

/* предпросмотр */
.preview-controls { display: flex; gap: 10px; align-items: center; flex: none; }
.preview-note {
  padding: 10px 14px; border-radius: 8px; background: var(--info-tint);
  color: var(--info-text); font-size: 0.92rem;
}
.preview-finding {
  border-left: 3px solid var(--sev-low); padding: 6px 0 6px 14px; margin: 12px 0;
  background: transparent;
}
.preview-finding.sev-critical { border-left-color: var(--sev-critical); background: transparent; color: inherit; }
.preview-finding.sev-high { border-left-color: var(--sev-high); background: transparent; color: inherit; }
.preview-finding.sev-medium { border-left-color: var(--sev-medium); background: transparent; color: inherit; }
.preview-finding.sev-low { background: transparent; color: inherit; }

/* правила клиента */
.client-rules { display: grid; }
.client-rule {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 14px;
  padding: 12px 4px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; margin: 0;
}
.client-rule:last-child { border-bottom: 0; }
.client-rule-main { display: grid; gap: 8px; min-width: 0; }
.client-rule-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.client-rule .rule-sentence { display: flex; gap: 14px; flex-wrap: wrap; }
.param-override { margin: 0; display: grid; gap: 3px; }
.param-override .param-input { width: 110px; text-align: left; }
.override-badge { background: var(--brand); color: var(--ink); }
.override-badge::before { content: none; }
.badge.off { background: var(--sev-low-tint); color: var(--sev-low-text); }
.badge.off::before { content: none; }
.client-rule.has-override { background: #fffdf2; border-radius: 8px; padding-left: 10px; padding-right: 10px; }

@media (max-width: 640px) {
  .rule-form-grid { grid-template-columns: 1fr; }
  .rule-form-grid .span2 { grid-column: auto; }
  .cond-field, .cond-op, .cond-value { max-width: 100%; }
  .preview-controls { flex-wrap: wrap; }
}

/* ---------- печать / PDF ---------- */
.print-only { display: none; }

@media print {
  body { background: #fff; }
  .topbar, .filters, .toc, .no-print, dialog { display: none !important; }
  .container { margin: 0; max-width: none; }
  .container > * { animation: none !important; }
  .card { border: 1px solid #ddd; box-shadow: none; break-inside: avoid; }
  .report-block { break-inside: auto; }
  .finding, .verdict, .report-head { break-inside: avoid; }
  a { text-decoration: none; color: inherit; }
  .print-only { display: block; }
  .report-print-footer {
    margin-top: 24px; padding-top: 10px; border-top: 1px solid #ddd;
    font-size: 0.8rem; color: #666;
  }
  /* цвета серьёзности обязаны пережить печать */
  .badge, .sev-meter span, .sev-legend .dot, .verdict-top .dot, .sev-dot i,
  .verdict-title::before, .recommendation, .all-good .icon, .note {
    print-color-adjust: exact; -webkit-print-color-adjust: exact;
  }
  /* свёрнутые серии находок раскрываются целиком */
  .finding-group[data-collapsed] .finding:nth-of-type(n+6) { display: block; }
}

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .topbar-right { flex: 1 1 100%; justify-content: space-between; gap: 14px; }
  .brand { white-space: nowrap; }
  .topbar nav { gap: 14px; }
  .client-head .button { width: 100%; text-align: center; }
  .report-head { flex-direction: column; }
  .filters select { margin-left: 0; width: 100%; }
  .verdict-stats { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 14px 24px; }
  .stat::before { left: -12px; }
  td.row-actions { text-align: left; }
}
