/* ==========================================================================
   Мир «Грид» — Дизайн-система страницы /live (Выполнение задач)
   WCAG 2.2 AAA Compliant · HSL Design Tokens · 8px Grid · Dark / Light Themes
   ========================================================================== */

@import url("./typography.css?v=56");
@import url("./live/tiles.css?v=56");
@import url("./live/graph.css?v=56");
@import url("./live/timeline.css?v=56");
@import url("./live/messages.css?v=56");
@import url("./live/terminal.css?v=56");
@import url("./live/system_status.css?v=56");
@import url("./live/health_bar.css?v=56");
@import url("./live/capsule_shimmer.css?v=56");
@import url("./live/stage_details.css?v=56");
@import url("./live/responsive.css?v=56");
@import url("./live/code_surface.css?v=56");
@import url("./tokens.css?v=56");


* { box-sizing: border-box; }
*:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
}
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--tx);
  font: var(--fs-body)/var(--lh-normal) var(--sans); overflow-x: clip;
  letter-spacing: -0.01em;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--black-alpha-15); border-radius: var(--r-xs); }
::-webkit-scrollbar-thumb { background: var(--slate-400-alpha-20); border-radius: var(--r-xs); transition: background var(--dur-normal) ease; }
::-webkit-scrollbar-thumb:hover { background: var(--violet-alpha-60); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
h1, .hero-title { font-size: var(--fs-xl); line-height: var(--lh-tight, 1.15); }
h2, .card-h h2, .section-title { font-size: var(--fs-h2); line-height: var(--lh-snug, 1.25); }
h3, .card-h h3, .stage-params-head h3, .ag-name { font-size: var(--fs-base); line-height: var(--lh-snug, 1.25); }
button { font: inherit; color: inherit; cursor: pointer; }

/* Базовые кнопки Державы (.btn, .btn.prim, .btn.sq) */
.btn {
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: var(--sp-1-5) var(--sp-3);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--card2);
  color: var(--tx);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1-5);
  box-sizing: border-box;
  user-select: none;
  transition: background var(--dur-fast) ease-out, border-color var(--dur-fast) ease-out, color var(--dur-fast) ease-out, box-shadow var(--dur-fast) ease-out, transform var(--dur-fast) var(--ease-spring);
  line-height: var(--lh-tight);
  text-decoration: none;
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
}
a.btn, .btn a {
  text-decoration: none;
}
.btn:hover {
  background: var(--card-hover);
  border-color: var(--violet-alpha-40);
  color: var(--white);
}
.btn:active {
  transform: scale(0.98);
}
.btn.sq {
  padding: var(--sp-1-5) var(--sp-2);
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  justify-content: center;
}
.btn.prim {
  background: var(--violet);
  border-color: var(--violet-light);
  color: var(--white);
  box-shadow: 0 0 12px var(--violet-alpha-40);
}
.btn.prim:hover {
  background: var(--violet-dark);
  border-color: var(--violet);
  box-shadow: 0 0 16px var(--violet-alpha-60);
}
.btn.ghost {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Базовые карточки и контейнеры метрик конвейера (Linear Elevation & 4-сторонний субпиксельный световой контур)
   4-сторонний субпиксельный световой контур box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05) без сдвига верстки
   для радарных карточек (.card, .graph-card, .pipeline-group-card, .stage-params-card, .stage-reqs-box, .stage-files-box) */
.card,
.graph-card,
.pipeline-group-card,
.stage-params-card,
.stage-reqs-box,
.stage-files-box,
.terminal-card,
.bottom-collapsible-section {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--sp-3) var(--sp-3-5);
  box-shadow: var(--shadow-card-inset);
  transition: border-color var(--dur-normal) ease, box-shadow var(--dur-normal) ease, background var(--dur-normal) ease;
  min-width: 0;
  box-sizing: border-box;
}
.card:hover,
.graph-card:hover,
.pipeline-group-card:hover,
.terminal-card:hover,
.stage-params-card:hover,
.stage-reqs-box:hover,
.stage-files-box:hover,
.bottom-collapsible-section:hover {
  border-color: var(--violet-alpha-40);
  box-shadow: var(--light-perimeter-hover), 0 0 16px var(--violet-alpha-20), var(--shadow-card-hover);
}
.terminal-card {
  padding: 0;
}
.card-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
  min-width: 0;
  flex-wrap: wrap;
}
.card-h h2 {
  font-size: var(--fs-h2);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: var(--lh-snug);
  color: var(--tx);
  margin: 0;
}

.brand { display: flex; gap: var(--sp-3); align-items: center; padding: var(--sp-1) var(--sp-1) var(--sp-2); }
.brand-logo {
  width: 36px; height: 36px; border-radius: var(--r-10); display: grid; place-items: center;
  font-size: var(--fs-xl); background: linear-gradient(135deg, var(--violet), var(--violet-dark));
  box-shadow: 0 0 18px var(--violet-alpha-30); flex: 0 0 auto;
}
.brand-name { font-weight: 600; font-size: var(--fs-base); letter-spacing: -0.01em; }
.brand-sub { font-size: var(--fs-sm); color: var(--tx3); }
.nav { display: flex; flex-direction: column; gap: var(--sp-1); }
.nav-i {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md); color: var(--tx2); text-decoration: none;
  cursor: pointer; font-size: var(--fs-body); transition: background var(--dur-normal) ease, color var(--dur-normal) ease;
}
/* ---------- Шапка ---------- */
.head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2-5); flex-wrap: wrap; padding-bottom: 0; min-height: 34px; min-width: 0; }
.head-left { display: flex; align-items: baseline; gap: var(--sp-2); min-width: 0; flex: 1 1 auto; flex-wrap: wrap; }
.head h1 { font-size: var(--fs-h2); letter-spacing: -0.02em; font-weight: 700; margin: 0; line-height: var(--lh-tight); }
.head-sub { color: var(--tx3); font-size: var(--fs-sm); margin: 0; word-break: break-word; }
.head-right { display: flex; align-items: center; gap: var(--sp-1-5); flex: 0 0 auto; }

/* Индикатор статуса соединения */
.live {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  background: var(--green-alpha-12);
  border: 1px solid var(--green-alpha-30);
  color: var(--green-light);
  border-radius: var(--r-md); padding: var(--sp-1-5) var(--sp-2-5); font-size: var(--fs-sm); font-weight: 600;
  transition: background var(--dur-smooth) ease, border-color var(--dur-smooth) ease, color var(--dur-smooth) ease, box-shadow var(--dur-smooth) ease;
  user-select: none;
}
.live.status-live {
  background: var(--green-alpha-12);
  border-color: var(--green-alpha-30);
  color: var(--green-light);
}
.live.status-polling {
  background: var(--violet-alpha-15);
  border-color: var(--violet-alpha-40);
  color: var(--violet-light);
}
.live.status-reconnecting {
  background: var(--amber-alpha-15);
  border-color: var(--amber-alpha-40);
  color: var(--tx-pastel-amber);
}
.live.status-offline {
  background: var(--red-alpha-15);
  border-color: var(--red-alpha-40);
  color: var(--status-failed-border);
}
.live b { font-family: var(--mono); color: var(--white); font-weight: 600; }
.live-label { font-size: var(--fs-sm); letter-spacing: 0.04em; font-weight: 700; }
.latency-pill {
  font-size: var(--fs-xs); font-family: var(--mono); color: var(--blue);
  background: var(--blue-alpha-12); border: 1px solid var(--blue-alpha-20);
  border-radius: var(--r-xs); padding: var(--sp-0-5) var(--sp-1-5); font-weight: 600;
}
.reconnect-pill {
  font-size: var(--fs-xs); font-family: var(--mono); color: var(--rank-celestial);
  background: var(--amber-alpha-15); border: 1px solid var(--amber-alpha-30);
  border-radius: var(--r-xs); padding: var(--sp-0-5) var(--sp-1-5); font-weight: 700;
}
.live-dot { background: var(--green); animation: pulseGreen var(--dur-pulse) cubic-bezier(0.4, 0, 0.2, 1) infinite; box-shadow: 0 0 8px var(--green); }
.polling-dot { background: var(--violet); animation: spinDot var(--dur-slow) infinite linear; }
.reconnect-dot { background: var(--amber); animation: pulseAmber var(--dur-pulse) cubic-bezier(0.4, 0, 0.2, 1) infinite; box-shadow: 0 0 8px var(--amber); }

/* Радарный маяк живой активности статус-дотов конвейера (Zero Layout Shift & Jitter Free)
   Пульсация псевдоэлемента ::after с периодом ровно 2.0s infinite cubic-bezier со scale(1) до scale(2)
   и затуханием прозрачности до 0 при сохранении pointer-events: none
   для статус-дотов (.live-dot, .status-beacon, .status-dot, .dot.radar-pulse, .status-dot.running) */
.live-dot,
.status-beacon,
.status-dot,
.dot.radar-pulse,
.status-dot.running {
  position: relative;
  display: inline-block;
  transform: scale(1) !important;
  flex-shrink: 0;
  will-change: transform;
}

.live-dot::after,
.dot.ok.live-dot::after,
.dot.live-dot::after,
.status-beacon::after,
.status-dot::after,
.dot.radar-pulse::after,
.status-dot.running::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  transform-origin: center center;
  border-radius: var(--r-circle, 50%);
  background: inherit;
  pointer-events: none;
  animation: radarPulse var(--dur-pulse) infinite cubic-bezier(0.4, 0, 0.2, 1) !important;
  will-change: transform, opacity;
  z-index: 0;
}

@keyframes radarPulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot::after,
  .dot.ok.live-dot::after,
  .dot.live-dot::after,
  .status-beacon::after,
  .status-dot::after,
  .dot.radar-pulse::after,
  .status-dot.running::after {
    animation: none !important;
    display: none !important;
  }
}

@keyframes pulseGreen {
  0% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 var(--green-alpha-70), 0 0 8px var(--green-alpha-80); }
  50% { opacity: 0.7; transform: scale(1); box-shadow: 0 0 0 4px var(--green-alpha-04), 0 0 4px var(--green-alpha-30); }
  100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 var(--green-alpha-70), 0 0 8px var(--green-alpha-80); }
}
@keyframes pulseAmber {
  0% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 var(--amber-alpha-70), 0 0 8px var(--amber-alpha-80); }
  50% { opacity: 0.7; transform: scale(1); box-shadow: 0 0 0 4px var(--amber-alpha-08), 0 0 4px var(--amber-alpha-30); }
  100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 var(--amber-alpha-70), 0 0 8px var(--amber-alpha-80); }
}
@keyframes spinDot { 0% { opacity: 0.4; } 50% { opacity: 1; } 100% { opacity: 0.4; } }

/* ---------- Вкладки задач ---------- */
.tabs-row { display: flex; align-items: stretch; gap: var(--sp-2); min-width: 0; }
.tabs { display: flex; gap: var(--sp-2); overflow-x: auto; scrollbar-width: none; padding-bottom: var(--sp-0-5); min-width: 0; }
.tabs::-webkit-scrollbar { display: none; }
.tab,
#tabs button,
#tabs .tab {
  display: flex; align-items: center; gap: var(--sp-2); background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-1-5) var(--sp-2-5);
  min-width: 155px;
  min-height: 32px;
  box-sizing: border-box;
  box-shadow: inset 0 1px 0 0 var(--white-alpha-04);
  transition: transform var(--dur-normal) var(--ease-spring), border-color var(--dur-normal) ease, box-shadow var(--dur-normal) ease;
  cursor: pointer;
}
.tab:hover {
  transform: translateY(-1px);
  border-color: var(--violet-alpha-40);
  box-shadow: 0 4px 14px var(--black-alpha-20);
}
.tab.on { border-color: var(--violet); box-shadow: 0 0 0 1px var(--violet) inset, 0 4px 14px var(--violet-alpha-20); }
.tab .ring { flex: 0 0 auto; }
.tab-name { font-size: var(--fs-sm); font-weight: 600; }
.tab-sub { font-size: var(--fs-2xs); color: var(--tx3); font-family: var(--mono); }
.tab-pct {
  margin-left: auto; font-size: var(--fs-xs); background: var(--card2);
  border-radius: var(--r-sm); padding: var(--sp-0-5) var(--sp-1-5); font-family: var(--mono); font-weight: 600;
}
.tabs-empty {
  display: flex; align-items: center; gap: var(--sp-2); background: var(--card);
  border: 1px dashed var(--line); border-radius: var(--r-md); padding: var(--sp-1-5) var(--sp-3);
  color: var(--tx3); font-size: var(--fs-sm);
}
#btnAdd,
.btn.sq.add {
  flex: 0 0 auto; width: 32px; height: 32px; min-width: 32px; min-height: 32px; box-sizing: border-box; display: grid; place-items: center;
  font-size: var(--fs-h2); border-style: dashed; color: var(--tx2); border-radius: var(--r-md);
}
#btnAdd:hover,
.btn.sq.add:hover { border-color: var(--violet); color: var(--white); }

/* ---------- Плитки сводки (KPI) вынесены в live/tiles.css ---------- */

/* Анимированный прогресс-бар для KPI-панели */
.tile-progress-wrap { margin-top: var(--sp-1-5); }
.tile-progress-bar {
  height: 4px;
  border-radius: var(--r-2xs);
  background: var(--white-alpha-08);
  overflow: hidden;
  position: relative;
  border: 1px solid var(--white-alpha-04);
}
.tile-progress-fill {
  height: 100%;
  border-radius: var(--r-2xs);
  background: linear-gradient(90deg, var(--violet) 0%, var(--blue) 55%, var(--green) 100%);
  transition: width var(--dur-slow) var(--ease-spring);
  position: relative;
}
.tile-progress-fill.progress-animated::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, var(--white-alpha-04) 0%, var(--white-alpha-40) 50%, var(--white-alpha-04) 100%);
  animation: tileProgressShimmer var(--dur-slow) infinite ease-in-out;
  transform: translateX(-100%);
}
@keyframes tileProgressShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ---------- Сетка основных панелей ---------- */
.grid3 { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--sp-2-5); align-items: start; }
.col-l, .col-r { display: flex; flex-direction: column; gap: var(--sp-2-5); min-width: 0; }

/* Миссия и Центр управления (Linear / Stripe High Density) */
.mis-top { display: flex; gap: var(--sp-2-5); align-items: center; }
.mis-name { font-size: var(--fs-body); font-weight: 600; line-height: var(--lh-snug); max-width: var(--measure-prose); word-break: break-word; overflow-wrap: anywhere; color: var(--tx); }
.mis-stats-row { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-top: var(--sp-1); font-size: var(--fs-2xs); font-family: var(--mono); }
.mis-stats-row span { background: var(--white-alpha-04); border: 1px solid var(--white-alpha-04); padding: var(--sp-0-5) var(--sp-1-5); border-radius: var(--r-xs); color: var(--tx2); font-variant-numeric: tabular-nums; }
.mis-goal-desc { font-size: var(--fs-xs); color: var(--tx2); background: var(--white-alpha-04); border-left: 2px solid var(--violet); border-radius: 0 var(--r-xs) var(--r-xs) 0; padding: var(--sp-1) var(--sp-2); margin-top: var(--sp-1-5); line-height: var(--lh-normal); max-width: var(--measure-prose); word-break: break-word; overflow-wrap: anywhere; }
.railway-progress-wrap { margin-top: var(--sp-1-5); overflow: hidden; position: relative; contain: paint; }
.railway-progress-bar { height: 4px; background: var(--white-alpha-08); border-radius: var(--r-2xs); overflow: hidden; position: relative; border: 1px solid var(--white-alpha-04); contain: paint; }
.railway-progress-fill { height: 100%; border-radius: var(--r-2xs); background: linear-gradient(90deg, var(--violet) 0%, var(--blue) 55%, var(--green) 100%); transition: width var(--dur-slow) var(--ease-spring); position: relative; overflow: hidden; contain: paint; }
.railway-progress-glow { position: absolute; top: 0; left: 0; right: 0; bottom: 0; width: 100%; max-width: 100%; pointer-events: none; background: linear-gradient(90deg, var(--white-alpha-04) 0%, var(--white-alpha-40) 50%, var(--white-alpha-04) 100%); animation: tileProgressShimmer var(--dur-slow) infinite ease-in-out; transform: translateX(-100%); will-change: transform; }
.hq-live-status-box { margin-top: var(--sp-2); padding: var(--sp-1-5) var(--sp-2); background: var(--indigo-alpha-12); border: 1px solid var(--indigo-alpha-20); border-radius: var(--r-sm); font-size: var(--fs-xs); }
.kv { display: flex; justify-content: space-between; align-items: center; font-size: var(--fs-sm); color: var(--tx2); margin-top: var(--sp-1-5); }
.kv b { font-family: var(--mono); font-weight: 600; color: var(--tx); }
.bar { height: 6px; border-radius: var(--r-xs); background: var(--card2); overflow: hidden; margin-top: var(--sp-2-5); }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--violet), var(--blue)); border-radius: var(--r-xs); transition: width var(--dur-slow) ease; }

/* ---------- Статус-бейджи и Стек Задач ---------- */
.badge {
  font-size: var(--fs-xs); font-weight: 600; border-radius: var(--r-sm); padding: var(--sp-1) var(--sp-2);
  background: var(--white-alpha-12); color: var(--white);
  border: 1px solid var(--white-alpha-20);
  display: inline-flex; align-items: center; gap: var(--sp-1-5);
  letter-spacing: 0.02em; white-space: nowrap; flex-shrink: 0; min-width: 0; max-width: max-content;
}
.badge.ok, .badge.badge-completed {
  background: var(--status-completed-bg); color: var(--status-completed-tx);
  border: 1px solid var(--status-completed-border);
  box-shadow: 0 0 10px var(--green-alpha-15);
}
.badge.badge-running {
  background: var(--status-running-bg); color: var(--status-running-tx);
  border: 1px solid var(--status-running-border);
  box-shadow: 0 0 12px var(--green-alpha-20);
}
.badge.warn, .badge.badge-paused {
  background: var(--status-paused-bg); color: var(--status-paused-tx);
  border: 1px solid var(--status-paused-border);
  box-shadow: 0 0 10px var(--amber-alpha-15);
}
.badge.bad, .badge.badge-failed {
  background: var(--status-failed-bg); color: var(--status-failed-tx);
  border: 1px solid var(--status-failed-border);
  box-shadow: 0 0 10px var(--red-alpha-15);
}
.badge.badge-pending {
  background: var(--status-pending-bg); color: var(--status-pending-tx);
  border: 1px solid var(--status-pending-border);
}

.status-indicator {
  width: 8px; height: 8px; border-radius: var(--r-circle); display: inline-block;
  position: relative; flex: 0 0 auto;
}
.status-indicator.pulse .dot-pulse-ring {
  position: absolute; inset: -3px; border-radius: var(--r-circle);
  background: inherit; opacity: 0.6;
  animation: pulseRing var(--dur-slow) cubic-bezier(0.16, 1, 0.3, 1) infinite;
  pointer-events: none;
}
@keyframes pulseRing {
  0% { transform: scale(0.8); opacity: 0.8; }
  100% { transform: scale(2.4); opacity: 0; }
}

/* Пайплайн и Стек Задач */
.step {
  display: flex; gap: var(--sp-3); align-items: center; padding: var(--sp-2) var(--sp-2);
  border-bottom: 1px dashed var(--white-alpha-08);
  border-radius: var(--r-md); transition: background var(--dur-normal) ease, transform var(--dur-normal) ease;
}
.step:hover { background: var(--white-alpha-04); }
.step:last-child { border-bottom: 0; }
.step-i {
  width: 26px; height: 26px; border-radius: var(--r-circle); display: grid; place-items: center;
  font-size: var(--fs-sm); font-weight: 700; flex: 0 0 auto; background: var(--card2); color: var(--tx3);
  border: 1px solid var(--line); font-family: var(--mono);
}
.step-i.done { background: var(--status-completed-bg); color: var(--status-completed-tx); border: 1px solid var(--status-completed-border); }
.step-i.run {
  background: var(--status-running-bg); color: var(--status-running-tx);
  border: 1px solid var(--status-running-border); animation: stepIconPulse var(--dur-pulse) cubic-bezier(0.4, 0, 0.6, 1) infinite;
  box-shadow: 0 0 10px var(--green-alpha-30);
}
.step-i.failed { background: var(--status-failed-bg); color: var(--status-failed-tx); border: 1px solid var(--status-failed-border); }
.step-i.paused { background: var(--status-paused-bg); color: var(--status-paused-tx); border: 1px solid var(--status-paused-border); }
.step-i.pending { background: var(--status-pending-bg); color: var(--status-pending-tx); border: 1px solid var(--status-pending-border); }

.step-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--sp-0-5); max-width: var(--measure-prose); }
.step-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.step-n { font-size: var(--fs-body); font-weight: 600; color: var(--tx); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: var(--measure-prose); line-height: var(--lh-snug); }
.step-actor {
  display: inline-flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-xs);
  color: var(--tx3); font-family: var(--mono);
}
.step-bottom { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-0-5); }
.step-s { font-size: var(--fs-sm); color: var(--tx3); line-height: var(--lh-normal); max-width: var(--measure-prose); word-break: break-word; }
.step-dur { font-size: var(--fs-xs); color: var(--blue); font-family: var(--mono); font-weight: 500; }
.step-t { margin-left: auto; font-size: var(--fs-xs); color: var(--tx3); font-family: var(--mono); font-variant-numeric: tabular-nums; flex: 0 0 auto; }

/* ---------- Выбранный гражданин ---------- */
.ag-top { display: flex; gap: var(--sp-3); align-items: center; }
.ag-face { width: 54px; height: 54px; border-radius: var(--r-card); object-fit: cover; border: 1px solid var(--line); background: var(--card2); flex: 0 0 auto; }
.ag-name { font-size: var(--fs-h2); font-weight: 600; line-height: var(--lh-snug); }
.ag-sub { font-size: var(--fs-sm); color: var(--tx3); margin-top: var(--sp-0-5); }
.ag-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); margin-top: var(--sp-3); }
.ag-cell { background: var(--card2); border-radius: var(--r-md); padding: var(--sp-2) var(--sp-3); border: 1px solid var(--white-alpha-04); }
.ag-cell b { display: block; font-size: var(--fs-h2); font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; line-height: var(--lh-tight); }
.ag-cell span { font-size: var(--fs-xs); color: var(--tx3); }
.attrs { display: flex; flex-wrap: wrap; gap: var(--sp-1-5); margin-top: var(--sp-2-5); }
.attr { font-size: var(--fs-xs); background: var(--card2); border-radius: var(--r-sm); padding: var(--sp-1) var(--sp-2); font-family: var(--mono); }
.perk { font-size: var(--fs-xs); background: var(--violet-alpha-12); color: var(--violet-light); border-radius: var(--r-sm); padding: var(--sp-1) var(--sp-2); font-weight: 500; }

/* ---------- Нижние карточки и виджеты (Мышление, Трибунал, Бригады) ---------- */
.grid6 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--sp-4); }
.row { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); padding: var(--sp-1) 0; }
.row b { font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; }
.thought-log-row { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-1-5) var(--sp-2); border-radius: var(--r-sm); transition: background var(--dur-fast) ease; }
.thought-log-row:hover { background: var(--white-alpha-04); }
.thought-log { font-size: var(--fs-xs); color: var(--tx3); max-width: var(--measure-prose, 60ch); line-height: var(--lh-normal, 1.5); word-break: break-word; overflow-wrap: anywhere; }
.tribunal-verdict-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-1-5) var(--sp-2); border-radius: var(--r-sm); transition: background var(--dur-fast) ease; }
.tribunal-verdict-row:hover { background: var(--white-alpha-04); }
.tribunal-verdict-text { font-size: var(--fs-xs); font-weight: 500; color: var(--tx); max-width: var(--measure-prose, 60ch); line-height: var(--lh-normal, 1.5); word-break: break-word; overflow-wrap: anywhere; }
.qbar { height: 6px; border-radius: var(--r-xs); background: var(--card2); overflow: hidden; margin-top: var(--sp-1); }
.qbar > i { display: block; height: 100%; background: var(--green); border-radius: var(--r-xs); }
.qbar.warn > i { background: var(--amber); }
.qbar.bad > i { background: var(--red); }
.errbar { font-size: var(--fs-sm); color: var(--status-failed-border); font-weight: 500; }
.link { color: var(--blue); cursor: pointer; text-decoration: none; }
.sys-mini { display: flex; align-items: center; gap: var(--sp-2-5); padding: var(--sp-3); }
.sys-mini .wave { width: 40px; height: 20px; flex: 0 0 auto; }
.sys-mini-t { font-size: var(--fs-sub); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sys-mini-s { font-size: var(--fs-xs); color: var(--tx3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grip, .chev { margin-left: auto; color: var(--tx3); font-size: var(--fs-sub); flex: 0 0 auto; }

/* Статусные бейджи Linear/Grafana (Изумрудный, Янтарный, Сапфировый, Рубиновый) */
.badge.badge-success {
  background: var(--status-completed-bg);
  color: var(--status-completed-tx);
  border: 1px solid var(--status-completed-border);
  box-shadow: 0 0 10px var(--green-alpha-15);
}
.badge.badge-failed {
  background: var(--status-failed-bg);
  color: var(--status-failed-tx);
  border: 1px solid var(--status-failed-border);
  box-shadow: 0 0 10px var(--red-alpha-15);
}

/* Стили требований, файлов и чеклиста параметров стадии (Layout Shift Proof) */
#cardMission {
  height: auto;
  min-height: fit-content;
  flex-shrink: 0;
  contain: style;
  box-sizing: border-box;
}


/* ---------- Сворачиваемая секция системных показателей (#bottomSection) ---------- */
.bottom-collapsible-section {
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--sp-3) var(--sp-3-5);
  box-shadow: inset 0 1px 0 0 var(--white-alpha-04);
  transition: padding var(--dur-normal) ease, border-color var(--dur-normal) ease;
}

.bottom-body-wrap,
.timeline-body-wrap {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows var(--dur-normal) var(--ease-out);
  width: 100%;
}

.bottom-collapsible-section.collapsed .bottom-body-wrap,
.timeline-card.collapsed .timeline-body-wrap {
  grid-template-rows: 0fr !important;
}

.bottom-body-wrap > *,
.timeline-body-wrap > * {
  min-height: 0;
  opacity: 1;
  transition: opacity var(--dur-fast) var(--ease-out);
}

.bottom-collapsible-section.collapsed .bottom-body-wrap,
.timeline-card.collapsed .timeline-body-wrap {
  grid-template-rows: 0fr !important;
  overflow: hidden !important;
}

.bottom-collapsible-section.collapsed .bottom-body-wrap > *,
.timeline-card.collapsed .timeline-body-wrap > * {
  opacity: 0 !important;
  overflow: hidden !important;
}

.bottom-collapsible-section.collapsed {
  padding-bottom: var(--sp-3);
}

.bottom-collapsible-section.collapsed .card-h {
  margin-bottom: 0;
}

.collapsible-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2-5);
}

.collapsible-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* ---------- Сорванные задачи, бейдж попыток и причина сдачи (/live) ---------- */
.badge-attempts {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-0-5) var(--sp-1);
  border-radius: var(--r-xs);
  background: var(--status-failed-bg);
  color: var(--status-failed-tx);
  border: 1px solid var(--status-failed-border);
  font-family: var(--mono);
  font-size: var(--fs-2xs);
  font-weight: 600;
  vertical-align: middle;
  white-space: nowrap;
}

.fail-reason {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  color: var(--status-failed-tx);
  font-size: var(--fs-2xs);
  opacity: 0.95;
  line-height: var(--lh-snug);
}

.task-failure-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-1-5);
  margin-top: var(--sp-1);
  padding: var(--sp-1) var(--sp-1-5);
  background: var(--status-failed-bg);
  border: 1px solid var(--status-failed-border);
  border-radius: var(--r-xs);
}

.stage-fail-card {
  margin-top: var(--sp-2);
  padding: var(--sp-2) var(--sp-2-5);
  background: var(--status-failed-bg);
  border: 1px solid var(--status-failed-border);
  border-radius: var(--r-sm);
}

.stage-fail-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-top: var(--sp-1);
}

/* ---------- Каноническая геометрия /live (F22-GOAL-w1, F22-GOAL-w7-g3) ---------- */
.pipeline-group-card,
.pipeline-group-card.step {
  display: flex !important;
  flex-direction: column !important;
  height: auto !important;
  min-height: fit-content !important;
  max-height: none !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
}

#sideHQAction,
.side-hq-action {
  white-space: normal !important;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
  line-height: var(--lh-snug) !important;
  max-width: 100% !important;
  text-overflow: clip !important;
  overflow: visible !important;
}

#tabs,
.tabs,
#tabs.tabs,
.tabs-row,
.chips,
#graphChips,
#termLevelChips,
#graphModeChips,
#msgChips,
.mode-chips,
.graph-chips,
.term-level-chips {
  border-radius: var(--r-md) !important;
  flex-wrap: wrap;
}

.tabs,
#tabs.tabs {
  flex-wrap: nowrap !important;
}

.chip,
.term-level-chips .chip,
#graphChips .chip,
#termLevelChips .chip,
#graphModeChips .chip,
#msgChips .chip,
.mode-chips .chip,
.graph-chips .chip,
.chip.filter {
  border-radius: var(--r-md) !important;
  height: auto !important;
  min-height: 32px !important;
  min-width: 32px !important;
  max-height: var(--touch-target-touchable) !important;
  white-space: nowrap !important;
  box-sizing: border-box !important;
  flex-shrink: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Гарантия минимальной области нажатия не менее 32px (WCAG 2.2 Target Size)
   Для всех кнопок вкладок (.tab, #tabs button, #btnAdd) и чипов фильтрации событий (#msgChips .chip, .chip.filter) */
.tab,
#tabs button,
#tabs .tab,
#btnAdd,
#msgChips .chip,
.chip.filter {
  min-height: 32px !important;
  min-width: 32px !important;
  box-sizing: border-box !important;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
  box-sizing: border-box;
}

.sk-tab, .sk-tile, .sk-step, .sk-msg, .sk-tl {
  padding: var(--sp-2) var(--sp-2-5) !important;
  box-sizing: border-box !important;
  border-radius: var(--r-md) !important;
  position: relative;
  overflow: hidden;
  background: var(--white-alpha-04);
}

.sk-tab::after, .sk-tile::after, .sk-step::after, .sk-msg::after, .sk-tl::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--white-alpha-08) 50%,
    transparent 100%
  );
  transform: translateX(-100%);
  animation: skShimmer var(--dur-shimmer) cubic-bezier(0.4, 0, 0.2, 1) infinite;
  pointer-events: none;
}

@keyframes skShimmer {
  100% { transform: translateX(100%); }
}

html.light-theme .sk-tab,
html.light-theme .sk-tile,
html.light-theme .sk-step,
html.light-theme .sk-msg,
html.light-theme .sk-tl {
  background: var(--slate-100);
}

html.light-theme .sk-tab::after,
html.light-theme .sk-tile::after,
html.light-theme .sk-step::after,
html.light-theme .sk-msg::after,
html.light-theme .sk-tl::after {
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--white-alpha-50) 50%,
    transparent 100%
  );
}

