:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e3e8f0;
  --text: #1c2434;
  --muted: #6b7686;
  --primary: #3b5bff;
  --primary-hover: #2c49e6;
  --secondary: #eef1fb;
  --danger: #e5484d;
  --ok: #2b8a5b;
  --shadow: 0 1px 3px rgba(20, 30, 60, 0.06), 0 8px 24px rgba(20, 30, 60, 0.05);
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #eef2fc, #f7f8fc);
  z-index: 50;
}
.login-card {
  width: 320px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-title { margin: 0; font-size: 20px; text-align: center; letter-spacing: -0.01em; }
.login-sub { margin: 0; text-align: center; color: var(--muted); font-size: 13px; }
.login-error { margin: 0; text-align: center; color: var(--danger); font-size: 13px; }

/* ---------- Layout ---------- */
.topbar {
  height: 60px;
  /* §12 translucent chrome: content scrolls under a floating material */
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid rgba(227, 232, 240, 0.8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 600; font-size: 16px; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(59, 91, 255, 0.15);
}
.container { max-width: 1080px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* ---------- Filters ---------- */
.filters-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 140px auto;
  gap: 16px;
  align-items: end;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.field-label em { color: var(--danger); font-style: normal; }
.field-action { align-self: end; }
.hint { margin: 12px 0 0; font-size: 12px; color: var(--muted); }

.input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59, 91, 255, 0.12); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, opacity .15s, transform .1s ease-out;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
/* §1 Response: feedback on press, not release */
.btn:not(:disabled):active { transform: scale(.97); }
.btn-row:not(:disabled):active,
.ms-sel-btn:active { transform: scale(.97); }
.btn-row, .ms-sel-btn { transition: background .15s, transform .1s ease-out; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--primary-hover); }
.btn-secondary { background: var(--secondary); color: var(--primary); border-color: var(--border); }
.btn-secondary:not(:disabled):hover { background: #e3e8fb; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--secondary); }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; flex: none; }
.btn-row {
  height: 32px; padding: 0 12px; font-size: 13px;
  background: var(--secondary); color: var(--primary); border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer;
}
.btn-row:hover { background: #e3e8fb; }
.btn-row:disabled { opacity: .5; cursor: progress; }

/* ---------- Results ---------- */
.results-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.results-count { font-weight: 600; }
.results-actions { display: flex; gap: 10px; }

.result-filters {
  display: grid;
  grid-template-columns: repeat(4, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  margin-bottom: 14px;
  background: #fafbff;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.rf-field { display: flex; flex-direction: column; gap: 5px; }
.rf-label { font-size: 11px; color: var(--muted); font-weight: 500; }
.rf-field .input { height: 36px; font-size: 13px; }
.rf-reset { align-self: end; }
.rf-reset .btn { height: 36px; }

/* Multi-select dropdown (agent filter) */
.ms { position: relative; }
.ms-toggle {
  text-align: left;
  cursor: pointer;
  background: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 26px;
}
.ms-toggle::after {
  content: "▾";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.ms-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 6px;
  /* §7 anchor to trigger + §12 materialize on open */
  transform-origin: top center;
  animation: menu-in .16s cubic-bezier(.2, .8, .2, 1);
}
@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1);   }
}
.ms-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.ms-option:hover { background: var(--secondary); }
.ms-option input { cursor: pointer; margin: 0; }

.bulk-panel {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 14px; margin-bottom: 14px;
  background: var(--secondary); border: 1px solid var(--border); border-radius: 8px;
}
.bulk-row { display: flex; align-items: center; gap: 12px; flex: 1; }
.progress { flex: 1; height: 8px; background: #dfe4f3; border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: var(--primary); transition: width .3s ease; }
.bulk-text { font-size: 13px; color: var(--muted); min-width: 120px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.table tbody tr:hover { background: #fafbff; }
.table .col-action { text-align: right; }
.table td.col-action { text-align: right; }
.empty-row td { text-align: center; color: var(--muted); padding: 32px; }

.table .col-select { width: 36px; text-align: center; }
.table td.col-select, .table th.col-select { text-align: center; }
.table tbody tr.selectable { cursor: default; }
.table tbody tr.selected { background: #eaf0ff; }
.table tbody tr.selected:hover { background: #e1eaff; }
/* Prevent text-selection while drag-selecting rows. */
.table.selecting { user-select: none; }
.row-check { cursor: pointer; }

.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; background: var(--secondary); color: var(--muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1c2434; color: #fff; padding: 12px 20px; border-radius: 8px;
  font-size: 13px; box-shadow: var(--shadow); z-index: 80; max-width: 90vw;
  animation: toast-in .22s cubic-bezier(.2, .8, .2, 1);
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0);   }
}

@media (max-width: 760px) {
  .filters-grid { grid-template-columns: 1fr 1fr; }
  .field-action { grid-column: 1 / -1; }
  .result-filters { grid-template-columns: 1fr 1fr; }
  .rf-reset { grid-column: 1 / -1; }
}

/* ---------- Topbar right group ---------- */
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* ---------- Admin panel ---------- */
.admin-panel { background: var(--bg); border-bottom: 1px solid var(--border); }

.admin-section-title { margin: 0 0 16px; font-size: 16px; font-weight: 600; }
.admin-section-subtitle { margin: 16px 0 10px; font-size: 14px; font-weight: 600; color: var(--muted); }

/* сворачиваемый заголовок формы (rules.html) */
.rule-form-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 0; margin: 0 0 16px; border: none; background: none;
  font: inherit; text-align: left; cursor: pointer;
}
.rule-form-toggle .admin-section-title { margin: 0; }
.rule-form-caret { font-size: 12px; color: var(--muted); transition: transform .15s; }
.rule-form-toggle[aria-expanded="true"] .rule-form-caret { transform: rotate(180deg); }

.admin-action-row { display: flex; gap: 8px; margin-top: 12px; }

.admin-user-actions { display: flex; gap: 6px; justify-content: flex-end; }

.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }

.btn-danger-outline {
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger-outline:hover { background: #fff0f0; }

.edit-campaigns-panel {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ---------- Campaign checkboxes ---------- */
.campaign-search { margin-bottom: 8px; height: 36px; font-size: 13px; }

.campaign-checkbox-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  background: #fff;
}

.campaign-cb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.campaign-cb-row:hover { background: var(--secondary); }
.campaign-cb-row input { cursor: pointer; margin: 0; }

/* ---------- Create user form ---------- */
.create-user-form { display: flex; flex-direction: column; gap: 14px; max-width: 420px; }

/* ---------- Campaign multi-select dropdown ---------- */
.campaign-ms .ms-menu { max-height: none; overflow-y: visible; }
.ms-search { margin-bottom: 6px; }
.ms-sel-row { display: flex; gap: 6px; margin-bottom: 6px; }
.ms-sel-btn {
  flex: 1; height: 28px; font-size: 12px; cursor: pointer;
  background: var(--secondary); color: var(--primary);
  border: 1px solid var(--border); border-radius: 6px;
}
.ms-sel-btn:hover { background: #e3e8fb; }
.ms-options-list { max-height: 200px; overflow-y: auto; }

/* ---------- Analysis stats page ---------- */
.container-wide { max-width: 1400px; }

.stats-table th, .stats-table td { vertical-align: top; }
.stats-table th { white-space: nowrap; }
.stats-table tbody tr { cursor: pointer; }
.nowrap { white-space: nowrap; }

.cell-text {
  max-width: 240px;
  font-size: 13px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.score-pill {
  display: inline-block; min-width: 34px; text-align: center;
  padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--secondary); color: var(--muted);
}
.score-bad { background: #fdecec; color: var(--danger); }
.score-mid { background: #fff4e0; color: #b7791f; }
.score-good { background: #e7f5ee; color: var(--ok); }

.ko-yes { color: var(--danger); font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.ko-no { color: var(--muted); }
.ko-help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; cursor: pointer;
}
.ko-pop {
  position: fixed; width: 260px;
  background: #1c2434; color: #fff; padding: 10px 12px; border-radius: 8px;
  font-size: 12px; font-weight: 400; line-height: 1.45;
  box-shadow: var(--shadow); z-index: 90; text-align: left;
}
.ko-pop ul { margin: 6px 0 0; padding-left: 16px; }

/* ---------- Block-scores modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 30, 60, .45);
  display: flex; align-items: center; justify-content: center; z-index: 80; padding: 24px;
  animation: scrim-in .18s ease-out;
}
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  width: 560px; max-width: 100%; max-height: 85vh; display: flex; flex-direction: column;
  /* §12 materialize: real surface arriving, not a flat fade */
  animation: modal-in .22s cubic-bezier(.2, .8, .2, 1);
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(.96); }
  to   { opacity: 1; transform: scale(1);   }
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.modal-title { margin: 0; font-size: 16px; }
.modal-player { padding: 14px 20px; border-bottom: 1px solid var(--border); background: #fafbff; }
.audio { width: 100%; height: 38px; }
.modal-body { padding: 8px 20px 20px; overflow-y: auto; }
.modal-narrow { width: 520px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 20px; border-top: 1px solid var(--border);
}

/* ---------- Analysis filters (toolbar) ---------- */
/* Compound selector beats the base .result-filters grid regardless of order. */
.result-filters.stats-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 18px;
  padding: 16px 18px;
}
.stats-filters .rf-field { flex: 0 0 auto; gap: 6px; }
.stats-filters select.input { min-width: 168px; }
.stats-filters .ms { min-width: 168px; }
/* Логины/статусы длиннее поля — меню растёт по контенту, а не по ширине кнопки. */
.stats-filters .ms-menu,
.more-grid .ms-menu { right: auto; min-width: 100%; width: max-content; max-width: 340px; }
/* Доп. фильтры: контент короткий, скролл body не нужен — иначе он режет меню. */
.modal-narrow .modal-body { overflow: visible; }
/* paired "от – до" range control */
.rf-range { display: flex; align-items: center; gap: 8px; }
.rf-range .input { width: auto; }
.rf-range .input.date { width: 150px; }
.rf-range .input.num { width: 68px; text-align: center; padding: 0 8px; }
.rf-range-sep { color: var(--muted); user-select: none; }
/* action cluster pinned to the right, divided from the fields */
.stats-filters .rf-actions {
  margin-left: auto;
  align-self: flex-end;
  display: flex; align-items: center; gap: 8px;
  padding-left: 18px;
  border-left: 1px solid var(--border);
}
.btn-ico { margin-right: 6px; opacity: .8; }
.filter-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px;
  border-radius: 999px; background: var(--primary); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
}
.btn-ghost .filter-badge { background: var(--primary); color: #fff; }

/* modal filter grid: two even columns, date range spans both */
.more-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 18px;
  padding: 4px 0 8px;
}
.more-grid .rf-field { display: flex; flex-direction: column; gap: 6px; }
.more-grid .more-span { grid-column: 1 / -1; }
.more-grid .rf-range .input.date { flex: 1 1 0; width: auto; }
.more-grid .rf-range .input.num { width: 84px; }

@media (max-width: 560px) {
  .more-grid { grid-template-columns: 1fr; }
  .more-grid .more-span { grid-column: auto; }
  .stats-filters .rf-actions { margin-left: 0; padding-left: 0; border-left: none; width: 100%; }
}
.block-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.block-row:last-child { border-bottom: none; }
.block-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.block-name { font-weight: 500; font-size: 13px; }
.block-num { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: #eef1fb; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 999px; }

/* sub-block (items) breakdown inside modal */
.item-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--secondary); color: var(--primary);
  font-size: 11px; font-weight: 700; cursor: pointer; vertical-align: middle;
}
.item-toggle:hover { background: #e3e8fb; }
.item-toggle.open { background: var(--primary); color: #fff; }

.item-list { margin-top: 10px; padding-left: 12px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.item-row { display: flex; flex-direction: column; gap: 3px; }
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.item-key { font-size: 12px; font-weight: 500; }
.item-meta { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.item-score { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 16px; text-align: right; }
.item-comment { font-size: 12px; color: var(--muted); line-height: 1.4; }

.st-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.st-ok { background: #e7f5ee; color: var(--ok); }
.st-ko { background: #fdecec; color: var(--danger); }
.st-fail { background: #fff4e0; color: #b7791f; }
.st-na { background: var(--secondary); color: var(--muted); }

.stats-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.stats-table th.sortable:hover { color: var(--text); }
.sort-arrow { font-size: 10px; color: var(--primary); }

/* ---------- Pagination ---------- */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--border);
}
.pager-size { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.pager-size .input { width: auto; height: 32px; font-size: 13px; }
.pager-nav { display: flex; align-items: center; gap: 10px; }
.pager-info { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }


/* ---------- Campaigns multiselect (search form) ---------- */
#camp-ms-search {
  margin: 6px;
  width: calc(100% - 12px);
  box-sizing: border-box;
}
.ms-all {
  display: block;
  width: 100%;
  text-align: left;
}
#camp-ms-options {
  max-height: 240px;
  overflow-y: auto;
}

/* Длинные значения в таблице результатов: обрезка + полный текст в title */
.table td.clip {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- §14 Accessibility: reduced motion / transparency ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .btn:not(:disabled):active { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .topbar {
    background: var(--card);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* ---------- Страница промптов ---------- */
.prompt-layout { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
.prompt-side { position: sticky; top: 16px; }
.prompt-camp-list { margin-top: 10px; max-height: 60vh; overflow-y: auto; }
.prompt-camp {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 8px 10px; margin-bottom: 4px;
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  font: inherit; text-align: left; cursor: pointer;
}
.prompt-camp:hover { background: var(--secondary); }
.prompt-camp.active { background: var(--secondary); border-color: var(--border); }
.prompt-camp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prompt-camp-ver { flex: none; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.prompt-camp-ver.none { color: #b4453c; }

.prompt-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.prompt-head-actions { display: flex; gap: 8px; flex: none; }
.prompt-ph { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 12px 0 8px; }
.ph-chip {
  padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--secondary); color: var(--primary);
  font: 500 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; cursor: pointer;
}
.ph-chip:hover { background: #e3e8fb; }
.ph-hint { margin-left: 4px; }

.prompt-editor {
  width: 100%; height: 62vh; padding: 12px; resize: vertical;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre; overflow-wrap: normal; overflow-x: auto;
}
.prompt-save-row { display: flex; gap: 10px; align-items: center; margin: 12px 0 4px; }
.prompt-save-row .input { flex: 1; }

.prompt-versions { margin-top: 6px; }
.prompt-ver {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.prompt-ver:last-of-type { border-bottom: none; }
.prompt-ver-pick { display: flex; align-items: center; gap: 6px; flex: none; cursor: pointer; }
.prompt-ver-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.prompt-ver-note { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.modal-wide { width: min(1100px, 92vw); }
.diff {
  margin: 0; padding: 12px; background: #fafbff; border: 1px solid var(--border);
  border-radius: 8px; overflow-x: auto;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.diff span { display: block; white-space: pre; }
.diff .d-add { background: #e8f6e8; color: #22571f; }
.diff .d-del { background: #fdeceb; color: #8c2f27; }
.diff .d-hunk { color: var(--muted); }

@media (max-width: 900px) {
  .prompt-layout { grid-template-columns: 1fr; }
  .prompt-side { position: static; }
}

/* ---------- Страница правил автоанализа ---------- */
.rule-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.rule-grid-sm { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.rule-row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.rule-row-wide { display: flex; gap: 16px; flex-wrap: wrap; }
.rule-actions { display: flex; gap: 10px; margin-top: 14px; }
.field-checkbox { flex-direction: row; align-items: center; gap: 8px; }
.field-checkbox-label { font-size: 14px; color: var(--text); }
.field-w-90 { flex: 0 0 90px; }
.field-w-140 { flex: 0 0 140px; }
.field-w-200 { flex: 0 0 200px; }
.field-w-220 { flex: 0 0 220px; }

/* multi-segment run progress bar */
#rules-body tr[data-id] { cursor: pointer; }
#rules-body tr.row-active { background: var(--row-active, rgba(90, 120, 220, .10)); }
.run-row { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px; }
.run-row-bar { flex: 1; }
.run-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--border); }
.run-bar-seg { height: 100%; }
.run-bar-seg-done { background: var(--ok); }
.run-bar-seg-processing { background: var(--primary); }
.run-bar-seg-error { background: var(--danger); }
.run-bar-seg-pending { background: transparent; }
