/* ============================================================
   Парсер-панель — design system v5 «Cold Precision»
   Холодный графит · индиго-акцент · сайдбар · Onest + JetBrains Mono
   ============================================================ */
:root {
  color-scheme: dark;

  /* Surfaces — холодный графит, единое семейство серых */
  --bg: #0b0c0f;
  --surface: #0f1114;
  --surface-2: #14161b;
  --surface-3: #1a1d24;
  --elevated: #232732;
  --inset: #08090b;

  /* Text */
  --text: #e9eaee;
  --text-2: #9aa0ac;
  --muted: #5c626e;

  /* Borders */
  --border: #1d2027;
  --border-strong: #2c313c;

  /* Brand: один сдержанный индиго. Семантика данных отдельно. */
  --primary: #5e6ad2;
  --primary-2: #8b93e8;
  --primary-strong: #4d58c4;
  --primary-soft: rgba(94, 106, 210, .13);
  --primary-grad: linear-gradient(180deg, #6570d8, #5560cc);
  --on-primary: #fff;
  --accent: #5e6ad2;

  --ok: #3fca8d;
  --ok-soft: rgba(63, 202, 141, .12);
  --danger: #ee6e6e;
  --danger-soft: rgba(238, 110, 110, .12);
  --warn: #d9a13f;
  --warn-soft: rgba(217, 161, 63, .13);

  /* Layout */
  --sb-w: 228px;

  /* Radius / shadow / motion */
  --r-sm: 7px;
  --r: 10px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(3, 4, 6, .5);
  --shadow: 0 6px 18px -4px rgba(3, 4, 6, .5), 0 2px 4px rgba(3, 4, 6, .4);
  --shadow-lg: 0 24px 60px -16px rgba(3, 4, 6, .8);
  --glow: 0 6px 22px -8px rgba(94, 106, 210, .55);
  --ring: 0 0 0 3px var(--primary-soft);
  --t: 160ms cubic-bezier(.4, 0, .2, 1);

  --sans: "Onest", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  padding-left: var(--sb-w);
  font-family: var(--sans);
  background:
    radial-gradient(900px 480px at 85% -12%, rgba(94, 106, 210, .05), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  text-wrap: pretty;
}

/* Едва заметный грейн — снимает «цифровую плоскость» */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: .025; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.sidebar, .layout, #data-page, #system-page, #chat-page { position: relative; z-index: 1; }

h1, h2, h3, .detail-head h2 { text-wrap: balance; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
}

/* Все цифры табличные; данные — в моно */
.num, td, .kv-line .v, .run-item small { font-variant-numeric: tabular-nums; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: padding-box; }
::selection { background: rgba(94, 106, 210, .32); }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

/* Inline SVG icons */
.ic { width: 16px; height: 16px; display: inline-flex; flex: none; vertical-align: -3px; }
.ic svg { width: 100%; height: 100%; display: block; }
.btn.small .ic { width: 14px; height: 14px; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--sb-w); z-index: 30;
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 10px 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.sb-brand {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 6px 10px 14px; font-size: 14.5px; font-weight: 800; letter-spacing: -.02em;
  background: none; border: none; cursor: pointer; text-align: left;
  color: var(--text); font-family: var(--sans);
}
.sb-brand:hover .sb-title { color: var(--primary-2); }
.sb-title { transition: color var(--t); }
.sb-brand .ic {
  width: 28px; height: 28px; padding: 6px; border-radius: 8px;
  color: var(--on-primary); background: var(--primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), var(--shadow-sm);
}
.sb-nav { display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow-y: auto; }
.sb-label {
  font-family: var(--mono); font-size: 9.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .14em; color: var(--muted);
  padding: 16px 10px 6px;
}
.sb-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: 8px;
  background: none; border: none; cursor: pointer; text-align: left;
  color: var(--text-2); text-decoration: none;
  font-family: var(--sans); font-size: 13px; font-weight: 500; line-height: 1.2;
  transition: background var(--t), color var(--t);
}
.sb-item .ic { width: 15px; height: 15px; color: var(--muted); transition: color var(--t); }
.sb-item:hover { background: var(--surface-3); color: var(--text); }
.sb-item:hover .ic { color: var(--text-2); }
.sb-item:active { transform: translateY(1px); }
.sb-item.nav-active { background: var(--primary-soft); color: var(--primary-2); }
.sb-item.nav-active .ic { color: var(--primary-2); }
.sb-item.accent { background: var(--primary); color: var(--on-primary); font-weight: 600; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), var(--shadow-sm); }
.sb-item.accent .ic { color: var(--on-primary); }
.sb-item.accent:hover { background: var(--primary-strong); color: var(--on-primary); box-shadow: var(--glow); }
.sb-bottom { margin-top: auto; border-top: 1px solid var(--border); padding-top: 8px; }

/* ---------------- Layout ---------------- */
.layout {
  display: grid; grid-template-columns: 340px 1fr; gap: 16px;
  padding: 20px 24px; align-items: start; width: 100%;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  min-height: 220px;
  box-shadow: var(--shadow-sm);
}
#detail-panel { padding: 22px 24px; }
.panel h2 {
  margin: 0 0 14px; font-size: 10px; font-weight: 600;
  font-family: var(--mono); text-transform: uppercase; letter-spacing: .14em; color: var(--muted);
}
.panel h3 { font-size: 13px; font-weight: 600; margin: 22px 0 10px; color: var(--text-2); }

/* ---------------- Projects bar ---------------- */
.proj-bar { display: flex; gap: 8px; margin-bottom: 10px; }
.proj-bar select { flex: 1; }
.proj-bar .btn { white-space: nowrap; }
.proj-actions { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }

/* Поиск по задачам */
.jobs-search { margin-bottom: 10px; padding: 8px 11px; font-size: 12.5px; }
.jobs-onboard { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; padding: 14px 4px; }

/* ---------------- Lists (jobs / runs) ---------------- */
.list { display: flex; flex-direction: column; gap: 6px; }

.job-item, .run-item {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 11px 13px;
  cursor: pointer;
  transition: border-color var(--t), background var(--t), box-shadow var(--t);
}
.job-item:hover, .run-item:hover {
  border-color: var(--border-strong); background: var(--surface-3);
}
.job-item.active {
  border-color: rgba(94, 106, 210, .35);
  background: linear-gradient(0deg, var(--primary-soft), var(--primary-soft)), var(--surface-2);
}
.job-item.active::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--primary);
}
.job-item { display: flex; align-items: center; gap: 10px; }
.job-item .name { font-weight: 500; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-item .open-card { white-space: nowrap; flex-shrink: 0; }

.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--muted); }
.status-dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
/* Выключенная задача — полая точка: её ни с чем не спутать. Серая заливка
   осталась за «запусков ещё не было» (см. .idle ниже). */
.status-dot.off { background: transparent; border: 1.5px solid var(--muted); }
/* Последний запуск упал / собрал не всё — видно прямо в списке. */
.status-dot.fail { background: var(--danger); box-shadow: 0 0 0 3px rgba(238, 110, 110, .22); }
.status-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(230, 180, 80, .20); }
/* Запусков ещё не было — задача включена, но «зелёного» ей не заслужено. */
.status-dot.idle { background: var(--muted); }
/* Идёт сбор — жёлтая пульсирующая точка (видно в списке, что задача работает). */
.status-dot.busy { background: var(--warn); animation: dot-pulse 1.4s ease-in-out infinite; }
@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(230, 180, 80, .55); }
  50%      { box-shadow: 0 0 0 4px rgba(230, 180, 80, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .status-dot.busy { animation: none; box-shadow: 0 0 0 3px rgba(230, 180, 80, .35); }
}

/* Run items: цветной статус-кант */
.run-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-left: 3px solid var(--border-strong); }
.run-item.success { border-left-color: var(--ok); }
.run-item.error { border-left-color: var(--danger); }
.run-item.running { border-left-color: var(--warn); }
.run-item.pending { border-left-color: var(--muted); }
.run-item.partial { border-left-color: var(--warn); }
.run-item small { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.run-traffic { color: var(--primary-2); }
.run-actions { display: flex; gap: 6px; flex-shrink: 0; }
.run-info { min-width: 0; }
.run-progress { color: var(--primary-2) !important; display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; }
.run-progress .spin { width: 13px; height: 13px; display: inline-flex; animation: spin 1.3s linear infinite; }
.run-progress .spin svg { width: 100%; height: 100%; }
@keyframes spin { to { transform: rotate(360deg); } }
.run-bar { height: 4px; background: var(--surface-3); border-radius: 100px; margin-top: 7px; max-width: 360px; overflow: hidden; }
.run-bar-fill { height: 100%; background: var(--primary); border-radius: 100px; transition: width .3s ease; }

/* ---------------- Badges ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 500; padding: 3px 8px; border-radius: 5px;
  background: var(--surface-3); border: 1px solid var(--border); color: var(--text-2);
  white-space: nowrap; letter-spacing: .02em; font-family: var(--mono);
}
.badge .ic { width: 12px; height: 12px; }
.badge.static { color: var(--muted); }
.badge.dynamic { color: var(--warn); border-color: transparent; background: var(--warn-soft); }
.badge.on { color: var(--ok); border-color: transparent; background: var(--ok-soft); }
.badge.off { color: var(--muted); }

/* ---------------- Run status text ---------------- */
.status { font-weight: 600; text-transform: capitalize; }
.status.success { color: var(--ok); }
.status.error { color: var(--danger); }
.status.running { color: var(--warn); }
.status.pending { color: var(--muted); }
.status.partial { color: var(--warn); }
/* Баннер «неполный сбор» над таблицей данных */
.partial-banner {
  display: flex; align-items: flex-start; gap: 8px; margin-bottom: 12px;
  padding: 10px 14px; font-size: 12.5px; line-height: 1.5;
  background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-radius: var(--r); color: var(--text-2);
}
.partial-banner .ic { color: var(--warn); flex: none; margin-top: 1px; }

/* ---------------- Detail card ---------------- */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px 16px; flex-wrap: wrap; }
.detail-head h2 { font-size: 20px; font-weight: 800; color: var(--text); text-transform: none; letter-spacing: -.025em; margin: 0; font-family: var(--sans); flex: 1 1 280px; min-width: 0; }
.detail-actions { flex-wrap: wrap; }
#detail-url { color: var(--muted); font-size: 12px; word-break: break-all; margin: 5px 0 0; font-family: var(--mono); }
.detail-actions { display: flex; gap: 8px; flex-shrink: 0; }
.meta { display: flex; gap: 7px; flex-wrap: wrap; margin: 12px 0 4px; }

.check-result {
  margin: 10px 0 2px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--r); background: var(--surface-2); font-size: 13px;
}
.check-result .cr-head { font-weight: 600; display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.check-result .cr-verdict { margin-top: 8px; color: var(--text-2); line-height: 1.5; }

.autofeeder-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 10px 0 14px; padding: 10px 12px; border: 1px dashed var(--border-strong);
  border-radius: var(--r); background: var(--surface-2);
}
.autofeeder-row select { width: auto; min-width: 160px; }

/* Дашборд-обзор (пустое состояние правой панели) */
/* Шапка обзора: заголовок слева, действия справа. */
.dash-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.dash-head h2 { margin: 0 0 2px; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.dash-head .hint { margin: 0; display: block; }
.dash-head .dash-actions { margin-left: auto; }
.dash-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.dash-tile {
  position: relative; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 16px 14px;
}
/* Тонкая цветная полоса слева — показатель «говорит» состоянием, а не только
   числом: успешность, деньги, идущая работа. */
.dash-tile::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: transparent;
}
.dash-tile.ok::before    { background: var(--ok); }
.dash-tile.warn::before  { background: var(--warn); }
.dash-tile.fail::before  { background: var(--danger); }
.dash-tile.busy::before  { background: var(--warn); }
.dash-tile.money::before { background: var(--primary); }
.dash-tile.fail .dash-val { color: var(--danger); }
.dash-tile.busy .dash-val { color: var(--warn); }
.dash-val { font-size: 26px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.dash-lbl { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.dash-sub { font-size: 11px; color: var(--muted); font-family: var(--mono); margin-top: 6px; }
.dash-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; align-items: start; }
.dash-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 16px; }
.dash-card h3 { margin: 0 0 10px; font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.dash-card h3 .ic { color: var(--primary-2); }
.dash-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 1000px) { .dash-row { grid-template-columns: 1fr; } }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 8px 14px; border-radius: var(--r-sm); cursor: pointer;
  font-family: var(--sans); font-size: 13px; font-weight: 500; line-height: 1;
  text-decoration: none; white-space: nowrap;
  transition: background var(--t), border-color var(--t), color var(--t), box-shadow var(--t), transform var(--t);
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn.primary {
  background: var(--primary); border-color: transparent; color: var(--on-primary);
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), var(--shadow-sm);
}
.btn.primary:hover { background: var(--primary-strong); box-shadow: var(--glow); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); background: var(--danger-soft); }
.btn.danger:hover { background: var(--danger); color: #26090b; border-color: var(--danger); }
.btn.small { padding: 5px 11px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------------- Forms ---------------- */
label { display: block; margin: 15px 0 6px; font-size: 13px; font-weight: 500; color: var(--text-2); }
label.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.hint { color: var(--muted); font-weight: 400; font-size: 11.5px; }
code { font-family: var(--mono); font-size: 11.5px; background: var(--inset); padding: 2px 6px; border-radius: 5px; color: var(--primary-2); border: 1px solid var(--border); }

input, select, textarea {
  width: 100%; padding: 9px 12px; background: var(--inset); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); font-size: 13px;
  font-family: var(--sans); resize: vertical;
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
input[type=checkbox] { width: auto; accent-color: var(--primary); }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); background: var(--bg); }

.fields-head { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.field-row { display: grid; grid-template-columns: 1fr 1.6fr 90px 90px 30px; gap: 6px; margin-top: 6px; }
.field-row input, .field-row select { padding: 7px 9px; }
.field-row .del, .kv-row .del {
  background: none; border: none; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-sm);
  transition: color var(--t), background var(--t);
}
.field-row .del:hover, .kv-row .del:hover { color: var(--danger); background: var(--danger-soft); }
.kv-row { display: grid; grid-template-columns: 1fr 1fr 90px 30px; gap: 6px; margin-top: 6px; }
.kv-row input, .kv-row select { padding: 7px 9px; }

/* ---------------- Modal ---------------- */
.modal {
  position: fixed; inset: 0; background: rgba(4, 5, 8, .72);
  backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 16px; overflow-y: auto; z-index: 50;
  animation: modal-fade var(--t) ease-out;
}
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); padding: 24px 28px; width: 100%; max-width: 720px;
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, .03);
  animation: modal-rise 220ms cubic-bezier(.34, 1.1, .4, 1);
}
@keyframes modal-rise { from { transform: translateY(14px) scale(.985); opacity: .3; } to { transform: none; opacity: 1; } }
/* Заголовок модалки — отделён линией на всю ширину карточки */
.modal-card h2 {
  margin: 0 -28px 16px; padding: 0 28px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 17px; font-weight: 700; letter-spacing: -.015em;
  display: flex; align-items: center; gap: 9px;
}
.modal-card h2 .ic { color: var(--primary-2); }
.modal-card > .hint { display: block; margin-bottom: 8px; line-height: 1.55; }
/* Панель действий — плавающая, липнет к низу при длинной форме */
.modal-actions {
  position: sticky; bottom: 12px; z-index: 2;
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-top: 24px; padding: 10px 12px;
  background: var(--elevated); border: 1px solid var(--border-strong);
  border-radius: var(--r); box-shadow: var(--shadow);
}

.presets { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.site-hint { margin-top: 8px; font-size: 12px; color: var(--ok); display: flex; align-items: center; gap: 5px; }
.dyn-settings {
  margin-top: 16px; border: 1px solid var(--border); border-radius: var(--r);
  padding: 4px 14px 14px; background: var(--surface);
}
.dyn-settings summary {
  cursor: pointer; font-size: 13px; font-weight: 600; user-select: none;
  padding: 10px 0; color: var(--text-2); list-style-position: inside;
}
.dyn-settings summary::marker { color: var(--muted); }
.dyn-settings .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------------- Tables ---------------- */
.feed-tables { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.feed-section { min-width: 0; }
.feed-section h4 {
  margin: 0 0 8px; font-size: 13px; color: var(--text-2);
  display: flex; align-items: center; gap: 6px;
}
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { padding: 10px 13px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th {
  background: var(--surface-2); position: sticky; top: 0; z-index: 1;
  font-weight: 600; color: var(--muted); white-space: nowrap;
  font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .09em;
}
tbody tr { transition: background var(--t); }
tbody tr:nth-child(even) { background: rgba(255, 255, 255, .012); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
td a { color: var(--primary-2); text-decoration: none; }
td a:hover { text-decoration: underline; }

.results-head, .export-buttons { display: flex; align-items: center; gap: 8px; }
.results-head { justify-content: space-between; margin-bottom: 18px; }
.export-buttons { flex-wrap: wrap; }

/* ---------------- Data card (key → value) ---------------- */
.data-card {
  border: 1px solid var(--border); border-radius: var(--r); padding: 2px 18px;
  margin-bottom: 14px; background: var(--surface-2);
}
.data-card-head { font-weight: 700; padding: 12px 0; color: var(--primary-2); border-bottom: 1px solid var(--border); letter-spacing: -.01em; }
.kv-line {
  display: grid; grid-template-columns: 240px 1fr; gap: 16px;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.kv-line:last-child { border-bottom: none; }
.kv-line .k { color: var(--muted); }
.kv-line .v { word-break: break-word; color: var(--text); }
#results-modal .modal-card { max-width: 800px; }

/* Свёрнутый список записей */
.data-item {
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface-2); margin-bottom: 8px; overflow: hidden;
}
.data-item-head {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: none; border: none; cursor: pointer; color: var(--text); text-align: left;
  font-family: var(--sans); transition: background var(--t);
}
.data-item-head:hover { background: var(--surface-3); }
.di-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; }
.di-sub { color: var(--muted); font-size: 12.5px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.di-chevron { color: var(--muted); transition: transform var(--t); margin-left: auto; flex: none; }
.data-item.open .di-chevron { transform: rotate(90deg); }
.data-item-body { display: none; padding: 2px 16px 6px; border-top: 1px solid var(--border); }
.data-item.open .data-item-body { display: block; }

.thumbs { display: flex; flex-wrap: nowrap; gap: 6px; align-items: center; }
.thumbs > a { flex: 0 0 auto; line-height: 0; }
.thumb {
  width: 58px; height: 44px; object-fit: cover; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface-3); transition: transform var(--t), border-color var(--t);
}
.thumb:hover { transform: scale(1.08); border-color: var(--primary); }

/* ---------------- AI agent chat ---------------- */
.chat-page {
  height: 100vh;
  max-width: 900px; margin: 0 auto; padding: 18px 20px 22px;
  display: flex; flex-direction: column;
}
.chat-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.chat-head h2 {
  flex: 1; font-size: 18px; font-weight: 800; margin: 0; letter-spacing: -.02em;
  display: flex; align-items: center; gap: 8px;
}
.chat-head h2 .ic { color: var(--primary-2); }
.agent-messages {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
  padding: 6px 2px; min-height: 280px; margin: 8px 0 14px;
}
.agent-msg { display: flex; flex-direction: column; max-width: 86%; }
.agent-msg.user { align-self: flex-end; align-items: flex-end; }
.agent-msg.assistant { align-self: flex-start; }
.agent-msg .bubble {
  padding: 10px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.5;
  border: 1px solid var(--border);
}
.agent-msg.user .bubble { background: var(--primary); color: var(--on-primary); border-color: transparent; border-bottom-right-radius: 4px; }
.agent-msg.assistant .bubble { background: var(--surface-2); color: var(--text); border-bottom-left-radius: 4px; }
.agent-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.agent-chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px;
  padding: 3px 9px; border-radius: 6px; background: var(--ok-soft); color: var(--ok);
}
.agent-chip .ic { width: 11px; height: 11px; }
.agent-msg .caret { color: var(--primary-2); animation: blink 1s step-end infinite; margin-left: 1px; }
@keyframes blink { 50% { opacity: 0; } }

/* Skill suggestion chips */
.agent-suggest { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.suggest-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px;
  padding: 7px 12px; border-radius: 8px; background: var(--surface-2);
  border: 1px solid var(--border-strong); color: var(--text-2); cursor: pointer;
  font-family: var(--sans); transition: border-color var(--t), color var(--t), background var(--t);
}
.suggest-chip:hover { border-color: var(--primary); color: var(--text); background: var(--surface-3); }
.suggest-chip .ic { width: 13px; height: 13px; color: var(--primary-2); }

/* Composer (input area) */
.agent-input-row {
  display: flex; gap: 8px; align-items: flex-end;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); padding: 10px;
  transition: border-color var(--t), box-shadow var(--t);
}
.agent-input-row:focus-within { border-color: var(--primary); box-shadow: var(--ring); }
.agent-input-row textarea {
  flex: 1; border: none; background: transparent; padding: 6px 8px; resize: none;
  min-height: 24px;
}
.agent-input-row textarea:focus { border: none; box-shadow: none; }
.agent-input-row .btn { flex: none; align-self: stretch; }

/* ---------------- Система (мониторинг + справка) ---------------- */
#system-page { max-width: 1100px; }
.system-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; overflow-y: auto; padding-bottom: 20px; }
.sys-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px; }
.sys-card h3 { margin: 0 0 12px; font-size: 13px; display: flex; align-items: center; gap: 7px; color: var(--text-2); }
.sys-card h3 .ic { color: var(--primary-2); }
.sys-help { grid-column: 1 / -1; }
.stat-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.stat-row:last-child { border-bottom: none; }
.stat-row span { color: var(--muted); }
.stat-row b { font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12.5px; }
.stat-run { font-size: 12px; color: var(--primary-2); padding: 3px 0; display: flex; align-items: center; gap: 5px; }
.stat-err { font-size: 12px; color: var(--danger); padding: 3px 0; display: flex; align-items: center; gap: 5px; }
.help-list { margin: 0; padding-left: 18px; line-height: 1.7; font-size: 13px; color: var(--text-2); }
.help-list li { margin-bottom: 5px; }
.help-list b { color: var(--text); }
#system-live { margin-left: auto; font-size: 12px; color: var(--ok); }
@media (max-width: 760px) { .system-grid { grid-template-columns: 1fr; } }

/* ---------------- Данные запуска ---------------- */
.data-page {
  height: 100vh;
  padding: 18px 28px 26px; display: flex; flex-direction: column;
}
.data-tree { flex: 1; overflow-y: auto; padding-right: 6px; }

/* Узел дерева: модель → поколение → модификация */
.dt-model { border: 1px solid var(--border); border-radius: var(--r-lg); margin-bottom: 12px; background: var(--surface); overflow: hidden; }
.dt-row {
  width: 100%; display: flex; align-items: center; gap: 10px; cursor: pointer;
  background: none; border: none; color: var(--text); text-align: left;
  padding: 12px 16px; font-size: 14px; font-family: inherit; transition: background var(--t);
}
.dt-row:hover { background: var(--surface-2); }
.dt-chev { color: var(--muted); transition: transform var(--t); flex-shrink: 0; }
.dt-chev svg { width: 16px; height: 16px; }
.open > .dt-row > .dt-chev { transform: rotate(90deg); color: var(--primary-2); }
.dt-name { font-weight: 600; }
.dt-sub, .dt-meta { color: var(--muted); font-size: 12.5px; margin-left: auto; font-weight: 400; }
.dt-badge { margin-left: auto; background: var(--surface-3); color: var(--text-2); border-radius: 100px; padding: 1px 9px; font-size: 11px; font-variant-numeric: tabular-nums; font-family: var(--mono); }

.dt-row.lvl1 { font-size: 15px; }
.dt-row.lvl1 .dt-name { font-size: 15px; }
.dt-row.lvl2 { padding-left: 30px; background: var(--surface-2); }
.dt-row.lvl3 { padding-left: 46px; font-size: 13px; border-top: 1px solid var(--border); }

.dt-body { display: none; }
.dt-model.open > .dt-body, .dt-gen.open > .dt-body, .dt-mod.open > .dt-body { display: block; }

.dt-sec { padding: 6px 0 10px; }
.dt-sec-h {
  display: flex; align-items: center; gap: 7px; font-size: 10px; text-transform: uppercase;
  letter-spacing: .12em; color: var(--text-2); font-weight: 600; font-family: var(--mono); padding: 12px 16px 8px;
}
.dt-sec-h .ic { color: var(--primary-2); }
.dt-gen, .dt-mod { border-top: 1px solid var(--border); }
.dt-sec .table-wrap { margin: 0 16px 8px; }

/* Тело модификации: спеки слева, фото/оборудование справа */
.dt-mod .dt-body { padding: 6px 16px 16px 46px; background: rgba(255,255,255,.012); }
.dt-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 22px; }
.dt-specs .kv-line { grid-template-columns: 230px 1fr; padding: 7px 0; }
.dt-side { display: flex; flex-direction: column; gap: 12px; }
.dt-link { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--primary-2); text-decoration: none; }
.dt-link:hover { text-decoration: underline; }
.dt-photos .thumbs { flex-wrap: wrap; }
.dt-eq { display: flex; flex-direction: column; gap: 10px; }
.dt-eqg-h { font-size: 12px; font-weight: 700; color: var(--text-2); margin-bottom: 5px; }
.dt-eqg-h .muted { font-weight: 400; }
.dt-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.dt-chip { background: var(--surface-3); color: var(--text-2); border-radius: 6px; padding: 3px 8px; font-size: 11.5px; }
@media (max-width: 900px) { .dt-grid { grid-template-columns: 1fr; } }

/* ============================================================
   Polish — motion, states
   ============================================================ */

/* Плавное каскадное появление (никогда не «всё разом») */
@keyframes rise-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.list .job-item, .list .run-item, .dt-model, .sys-card, .feed-section {
  animation: rise-in .3s cubic-bezier(.4, 0, .2, 1) both;
}
.list > :nth-child(2) { animation-delay: .03s; }
.list > :nth-child(3) { animation-delay: .06s; }
.list > :nth-child(4) { animation-delay: .09s; }
.list > :nth-child(5) { animation-delay: .12s; }
.list > :nth-child(n+6) { animation-delay: .15s; }
.dt-model:nth-child(2) { animation-delay: .04s; }
.dt-model:nth-child(3) { animation-delay: .08s; }
.dt-model:nth-child(4) { animation-delay: .12s; }
.sys-card:nth-child(2) { animation-delay: .05s; }
.sys-card:nth-child(3) { animation-delay: .10s; }
.sys-card:nth-child(4) { animation-delay: .15s; }

/* Спотлайт под курсором — едва заметный, в тон акцента */
.spotlight { position: relative; }
.spotlight::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  opacity: 0; transition: opacity var(--t);
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%),
              rgba(139, 147, 232, .07), transparent 42%);
}
.spotlight:hover::before { opacity: 1; }

/* Тинт-тени под цвет фона на ключевых поверхностях */
.panel, .modal-card, .sys-card, .dt-model {
  box-shadow: 0 1px 0 rgba(255,255,255,.02), 0 18px 40px -24px rgba(3, 4, 8, .9);
}

/* Скелетоны загрузки */
.skeleton { position: relative; overflow: hidden; background: var(--surface-2);
  border-radius: var(--r); }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.05), transparent);
  transform: translateX(-100%); animation: shimmer 1.25s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.skeleton-row { height: 56px; margin-bottom: 8px; }

.muted { color: var(--muted); }
.hidden { display: none !important; }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--elevated);
  border: 1px solid var(--border-strong); border-left: 3px solid var(--primary);
  padding: 13px 18px; border-radius: var(--r); color: var(--text);
  z-index: 100; box-shadow: var(--shadow-lg); max-width: 380px;
  animation: toast-in 220ms cubic-bezier(.34, 1.1, .4, 1);
}
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }

/* ---------------- Настройки (страница) ---------------- */
.settings-page {
  max-width: 1440px; margin: 0 auto; padding: 22px 28px 40px;
  min-height: 100vh; overflow-y: auto; width: 100%;
}
.settings-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.settings-head h2 {
  margin: 0 0 4px; font-size: 22px; font-weight: 800; letter-spacing: -.025em;
  display: flex; align-items: center; gap: 10px;
}
.settings-head h2 .ic { color: var(--primary-2); }
.settings-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start;
}
.set-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px 20px;
}
.set-card.set-wide { grid-column: 1 / -1; }
.set-card h3 {
  margin: 0 0 6px; font-size: 14px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.set-card h3 .ic { color: var(--primary-2); width: 16px; height: 16px; }
.set-card > .hint { display: block; margin-bottom: 12px; line-height: 1.5; }
.set-card label:first-of-type { margin-top: 4px; }
.set-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* Таблица проверки прокси — по каждому прокси видно, кто пропускает/блокирует */
.proxy-result { margin-top: 14px; }
.pc-loading { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; }
.pc-loading svg { width: 15px; height: 15px; animation: spin 1.3s linear infinite; }
.pc-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.pc-table th { background: var(--surface-2); text-align: left; padding: 8px 12px; }
.pc-table td { padding: 9px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.pc-host { font-family: var(--mono); font-size: 11.5px; color: var(--text); }
.pc-ok { color: var(--ok); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.pc-bad { color: var(--danger); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.pc-ok .ic, .pc-bad .ic { width: 13px; height: 13px; }
.pc-summary { margin-top: 10px; font-size: 13px; color: var(--text-2); }
.pc-summary b { color: var(--text); font-variant-numeric: tabular-nums; }
.pc-note {
  margin-top: 10px; padding: 10px 12px; font-size: 12.5px; line-height: 1.5;
  background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-radius: var(--r); color: var(--text-2);
  display: flex; gap: 8px; align-items: flex-start;
}
.pc-note .ic { color: var(--warn); flex: none; margin-top: 1px; }
@media (max-width: 820px) { .settings-grid { grid-template-columns: 1fr; } }

/* ---------------- Проекты, сгруппированные по площадкам ---------------- */
.pg-group { margin-bottom: 22px; }
.pg-title {
  display: flex; align-items: center; gap: 9px; margin: 0 0 10px;
  font-size: 13px; font-weight: 700; letter-spacing: .02em; color: var(--text-2);
}
.pg-title .ic { width: 16px; height: 16px; color: var(--muted); }
.pg-count {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  background: var(--surface-2); border-radius: 5px; padding: 1px 6px;
}
/* По две карточки в ряд: проектов на площадку немного, широкие карточки
   читаются лучше сетки из четырёх узких. */
.pg-cards {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px; align-items: start;
}
/* Карточке проекта не нужна высота под три строки описания (это правило для
   карточек шаблонов) — иначе внутри зияет пустота. */
.pg-cards .tpl-card-desc { min-height: 0; -webkit-line-clamp: 2; }
.pg-cards .tpl-card-h { min-height: 0; }
.pg-cards .tpl-card { gap: 6px; padding: 14px 16px; }
.pg-cards .tpl-card-meta { margin-top: 2px; }
@media (max-width: 900px) { .pg-cards { grid-template-columns: 1fr; } }
.pc-busy { color: var(--warn); }
.pc-fail { color: var(--danger); }

/* ---------------- Карточки проектов и шаблонов ---------------- */
.tpl-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px; align-items: stretch;   /* карточки в строке одной высоты */
}
/* Фавикон площадки вместо обезличенной иконки */
.site-ic {
  width: 18px; height: 18px; flex: none; border-radius: 4px;
  object-fit: contain; background: #fff; padding: 1px;
}
.job-item .site-ic { width: 14px; height: 14px; }  /* в узком списке имя важнее */
#detail-name .site-ic { width: 20px; height: 20px; vertical-align: -3px; }
.tpl-card {
  display: flex; flex-direction: column; gap: 9px; text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 18px;
  font-family: var(--sans); color: var(--text); width: 100%;
  transition: border-color var(--t), background var(--t), transform var(--t);
}
/* Кликабельна карточка целиком только там, где она — кнопка (проекты). */
button.tpl-card { cursor: pointer; }
button.tpl-card:hover { border-color: var(--border-strong); background: var(--surface-2); transform: translateY(-2px); }
button.tpl-card:active { transform: translateY(0); }
section.tpl-card:hover { border-color: var(--border-strong); }
/* Заголовок карточки: место под две строки, чтобы бейдж и текст ниже
   выстраивались в один уровень у всех карточек ряда. */
.tpl-card-h { display: flex; align-items: flex-start; gap: 9px; min-height: 38px; }
.tpl-card-h .site-ic, .tpl-card-h .ic { margin-top: 1px; }
.tpl-card-h .tpl-badge { align-self: flex-start; }
.tpl-card-h .ic { color: var(--primary-2); width: 17px; height: 17px; }
.tpl-card-title { font-weight: 700; font-size: 14.5px; letter-spacing: -.01em; }
.tpl-badge {
  margin-left: auto; font-family: var(--mono); font-size: 9.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: var(--primary-2);
  background: var(--primary-soft); border-radius: 5px; padding: 3px 7px; white-space: nowrap;
}
/* Описание фиксированной высоты (3 строки) — списки задач ниже начинаются
   на одном уровне, а не «лесенкой». */
.tpl-card-desc {
  font-size: 12.5px; color: var(--text-2); line-height: 1.5; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; min-height: calc(3 * 1.5 * 12.5px);
}
.tpl-card-title { line-height: 1.3; }
.tpl-card-meta { font-size: 12px; color: var(--muted); font-family: var(--mono); margin-top: auto; }
.tpl-card-ex { font-size: 11px; }
.tpl-card-ex code { font-size: 10.5px; word-break: break-all; }
/* Привязанные к шаблону задачи */
.tpl-card-stat { font-size: 12px; color: var(--text-2); font-family: var(--mono); }
.tpl-card-stat b { color: var(--text); font-size: 13px; }
.tpl-card-tasks { display: flex; flex-direction: column; gap: 4px; }
/* Раскрытый список не должен растягивать весь ряд карточек — прокручиваем
   его внутри карточки. */
/* Высота ровно как у свёрнутого списка (5 строк): раскрытие даёт прокрутку
   внутри карточки и НЕ двигает соседние карточки. */
.tpl-card-tasks.open { max-height: 166px; overflow-y: auto; padding-right: 4px; }
.tpl-card-tasks.open::-webkit-scrollbar { width: 6px; }
.tpl-card-tasks.open::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 3px;
}
.tpl-task {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 6px 10px; cursor: pointer; color: var(--text); font-family: var(--sans);
  font-size: 12.5px; font-weight: 500; transition: border-color var(--t), background var(--t);
}
.tpl-task:hover { border-color: var(--primary); background: var(--surface-3); }
.tpl-task-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-task .ic { color: var(--muted); width: 14px; height: 14px; margin-left: auto; flex: none; }
.tpl-more {
  align-self: flex-start; background: none; border: 0; padding: 2px 0;
  color: var(--primary-2); font-family: var(--sans); font-size: 12px;
  font-weight: 600; cursor: pointer;
}
.tpl-more:hover { text-decoration: underline; }
.tpl-empty {
  font-size: 12.5px; color: var(--muted); background: var(--surface-2);
  border: 1px dashed var(--border); border-radius: var(--r-sm);
  padding: 10px 12px; align-self: stretch;
}
/* Кнопка действия всегда у нижнего края — карточки выглядят одинаково */
.tpl-card-act { margin-top: auto; padding-top: 4px; }

/* Список задач внутри проекта */
.pp-jobs { display: flex; flex-direction: column; gap: 6px; }
.pp-job {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r);
  padding: 10px 12px; cursor: pointer; color: var(--text); font-family: var(--sans);
  transition: border-color var(--t), background var(--t);
}
.pp-job:hover { border-color: var(--border-strong); background: var(--surface-3); }
.pp-job .name { font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-job .ic { color: var(--muted); }

/* ---------------- Responsive ---------------- */
@media (max-width: 980px) {
  body { padding-left: 0; }
  .sidebar {
    position: static; width: 100%; height: auto;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px;
    border-right: none; border-bottom: 1px solid var(--border); padding: 10px 12px;
  }
  .sb-brand { padding: 0 8px 0 0; }
  .sb-nav { flex-direction: row; flex-wrap: wrap; overflow: visible; }
  .sb-label { display: none; }
  .sb-item { width: auto; }
  .sb-bottom { margin: 0; border: none; padding: 0; }
  .layout { grid-template-columns: 1fr; padding: 14px; }
  .chat-page, .data-page { height: auto; min-height: calc(100dvh - 60px); }
}

/* ---------------- Отчёт прайс-мониторинга ---------------- */
.pm-wrap {
  flex: 1; overflow: auto;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface);
}
.pm-table { border-collapse: separate; border-spacing: 0; font-size: 12px; width: max-content; min-width: 100%; }
.pm-table th, .pm-table td {
  padding: 7px 10px; border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border); white-space: nowrap;
}
.pm-table thead th { position: sticky; background: var(--surface-3); z-index: 2; }
.pm-table thead tr:first-child th { top: 0; }
/* Смещение только у ВТОРОГО ряда шапки (двухрядная шапка);
   у одинарной шапки отчёта ряд один — он липнет к самому верху. */
.pm-table thead tr:nth-child(2) th { top: 31px; }
.pm-table thead th.pm-sub, .pm-table thead tr:nth-child(2) th {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .07em;
  text-transform: uppercase; font-weight: 600; color: var(--muted);
}
.pm-table td.pm-key { color: var(--text-2); }
.pm-table td.pm-num { text-align: center; font-family: var(--mono); font-size: 11.5px; }
.pm-table td.pm-price { font-weight: 600; }
.pm-metrics { display: flex; gap: 6px; flex-wrap: wrap; margin: 2px 0 10px; }
.pm-metrics:empty { display: none; }
.pm-metric {
  font-family: var(--sans); font-size: 12px; padding: 5px 11px; cursor: pointer;
  border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2);
  transition: border-color var(--t), color var(--t), background var(--t);
}
.pm-metric:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface-3); }
.pm-metric.active {
  color: var(--primary-2); background: var(--primary-soft);
  border-color: rgba(94, 106, 210, .35);
}
.pm-bar-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 4px; }
.pm-filter {
  font-family: var(--sans); font-size: 12px; padding: 5px 10px; cursor: pointer;
  border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2); max-width: 230px;
}
.pm-filter:hover { border-color: var(--border-strong); color: var(--text); }
.pm-filter.active { color: var(--primary-2); border-color: rgba(94, 106, 210, .45); }
.pm-reset { color: var(--danger); }
.pm-table tr.pmo-group-start td { border-top: 2px solid var(--border-strong); }
.pm-table th.pmo-sort { cursor: pointer; user-select: none; white-space: nowrap; }
.pm-table th.pmo-sort:hover { color: var(--text); }
.pm-table th.pmo-sort.active { color: var(--primary-2); }
.pm-bestv {
  background: var(--ok-soft); color: var(--ok); font-weight: 700;
  border-radius: 4px; padding: 1px 5px; margin: 0 -5px;
}
/* Динамика цены vs прошлый запуск */
.pm-dyn { font-size: 10px; font-weight: 600; white-space: nowrap; }
.pm-dyn.down { color: var(--ok); }       /* цена упала — дешевле */
.pm-dyn.up { color: var(--danger); }      /* цена выросла */
.pm-dyn.same { color: var(--muted); }
.pm-dyn.new { color: var(--primary-2); background: var(--primary-soft); border-radius: 4px; padding: 0 4px; }
.pm-link { display: inline-flex; vertical-align: -2px; margin-left: 5px; color: var(--muted); transition: color var(--t); }
.pm-link .ic { width: 12px; height: 12px; }
.pm-link:hover { color: var(--primary-2); }
.pm-table tbody tr:hover td { background: var(--surface-2); }

/* «Наш ДЦ» + чеклист конкурентов */
.pm-our { max-width: 260px; }
.pm-comp { position: relative; display: inline-block; }
.pm-comp > summary {
  list-style: none; display: inline-block; user-select: none;
  font-family: var(--sans); font-size: 12px; padding: 5px 10px; cursor: pointer;
  border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2);
}
.pm-comp > summary::-webkit-details-marker { display: none; }
.pm-comp > summary:hover { border-color: var(--border-strong); color: var(--text); }
.pm-comp[open] > summary { border-color: rgba(94, 106, 210, .45); color: var(--primary-2); }
.pm-comp-list {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0;
  min-width: 240px; max-height: 320px; overflow: auto; padding: 6px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.pm-comp-actions { display: flex; gap: 8px; padding: 2px 6px 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.pm-comp-actions a { color: var(--primary-2); cursor: pointer; font-size: 12px; }
.pm-comp-item {
  display: flex; align-items: center; gap: 7px; padding: 4px 6px; cursor: pointer;
  font-size: 12px; color: var(--text-2); border-radius: 6px; white-space: nowrap;
}
.pm-comp-item:hover { background: var(--surface-3); color: var(--text); }
.pm-comp-item input { width: auto; }
/* Подсветка нашего ДЦ и знак разницы */
/* Наш ДЦ: подсветка фоном И жирный текст во всей строке. Одного цвета
   оказалось мало — в длинной таблице свою строку глазами не выхватить. */
.pm-table tr.pmo-our td { background: var(--primary-soft); font-weight: 600; }
.pm-table tr.pmo-our:hover td { background: color-mix(in srgb, var(--primary-soft) 70%, var(--surface-2)); }
.pmo-badge {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--primary-2); background: var(--primary-soft); border-radius: 4px; padding: 1px 5px;
}
.pm-num.pm-win { color: var(--ok); font-weight: 700; }
.pm-num.pm-lose { color: var(--danger); font-weight: 700; }

/* Блок уникальных описаний по дилерам */
.pm-desc-block { margin-top: 18px; }
.pm-desc-block > summary {
  cursor: pointer; user-select: none; font-weight: 600; font-size: 13px;
  color: var(--text); padding: 6px 2px;
}
.pm-desc-block > summary::-webkit-details-marker { color: var(--muted); }
.pm-desc-tools { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; }
.pm-desc-list { display: grid; gap: 10px; }
.pm-desc-item {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 10px 12px;
}
.pm-desc-dealers { font-size: 11px; font-weight: 600; color: var(--primary-2); margin-bottom: 6px; }
.pm-desc-text { white-space: pre-wrap; font-size: 12.5px; line-height: 1.5; color: var(--text-2); }

/* Заметная опция задачи «Собирать описания» */
.job-desc-opt {
  margin: 6px 0 4px; padding: 10px 12px; border-radius: var(--r);
  background: var(--surface-2); border: 1px solid var(--border);
}

@media (prefers-reduced-motion: reduce) {
  *, .modal, .modal-card, .toast { animation: none !important; transition: none !important; }
}


/* ---------------- Затраты: трафик и деньги ---------------- */
.cost-card { grid-column: 1 / -1; }
.cost-cells {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px; margin-bottom: 12px;
}
.cost-cell {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 10px 12px;
}
.cost-lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cost-val { font-size: 19px; font-weight: 700; margin-top: 2px; }
.cost-sub { font-size: 11.5px; color: var(--text-2); font-family: var(--mono); margin-top: 2px; }
/* Столбики трафика по дням */
.cost-spark {
  display: flex; align-items: flex-end; gap: 3px; height: 50px;
  padding: 4px 2px; margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.cost-spark i { flex: 1; background: var(--primary); border-radius: 2px 2px 0 0; opacity: .75; }
.cost-spark i:hover { opacity: 1; }
.cost-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.cost-cols h4, .cost-card h4 { margin: 0 0 6px; font-size: 12px; color: var(--text-2); }
.cost-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 12.5px; }
.cost-row-name { flex: 0 0 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cost-row-name a { color: var(--text); text-decoration: none; }
.cost-row-name a:hover { color: var(--primary-2); }
.cost-bar { flex: 1; height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.cost-bar i { display: block; height: 100%; background: var(--primary); border-radius: 3px; }
.cost-row-val { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); white-space: nowrap; }
/* Затраты в карточке задачи */
.job-costs {
  display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 4px 0 14px;
  padding: 10px 14px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r); font-size: 12.5px;
}
.job-costs b { font-size: 14px; }
.jc-item { font-family: var(--mono); }


/* ---------------- Пользователи и права ---------------- */
.sb-user {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin-top: 6px;
  border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-2);
}
.sb-user-name { display: flex; align-items: center; gap: 6px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.sb-user .ic { width: 14px; height: 14px; color: var(--muted); }
.sb-user .btn { margin-left: auto; }
.user-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); margin-bottom: 8px;
}
.user-name { font-weight: 600; min-width: 120px; }
.user-role {
  font-family: var(--mono); font-size: 11px; padding: 2px 8px; border-radius: 5px;
  background: var(--surface-2); color: var(--text-2);
}
.user-role.admin { color: var(--primary-2); background: var(--primary-soft); }
.user-projects-list { flex: 1; display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  font-size: 11.5px; padding: 2px 8px; border-radius: 5px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
}
.user-projects { display: flex; flex-direction: column; gap: 6px; max-height: 220px;
  overflow-y: auto; padding: 8px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r); }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.chk input { width: 15px; height: 15px; accent-color: var(--primary); }


/* ---------------- Обзор: что требует внимания ---------------- */
.dash-card h3 .dash-count {
  margin-left: auto; font-family: var(--mono); font-size: 11px; font-weight: 700;
  background: var(--surface-3); color: var(--text-2);
  border-radius: 5px; padding: 2px 7px;
}
.dash-attention { border-color: rgba(238, 110, 110, .35); }
.dash-attention h3 .ic { color: var(--danger); }
.dash-attention .dash-count { background: rgba(238, 110, 110, .16); color: var(--danger); }
.dash-ok h3 .ic { color: var(--ok); }
.att-row {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  background: none; border: 0; border-radius: var(--r-sm);
  padding: 7px 8px; cursor: pointer; color: var(--text);
  font-family: var(--sans); font-size: 13px;
}
.att-row:hover { background: var(--surface-3); }
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-note { margin-left: auto; font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.att-row .ic { width: 14px; height: 14px; color: var(--muted); flex: none; }
/* Активные запуски с полоской прогресса */
.act-run { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 12.5px; }
.act-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.act-bar { flex: 0 0 68px; height: 5px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.act-bar i { display: block; height: 100%; background: var(--warn); border-radius: 3px; }

/* ---------- Ценообразование: рекомендованные цены по срезу ---------- */
.pricing-box { margin: 0 0 10px; }
.pricing {
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); overflow: hidden;
}
.pricing > summary {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 9px 12px; font-size: 13px; font-weight: 600; color: var(--text);
  list-style: none; user-select: none;
}
.pricing > summary::-webkit-details-marker { display: none; }
.pricing > summary:hover { background: var(--surface-2); }
.pricing[open] > summary { border-bottom: 1px solid var(--border); }
.pricing-sum-title { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.pricing-sum-rule {
  font-size: 11.5px; font-weight: 400; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pricing-body { padding: 12px; }
.pricing-form { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.pricing-lbl {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 10.5px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; font-weight: 600;
}
.pricing-sel, .pricing-num {
  font-family: var(--sans); font-size: 12.5px; padding: 6px 9px;
  border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); text-transform: none;
  letter-spacing: 0; font-weight: 400;
}
.pricing-num { width: 118px; font-family: var(--mono); }
.pricing-sel:hover, .pricing-num:hover { border-color: var(--border-strong); }
.pricing-delta { display: flex; gap: 4px; }
.pricing-sel.narrow { width: 56px; }
.pricing-actions { display: flex; gap: 8px; margin-left: auto; }
.pricing-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0 8px; }
.pricing-chip {
  font-size: 11.5px; padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
}
.pricing-chip b { color: var(--text); font-variant-numeric: tabular-nums; }
.pricing-chip.down { border-color: rgba(63, 202, 141, .35); background: var(--ok-soft); }
.pricing-chip.down b { color: var(--ok); }
.pricing-chip.up { border-color: rgba(238, 110, 110, .35); background: var(--danger-soft); }
.pricing-chip.up b { color: var(--danger); }
.pricing-chip.ok { border-color: rgba(94, 106, 210, .35); background: var(--primary-soft); }
.pricing-chip.ok b { color: var(--primary-2); }
.pricing-chip.dim { opacity: .7; }
.pricing-note { font-size: 11px; color: var(--muted); margin: 0 0 10px; }
.pricing-hint { font-size: 12.5px; color: var(--text-2); padding: 12px 2px; }
.pricing-cap {
  font-size: 9.5px; font-weight: 700; color: var(--warn);
  background: var(--warn-soft); border-radius: 4px; padding: 1px 4px; margin-left: 4px;
}
.pricing-chip.warn { border-color: rgba(217, 161, 63, .4); background: var(--warn-soft); }
.pricing-chip.warn b { color: var(--warn); }
