/* ============================================================================
   AutoCert — дизайн-система интерфейса.
   Слои: токены → база → каркас (AppShell) → компоненты → страницы → печать.
   Все цвета — ТОЛЬКО через токены. Темы: светлая (по умолчанию) и тёмная
   (data-theme на <html>; без атрибута уважается prefers-color-scheme).
   ========================================================================= */

/* ------------------------------------------------------------------ токены */

:root {
  /* шрифты */
  --font-ui: -apple-system, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "JetBrains Mono", "Roboto Mono", monospace;

  /* шкала отступов (база 4px) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;

  /* радиусы и тени */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 4px rgba(16, 24, 40, .04);
  --shadow-2: 0 6px 24px rgba(16, 24, 40, .10), 0 2px 6px rgba(16, 24, 40, .05);

  /* поверхность — светлая тема */
  color-scheme: light;
  --bg: #f5f6f8;
  --bg-raised: #ffffff;
  --bg-sunken: #eceef2;
  --bg-hover: #f1f3f6;
  --border: #e4e7ec;
  --border-strong: #cfd5dd;
  --text: #182130;
  --text-muted: #5d6b7d;
  --text-faint: #8d97a5;

  /* бренд */
  --accent: #4f5ce5;
  --accent-hover: #3d49cf;
  --accent-soft: rgba(79, 92, 229, .10);
  --accent-soft-2: rgba(79, 92, 229, .18);
  --on-accent: #ffffff;

  /* статусные тона */
  --ok: #189646;      --ok-soft: rgba(24, 150, 70, .12);   --ok-text: #116e35;
  --warn: #cf7307;    --warn-soft: rgba(207, 115, 7, .13); --warn-text: #965405;
  --err: #d92d20;     --err-soft: rgba(217, 45, 32, .11);  --err-text: #b42318;
  --info: #2467d6;    --info-soft: rgba(36, 103, 214, .11);--info-text: #1a4fa8;
  --purple: #7a3ee8;  --purple-soft: rgba(122, 62, 232, .11); --purple-text: #6023c9;
  --neutral: #64748b; --neutral-soft: rgba(100, 116, 139, .13); --neutral-text: #4b5768;
  --muted: #94a0ae;   --muted-soft: rgba(148, 160, 174, .16); --muted-text: #67717e;

  /* терминал (лог всегда тёмный, в обеих темах) */
  --term-bg: #0d1420;
  --term-bg-head: #111a29;
  --term-text: #c6d0de;
  --term-faint: #5f6f85;
  --term-border: #1d2940;

  /* дифф */
  --diff-add-bg: rgba(24, 150, 70, .13);
  --diff-del-bg: rgba(217, 45, 32, .11);
  --diff-add-text: #116e35;
  --diff-del-text: #b42318;

  --sidebar-w: 224px;
  --topbar-h: 52px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1116;
    --bg-raised: #151a22;
    --bg-sunken: #0a0d12;
    --bg-hover: #1b212c;
    --border: #262d39;
    --border-strong: #38414f;
    --text: #e7eaef;
    --text-muted: #9aa5b3;
    --text-faint: #6c7787;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-2: 0 8px 28px rgba(0, 0, 0, .5);

    --accent: #7b86f2;
    --accent-hover: #97a0f6;
    --accent-soft: rgba(123, 134, 242, .14);
    --accent-soft-2: rgba(123, 134, 242, .25);
    --on-accent: #10132a;

    --ok: #3fd472;      --ok-soft: rgba(63, 212, 114, .13);  --ok-text: #6fe89a;
    --warn: #f7b13c;    --warn-soft: rgba(247, 177, 60, .13);--warn-text: #ffc963;
    --err: #f97066;     --err-soft: rgba(249, 112, 102, .13);--err-text: #ff9d95;
    --info: #62a2fb;    --info-soft: rgba(98, 162, 251, .13);--info-text: #8ebcff;
    --purple: #b08cf9;  --purple-soft: rgba(176, 140, 249, .14); --purple-text: #c8adfd;
    --neutral: #8b99ab; --neutral-soft: rgba(139, 153, 171, .15); --neutral-text: #aab6c5;
    --muted: #5f6b7b;   --muted-soft: rgba(95, 107, 123, .22); --muted-text: #98a4b3;

    --term-bg: #0a0f18;
    --term-bg-head: #0e1521;
    --term-text: #c6d0de;
    --term-faint: #5f6f85;
    --term-border: #1c2536;

    --diff-add-bg: rgba(63, 212, 114, .12);
    --diff-del-bg: rgba(249, 112, 102, .11);
    --diff-add-text: #6fe89a;
    --diff-del-text: #ff9d95;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1116;
  --bg-raised: #151a22;
  --bg-sunken: #0a0d12;
  --bg-hover: #1b212c;
  --border: #262d39;
  --border-strong: #38414f;
  --text: #e7eaef;
  --text-muted: #9aa5b3;
  --text-faint: #6c7787;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-2: 0 8px 28px rgba(0, 0, 0, .5);

  --accent: #7b86f2;
  --accent-hover: #97a0f6;
  --accent-soft: rgba(123, 134, 242, .14);
  --accent-soft-2: rgba(123, 134, 242, .25);
  --on-accent: #10132a;

  --ok: #3fd472;      --ok-soft: rgba(63, 212, 114, .13);  --ok-text: #6fe89a;
  --warn: #f7b13c;    --warn-soft: rgba(247, 177, 60, .13);--warn-text: #ffc963;
  --err: #f97066;     --err-soft: rgba(249, 112, 102, .13);--err-text: #ff9d95;
  --info: #62a2fb;    --info-soft: rgba(98, 162, 251, .13);--info-text: #8ebcff;
  --purple: #b08cf9;  --purple-soft: rgba(176, 140, 249, .14); --purple-text: #c8adfd;
  --neutral: #8b99ab; --neutral-soft: rgba(139, 153, 171, .15); --neutral-text: #aab6c5;
  --muted: #5f6b7b;   --muted-soft: rgba(95, 107, 123, .22); --muted-text: #98a4b3;

  --term-bg: #0a0f18;
  --term-bg-head: #0e1521;
  --term-text: #c6d0de;
  --term-faint: #5f6f85;
  --term-border: #1c2536;

  --diff-add-bg: rgba(63, 212, 114, .12);
  --diff-del-bg: rgba(249, 112, 102, .11);
  --diff-add-text: #6fe89a;
  --diff-del-text: #ff9d95;
}

/* -------------------------------------------------------------------- база */

* { box-sizing: border-box; }
html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 700; margin: 0 0 var(--sp-3); }

.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--accent-soft-2); }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

.icon { flex-shrink: 0; vertical-align: -3px; }

[x-cloak] { display: none !important; }
[hidden] { display: none !important; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------- AppShell */

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 60;
  transition: transform .18s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);
  padding: 0 var(--sp-4);
  border-bottom: 1px solid var(--border);
  font-weight: 800;
  font-size: 15.5px;
  color: var(--text);
  letter-spacing: -.01em;
}
.sidebar-brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff;
  flex-shrink: 0;
}
.brand-mark .icon { vertical-align: 0; }
.sidebar-brand em { font-style: normal; color: var(--accent); }

.sidebar-nav { padding: var(--sp-3) var(--sp-2); display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 550;
  font-size: 13.5px;
}
button.nav-item {
  background: none;
  border: none;
  font: inherit;
  font-weight: 550;
  font-size: 13.5px;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item .icon { color: inherit; }
.nav-sep { height: 1px; background: var(--border); margin: var(--sp-2) var(--sp-2); }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); padding: var(--sp-3) 10px 4px; }

.sidebar-foot { border-top: 1px solid var(--border); padding: var(--sp-2); display: flex; flex-direction: column; gap: 2px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft-2);
  color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  flex-shrink: 0;
}
.sidebar-user .name { font-weight: 600; font-size: 13px; }
.sidebar-user form { margin-left: auto; display: inline; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-6);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar .burger { display: none; }

.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13.5px; }
.crumbs a { color: var(--text-muted); }
.crumbs a:hover { color: var(--text); text-decoration: none; }
.crumbs .sep { color: var(--text-faint); }
.crumbs .here { color: var(--text); font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-faint);
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  min-width: 180px;
}
.search-trigger:hover { border-color: var(--border-strong); color: var(--text-muted); }
.search-trigger kbd { margin-left: auto; }

kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-muted);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
}

.content { width: 100%; max-width: 1400px; margin: 0 auto; padding: var(--sp-5) var(--sp-6) 72px; }
.content-narrow { max-width: 860px; }
.content-wide { max-width: none; }

/* App-shell: карточка сертификации живёт в полноэкранной колонке — шапка и вкладки
   фиксированы, рабочая область (чат/артефакты/пайплайн) прокручивается внутри себя,
   а не гоняет всю страницу. Так «верх» перестаёт съедать высоту. */
.content.content-app {
  max-width: none;
  margin: 0;
  padding: 0;
  height: calc(100dvh - var(--topbar-h));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.content-app #cert-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.content-app #tab-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-6) var(--sp-6);
}
/* чат сам управляет высотой и прокруткой — контейнер не должен добавлять свою */
.content-app #tab-content:has(.chat-wrap) { overflow: hidden; padding: 0; }
/* последняя карточка во вкладке не должна тащить лишний нижний отступ */
.content-app #tab-content > [data-partial] > .card:last-child,
.content-app #tab-content > [data-partial]:last-child { margin-bottom: 0; }

.page-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.page-head .sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.page-actions { margin-left: auto; display: flex; gap: var(--sp-2); align-items: center; }

/* ------------------------------------------------------------------ кнопки */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 13px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn[disabled], .btn.disabled { opacity: .55; cursor: not-allowed; pointer-events: auto; }
.btn[disabled]:hover { background: var(--bg-raised); border-color: var(--border); }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--err) 45%, transparent); color: var(--err-text); }
.btn-danger:hover { background: var(--err-soft); border-color: var(--err); }
.btn-warn { background: transparent; border-color: color-mix(in srgb, var(--warn) 50%, transparent); color: var(--warn-text); }
.btn-warn:hover { background: var(--warn-soft); border-color: var(--warn); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-hover); border-color: transparent; color: var(--text); }

.btn-sm { padding: 4px 9px; font-size: 12.5px; border-radius: 7px; gap: 5px; }
.btn-icon { padding: 6px; width: 30px; height: 30px; }
.btn-icon.btn-sm { width: 26px; height: 26px; padding: 4px; }
.btn-block { width: 100%; }
.btn .icon { vertical-align: 0; }

.icon-spin { animation: spin .9s linear infinite; }

/* ------------------------------------------------------------------ бейджи */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px 2px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
  background: var(--neutral-soft);
  color: var(--neutral-text);
  line-height: 1.6;
}
.badge .badge-icon { vertical-align: 0; }
.badge-sm { padding: 1px 7px 1px 5px; font-size: 10.5px; }
.badge-spin { animation: spin 1s linear infinite; }

.tone-neutral { background: var(--neutral-soft); color: var(--neutral-text); }
.tone-info    { background: var(--info-soft);    color: var(--info-text); }
.tone-ok      { background: var(--ok-soft);      color: var(--ok-text); }
.tone-warn    { background: var(--warn-soft);    color: var(--warn-text); }
.tone-err     { background: var(--err-soft);     color: var(--err-text); }
.tone-muted   { background: var(--muted-soft);   color: var(--muted-text); }
.tone-purple  { background: var(--purple-soft);  color: var(--purple-text); }

.status-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--neutral);
  flex-shrink: 0;
}
.status-dot.tone-info { background: var(--info); }
.status-dot.tone-ok { background: var(--ok); }
.status-dot.tone-warn { background: var(--warn); }
.status-dot.tone-err { background: var(--err); }
.status-dot.tone-muted { background: var(--muted); }
.status-dot.tone-purple { background: var(--purple); }
.status-dot.tone-neutral { background: var(--neutral); }
.dot-pulse { animation: pulse 1.2s ease-in-out infinite; }

.chip-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 999px;
  background: var(--warn); color: #fff;
  font-size: 10.5px; font-weight: 700;
}

/* ---------------------------------------------------------------- карточки */

.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.card-flush { padding: 0; overflow: hidden; }
.card-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin: 0 0 var(--sp-3);
  display: flex;
  align-items: center;
  gap: 7px;
}
.card-title .icon { color: var(--text-faint); }
.card-title .right { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500; }

/* ---------------------------------------------------------------- таблицы */

.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  font-weight: 650;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--bg-raised);
}
.table-sticky thead th { position: sticky; top: 0; z-index: 2; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-hover); }
.table-compact td, .table-compact th { padding: 6px 10px; font-size: 13px; }
.row-link { font-weight: 650; color: var(--text); }
.row-link:hover { color: var(--accent); text-decoration: none; }
.cell-sub { color: var(--text-faint); font-size: 12px; margin-top: 1px; }

th.sortable a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
th.sortable a:hover { color: var(--text); text-decoration: none; }
th.sorted a { color: var(--accent); }

/* --------------------------------------------------------------- вкладки */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-4);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: none;
  background: none;
  padding: 9px 14px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn .icon { vertical-align: 0; }

/* ------------------------------------------------------- фильтры и чипы */

.filterbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }

.searchbox { position: relative; }
.searchbox .icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
.searchbox input {
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 11px 7px 31px;
  font: inherit;
  font-size: 13.5px;
  width: 260px;
}
.searchbox input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.searchbox input::placeholder { color: var(--text-faint); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 3.5px 11px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: all .12s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); text-decoration: none; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip .icon { vertical-align: 0; }

/* --- список сертификаций: тулбар фильтров, статус-чипы со счётчиками, селект вендора --- */
.cert-toolbar { display: flex; flex-direction: column; gap: 0; padding: 12px 14px; }
.cert-search-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cert-search-form .searchbox { flex: 1; min-width: 240px; }
.cert-search-form .searchbox input { width: 100%; }
.cert-select-group { display: flex; align-items: center; gap: 8px; }
.cert-filter-label { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-faint); white-space: nowrap; }
.cert-select {
  border: 1px solid var(--border); background: var(--bg-raised); color: var(--text);
  border-radius: 8px; padding: 7px 30px 7px 11px; font: inherit; font-size: 13.5px;
  max-width: 240px; cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238d97a5' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.cert-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cert-status-filter { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.chip-status { padding-left: 9px; }
.chip-status .status-dot { width: 8px; height: 8px; }
.chip-n {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 16px; padding: 0 5px; margin-left: 1px;
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
  border-radius: 999px; background: var(--bg-sunken); color: var(--text-muted);
}
.chip.on .chip-n { background: var(--accent-soft-2); color: var(--accent); }
.chip-empty { opacity: .5; }
.chip-empty:hover { opacity: 1; }
.cert-list-table tbody tr { cursor: default; }

/* ------------------------------------------------------------------ формы */

.field { display: block; margin: 0 0 var(--sp-4); }
.field > span { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 5px; color: var(--text-muted); }
input[type="text"], input[type="password"], input[type="email"], input[type="number"], textarea, select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  font: inherit;
  font-size: 13.5px;
  background: var(--bg-raised);
  color: var(--text);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
textarea { resize: vertical; min-height: 60px; }
.field-error { color: var(--err-text); display: block; font-size: 12.5px; margin-top: 3px; }
.field-hint { color: var(--text-faint); font-size: 12px; margin-top: 3px; display: block; }
.form-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-5); align-items: center; }

.radio-cards { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.radio-card {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  cursor: pointer;
  display: block;
}
.radio-card:hover { border-color: var(--border-strong); }
.radio-card.on { border-color: var(--accent); background: var(--accent-soft); }
.radio-card input { display: none; }
.radio-card .rc-title { font-weight: 650; font-size: 13px; display: flex; gap: 7px; align-items: center; }
.radio-card .rc-desc { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* --------------------------------------------------------------- дропзона */

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: var(--sp-5);
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
  background: var(--bg-raised);
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone .dz-icon { color: var(--text-faint); margin-bottom: 6px; }
.dropzone.drag .dz-icon { color: var(--accent); }
.dropzone .dz-title { font-weight: 600; color: var(--text); font-size: 13.5px; }
.dropzone.drag .dz-title { color: var(--accent); }
.dropzone .dz-hint { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.dropzone-sm { padding: var(--sp-3); display: flex; align-items: center; gap: 10px; text-align: left; }
.dropzone-sm .dz-icon { margin: 0; }

.file-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
  min-width: 0;
}
.file-row:last-child { border-bottom: none; }
.file-row .icon { color: var(--text-faint); }
.file-row .fname { font-family: var(--mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .fmeta { color: var(--text-faint); font-size: 11.5px; }
.file-row .grow { min-width: 0; }

.progress { height: 4px; border-radius: 4px; background: var(--bg-sunken); overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .2s; }

/* ------------------------------------------------------------------ тосты */

.toast-stack {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(380px, calc(100vw - 28px));
}
.toast {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--neutral);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-2);
  padding: 10px 12px;
  font-size: 13px;
  animation: toast-in .18s ease;
}
.toast .icon { margin-top: 1px; }
.toast-ok { border-left-color: var(--ok); } .toast-ok .icon { color: var(--ok); }
.toast-err { border-left-color: var(--err); } .toast-err .icon { color: var(--err); }
.toast-warn { border-left-color: var(--warn); } .toast-warn .icon { color: var(--warn); }
.toast-info { border-left-color: var(--info); } .toast-info .icon { color: var(--info); }
.toast .close { margin-left: auto; background: none; border: none; color: var(--text-faint); cursor: pointer; padding: 0 2px; }
.toast .close:hover { color: var(--text); }

/* ----------------------------------------------------------------- модалы */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(9, 12, 18, .55);
  backdrop-filter: blur(2px);
  z-index: 150;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 9vh var(--sp-4) var(--sp-4);
  animation: fade-in .12s ease;
  overflow-y: auto;
}
.modal {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  width: 100%;
  max-width: 540px;
  animation: rise .16s ease;
}
.modal-lg { max-width: 860px; }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 15px;
}
.modal-head .icon { color: var(--text-muted); }
.modal-head .close { margin-left: auto; }
.modal-body { padding: var(--sp-5); max-height: 65vh; overflow-y: auto; }
.modal-foot {
  display: flex; gap: var(--sp-2); justify-content: flex-end;
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ------------------------------------------------- мастер запуска (визард) */

.modal-wizard { max-width: 660px; }
.wizard-steps {
  display: flex; gap: 6px;
  padding: 12px var(--sp-5) 0;
}
.ws-dot {
  height: 4px; flex: 1;
  border-radius: 3px;
  background: var(--border-strong);
  transition: background .18s ease;
}
.ws-dot.done { background: var(--accent-soft-2); }
.ws-dot.on { background: var(--accent); }
.ws-dot:not(.on):not(.done) { cursor: default; }
.ws-dot.done { cursor: pointer; }

/* ---------------------------------------------- наряд на прогон (RunSpec) */

.runspec { display: block; }
.rs-modes { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.rs-catalog {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-sunken);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.rs-catalog-hint { margin: 0 0 var(--sp-2); }
.rs-group { margin-bottom: var(--sp-3); }
.rs-group:last-child { margin-bottom: 0; }
.rs-group-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-faint);
  padding: 2px 2px 5px; border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.rs-group-tools { display: flex; align-items: center; gap: 5px; }
.rs-bulk {
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: 11px; font-weight: 600;
  padding: 2px 3px; border-radius: 4px;
}
.rs-bulk:hover { background: var(--accent-soft); }
.rs-dot { color: var(--text-faint); }
.rs-item { padding: 1px 0; }
.rs-row {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 5px 4px; border-radius: var(--r-sm); cursor: pointer;
}
.rs-row:hover { background: var(--bg-hover); }
.rs-row input[type="checkbox"] { margin-top: 2px; flex: none; }
.rs-name { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; line-height: 1.3; }
.rs-title { font-size: 13px; font-weight: 550; color: var(--text); }
.rs-slug { font-size: 11px; color: var(--text-faint); }
.rs-core {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--warn-text); background: var(--warn-soft);
  padding: 1px 5px; border-radius: 4px; cursor: help;
}
.rs-hint { margin: 0 0 2px 26px; }
.rs-hint-sum {
  list-style: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--text-faint);
  padding: 1px 0;
}
.rs-hint-sum::-webkit-details-marker { display: none; }
.rs-hint-sum:hover { color: var(--accent); }
.rs-hint[open] .rs-hint-sum { color: var(--accent); margin-bottom: 3px; }
.rs-hint-ta {
  width: 100%; font-family: var(--mono); font-size: 11.5px;
  padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--bg-raised); color: var(--text); resize: vertical;
}
.rs-global { margin-top: var(--sp-2); }
.rs-global textarea, .runspec textarea[name="guidance"] {
  width: 100%; font-size: 12.5px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--bg-raised); color: var(--text); resize: vertical;
}

/* --------------------------------------------------- ревью и запуск (шаг 5) */

.review {
  border: 1px solid var(--border); border-radius: var(--r-md);
  overflow: hidden; margin-bottom: var(--sp-3);
}
.review-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 13px;
}
.review-row:last-child { border-bottom: none; }
.rv-k { color: var(--text-muted); display: inline-flex; align-items: center; gap: 7px; }
.rv-k .icon { color: var(--text-faint); }
.rv-v { font-weight: 550; text-align: right; }
.rv-v.rv-warn { color: var(--warn-text); }
.launch-toggle {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--accent-soft); cursor: pointer;
}
.launch-toggle.disabled { background: var(--bg-sunken); opacity: .7; cursor: not-allowed; }
.launch-toggle input { margin-top: 2px; flex: none; }
.lt-title { font-weight: 650; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.lt-desc { display: block; color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* ----------------------------- наряд: двухпанельный master-detail редактор */

.modal-wide { max-width: 940px; transition: max-width .18s ease; }
.modal-runspec .modal-body { max-height: 72vh; }

.rs-editor { display: block; }
.rs-scope { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.rs-scope-opt {
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 9px 12px; cursor: pointer; display: block;
}
.rs-scope-opt:hover { border-color: var(--border-strong); }
.rs-scope-opt.on { border-color: var(--accent); background: var(--accent-soft); }
.rs-scope-opt input { display: none; }
.rs-scope-t { font-weight: 650; font-size: 13px; display: flex; align-items: center; gap: 7px; }
.rs-scope-d { color: var(--text-muted); font-size: 12px; margin-top: 2px; display: block; }
.rs-scope-count {
  margin-left: auto; font-size: 11px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); padding: 1px 7px; border-radius: 20px;
}

.rs-panes { display: grid; grid-template-columns: 300px 1fr; gap: var(--sp-3); align-items: stretch; }
.rs-master {
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg-sunken); display: flex; flex-direction: column;
  max-height: 54vh; min-height: 320px; overflow: hidden;
}
.rs-master-tools {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border-bottom: 1px solid var(--border);
}
.rs-search {
  flex: 1; min-width: 0; font-size: 12.5px; padding: 6px 9px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--bg-raised); color: var(--text);
}
.rs-master-bulk { display: flex; align-items: center; gap: 5px; flex: none; }
.rs-master-bulk button {
  background: none; border: none; cursor: pointer; color: var(--accent);
  font-size: 11px; font-weight: 600; padding: 2px 4px; border-radius: 4px;
}
.rs-master-bulk button:hover { background: var(--accent-soft); }
.rs-master-list { overflow-y: auto; padding: 6px; }
.rs-mgroup { margin-bottom: 8px; }
.rs-mgroup:last-child { margin-bottom: 0; }
.rs-mgroup-head {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-faint); padding: 4px 6px 3px;
}
.rs-mrow {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid transparent;
}
.rs-mrow:hover { background: var(--bg-hover); }
.rs-mrow.on { background: var(--accent-soft); border-color: var(--accent-soft-2); }
.rs-mcheck { flex: none; }
.rs-mrow-main { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.rs-mrow-title { font-size: 12.5px; font-weight: 550; color: var(--text); }
.rs-mrow-title.off { color: var(--text-faint); text-decoration: line-through; }
.rs-mrow-slug { font-size: 10.5px; color: var(--text-faint); }
.rs-mrow-tags { display: flex; align-items: center; gap: 5px; flex: none; }
.rs-hasnote { color: var(--accent); display: inline-flex; }

.rs-detail {
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg-raised); padding: var(--sp-4);
  min-height: 320px; display: flex;
}
.rs-detail-in { width: 100%; }
.rs-detail-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: var(--sp-3);
}
.rs-detail-title { font-size: 15px; font-weight: 700; }
.rs-detail-slug { font-size: 12px; color: var(--text-faint); margin-top: 1px; }
.rs-detail-cert {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  font-size: 12.5px; font-weight: 600; cursor: pointer;
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 20px;
  background: var(--bg-sunken); white-space: nowrap;
}
.rs-detail-note {
  display: flex; align-items: flex-start; gap: 6px;
  font-size: 12px; color: var(--warn-text); background: var(--warn-soft);
  padding: 7px 10px; border-radius: var(--r-sm); margin-bottom: var(--sp-3);
}
.rs-detail-field { display: block; }
.rs-detail-label { font-weight: 650; font-size: 13px; display: block; }
.rs-detail-sub { color: var(--text-muted); font-size: 12px; margin: 2px 0 7px; display: block; }
.rs-detail-ta {
  width: 100%; font-family: var(--mono); font-size: 12.5px; line-height: 1.5;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--bg-sunken); color: var(--text); resize: vertical;
}
.rs-detail-ta:focus { outline: none; border-color: var(--accent); background: var(--bg-raised); }
.rs-global-block { margin-top: var(--sp-4); }
.rs-global-block .rs-detail-ta { font-family: var(--font-ui); }

/* --------------------------------------------- панель наряда на карточке */

.runspec-panel .rs-summary { display: grid; gap: 6px; }
.rs-sum-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.rs-sum-k { color: var(--text-muted); }
.rs-sum-v { text-align: right; }
.runspec-panel .rs-catalog { background: var(--bg-raised); }
/* узкий сайдбар: режимы и группы кнопок в один столбец, чтобы не сплющивались */
.runspec-panel .rs-modes { grid-template-columns: 1fr; }
.runspec-panel .rs-name { gap: 5px; }

/* --------------------------------------------------------------- скелетон */

.skeleton {
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--bg-hover) 50%, var(--bg-sunken) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s linear infinite;
  color: transparent !important;
  min-height: 14px;
}

/* ---------------------------------------------------------- empty / error */

.empty {
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  color: var(--text-muted);
}
.empty .empty-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-sunken);
  color: var(--text-faint);
}
.empty .empty-title { font-weight: 650; color: var(--text); font-size: 14px; margin-bottom: 3px; }
.empty .empty-text { font-size: 13px; max-width: 420px; margin: 0 auto 14px; }
.empty-sm { padding: var(--sp-5); }

/* --------------------------------------------------------------- тултипы */

[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg-raised);
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: pre-line;
  width: max-content;
  max-width: 260px;
  z-index: 100;
  pointer-events: none;
  box-shadow: var(--shadow-2);
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.4;
}

/* -------------------------------------------------------------- KV-паспорт */

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--sp-3) var(--sp-5);
}
.kv-item .kv-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); font-weight: 650; margin-bottom: 2px; display: flex; align-items: center; gap: 4px; }
.kv-item .kv-value { font-size: 13.5px; font-weight: 550; display: flex; align-items: center; gap: 6px; min-width: 0; }
.kv-item .kv-value.mono { font-weight: 500; }

.copy-btn { background: none; border: none; padding: 2px; color: var(--text-faint); cursor: pointer; border-radius: 4px; display: inline-flex; }
.copy-btn:hover { color: var(--accent); background: var(--accent-soft); }

.meter { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.meter .bar { flex: 1; min-width: 44px; max-width: 90px; height: 5px; border-radius: 4px; background: var(--bg-sunken); overflow: hidden; }
.meter .bar > i { display: block; height: 100%; border-radius: 4px; background: var(--ok); }
.meter.warn .bar > i { background: var(--warn); }
.meter.err .bar > i { background: var(--err); }
.meter .val { font-weight: 650; font-variant-numeric: tabular-nums; }

/* ----------------------------------------------- степпер: мини (списки/дашборд) */

.stepper-mini { display: flex; gap: 4px; align-items: center; }
.stepper-mini .mini-seg { width: 14px; height: 5px; border-radius: 3px; background: var(--bg-sunken); }
.stepper-mini .mini-seg.tone-ok { background: var(--ok); }
.stepper-mini .mini-seg.tone-err { background: var(--err); }
.stepper-mini .mini-seg.tone-info { background: var(--info); animation: pulse 1.2s infinite; }
.stepper-mini .mini-seg.tone-warn { background: var(--warn); }
.stepper-mini .mini-seg.tone-purple { background: var(--purple); }
.stepper-mini .mini-seg.tone-muted { background: var(--border-strong); }

/* -------------------------------------------------------------- лог-вьюер */

.logview { border: 1px solid var(--term-border); border-radius: var(--r-sm); overflow: hidden; background: var(--term-bg); }
.logview-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: var(--term-bg-head);
  border-bottom: 1px solid var(--term-border);
  flex-wrap: wrap;
}
.logview-bar .chip {
  background: transparent; border-color: var(--term-border); color: var(--term-faint);
  padding: 1.5px 9px; font-size: 11.5px;
}
.logview-bar .chip.on { background: rgba(123, 134, 242, .16); border-color: #7b86f2; color: #aab3ff; }
.logview-bar input {
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--term-border);
  color: var(--term-text);
  border-radius: 6px;
  font-size: 12px;
  padding: 3px 8px;
  width: 150px;
}
.logview-bar input:focus { box-shadow: none; border-color: #7b86f2; }
.logview-bar .lv-btn {
  background: none; border: none; color: var(--term-faint); cursor: pointer;
  padding: 3px; border-radius: 5px; display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-family: var(--font-ui);
}
.logview-bar .lv-btn:hover { color: var(--term-text); background: rgba(255,255,255,.06); }
.logview-bar .lv-btn.on { color: #aab3ff; }

.logview-body {
  max-height: 340px;
  overflow: auto;
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--term-text);
  overscroll-behavior: contain;
}
/* .log-line — normal: иначе перенос строки и отступы из шаблона (между <div>
   и первым span) рендерятся как пустая строка перед текстом и растягивают лог.
   pre-wrap оставляем только на самом тексте сообщения. */
.log-line { white-space: normal; padding: 1px 0; }
.log-line.hidden { display: none; }
.log-msg { white-space: pre-wrap; word-break: break-word; }
.log-ts { color: var(--term-faint); margin-right: 7px; user-select: none; }
.log-kind { color: #7fb3f9; margin-right: 5px; font-weight: 600; }
.log-warning .log-msg, .log-warn .log-msg { color: #ffd57e; }
.log-error .log-msg { color: #ff9d95; }
.log-line .log-msg.long { cursor: pointer; }
.log-line .log-msg.long.clamped { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.log-more { color: var(--term-faint); text-align: center; padding: 4px; font-size: 11.5px; }
.log-more button { background: none; border: 1px solid var(--term-border); color: var(--term-faint); border-radius: 6px; padding: 2px 10px; cursor: pointer; font-size: 11.5px; }
.log-more button:hover { color: var(--term-text); border-color: var(--term-faint); }

/* --------------------------------------------------- подсветка Pygments */

.codebox { position: relative; border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; background: var(--bg-raised); }
.codebox .code-head {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunken);
  font-family: var(--mono); font-size: 12px; color: var(--text-muted);
}
.codebox .code-head .right { margin-left: auto; display: flex; gap: 4px; }

.highlight { overflow-x: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
.highlight pre { margin: 0; padding: 12px 14px; }
.highlighttable { border-spacing: 0; width: 100%; }
.highlighttable .linenos {
  user-select: none;
  color: var(--text-faint);
  background: var(--bg-sunken);
  text-align: right;
  padding: 0;
  width: 1%;
  border-right: 1px solid var(--border);
  vertical-align: top;
}
.highlighttable .linenos pre { padding: 12px 10px; margin: 0; font-size: 12.5px; line-height: 1.6; }
.highlighttable .code { width: 99%; vertical-align: top; }

/* токены: светлая тема */
.highlight .c, .highlight .cm, .highlight .c1, .highlight .cs { color: var(--text-faint); font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kr, .highlight .kt, .highlight .ow { color: var(--purple-text); font-weight: 600; }
.highlight .kc { color: var(--info-text); font-weight: 600; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sd, .highlight .sb, .highlight .se, .highlight .si { color: var(--ok-text); }
.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh, .highlight .mo { color: var(--warn-text); }
.highlight .nf, .highlight .fm, .highlight .nc { color: var(--info-text); font-weight: 600; }
.highlight .nd { color: var(--purple-text); }
.highlight .nb, .highlight .bp { color: var(--info-text); }
.highlight .o { color: var(--text-muted); }
.highlight .err { color: var(--err-text); }
.highlight .gh, .highlight .gu { color: var(--purple-text); font-weight: 700; }
.highlight .gd { color: var(--diff-del-text); background: var(--diff-del-bg); display: inline-block; width: 100%; }
.highlight .gi { color: var(--diff-add-text); background: var(--diff-add-bg); display: inline-block; width: 100%; }
.highlight .ge { font-style: italic; }
.highlight .gs { font-weight: 700; }

/* ------------------------------------------------------------------- дифф */

.diff-meta { font-family: var(--mono); font-size: 12px; color: var(--text-muted); padding: 8px 12px; background: var(--bg-sunken); border-bottom: 1px solid var(--border); white-space: pre-wrap; }
.diff-stat-add { color: var(--ok-text); font-weight: 700; }
.diff-stat-del { color: var(--err-text); font-weight: 700; }
/* Дифф: «откуда пришло» (чат/пайплайн) — корреляция источника изменения */
.diff-source { display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 10px 12px; background: var(--bg-sunken); border-bottom: 1px solid var(--border); }
.diff-source-req { flex-basis: 100%; margin-top: 4px; font-size: 12.5px; color: var(--text); }
.diff-source-note { flex-basis: 100%; }
.diff-scroll { max-height: 68vh; overflow: auto; border: 1px solid var(--border);
  border-radius: 8px; margin-top: 10px; }
.diff-page { max-width: 1100px; margin: 0 auto; padding: 16px; }

/* --------------------------------------------------------------- таймлайн */

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: "";
  position: absolute;
  left: 14px; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--border);
}
.tl-item { display: flex; gap: 12px; padding: 8px 0; position: relative; }
.tl-icon {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  z-index: 1;
  flex-shrink: 0;
}
.tl-icon.tone-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.tl-icon.tone-err { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--border)); }
.tl-icon.tone-info { color: var(--info); }
.tl-icon.tone-warn { color: var(--warn); }
.tl-icon.tone-purple { color: var(--purple); }
.tl-body { flex: 1; min-width: 0; padding: 3px 9px; border-radius: 8px; transition: background .12s; }
.tl-item:hover .tl-body { background: var(--bg-hover); }
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.tl-actor {
  display: inline-flex; align-items: center; gap: 4px; max-width: 220px;
  font-weight: 650; font-size: 12px; line-height: 1.5;
  padding: 1.5px 9px 1.5px 7px; border-radius: 999px;
  background: var(--neutral-soft); color: var(--neutral-text);
}
.tl-actor .icon { flex-shrink: 0; vertical-align: 0; }
.tl-actor-ai { background: var(--purple-soft); color: var(--purple-text); }
.tl-actor-user { background: var(--accent-soft); color: var(--accent); }
.tl-actor-system { background: var(--neutral-soft); color: var(--neutral-text); }
.tl-label { color: var(--text); font-size: 13px; min-width: 0; }
.tl-time { color: var(--text-faint); font-size: 12px; font-variant-numeric: tabular-nums; margin-left: auto; white-space: nowrap; }
.tl-text { color: var(--text-muted); font-size: 13px; margin-top: 3px; word-break: break-word; }
.tl-chips { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }

/* разделитель по дням внутри ленты */
.tl-day { list-style: none; margin: 12px 0 4px; padding-left: 42px; position: relative; z-index: 1; }
.timeline > .tl-day:first-child { margin-top: 0; }
.tl-day-label {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-faint);
  background: var(--bg-raised); padding: 2px 6px 2px 0;
}
.tl-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; padding: 1.5px 8px;
  border: 1px solid var(--border); border-radius: 999px;
  color: var(--text-muted); background: var(--bg-raised);
}
.tl-chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* --- вкладка «История»: два раздельных фильтра (событие / кто) --- */
.hist-toolbar { display: flex; align-items: center; gap: var(--sp-3) var(--sp-4); flex-wrap: wrap; padding: 11px 14px; }
.hist-group { display: flex; align-items: center; gap: 9px; min-width: 0; flex-wrap: wrap; }
.hist-group-label { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-faint); white-space: nowrap; }
.hist-sep { width: 1px; align-self: stretch; min-height: 24px; background: var(--border); }
.chip-actor-ai.on { background: var(--purple-soft); border-color: var(--purple); color: var(--purple-text); }
.chip-actor-user.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip-actor-system.on { background: var(--neutral-soft); border-color: var(--neutral); color: var(--neutral-text); }
@media (max-width: 680px) {
  .hist-sep { display: none; }
  .hist-toolbar { flex-direction: column; align-items: stretch; }
}

/* ------------------------------------------------------------------- чат */

.chat-wrap { display: flex; flex-direction: column; min-height: 420px; }
.chat-scroll { flex: 1; overflow-y: auto; padding: var(--sp-4); display: flex; flex-direction: column; gap: 4px; max-height: 60vh; scroll-behavior: smooth; }

/* в полноэкранной колонке чат занимает всю доступную высоту, композер закреплён снизу */
.content-app #tab-content:has(.chat-wrap) { display: flex; flex-direction: column; }
.content-app .chat-wrap { flex: 1; min-height: 0; margin: 0; border-radius: 0; border: none; box-shadow: none; }
.content-app .chat-scroll { max-height: none; padding: var(--sp-4) var(--sp-6); }

/* индикатор «генерируется ответ» + оптимистичная вставка отправленного сообщения */
.msg-pending .msg-bubble { opacity: .72; }
.typing-bubble { display: inline-flex; align-items: center; gap: 4px; padding: 10px 12px !important; }
.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); animation: typing 1.1s ease-in-out infinite; }
.typing-dots i:nth-child(2) { animation-delay: .18s; }
.typing-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
.day-sep { display: flex; align-items: center; gap: 10px; color: var(--text-faint); font-size: 11.5px; font-weight: 650; margin: 10px 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.new-sep { display: flex; align-items: center; gap: 10px; color: var(--err-text); font-size: 11px; font-weight: 700; margin: 6px 0; text-transform: uppercase; letter-spacing: .05em; }
.new-sep::before, .new-sep::after { content: ""; flex: 1; height: 1px; background: color-mix(in srgb, var(--err) 45%, transparent); }

.msg-row { display: flex; gap: 9px; margin-top: 8px; max-width: 82%; align-self: flex-start; }
.msg-row.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--bg-sunken); color: var(--text-muted);
  margin-top: 2px;
}
.msg-row.ai .msg-avatar { background: var(--accent-soft); color: var(--accent); }
.msg { min-width: 0; }
.msg-head { display: flex; gap: 8px; align-items: baseline; font-size: 11.5px; margin: 0 2px 2px; color: var(--text-faint); }
.msg-row.mine .msg-head { justify-content: flex-end; }
.msg-author { font-weight: 700; color: var(--text-muted); }
.msg-bubble {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  border-top-left-radius: 4px;
  padding: 8px 12px;
  font-size: 13.5px;
  word-break: break-word;
}
.msg-row.mine .msg-bubble {
  background: var(--accent-soft);
  border-color: var(--accent-soft-2);
  border-radius: 12px;
  border-top-right-radius: 4px;
}
.msg-system { align-self: center; color: var(--text-faint); font-size: 12px; display: flex; gap: 6px; align-items: center; margin-top: 8px; text-align: center; }
.msg-bubble p { margin: 0 0 6px; } .msg-bubble p:last-child { margin: 0; }
.msg-bubble pre { background: var(--term-bg); color: var(--term-text); border-radius: 7px; padding: 8px 10px; overflow-x: auto; font-size: 12px; }
.msg-bubble code { font-family: var(--mono); font-size: 12px; background: var(--bg-sunken); border-radius: 4px; padding: 1px 4px; }
.msg-bubble pre code { background: none; padding: 0; }
.msg-attach { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; margin-top: 5px; }

.clarify-card {
  align-self: stretch;
  max-width: none;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--border));
  background: color-mix(in srgb, var(--warn-soft) 55%, var(--bg-raised));
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  margin-top: 10px;
}
.clarify-card.answered { border-color: var(--border); background: var(--bg-raised); }
.clarify-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.clarify-tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--warn-soft); color: var(--warn-text);
  font-weight: 700; font-size: 10.5px;
  padding: 2px 9px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .04em;
}
.clarify-q { font-size: 13.5px; font-weight: 550; }
.clarify-options { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.clarify-free { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; }
.clarify-free textarea { flex: 1; min-height: 38px; }
.clarify-evidence { margin-top: 8px; font-size: 12.5px; }
.clarify-evidence pre { background: var(--bg-sunken); border-radius: 6px; padding: 8px 10px; overflow-x: auto; font-size: 11.5px; max-height: 220px; }
.clarify-answered-note { display: flex; gap: 7px; align-items: center; color: var(--text-muted); font-size: 12.5px; margin-top: 6px; }

/* --- копайлот: карточки действий --- */
.action-card {
  border: 1px solid var(--border);
  background: var(--bg-raised);
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-3);
  font-size: 12.5px;
}
.action-card.action-applied { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.action-card.action-rejected { border-color: color-mix(in srgb, var(--err) 40%, var(--border)); }
.action-head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.action-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-weight: 700; font-size: 10.5px; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-muted);
}
.action-reply { color: var(--text); }
.action-meta {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px; padding-top: 7px; border-top: 1px solid var(--border);
}
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .03em;
}
.chip-applied  { background: var(--ok-soft);    color: var(--ok-text); }
.chip-rejected { background: var(--err-soft);   color: var(--err-text); }
.chip-reverted { background: var(--muted-soft); color: var(--muted-text); }

.composer { border-top: 1px solid var(--border); padding: var(--sp-3) var(--sp-4); background: var(--bg-raised); }
.content-app .composer { padding: var(--sp-3) var(--sp-6); }
.composer.is-sending .composer-box textarea,
.composer.is-sending .composer-box label { opacity: .55; pointer-events: none; }
.composer-status { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-muted); padding-bottom: 6px; }
.composer-box { display: flex; gap: 9px; align-items: flex-end; }
.composer-box textarea { flex: 1; max-height: 180px; }
.composer-hint { color: var(--text-faint); font-size: 11px; margin-top: 4px; }
.composer-attach { font-size: 12px; display: flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--text-muted); }

/* ------------------------------------------------------------ дерево файлов */

.artifacts-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: var(--sp-4);
  align-items: start;
}
/* панели прилипают к верху ВНУТРЕННЕГО скроллера вкладки (#tab-content) */
.artifacts-tree {
  position: sticky;
  top: var(--sp-2);
  max-height: calc(100dvh - var(--topbar-h) - var(--passport-h, 150px) - 96px);
  overflow-y: auto;
  margin-bottom: 0;
}
.artifacts-viewer {
  position: sticky;
  top: var(--sp-2);
}
.artifacts-viewer .codebox { margin-bottom: 0; }
.artifacts-viewer .file-scroll {
  max-height: calc(100dvh - var(--topbar-h) - var(--passport-h, 150px) - 150px);
  min-height: 240px;
  overflow: auto;
}
.file-scroll { max-height: 66vh; overflow: auto; }
@media (max-width: 900px) {
  .artifacts-grid { grid-template-columns: 1fr; }
  .artifacts-tree, .artifacts-viewer { position: static; max-height: none; }
  .artifacts-tree { max-height: 44vh; }
}

/* ---------------------------------------------------------- MIB tree-браузер */

.mib-browser {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) minmax(360px, 440px);
  gap: var(--sp-4);
  align-items: start;
}
@media (max-width: 1280px) { .mib-browser { grid-template-columns: 260px minmax(0, 1fr) minmax(320px, 380px); gap: var(--sp-3); } }
@media (max-width: 1024px) { .mib-browser { grid-template-columns: 260px minmax(0, 1fr); } .mib-detail-pane { grid-column: 1 / -1; position: static; max-height: none; } }
@media (max-width: 900px) { .mib-browser { grid-template-columns: 1fr; } }

.mib-modules { position: sticky; top: calc(var(--topbar-h) + 12px); max-height: calc(100vh - var(--topbar-h) - 28px); overflow-y: auto; margin-bottom: 0; }
.mib-filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.mib-filters select { font-size: 13px; }
.mib-module-list { list-style: none; margin: 0; padding: 0; }
.mib-module-item {
  display: flex; align-items: center; gap: 7px; width: 100%;
  border: none; background: none; font: inherit; text-align: left;
  padding: 6px 8px; border-radius: 7px; cursor: pointer; color: var(--text);
}
.mib-module-item:hover { background: var(--bg-hover); }
.mib-module-item.sel { background: var(--accent-soft); color: var(--accent); }
.mib-module-item .icon { color: var(--text-faint); flex-shrink: 0; }
.mib-module-item.sel .icon { color: var(--accent); }
.mm-name { font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.mm-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; font-size: 11px; }

.mib-tree-pane { min-height: 400px; margin-bottom: 0; }
.mib-tree-head { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding-bottom: 10px; margin-bottom: 8px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.mib-within input, .searchbox.mib-within input { width: 200px; }
.mib-tree-body { max-height: calc(100vh - var(--topbar-h) - 160px); overflow: auto; }

.mib-tree { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.mib-tree .mib-tree { padding-left: 16px; border-left: 1px dashed var(--border); margin-left: 6px; }
.mib-tree details > summary { list-style: none; }
.mib-tree details > summary::-webkit-details-marker { display: none; }
.mib-tree .chev { display: inline-flex; transition: transform .12s; color: var(--text-faint); }
.mib-tree details[open] > summary .chev { transform: rotate(90deg); }

.mib-node {
  display: flex; align-items: center; gap: 7px;
  padding: 3px 7px; border-radius: 6px; cursor: pointer;
  color: var(--text);
}
.mib-node:hover { background: var(--bg-hover); }
.mib-node.sel { background: var(--accent-soft); }
.mib-node .icon { color: var(--text-faint); flex-shrink: 0; }
.mib-node.sel .icon { color: var(--accent); }
.mib-node.sel .mib-sym { color: var(--accent); }
.mib-sym { font-weight: 550; }
.mib-oid { color: var(--text-faint); font-size: 11.5px; }
.mib-arc { color: var(--text-faint); font-size: 11px; }
.mib-type {
  margin-left: auto; font-family: var(--mono); font-size: 10.5px;
  color: var(--info-text); background: var(--info-soft);
  padding: 0 6px; border-radius: 5px; white-space: nowrap;
}

.mib-detail-pane {
  position: sticky; top: calc(var(--topbar-h) + 12px);
  max-height: calc(100vh - var(--topbar-h) - 28px);
  overflow-y: auto;
}
.mib-detail-pane > .card { margin-bottom: 0; }
.mib-detail-actions { display: inline-flex; gap: 2px; }
.mib-detail-name { font-size: 16px; font-weight: 700; word-break: break-word; }
.mib-desc { font-size: 13px; color: var(--text-muted); line-height: 1.55; white-space: pre-wrap; margin: 4px 0 0; }
.mib-desc-block {
  font-size: 13px; color: var(--text); line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 9px 11px; margin-top: 5px;
  max-height: 320px; overflow-y: auto;
}
.mib-desc-block.muted { color: var(--text-muted); }
.mib-children { max-height: 260px; overflow-y: auto; margin-top: 4px; }

/* строки результатов поиска кликабельны → полная деталь узла в модале */
.table-clickable tbody tr { cursor: pointer; }
.mib-result-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.mib-open-cue { text-align: right; color: var(--accent); opacity: 0; transition: opacity .12s; white-space: nowrap; }
.mib-open-cue .icon { vertical-align: -2px; }
.mib-result-row:hover .mib-open-cue,
.mib-result-row:focus-visible .mib-open-cue { opacity: 1; }

.ftree { list-style: none; margin: 0; padding: 0; font-size: 13px; user-select: none; }
.ftree ul { list-style: none; margin: 0; padding-left: 18px; }
.ftree .t-row {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 6px; border-radius: 6px; cursor: pointer;
  color: var(--text); min-width: 0;
}
.ftree .t-row:hover { background: var(--bg-hover); text-decoration: none; }
.ftree .t-row.sel { background: var(--accent-soft); color: var(--accent); }
.ftree .t-row .icon { color: var(--text-faint); }
.ftree .t-row.sel .icon { color: var(--accent); }
.ftree .t-name { font-family: var(--mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ftree .t-dir > .t-name { font-family: var(--font-ui); font-weight: 600; font-size: 13px; }
.ftree .t-badge { margin-left: auto; }
.ftree details > summary { list-style: none; }
.ftree details > summary::-webkit-details-marker { display: none; }
.ftree details > summary .chev { transition: transform .12s; }
.ftree details[open] > summary .chev { transform: rotate(90deg); }

/* ------------------------------------------------------------------- KPI */

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-4); }
.kpi {
  position: relative;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  padding: var(--sp-4) var(--sp-4) var(--sp-4) calc(var(--sp-4) + 3px);
  display: flex; flex-direction: column; gap: 3px;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--border-strong); }
.kpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.kpi-top { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 12px; font-weight: 600; }
.kpi-top .icon { color: var(--text-faint); }
.kpi-value { font-size: 26px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-sub { color: var(--text-faint); font-size: 11.5px; }
a.kpi-sub:hover { color: var(--accent); }
.kpi.accent .kpi-value { color: var(--accent); }
.kpi.accent::before { background: var(--accent); }
.kpi.ok .kpi-value { color: var(--ok-text); }
.kpi.ok::before { background: var(--ok); }
.kpi.warn .kpi-value { color: var(--warn-text); }
.kpi.warn::before { background: var(--warn); }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--sp-4); align-items: start; }
.dash-col { min-width: 0; display: flex; flex-direction: column; gap: var(--sp-4); }
.dash-col .card { margin-bottom: 0; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }

.run-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-2);
  background: var(--bg-raised);
  color: var(--text);
}
.run-card:hover { border-color: var(--accent); text-decoration: none; box-shadow: var(--shadow-1); }
.run-card .rc-top { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; }
.run-card .rc-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-card .rc-meta { display: flex; gap: 12px; color: var(--text-faint); font-size: 12px; margin-top: 7px; flex-wrap: wrap; }
.run-card .rc-meta span { display: inline-flex; gap: 4px; align-items: center; }

/* --------------------------------------------------------------- пайплайн */

/* Компактная шапка-паспорт: строка идентификации + сворачиваемая лента фактов. */
.cert-passport { flex: none; padding: var(--sp-3) var(--sp-6) 0; background: var(--bg); }
.passport-card { margin-bottom: var(--sp-3); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); }

.pp-head { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.pp-id { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.pp-name { font-size: 17px; font-weight: 700; letter-spacing: -.01em; max-width: 46ch; }
.passport-actions { margin-left: auto; display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.pp-toggle .icon { transition: transform .18s ease; }
.pp-toggle.collapsed .icon { transform: rotate(180deg); }

/* плотная лента фактов — разделители-точки, без крупной сетки */
.pp-facts {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 4px 18px;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
}
.pp-stat { display: inline-flex; align-items: baseline; gap: 6px; min-width: 0; max-width: 100%; }
.pp-stat-wide { max-width: min(340px, 42vw); }
.pp-k { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); font-weight: 650; white-space: nowrap; }
.pp-v { font-size: 13px; font-weight: 600; color: var(--text); display: inline-flex; align-items: baseline; gap: 5px; min-width: 0; }
.pp-v.mono { font-weight: 500; }
.pp-v .truncate { max-width: 30ch; }
.pp-stat-wide .pp-v .truncate { max-width: 100%; }
.pp-cov { display: inline-flex; gap: 12px; font-variant-numeric: tabular-nums; }
.pp-cov .cov { display: inline-flex; align-items: center; gap: 5px; }
.cov-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.cov-dot.cov-req { background: var(--accent); }
.cov-dot.cov-dev { background: var(--ok); }

.live-ind { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-faint); font-weight: 600; }
.live-ind .status-dot { width: 7px; height: 7px; }
.live-ind.on { color: var(--ok-text); }
.live-ind.off { color: var(--err-text); }

.stage-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  margin-bottom: var(--sp-2);
  overflow: hidden;
  scroll-margin-top: calc(var(--topbar-h) + 120px);
}
.stage-card > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.stage-card > summary::-webkit-details-marker { display: none; }
.stage-card[open] > summary { border-bottom: 1px solid var(--border); }
.stage-key { color: var(--text-faint); min-width: 96px; font-size: 12px; }
.stage-title { font-weight: 650; font-size: 13.5px; }
.stage-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.stage-meta { color: var(--text-faint); font-size: 12px; display: inline-flex; gap: 4px; align-items: center; font-variant-numeric: tabular-nums; }
.st-failed { border-left: 3px solid var(--err); }
.st-succeeded { border-left: 3px solid var(--ok); }
.st-running, .st-queued { border-left: 3px solid var(--info); }
.st-waiting_input { border-left: 3px solid var(--warn); }
.st-reused { border-left: 3px solid var(--purple); }

.stage-body { padding: 10px 14px; }
.stage-error {
  background: var(--err-soft);
  border: 1px solid color-mix(in srgb, var(--err) 35%, transparent);
  color: var(--err-text);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  margin-bottom: var(--sp-2);
  white-space: pre-wrap;
  font-size: 12px;
  font-family: var(--mono);
  max-height: 220px;
  overflow: auto;
}
.stage-error-actions { margin: -2px 0 var(--sp-2); }

.llm-flash { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--purple-text); background: var(--purple-soft); border-radius: 999px; padding: 2px 9px; font-weight: 600; }

.spinner {
  width: 13px; height: 13px;
  flex-shrink: 0;
  border: 2px solid var(--accent-soft-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.pipeline-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--sp-4); align-items: start; }
@media (max-width: 1024px) { .pipeline-grid { grid-template-columns: 1fr; } }
.pipeline-side .card { margin-bottom: var(--sp-3); }

/* ---------------------------------------------------------------- отчёт */

.report-layout { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: var(--sp-4); align-items: start; }
@media (max-width: 1024px) { .report-layout { grid-template-columns: 1fr; } .report-toc { display: none; } }
.report-toc { position: sticky; top: var(--sp-2); font-size: 12.5px; max-height: calc(100dvh - var(--topbar-h) - var(--passport-h, 150px) - 96px); overflow-y: auto; }
.report-toc a { display: block; color: var(--text-muted); padding: 3px 10px; border-left: 2px solid var(--border); }
.report-toc a:hover { color: var(--accent); text-decoration: none; border-left-color: var(--accent); }

.prose { font-size: 14px; line-height: 1.65; }
.prose h1 { font-size: 21px; margin: 0 0 12px; }
.prose h2 { font-size: 17px; margin: 22px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 14.5px; margin: 16px 0 6px; }
.prose p { margin: 7px 0; }
.prose ul, .prose ol { margin: 7px 0; padding-left: 24px; }
.prose li { margin: 2px 0; }
.prose code { background: var(--bg-sunken); border-radius: 4px; padding: 1px 5px; font-family: var(--mono); font-size: 12.5px; }
.prose pre { background: var(--term-bg); color: var(--term-text); border-radius: var(--r-sm); padding: 12px 14px; overflow-x: auto; font-size: 12.5px; line-height: 1.55; }
.prose pre code { background: none; padding: 0; color: inherit; }
.prose blockquote { margin: 8px 0; padding: 4px 14px; border-left: 3px solid var(--border-strong); color: var(--text-muted); }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.prose .table-wrap, .prose-table-wrap { overflow-x: auto; }
.prose table { border-collapse: collapse; margin: 10px 0; font-size: 13px; min-width: 50%; }
.prose th, .prose td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--bg-sunken); font-weight: 650; }
.prose tr:hover td { background: var(--bg-hover); }

/* ------------------------------------------------------------ палитра ⌘K */

.palette-backdrop {
  position: fixed; inset: 0;
  background: rgba(9, 12, 18, .5);
  z-index: 180;
  display: flex; justify-content: center; align-items: flex-start;
  padding-top: 12vh;
  animation: fade-in .1s ease;
}
.palette {
  width: min(600px, calc(100vw - 32px));
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  animation: rise .14s ease;
}
.palette-input { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.palette-input .icon { color: var(--text-faint); }
.palette-input input { border: none; background: none; font-size: 15px; padding: 0; box-shadow: none; }
.palette-input input:focus { box-shadow: none; }
.palette-list { max-height: 46vh; overflow-y: auto; padding: 6px; }
.palette-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 11px; border-radius: 8px;
  color: var(--text); cursor: pointer;
  font-size: 13.5px;
}
.palette-item:hover, .palette-item.sel { background: var(--accent-soft); text-decoration: none; }
.palette-item .icon { color: var(--text-faint); }
.palette-item.sel .icon { color: var(--accent); }
.palette-item .pi-sub { color: var(--text-faint); font-size: 12px; margin-left: auto; }
.palette-empty { padding: 22px; text-align: center; color: var(--text-faint); font-size: 13px; }
.palette-hintbar { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--border); background: var(--bg-sunken); color: var(--text-faint); font-size: 11.5px; }

/* --------------------------------------------------------------- пагинация */

.pagination { display: flex; gap: var(--sp-2); align-items: center; margin-top: var(--sp-3); justify-content: flex-end; }
.pagination .muted { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ логин */

.login-wrap { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: var(--bg); padding: var(--sp-4); }
.login-card { width: 380px; padding: var(--sp-8); }
.login-logo { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 800; margin-bottom: 4px; }
.login-logo em { font-style: normal; color: var(--accent); }

/* --------------------------------------------------------------- мобильная */

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-2); }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(9, 12, 18, .45); z-index: 55; }
  body.sidebar-open .sidebar-overlay { display: block; }
  .main { margin-left: 0; }
  .topbar .burger { display: inline-flex; }
  .content { padding: var(--sp-4) var(--sp-4) 64px; }
  .cert-passport { padding: var(--sp-3) var(--sp-4) 0; }
  /* на телефоне полноэкранная колонка мешает (клавиатура, короткий вьюпорт) —
     возвращаем обычную прокрутку страницы */
  .content.content-app { height: auto; min-height: 0; overflow: visible; display: block; padding: 0 0 48px; }
  .content-app #cert-page { display: block; }
  .content-app #tab-content { overflow: visible; padding: var(--sp-4); }
  .content-app #tab-content:has(.chat-wrap) { display: block; padding: 0; }
  .content-app .chat-wrap { min-height: 70vh; }
  .content-app .chat-scroll { max-height: 62vh; padding: var(--sp-4); }
  .content-app .composer { padding: var(--sp-3) var(--sp-4); position: sticky; bottom: 0; }
  .search-trigger { min-width: 0; }
  .search-trigger .st-text, .search-trigger kbd { display: none; }
}

@media (max-width: 768px) {
  .table-collapse thead { display: none; }
  .table-collapse tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    margin: 0 0 var(--sp-2);
    padding: 6px 0;
  }
  .table-collapse td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border: none;
    padding: 5px 12px;
  }
  .table-collapse td::before {
    content: attr(data-label);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-faint);
    font-weight: 650;
  }
  .table-collapse td[data-label=""]::before { display: none; }
  .radio-cards, .rs-modes, .rs-scope, .rs-panes { grid-template-columns: 1fr; }
  .rs-master { max-height: 38vh; min-height: 0; }
  .rs-detail { min-height: 0; }
  .msg-row { max-width: 95%; }
}

/* ----------------------------------------------------------------- печать */

@media print {
  .sidebar, .topbar, .toast-stack, .passport-actions, .tabs, .composer,
  .filterbar, .pagination, .no-print { display: none !important; }
  .main { margin: 0; }
  .content { max-width: none; padding: 0; }
  body { background: #fff; color: #000; }
  .card { border: none; box-shadow: none; padding: 0; }
  .prose pre { background: #f3f4f6; color: #111; border: 1px solid #ddd; }
  .cert-passport { position: static; }
  a { color: inherit; }
}
