/* Stezha — design system
   Linear/Vercel-inspired: neutral near-black surfaces, soft shadows over hard
   borders, generous whitespace, a single restrained accent color. */

:root {
  /* surfaces */
  --page:      #0a0a0c;
  --sidebar:   #0c0c0f;
  --card:      #141417;
  --card-hi:   #1a1a1f;
  --inset:     #0a0a0d;
  --line:      rgba(255, 255, 255, 0.08);
  --line-soft: rgba(255, 255, 255, 0.05);

  /* text */
  --fg:        #eceef1;
  --fg-dim:    #a3a7b0;
  --muted:     #6f7380;

  /* accent (Linear indigo) */
  --acc:       #5e6ad2;
  --acc-hi:    #7280e8;
  --acc-soft:  rgba(94, 106, 210, 0.14);
  --acc-line:  rgba(94, 106, 210, 0.35);

  /* status */
  --ok:        #4fb46c;
  --ok-soft:   rgba(79, 180, 108, 0.14);
  --warn:      #d9a441;
  --warn-soft: rgba(217, 164, 65, 0.14);
  --bad:       #e5687a;
  --bad-soft:  rgba(229, 104, 122, 0.14);
  --neutral:      #5b5f6b;
  --neutral-soft: rgba(255, 255, 255, 0.06);

  /* scale */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  --ease: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--page);
  color: var(--fg);
  font: 14px/1.55 -apple-system, "Inter", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- скролбари під темну тему (дефолтні світлі вибивались) ---------- */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.16) transparent; }  /* Firefox */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.14); border-radius: 999px;
  border: 2px solid transparent; background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.26); background-clip: padding-box; }
*::-webkit-scrollbar-corner { background: transparent; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: 0.04em; }

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

/* ---------- app shell ---------- */

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

.sidebar {
  width: 232px;
  flex: none;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: var(--sp-4) var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  /* .shell лише min-height: 100vh, тож без цього сайдбар розтягується на
     всю висоту сторінки (вирівнюється по .main) — на довгій сторінці
     nav-spacer штовхає "Налаштування/Admin/юзера" в самий низ довгого
     контенту замість низу екрана. Прибиваємо до viewport і скролимо
     сайдбар окремо від контенту. */
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-2);
  color: var(--fg);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand .mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(155deg, var(--acc-hi), var(--acc));
  display: flex; align-items: center; justify-content: center; flex: none;
}
.brand .mark svg { width: 13px; height: 13px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; }
.nav-item {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 7px var(--sp-2);
  border-radius: var(--r-sm);
  color: var(--fg-dim);
  font-size: 13.5px; font-weight: 500;
  transition: background var(--ease), color var(--ease);
}
.nav-item:hover { color: var(--fg); background: var(--neutral-soft); text-decoration: none; }
.nav-item.active { color: var(--fg); background: var(--acc-soft); }
.nav-item.active svg { stroke: var(--acc-hi); }
.nav-item svg { width: 16px; height: 16px; stroke: currentColor; flex: none; }
.nav-spacer { flex: 1; }

.sidebar-user {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-2) var(--sp-1);
  border-top: 1px solid var(--line);
  flex: none;
}
.sidebar-user-name { font-size: 12.5px; color: var(--fg-dim); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user form { flex: none; }
.sidebar-logout {
  background: none; border: 0; color: var(--muted); font: inherit; font-size: 12px;
  cursor: pointer; padding: 4px 6px; border-radius: var(--r-sm); transition: color var(--ease), background var(--ease);
}
.sidebar-logout:hover { color: var(--fg); background: var(--neutral-soft); }

.main { flex: 1; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--line);
  gap: var(--sp-4);
}
.topbar .titles { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.topbar .eyebrow { color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; gap: var(--sp-2); flex: none; }

.content {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--sp-6);
}
/* форма правила: .rail фіксовані 300px, тож увесь виграш ширини йде
   в .main-col (flex:1) — саме туди, де Sigma YAML/use case/плейбук. */
.content-wide { max-width: 1640px; }
/* каталог: широка таблиця з тактикою+техніками — використовуємо бічний простір */
.content-xwide { max-width: 1840px; }

/* ---------- buttons / inputs ---------- */

.btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  background: var(--card-hi); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 8px 14px; font: inherit; font-weight: 500; font-size: 13.5px;
  cursor: pointer; transition: background var(--ease), border-color var(--ease), transform var(--ease);
}
.btn:hover { background: #202026; border-color: rgba(255,255,255,0.14); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--acc); border-color: var(--acc); color: #fff;
}
.btn-primary:hover { background: var(--acc-hi); border-color: var(--acc-hi); }

label { display: block; font-weight: 600; font-size: 13px; margin: var(--sp-4) 0 var(--sp-1); }
label.req::after { content: " *"; color: var(--bad); }
.help { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

input[type=text], input[type=password], input[type=url], input[type=email], input[type=number], select, textarea {
  width: 100%; background: var(--inset); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 9px 11px; font: inherit; transition: border-color var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--acc-line); box-shadow: 0 0 0 3px var(--acc-soft);
}
textarea.mono, .mono {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px;
}
textarea.mono {
  background: var(--inset); line-height: 1.6; min-height: 320px; resize: vertical;
}
.errorlist { color: var(--bad); list-style: none; padding: 0; margin: 4px 0; font-size: 12.5px; }

/* ---------- cards ---------- */

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: var(--sp-5);
  margin-bottom: var(--sp-4);
}
/* inset, а не border-left: не ламає border-radius картки на тому боці */
.card-accent-bad   { box-shadow: var(--shadow-card), inset 3px 0 0 var(--bad); }
.card-accent-ok    { box-shadow: var(--shadow-card), inset 3px 0 0 var(--ok); }
.card-accent-muted { box-shadow: var(--shadow-card), inset 3px 0 0 var(--line); }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-3);
}

/* ---------- rule page: chip strip + tabs ---------- */

/* паспорт правила — рядок кольорових чипів (статус/якість/лінтер/джерела/
   автор/правки); точні дати й імена — у title-підказках чипів */
.chip-strip {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-bottom: var(--sp-4);
}
.pill-acc { background: var(--acc-soft); color: var(--acc-hi); }
/* RID-пілюля поруч із заголовком сторінки */
h1 .title-ref { vertical-align: 3px; margin-left: 4px; }

.tabbar {
  display: flex; gap: 2px; border-bottom: 1px solid var(--line);
  margin-bottom: var(--sp-5);
  /* overflow-y: hidden обов'язково: margin-bottom:-1px активної вкладки
     дає 1px вертикального переповнення, і голий overflow-x:auto показував
     через нього постійну смугу прокрутки */
  overflow-x: auto; overflow-y: hidden;
}
.tabbar .tab {
  padding: 9px 16px; font-size: 13.5px; font-weight: 500;
  color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap;
  transition: color var(--ease);
}
.tabbar .tab:hover { color: var(--fg); text-decoration: none; }
.tabbar .tab.active { color: var(--fg); border-bottom-color: var(--acc); }
.tab-badge {
  font-size: 10.5px; padding: 1px 7px; border-radius: 999px;
  background: var(--neutral-soft); color: var(--fg-dim);
}
.tab-badge.warn { background: var(--warn-soft); color: var(--warn); }

/* секції-вкладки: одна активна, решта приховані (JS перемикає) */
.tab-section { display: none; }
.tab-section.active { display: block; }
/* без .tab-section (режим створення) секції — звичайний потік */
section:not(.tab-section) { display: block; }

.save-bar.hide { display: none; }

/* ---------- filter bar ---------- */

.filter-bar {
  display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center;
  margin-bottom: var(--sp-4);
}
.filter-bar input[type=text], .filter-bar select {
  width: auto; flex: 1 1 180px; margin: 0;
}
.filter-bar select { flex: 0 1 160px; }
.filter-bar .btn { flex: none; }
.filter-bar .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }

/* збережені фільтри (localStorage) */
.saved-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: calc(var(--sp-4) * -1 + 4px) 0 var(--sp-4); }
.saved-filters-label { font-size: 12px; color: var(--muted); margin-right: 2px; }
.saved-chip {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--card-hi); border: 1px solid var(--line); border-radius: 999px;
  padding: 2px 3px 2px 10px;
}
.saved-chip-link { font-size: 12.5px; color: var(--fg-dim); text-decoration: none; }
.saved-chip:hover { border-color: rgba(255,255,255,0.18); }
.saved-chip:hover .saved-chip-link { color: var(--fg); }
.saved-chip-del {
  border: none; background: none; cursor: pointer; color: var(--muted);
  font-size: 15px; line-height: 1; padding: 0 5px; border-radius: 999px;
}
.saved-chip-del:hover { color: var(--bad); }

/* ---------- stat cards ---------- */

.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--sp-4);
}
.stat-card .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat-card .value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-top: 6px; }
.stat-card.accent-ok .value { color: var(--ok); }
.stat-card.accent-warn .value { color: var(--warn); }
.stat-card.accent-bad .value { color: var(--bad); }

/* ---------- table ---------- */

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th {
  text-align: left; padding: 8px 12px; font-size: 11.5px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
}
td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr { transition: background var(--ease); }
tbody tr:hover { background: var(--neutral-soft); }
tbody tr:last-child td { border-bottom: none; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--neutral-soft); color: var(--fg-dim);
  white-space: nowrap;  /* напр. RID-25 не має ламатись по дефісу і розсувати рядок */
}
.pill-tactic { background: var(--acc-soft); color: var(--acc-hi); font-weight: 500; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill-tech {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px;
  background: var(--neutral-soft); color: var(--fg-dim);
}

.status-production { background: var(--ok-soft); color: var(--ok); }
.status-testing     { background: var(--warn-soft); color: var(--warn); }
.status-draft       { background: var(--neutral-soft); color: var(--muted); }
.status-deprecated  { background: var(--bad-soft); color: var(--bad); }

.level-critical, .level-high { background: var(--bad-soft); color: var(--bad); }
.level-medium            { background: var(--warn-soft); color: var(--warn); }
.level-low, .level-informational { background: var(--neutral-soft); color: var(--fg-dim); }

.quality-good { background: var(--ok-soft); color: var(--ok); }
.quality-mid  { background: var(--warn-soft); color: var(--warn); }
.quality-low  { background: var(--bad-soft); color: var(--bad); }

.quality-reasons { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; font-size: 12.5px; }
.quality-reasons .ok { color: var(--ok); }
.quality-reasons .warn { color: var(--muted); }
.quality-reasons .lint-high { color: var(--bad); }
.quality-reasons .lint-low { color: var(--fg-dim); }

.similar-list { display: flex; flex-direction: column; gap: 6px; }
.similar-list a { font-size: 13.5px; }

/* ---------- dashboard ---------- */

@keyframes dash-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
/* доростання заливки з 0 до власної (inline) ширини — implicit `to`.
   Чистий CSS: на відміну від requestAnimationFrame, не спиняється у фоні. */
@keyframes bar-grow { from { width: 0; } }
@keyframes trend-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes trend-fade { to { opacity: 1; } }
@keyframes dot-pop { 0% { transform: scale(0); } 70% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 var(--acc-soft); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Панель діапазону дат */
.dash-range {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  flex-wrap: wrap; margin-bottom: var(--sp-4);
}
.range-presets { display: inline-flex; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: 3px; }
.range-btn {
  padding: 6px 14px; border-radius: var(--r-sm); font-size: 12.5px; font-weight: 500;
  color: var(--fg-dim); text-decoration: none; transition: background var(--ease), color var(--ease);
}
.range-btn:hover { color: var(--fg); text-decoration: none; }
.range-btn.active { background: var(--acc-soft); color: var(--acc-hi); }
.range-custom { display: inline-flex; align-items: center; gap: 8px; }
.range-custom input[type="date"] {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--fg); padding: 7px 10px; font: inherit; font-size: 12.5px; color-scheme: dark;
}
.range-custom input[type="date"]:focus { outline: none; border-color: var(--acc-line); }
.range-dash { color: var(--muted); }

/* KPI-смуга */
.kpi-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.kpi-card {
  position: relative; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 14px 14px 16px;
  animation: dash-in 460ms cubic-bezier(0.4, 0, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 55ms);
  transition: border-color var(--ease), transform var(--ease);
}
.kpi-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--kc, var(--acc)); opacity: 0.9;
}
.kpi-card:hover { transform: translateY(-2px); border-color: rgba(255,255,255,0.16); }
.kpi-acc     { --kc: var(--acc); }
.kpi-ok      { --kc: var(--ok); }
.kpi-warn    { --kc: var(--warn); }
.kpi-bad     { --kc: var(--bad); }
.kpi-neutral { --kc: var(--muted); }
.kpi-muted   { opacity: 0.72; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.kpi-label { font-size: 11.5px; color: var(--muted); font-weight: 500; line-height: 1.3; }
.kpi-icon { color: var(--kc, var(--acc)); display: inline-flex; opacity: 0.85; flex: none; }
.kpi-value {
  font-size: 27px; font-weight: 680; letter-spacing: -0.03em; margin-top: 10px;
  color: var(--fg); font-variant-numeric: tabular-nums; line-height: 1;
}
.kpi-ok .kpi-value   { color: var(--ok); }
.kpi-warn .kpi-value { color: var(--warn); }
.kpi-bad .kpi-value  { color: var(--bad); }
.kpi-suffix { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 2px; letter-spacing: 0; }
.kpi-note { font-size: 11.5px; color: var(--fg-dim); margin-top: 5px; }
.kpi-spark {
  display: block; height: 3px; border-radius: 2px; margin-top: 10px;
  background: var(--neutral-soft); overflow: hidden;
}
.kpi-spark-fill { display: block; height: 100%; border-radius: 2px; background: var(--kc, var(--acc)); animation: bar-grow 800ms cubic-bezier(0.4, 0, 0.2, 1) 120ms both; }

/* Ряди дашборда */
.dash-2 { display: grid; grid-template-columns: 300px 1fr; gap: var(--sp-4); }
.dash-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); margin-top: var(--sp-4); }
.dash-2 > .card, .dash-3 > .card { margin-bottom: 0; }

/* Donut «стан парку» */
.donut-wrap { display: flex; flex-direction: column; align-items: center; gap: var(--sp-4); padding-top: 4px; }
.donut {
  position: relative; width: 176px; height: 176px;
  animation: dash-in 500ms cubic-bezier(0.4, 0, 0.2, 1) both;
}
/* Кільце — окремий шар: маска, що вирізає дірку, застосовується ЛИШЕ до нього,
   інакше вона зʼїла б і текст у центрі (дочірній елемент маскованого шару). */
.donut-ring {
  --hole: 62%;
  position: absolute; inset: 0; border-radius: 50%;
  -webkit-mask: radial-gradient(circle closest-side, transparent var(--hole), #000 calc(var(--hole) + 0.5%));
  mask: radial-gradient(circle closest-side, transparent var(--hole), #000 calc(var(--hole) + 0.5%));
}
.donut-hole {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; line-height: 1;
}
.donut-fig { display: flex; align-items: baseline; }
.donut-total { font-size: 36px; font-weight: 700; letter-spacing: -0.03em; color: var(--ok); font-variant-numeric: tabular-nums; }
.donut-pct { font-size: 17px; font-weight: 600; color: var(--ok); margin-left: 1px; }
.donut-cap { display: block; font-size: 11px; color: var(--muted); margin-top: 5px; text-transform: uppercase; letter-spacing: 0.05em; }
.donut-legend { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 8px; }
.donut-legend li {
  display: grid; grid-template-columns: 12px 1fr auto auto; align-items: center; gap: 8px;
  font-size: 12.5px;
  animation: dash-in 400ms ease both; animation-delay: calc(200ms + var(--i, 0) * 60ms);
}
.lg-dot { width: 10px; height: 10px; border-radius: 3px; }
.lg-ok { background: var(--ok); } .lg-warn { background: var(--warn); }
.lg-bad { background: var(--bad); } .lg-neutral { background: var(--muted); }
.lg-label { color: var(--fg-dim); }
.lg-val { font-weight: 650; font-variant-numeric: tabular-nums; }
.lg-pct { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }

/* bar-чарти */
.chart-bars { display: flex; flex-direction: column; gap: 10px; }
.chart-bar-row {
  display: grid; grid-template-columns: 168px 1fr 42px; align-items: center; gap: 10px;
  animation: dash-in 360ms ease both; animation-delay: calc(var(--i, 0) * 35ms);
}
.chart-bar-label { font-size: 12.5px; color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.chart-bar-row.is-blind .chart-bar-label { color: var(--muted); }
.blind-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); flex: none; box-shadow: 0 0 0 3px var(--bad-soft); }
.chart-bar-track { position: relative; height: 14px; border-radius: 7px; background: var(--neutral-soft); overflow: hidden; }
.chart-bar-fill {
  position: absolute; inset: 0 auto 0 0; height: 100%; border-radius: 7px;
  animation: bar-grow 800ms cubic-bezier(0.4, 0, 0.2, 1) calc(var(--i, 0) * 35ms) both;
}
.chart-bar-fill-ok      { background: linear-gradient(90deg, var(--ok), #63c47f); }
.chart-bar-fill-warn    { background: linear-gradient(90deg, var(--warn), #e8bd63); }
.chart-bar-fill-bad     { background: linear-gradient(90deg, var(--bad), #ef8494); }
.chart-bar-fill-neutral { background: var(--muted); }
.chart-bar-fill-good    { background: linear-gradient(90deg, var(--ok), #63c47f); }
.chart-bar-fill-mid     { background: linear-gradient(90deg, var(--warn), #e8bd63); }
.chart-bar-fill-low     { background: linear-gradient(90deg, var(--bad), #ef8494); }
.chart-bar-fill-acc     { background: linear-gradient(90deg, var(--acc), var(--acc-hi)); }
.chart-bar-fill-blind   { background: var(--neutral-soft); }
.chart-bar-value { font-size: 12.5px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

.chart-card-value { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.cov-badge, .trend-badge {
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: var(--acc-soft); color: var(--acc-hi);
}

/* trend-графік */
.dash-trend-card { display: flex; flex-direction: column; }
.trend-chart { width: 100%; height: auto; display: block; flex: 1; min-height: 0; }
.trend-axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.trend-grid { stroke: var(--line-soft); stroke-width: 1; }
.trend-area { opacity: 0; animation: trend-fade 600ms ease 700ms forwards; }
.trend-line {
  fill: none; stroke: var(--acc); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
  /* базовий стан — намальовано (dashoffset:0). Малювання лінії — лише
     enhancement поверх видимого стану, тож якщо анімація не відпрацює
     (спинена/недоступна), лінія все одно на місці. */
  stroke-dasharray: 1; stroke-dashoffset: 0;
  animation: trend-draw 1100ms cubic-bezier(0.4, 0, 0.2, 1) 150ms;
}
.trend-dot { fill: var(--acc); opacity: 0; transform-box: fill-box; transform-origin: center; animation: dot-pop 300ms ease both; animation-delay: calc(1000ms + var(--i, 0) * 40ms); }
.trend-dot[style*="--i"] { opacity: 1; }
.trend-dot-last { fill: var(--acc-hi); stroke: var(--card); stroke-width: 2; animation: pulse-ring 2.2s ease-in-out 1.4s infinite; border-radius: 50%; }
.trend-chart circle { cursor: default; }

/* Потребує уваги */
.attention-clear { color: var(--ok); font-weight: 500; margin: 4px 0 0; }
.attention-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-3); }
.att-item {
  display: block; padding: 14px; border-radius: var(--r-md); text-decoration: none;
  border: 1px solid var(--line); background: var(--card-hi);
  animation: dash-in 400ms ease both;
  transition: transform var(--ease), border-color var(--ease);
}
a.att-item, a.att-item:hover { text-decoration: none; }
a.att-item:hover { transform: translateY(-2px); border-color: rgba(255,255,255,0.18); }
a.att-item:hover .att-sub { color: var(--fg-dim); }
.att-bad { box-shadow: inset 3px 0 0 var(--bad); }
.att-warn { box-shadow: inset 3px 0 0 var(--warn); }
.att-head { display: flex; align-items: baseline; gap: 8px; }
.att-num { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.att-bad .att-num { color: var(--bad); }
.att-warn .att-num { color: var(--warn); }
.att-lbl { font-size: 13px; color: var(--fg-dim); }
.att-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
.att-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.att-chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--bad-soft); color: var(--bad); }

@media (prefers-reduced-motion: reduce) {
  .kpi-card, .donut, .donut-legend li, .chart-bar-row, .att-item,
  .trend-area, .trend-line, .trend-dot, .trend-dot-last,
  .kpi-spark-fill, .chart-bar-fill { animation: none; }
  .trend-line { stroke-dashoffset: 0; }
  .trend-area, .trend-dot { opacity: 1; }
}

.muted { color: var(--muted); }

/* ---------- rule page: layout grids ---------- */

/* вкладка Редагування: тіло (гумове) + інструменти (фіксована колонка).
   align-items: stretch (дефолт) — обидві колонки однієї висоти; тіло-картка
   flex-колонкою розтягує СВОЮ textarea, тож редактор YAML заповнює висоту. */
.split { display: grid; grid-template-columns: 1fr 480px; gap: var(--sp-4); }
.split-main .card { height: 100%; display: flex; flex-direction: column; margin-bottom: 0; }
.split-main .card textarea { flex: 1; }
.split-side { display: flex; flex-direction: column; gap: var(--sp-4); }
.split-side .card { margin-bottom: 0; }
.split-side .card:last-child { flex: 1; }

/* симетрична 2-колонка; align-items дефолтний (stretch) — картки одного
   ряду однієї висоти. Непарна остання картка (умовні секції на кшталт
   Схожі/Atomic можуть бути відсутні) розтягується на весь ряд — без дір */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.grid-2 > .card { margin-bottom: 0; min-width: 0; }
.grid-2 > .card:last-child:nth-child(odd) { grid-column: 1 / -1; }
.card + .grid-2 { margin-top: 0; }

/* довгі списки (історія, atomic-тести) — внутрішній скрол замість
   розтягування картки на пів сторінки */
.scroll-box { max-height: 380px; overflow-y: auto; padding-right: 4px; }

/* робочий процес у save-bar: статус + інтервал + причина в один рядок */
.wf-fields { display: flex; gap: 8px; align-items: center; flex: 1; min-width: 0; flex-wrap: wrap; }
.save-bar select { width: 150px; margin: 0; }
.save-bar input[type=number] { width: 100px; margin: 0; }
.save-bar input[type=text] { flex: 1; min-width: 180px; margin: 0; }

/* ---------- inline edit (перегляд тексту + олівець) ---------- */

.card-head-right { display: flex; align-items: center; gap: 8px; }
.edit-toggle {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  padding: 4px; border-radius: var(--r-sm); display: inline-flex;
  transition: color var(--ease), background var(--ease);
}
.edit-toggle:hover { color: var(--fg); background: var(--neutral-soft); }
.inline-edit.editing .edit-toggle { color: var(--acc-hi); }

.inline-edit .ie-edit { display: none; }
.inline-edit.editing .ie-view { display: none; }
.inline-edit.editing .ie-edit { display: block; }

.pre-text { white-space: pre-wrap; margin: 0; line-height: 1.6; }
.pre-text.empty { color: var(--muted); font-style: italic; }

/* ---------- SIEM query output ---------- */

.query-view {
  background: var(--inset); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 34px 10px 12px; margin: 0; font-size: 12.5px; line-height: 1.6;
  /* довгий однорядковий запит ПЕРЕНОСИТЬСЯ, а не тікає в горизонтальний
     скрол: копіюванню переноси не шкодять, а читати можна без прокрутки.
     padding-right лишає місце під кнопку копіювання. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.query-block { position: relative; }
.copy-btn {
  position: absolute; top: 6px; right: 6px;
  background: var(--card-hi); border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--muted); cursor: pointer; padding: 4px; display: inline-flex;
  transition: color var(--ease), border-color var(--ease);
}
.copy-btn:hover { color: var(--fg); border-color: rgba(255,255,255,0.2); }
.copy-btn.copied { color: var(--ok); border-color: var(--ok); }

/* ---------- unified diff (peer review) ---------- */

.diff-details { margin-top: var(--sp-3); }
.diff-details summary { cursor: pointer; font-size: 12.5px; }
.diff-view {
  background: var(--inset); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 12px; overflow-x: auto; margin: 8px 0 0;
  font-size: 12px; line-height: 1.55;
}
.diff-view span { display: block; white-space: pre; }
.diff-add  { background: var(--ok-soft); color: var(--ok); }
.diff-del  { background: var(--bad-soft); color: var(--bad); }
.diff-hunk { color: var(--acc-hi); }
.diff-file { color: var(--muted); }
.diff-ctx  { color: var(--fg-dim); }

/* ---------- catalog table: центровані колонки + сортування ---------- */

/* все по центру, крім широкої текстової "Назва" — її заголовок по центру
   висів би далеко від лівовирівняного тексту */
.catalog-table th, .catalog-table td { text-align: center; }
.catalog-table th.col-name, .catalog-table td.col-name { text-align: left; }
/* тактика по центру (заголовок і плашки) */
.catalog-table th.col-tactic, .catalog-table td.col-tactic { text-align: center; }
.catalog-table td.col-tactic .pill-tactic { margin-bottom: 3px; }
/* Назва забирає всю вільну ширину таблиці — решта колонок стискаються під
   свій контент, тож "Тактика" не розтягується порожнечею праворуч */
.catalog-table th.col-name, .catalog-table td.col-name { width: 100%; }

.th-sort {
  color: inherit; text-decoration: none;
  transition: color var(--ease);
}
.th-sort:hover { color: var(--fg); text-decoration: none; }
.th-sort.active { color: var(--fg); }
.th-sort .arrow { color: var(--acc-hi); font-size: 9px; }

/* ---------- pagination ---------- */

.pagination {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-4);
  padding-top: var(--sp-4); margin-top: var(--sp-2);
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px;
}

/* ---------- empty state ---------- */

.empty-state {
  text-align: center; padding: var(--sp-7) var(--sp-4); color: var(--muted);
}
.empty-state svg { width: 32px; height: 32px; stroke: var(--muted); margin-bottom: var(--sp-3); }
.empty-state p { margin: 0 0 var(--sp-3); }

/* ---------- flash messages ---------- */

.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: var(--sp-4); }
.flash {
  padding: 10px 14px; border-radius: var(--r-sm); font-size: 13.5px;
  border: 1px solid transparent;
}
.flash-success { background: var(--ok-soft); color: var(--ok); }
.flash-error   { background: var(--bad-soft); color: var(--bad); }
.flash-warning { background: var(--warn-soft); color: var(--warn); }
.flash-info, .flash-debug { background: var(--neutral-soft); color: var(--fg-dim); }

/* ---------- form page ---------- */

.field-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-4); }
.field-row > div { min-width: 0; }

/* ---------- rule form: main column + sticky metadata rail ---------- */

.two-col { display: flex; gap: var(--sp-4); align-items: flex-start; }
.two-col .main-col { flex: 1 1 0; min-width: 0; }
.two-col .rail {
  flex: 0 0 300px; min-width: 0;
  /* .content не має власного скролу — прилипає відносно viewport. Топбар
     не sticky (скролиться разом зі сторінкою), тож немає його висоти, яку
     треба віднімати з top. */
  position: sticky;
  top: var(--sp-4);
}
.two-col .rail label { margin-top: var(--sp-3); }
.two-col .rail label:first-of-type { margin-top: 0; }

.save-bar {
  position: sticky; bottom: 0;
  display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-3);
  background: rgba(10, 10, 12, 0.85); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: var(--sp-3) var(--sp-5);
  margin: var(--sp-5) calc(var(--sp-5) * -1) calc(var(--sp-5) * -1);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ---------- timeline ---------- */

.timeline { display: flex; flex-direction: column; }
.timeline-item {
  display: flex; gap: var(--sp-3); padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--line-soft);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--acc);
  margin-top: 6px; flex: none;
}
.timeline-body { min-width: 0; }
.timeline-date { font-size: 12px; color: var(--muted); }
.timeline-reason { font-size: 13.5px; margin-top: 2px; }
.timeline-user { color: var(--fg-dim); }

/* ---------- coverage: тактика-рядок + технік-чіпи, що переносяться ---------- */
/* Раніше — колонка на тактику (Navigator-стиль), фіксована ширина 128px×15
   тактик змушувала горизонтальний скрол і ховала частину тактик за краєм.
   tiles тут завжди розріджені (лише покриті техніки, не весь довідник
   ATT&CK), тож справжньої "матриці" з вирівняними рядками й так нема —
   рядок-на-тактику з чіпами, що переносяться, використовує ширину чесно
   і ніколи не ріже вміст. */

.heat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
/* чипи-лінки (coverage -> каталог з фільтром) — підсвітка замість підкреслення */
a.heat-chip { text-decoration: none; transition: filter var(--ease); }
a.heat-chip:hover { text-decoration: none; filter: brightness(1.25); }
.heat-chip .n { font-family: -apple-system, sans-serif; opacity: .75; }
.heat-0 { background: var(--neutral-soft); color: var(--fg-dim); }
.heat-1 { background: rgba(94, 106, 210, 0.16); color: var(--fg); }
.heat-2 { background: rgba(94, 106, 210, 0.32); color: var(--fg); }
.heat-3 { background: rgba(94, 106, 210, 0.5); color: #fff; }
.heat-4 { background: rgba(94, 106, 210, 0.74); color: #fff; }

.legend { display: flex; align-items: center; gap: 8px; margin-top: var(--sp-4); font-size: 12px; color: var(--muted); }
.legend .heat-chip { width: 16px; height: 16px; padding: 0; border-radius: 4px; }

/* ---------- ATT&CK матриця (тактики-колонки, техніки-стовпчиком) ---------- */
/* На широкому екрані 15 колонок ростуть і заповнюють ширину (flex-grow),
   тож повний ID технік читається без скролу; на вузьких — min-width тримає
   ID цілим і матриця скролиться горизонтально (Navigator-поведінка), а не
   обрізає текст. */
.matrix-scroll { overflow-x: auto; padding-bottom: 4px; }
.attck-matrix { display: flex; gap: 5px; align-items: flex-start; }
.matrix-col { flex: 1 1 84px; min-width: 84px; display: flex; flex-direction: column; }
.matrix-head {
  min-height: 56px; padding: 2px 2px 8px; margin-bottom: 8px;
  border-bottom: 2px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-align: center;
}
.mh-name {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.01em;
  color: var(--fg-dim); line-height: 1.2; overflow-wrap: anywhere;
}
.mh-count {
  min-width: 17px; padding: 0 5px; border-radius: 999px;
  background: var(--neutral-soft); color: var(--muted);
  font-size: 10px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.matrix-cells { display: flex; flex-direction: column; gap: 4px; }
.matrix-tile {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  padding: 5px 6px; border-radius: var(--r-sm);
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 10.5px;
  text-decoration: none; white-space: nowrap; transition: filter var(--ease);
}
a.matrix-tile:hover { filter: brightness(1.28); text-decoration: none; }
.matrix-tile .mt-id { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.matrix-tile .mt-n { font-family: -apple-system, sans-serif; font-size: 10px; opacity: .75; flex: none; }
.matrix-empty { text-align: center; color: var(--muted); font-size: 12px; opacity: .4; padding: 2px 0; }

.matrix-unclassified { margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px dashed var(--line); }
.matrix-unclassified .mu-label { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.matrix-unclassified .mu-tiles { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.matrix-unclassified .matrix-tile { flex: 0 0 auto; }

/* ---------- chip-row: label + wrapped chips (тактики, джерела логів) ---------- */

.chip-row-list { display: flex; flex-direction: column; }
.chip-row {
  display: flex; gap: var(--sp-4); align-items: flex-start;
  padding: var(--sp-3) 0; border-bottom: 1px solid var(--line-soft);
}
.chip-row:last-child { border-bottom: none; }
.chip-row.chip-row-dashed {
  border-top: 1px dashed var(--line); margin-top: var(--sp-2); padding-top: var(--sp-4);
}
.chip-row-label {
  flex: 0 0 190px; min-width: 0; padding-top: 5px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 6px;
  font-size: 12.5px; color: var(--fg-dim);
}
.chip-row-label .muted { font-size: 11px; }
.chip-row-items { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-row-items .chip-row-empty { font-size: 12.5px; padding: 4px 0; }
.chip-row-action { flex: none; padding-top: 1px; }

/* пілюлі-посилання (список правил на джерело) — без підкреслення при ховері,
   легке підсвічування замість нього (незалежно від кольору статус-пілюлі) */
a.pill { text-decoration: none; transition: filter var(--ease); }
a.pill:hover { text-decoration: none; filter: brightness(1.25); }

/* ---------- command palette ---------- */

.cmdk-trigger {
  display: flex; align-items: center; gap: 6px;
  width: 100%; margin-top: var(--sp-2);
  background: var(--inset); border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--muted); font: inherit; font-size: 12.5px; padding: 7px 10px; cursor: pointer;
}
.cmdk-trigger:hover { color: var(--fg); border-color: rgba(255,255,255,0.2); }
.cmdk-kbd { margin-left: auto; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; color: var(--muted); }

.cmdk-overlay[hidden] { display: none; }
.cmdk-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh; z-index: 100;
}
.cmdk-panel {
  width: 100%; max-width: 560px; margin: 0 var(--sp-4);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  overflow: hidden;
}
.cmdk-input {
  width: 100%; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; color: var(--fg); font: inherit; font-size: 15px;
  padding: 16px 18px; outline: none; border-radius: 0;
}
.cmdk-results { max-height: 50vh; overflow-y: auto; padding: 6px; }
.cmdk-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-sm); font-size: 13.5px; cursor: pointer;
}
.cmdk-item.active { background: var(--acc-soft); }
.cmdk-kind { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; flex: none; }
.cmdk-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 13px; }

@media (max-width: 860px) {
  .cmdk-trigger { display: none; }
  .shell { flex-direction: column; }
  .sidebar {
    width: auto; flex-direction: row; align-items: center;
    border-right: none; border-bottom: 1px solid var(--line);
    overflow-x: auto;
    /* десктопна версія прибиває сайдбар на всю висоту viewport (position:
       sticky + height:100vh) — тут це горизонтальний топ-бар, не колонка,
       тож повертаємо звичайну поведінку в потоці сторінки. */
    position: static;
    height: auto;
    overflow-y: visible;
  }
  .nav { flex-direction: row; }
  .nav-spacer { display: none; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-grid-3 { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .two-col { flex-direction: column; }
  .two-col .rail { flex: none; width: auto; position: static; top: auto; }
  .split, .grid-2 { grid-template-columns: 1fr; }
  .grid-2 > .card:last-child:nth-child(odd) { grid-column: auto; }
  .wf-fields { flex-basis: 100%; }
  .chip-row { flex-direction: column; gap: 4px; }
  .chip-row-label { flex: none; width: auto; padding-top: 0; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-2, .dash-3 { grid-template-columns: 1fr; }
  .chart-bar-row { grid-template-columns: 100px 1fr 34px; gap: 6px; }
  .chart-bar-label { font-size: 11.5px; }
  .content { padding: var(--sp-4); }
  .topbar { padding: var(--sp-3) var(--sp-4); flex-wrap: wrap; }
  .topbar-actions { flex: 1 1 100%; flex-wrap: wrap; }
  /* .save-bar розтягує себе назовні на -var(--sp-5) з обох боків, щоб
     дорівнятись краям картки; на мобільному padding контенту менший
     (var(--sp-4)), тож той самий відступ раніше вилазив за viewport. */
  .save-bar { margin-left: calc(var(--sp-4) * -1); margin-right: calc(var(--sp-4) * -1); }
}
