/* Мониторинг стримов — стили дашборда.
   Только системные шрифты и встроенные ресурсы. Все цвета — токены на :root;
   тёмная тема: data-theme="dark" или системная настройка (если не выбрана светлая). */

:root {
  color-scheme: light;

  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --surface-3: #e9e9ec;
  --hover: #f5f5f7;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-2: #52525b;
  --muted: #6b6b74;
  --accent: #2563eb;
  --focus: #2563eb;
  --grid: #efeff1;
  --axis: #c4c4ca;
  --skel: #ececef;
  --skel-shine: rgba(255, 255, 255, 0.65);
  --topbar: rgba(247, 247, 248, 0.82);
  --shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.05);
  --shadow: 0 1px 2px rgba(24, 24, 27, 0.04), 0 6px 20px -12px rgba(24, 24, 27, 0.12);
  --shadow-pop: 0 12px 32px -8px rgba(24, 24, 27, 0.22), 0 2px 6px rgba(24, 24, 27, 0.06);

  --sev-critical: #dc2626;
  --sev-critical-text: #b91c1c;
  --sev-major: #ea580c;
  --sev-major-text: #c2410c;
  --sev-minor: #eab308;
  --sev-minor-text: #a16207;
  --sev-info: #8a8a93;
  --sev-info-text: #52525b;
  --sev-ok: #16a34a;
  --sev-ok-text: #15803d;
  /* Приват (модель в привате, поток не мониторится): пурпурный — отличим от уровней и от PT. */
  --sev-private: #c026d3;
  --sev-private-text: #a21caf;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --radius: 12px;
  --radius-sm: 8px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t: 160ms;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0b0d;
  --surface: #141417;
  --surface-2: #1b1b1f;
  --surface-3: #26262b;
  --hover: #1c1c21;
  --border: #26262b;
  --border-strong: #35353c;
  --text: #f4f4f5;
  --text-2: #b4b4bc;
  --muted: #8e8e98;
  --accent: #60a5fa;
  --focus: #60a5fa;
  --grid: #1f1f24;
  --axis: #3f3f46;
  --skel: #1e1e23;
  --skel-shine: rgba(255, 255, 255, 0.05);
  --topbar: rgba(11, 11, 13, 0.78);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px -14px rgba(0, 0, 0, 0.6);
  --shadow-pop: 0 16px 40px -10px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --sev-critical: #f87171;
  --sev-critical-text: #fca5a5;
  --sev-major: #fb923c;
  --sev-major-text: #fdba74;
  --sev-minor: #facc15;
  --sev-minor-text: #fde047;
  --sev-info: #a1a1aa;
  --sev-info-text: #d4d4d8;
  --sev-ok: #4ade80;
  --sev-ok-text: #86efac;
  --sev-private: #e879f9;
  --sev-private-text: #f0abfc;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #2f9e2f;
  --series-7: #9085e9;
  --series-8: #e66767;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0b0d;
    --surface: #141417;
    --surface-2: #1b1b1f;
    --surface-3: #26262b;
    --hover: #1c1c21;
    --border: #26262b;
    --border-strong: #35353c;
    --text: #f4f4f5;
    --text-2: #b4b4bc;
    --muted: #8e8e98;
    --accent: #60a5fa;
    --focus: #60a5fa;
    --grid: #1f1f24;
    --axis: #3f3f46;
    --skel: #1e1e23;
    --skel-shine: rgba(255, 255, 255, 0.05);
    --topbar: rgba(11, 11, 13, 0.78);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px -14px rgba(0, 0, 0, 0.6);
    --shadow-pop: 0 16px 40px -10px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.04);
    --sev-critical: #f87171;
    --sev-critical-text: #fca5a5;
    --sev-major: #fb923c;
    --sev-major-text: #fdba74;
    --sev-minor: #facc15;
    --sev-minor-text: #fde047;
    --sev-info: #a1a1aa;
    --sev-info-text: #d4d4d8;
    --sev-ok: #4ade80;
    --sev-ok-text: #86efac;
    --sev-private: #e879f9;
    --sev-private-text: #f0abfc;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #2f9e2f;
    --series-7: #9085e9;
    --series-8: #e66767;
  }
}

/* ---------- основа ---------- */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--t) ease, color var(--t) ease;
}

a { color: inherit; }
button { font: inherit; color: inherit; }
svg { display: block; }

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

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.num, .tabular { font-variant-numeric: tabular-nums; }

/* ---------- верхняя панель ---------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--topbar);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  max-width: 1440px; margin: 0 auto; padding: var(--s2) var(--s5);
  min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
}
.topbar__left { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.topbar__right { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
/* Поиск уступает место первым (shrink 3): навигация и крошки слева не сжимаются раньше него. */
.topbar__mid { flex: 1 3 300px; display: flex; justify-content: center; min-width: 140px; }

/* ---------- поиск в шапке ---------- */
.gsearch { position: relative; display: flex; align-items: center; gap: var(--s2); width: min(400px, 100%); }
.gsearch .search { flex: 1 1 auto; min-width: 0; }
.gsearch .search input { width: 100%; }
.gsearch__pop {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; min-width: 320px; z-index: 50;
  max-height: min(60vh, 460px); overflow: auto; padding: 4px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-pop);
  animation: fade-in 120ms var(--ease);
}
.gsearch__pop[hidden] { display: none; }
.gs-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s3); padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.gs-item[aria-selected="true"] { background: var(--hover); }
.gs-item__text { display: flex; flex-direction: column; min-width: 0; }
.gs-item__name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-item__sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-item__actions { display: inline-flex; align-items: center; gap: var(--s2); }
.gs-item__card { font-size: 12px; line-height: 20px; padding: 0 7px; color: var(--text-2); text-decoration: none; border: 1px solid var(--border); border-radius: 5px; white-space: nowrap; }
.gs-item__card:hover { color: var(--text); border-color: var(--text-2); }
.gs-note { padding: 8px 10px; color: var(--muted); font-size: 12.5px; }
.gs-hint { margin-top: 4px; padding: 6px 10px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11.5px; }
.table--streams tr.is-hit > td { background: color-mix(in srgb, var(--focus) 16%, transparent); transition: background-color 600ms ease; }
@media (max-width: 900px) { .gsearch__kbd { display: none; } .topbar__mid { flex-basis: 160px; } .gsearch__pop { left: auto; right: 0; min-width: 300px; } }

.brand {
  display: inline-flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0;
  font-weight: 650; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap;
}
.brand__mark {
  width: 24px; height: 24px; border-radius: 7px; flex: none; position: relative;
  background: var(--text);
}
.brand__mark::before, .brand__mark::after {
  content: ""; position: absolute; border-radius: 50%;
}
.brand__mark::before { inset: 7px; background: var(--sev-ok); }
.brand__mark::after { inset: 4px; border: 1.5px solid color-mix(in srgb, var(--sev-ok) 45%, transparent); }

.crumbs { display: flex; align-items: center; gap: var(--s2); min-width: 0; color: var(--muted); font-size: 14px; }
.crumbs a { text-decoration: none; color: var(--text-2); border-radius: 6px; padding: 2px 4px; transition: color var(--t) ease, background-color var(--t) ease; }
.crumbs a:hover { color: var(--text); background: var(--hover); }
.crumbs__sep { color: var(--border-strong); }
.crumbs__current { color: var(--text); font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.freshness {
  display: inline-flex; align-items: center; gap: var(--s2); color: var(--text-2); font-size: 13px;
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  white-space: nowrap; min-width: 0; box-shadow: var(--shadow-sm);
}
.freshness__text { overflow: hidden; text-overflow: ellipsis; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; position: relative; }
.live-dot.is-live { background: var(--sev-ok); }
.live-dot.is-live::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--sev-ok); opacity: 0; animation: pulse 2.2s var(--ease) infinite;
}
.live-dot.is-stale { background: var(--sev-minor); }
.live-dot.is-down { background: var(--sev-critical); }
@keyframes pulse {
  0% { transform: scale(0.5); opacity: 0.65; }
  100% { transform: scale(1.45); opacity: 0; }
}

.theme-switch {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.theme-switch button {
  width: 30px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 7px;
  background: transparent; color: var(--muted); cursor: pointer;
  transition: background-color var(--t) ease, color var(--t) ease, transform var(--t) ease;
}
.theme-switch button:hover { color: var(--text); }
.theme-switch button:active { transform: scale(0.94); }
.theme-switch button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.theme-switch svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- пользователь ---------- */

.user-menu {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px; min-width: 0; flex: none;
  border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border);
}
.user-menu__who {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 8px 0 6px; min-width: 0;
  color: var(--muted); font-size: 13px;
}
.user-menu__name {
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text); font-weight: 550;
}
.user-menu__form { margin: 0; display: flex; }
.user-menu__logout {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border: 0; border-radius: 7px;
  background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 550; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: color var(--t) ease, background-color var(--t) ease, transform var(--t) ease;
}
.user-menu__logout:hover { color: var(--sev-critical-text); }
.user-menu__logout:active { transform: scale(0.96); }
.user-menu svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- нагрузка инстанса ---------- */

/* Одна тонкая полоса под верхней панелью; на телефоне — две короткие строки. */
.hostbar { background: var(--surface); border-bottom: 1px solid var(--border); transition: background-color var(--t) ease; }
.hostbar__inner {
  --hs-gap: var(--s5);
  max-width: 1440px; margin: 0 auto; padding: 5px var(--s5); min-height: 36px;
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px var(--hs-gap);
  font-size: 12.5px; line-height: 24px; color: var(--text-2); min-width: 0;
}
.hs__item { display: inline-block; position: relative; white-space: nowrap; }
.hs__item[hidden], .hs__na[hidden], .hs__scope[hidden] { display: none; }
.hs__item + .hs__item::before {
  content: ""; position: absolute; left: calc(var(--hs-gap) / -2 - 1.5px); top: 50%;
  width: 3px; height: 3px; margin-top: -1.5px; border-radius: 50%; background: var(--border-strong);
}
.hs__lbl, .hs__long { color: var(--text-2); }
.hs__val { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; transition: color var(--t) ease; }
.hs__pct { color: var(--muted); font-variant-numeric: tabular-nums; }
.hs__item.is-warn .hs__val, .hs__item.is-warn .hs__pct { color: var(--sev-minor-text); }
.hs__item.is-bad .hs__val, .hs__item.is-bad .hs__pct { color: var(--sev-critical-text); }
.hs__scope {
  margin-left: 6px; padding: 0 4px; border: 1px dashed var(--border-strong); border-radius: 4px;
  font-size: 11px; line-height: 16px; color: var(--muted); vertical-align: 1px;
}
.hs__spark { display: inline-block; width: 64px; height: 18px; margin-left: 8px; vertical-align: -4px; }
.hs__na { color: var(--muted); }

/* ---------- страница ---------- */

.page { max-width: 1440px; margin: 0 auto; padding: var(--s5) var(--s5) 48px; display: grid; gap: var(--s5); }
.page > * { min-width: 0; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; }
.page-title { margin: 0; font-size: 22px; line-height: 1.25; font-weight: 650; letter-spacing: -0.02em; }
.page-sub { margin: var(--s1) 0 0; color: var(--muted); font-size: 13.5px; }
.on-air { margin: 0; display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-size: 13.5px; color: var(--text-2); }
.on-air[hidden] { display: none; }
.on-air strong { font-weight: 650; font-variant-numeric: tabular-nums; }
.on-air__note { color: var(--muted); }
.off-air {
  margin: var(--s3) 0 0; padding: var(--s2) var(--s3); border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); font-size: 13.5px;
}
.off-air[hidden] { display: none; }
.off-air strong { font-weight: 650; color: var(--text); }
.off-air--private { border-color: color-mix(in srgb, var(--sev-private) 35%, var(--border)); background: color-mix(in srgb, var(--sev-private) 7%, var(--surface)); }
.off-air--private strong { color: var(--sev-private-text); }

.banner {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s3) var(--s4); border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--sev-minor) 45%, var(--border));
  background: color-mix(in srgb, var(--sev-minor) 10%, var(--surface));
  animation: fade-in var(--t) var(--ease);
}
.banner[hidden] { display: none; }
.banner::before {
  content: "!"; flex: none; width: 20px; height: 20px; border-radius: 50%; margin-top: 1px;
  display: grid; place-items: center; font-weight: 700; font-size: 12px; line-height: 1;
  background: var(--sev-minor); color: #1c1400;
}
.banner--down {
  border-color: color-mix(in srgb, var(--sev-critical) 45%, var(--border));
  background: color-mix(in srgb, var(--sev-critical) 9%, var(--surface));
}
.banner--down::before { background: var(--sev-critical); color: #fff; }
.banner strong { font-weight: 650; }
@keyframes fade-in { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }

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

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); min-width: 0; overflow: hidden;
  transition: background-color var(--t) ease, border-color var(--t) ease;
}
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s4) var(--s4) var(--s3); flex-wrap: wrap; min-height: 56px;
}
.card__title { margin: 0; font-size: 14.5px; font-weight: 650; letter-spacing: -0.005em; display: flex; align-items: center; gap: var(--s2); }
.card__meta { color: var(--muted); font-size: 12.5px; }
.card__foot { padding: 0 var(--s4) var(--s4); }
.section-title { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }

.count-pill {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 600;
}

.btn-link {
  border: 0; background: none; padding: var(--s1) 0; color: var(--accent); cursor: pointer; font-size: 13px; font-weight: 550;
}
.btn-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.empty { margin: 0; padding: var(--s5) var(--s4); color: var(--muted); text-align: center; }
.empty[hidden] { display: none; }
.empty-state {
  display: grid; justify-items: center; gap: var(--s2); padding: var(--s6) var(--s4); text-align: center; color: var(--text-2);
}
.empty-state__icon {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--sev-ok) 14%, var(--surface)); color: var(--sev-ok-text);
}
.empty-state__icon--ok::before {
  content: ""; width: 6px; height: 11px; margin-top: -3px;
  border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.empty-state__icon--info { background: var(--surface-2); color: var(--muted); }
.empty-state__icon--info::before { content: "i"; font-weight: 700; font-size: 15px; line-height: 1; font-style: normal; }
.empty-state__title { font-weight: 600; color: var(--text); }
.empty-state__text { font-size: 13px; color: var(--muted); max-width: 44ch; }

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

.skel {
  display: block; position: relative; overflow: hidden; border-radius: 6px; background: var(--skel);
}
.skel::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--skel-shine), transparent);
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.skel--num { width: 64px; height: 30px; margin: 2px 0; }
.skel--hint { width: 110px; height: 12px; }
.skel--line { height: 14px; margin: 14px var(--s4); }
.skel--line:nth-child(2n) { width: 72%; }
.skel--line:nth-child(3n) { width: 58%; }
.skel--cell { height: 12px; width: 70%; }
.skel--title { width: 180px; height: 22px; }

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

.kpis { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(6, minmax(0, 1fr)); gap: var(--s3); }
.kpis--six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--s4); display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow);
  position: relative; overflow: hidden; min-width: 0;
  transition: background-color var(--t) ease, border-color var(--t) ease;
}
.kpi::before {
  content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0;
  background: transparent; transition: background-color var(--t) ease;
}
.kpi--critical.has-value::before { background: var(--sev-critical); }
.kpi--major.has-value::before { background: var(--sev-major); }
.kpi--minor.has-value::before { background: var(--sev-minor); }
.kpi--ok.has-value::before { background: var(--sev-ok); }
.kpi--api.is-warn::before { background: var(--sev-major); }
.kpi__label { color: var(--text-2); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi__value {
  font-size: 30px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.2; min-height: 36px;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere; display: flex; align-items: baseline; gap: 6px;
}
.kpi__value small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.kpi__hint { color: var(--muted); font-size: 12px; min-height: 18px; }
.kpi.is-bad .kpi__value { color: var(--sev-critical-text); }
.kpi.is-warn .kpi__value { color: var(--sev-major-text); }

.dist { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--surface-3); margin-top: var(--s2); gap: 2px; }
.dist > span { display: block; height: 100%; transition: flex-grow 200ms var(--ease); flex: 0 0 0; min-width: 0; }
.dist .ok { background: var(--sev-ok); }
.dist .critical { background: var(--sev-critical); }
.dist .major { background: var(--sev-major); }
.dist .minor { background: var(--sev-minor); }
.dist .info { background: var(--sev-info); }

/* ---------- важность ---------- */

.sev-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--sev-info); }
.sev-dot--critical { background: var(--sev-critical); }
.sev-dot--major { background: var(--sev-major); }
.sev-dot--minor { background: var(--sev-minor); }
.sev-dot--info { background: var(--sev-info); }
.sev-dot--ok { background: var(--sev-ok); }
.sev-dot--private { background: var(--sev-private); }
.sev-dot--pending { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; line-height: 18px;
  padding: 1px 8px 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.pill--critical { background: color-mix(in srgb, var(--sev-critical) 11%, var(--surface)); border-color: color-mix(in srgb, var(--sev-critical) 30%, transparent); color: var(--sev-critical-text); }
.pill--major { background: color-mix(in srgb, var(--sev-major) 12%, var(--surface)); border-color: color-mix(in srgb, var(--sev-major) 32%, transparent); color: var(--sev-major-text); }
.pill--minor { background: color-mix(in srgb, var(--sev-minor) 14%, var(--surface)); border-color: color-mix(in srgb, var(--sev-minor) 38%, transparent); color: var(--sev-minor-text); }
.pill--info { color: var(--sev-info-text); }
.pill--ok { background: color-mix(in srgb, var(--sev-ok) 10%, var(--surface)); border-color: color-mix(in srgb, var(--sev-ok) 28%, transparent); color: var(--sev-ok-text); }
.pill--plain { font-weight: 500; color: var(--text-2); }
.pill--private { background: color-mix(in srgb, var(--sev-private) 10%, var(--surface)); border-color: color-mix(in srgb, var(--sev-private) 30%, transparent); color: var(--sev-private-text); }
.pill .count { font-weight: 700; opacity: 0.85; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ---------- текущий статус ---------- */

.status-groups { display: grid; gap: var(--s2); padding: 0 var(--s3) var(--s3); }
.sev-group { position: relative; border-radius: var(--radius-sm); background: var(--surface-2); padding: var(--s1) 0 var(--s1) 3px; overflow: hidden; }
.sev-group::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--sev-info); }
.sev-group--critical::before { background: var(--sev-critical); }
.sev-group--major::before { background: var(--sev-major); }
.sev-group--minor::before { background: var(--sev-minor); }
.sev-group--critical { background: color-mix(in srgb, var(--sev-critical) 5%, var(--surface)); }
.sev-group--major { background: color-mix(in srgb, var(--sev-major) 5%, var(--surface)); }
.sev-group--minor { background: color-mix(in srgb, var(--sev-minor) 6%, var(--surface)); }
.sev-group__head { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3) 2px; }
.sev-group__title { margin: 0; font-size: 12.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; }
.sev-group--critical .sev-group__title { color: var(--sev-critical-text); }
.sev-group--major .sev-group__title { color: var(--sev-major-text); }
.sev-group--minor .sev-group__title { color: var(--sev-minor-text); }
.sev-group--info .sev-group__title { color: var(--sev-info-text); }

.status-list { list-style: none; margin: 0; padding: 0 var(--s1) var(--s1); }
.status-item > a, .status-item > div {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--s3); align-items: baseline;
  padding: 7px var(--s2); text-decoration: none; border-radius: 6px;
  transition: background-color var(--t) ease;
}
.status-item > a:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.status-line { overflow-wrap: anywhere; color: var(--text); }
.status-line .model { font-weight: 650; }
.status-sub { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; }
.status-val { color: var(--text-2); font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.status-item.is-stale { opacity: 0.62; }
/* Удержанная по истории строка: проблемы сейчас нет — приглушённый текст
   (не прозрачность: она занята «по последней проверке»); главное — подпись. */
.status-item.is-held .status-line, .status-item.is-held .status-val { color: var(--muted); }
.status-item.is-stale .status-sub::after { content: ""; }
.stale-note { font-style: normal; }

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

.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; border-top: 1px solid var(--border); }
.table-wrap--tall { max-height: min(72vh, 900px); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th, .table td { padding: 10px var(--s3); text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border); }
.table th:first-child, .table td:first-child { padding-left: var(--s4); }
.table th:last-child, .table td:last-child { padding-right: var(--s4); }
.table thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2);
  font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: 0.01em;
  border-bottom-color: var(--border-strong);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .na { color: var(--muted); }
.table tbody td { transition: background-color var(--t) ease; }

.sort {
  border: 0; background: none; padding: 2px 0; cursor: pointer; font-weight: 600; color: inherit;
  display: inline-flex; align-items: center; gap: 6px; border-radius: 4px;
}
.sort::after {
  content: ""; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid currentColor; opacity: 0.25; transition: opacity var(--t) ease, transform var(--t) ease;
}
.sort:hover::after { opacity: 0.55; }
.sort[aria-sort="ascending"]::after { opacity: 0.95; transform: rotate(180deg); }
.sort[aria-sort="descending"]::after { opacity: 0.95; }
.sort[aria-sort] { color: var(--text); }
.num .sort { flex-direction: row-reverse; }

.table--streams tbody tr { cursor: pointer; }
.table--streams tbody tr:hover td, .table--streams tbody tr:focus-visible td { background: var(--hover); }
.table--streams tbody tr:focus-visible { outline: none; }
.table--streams tbody tr:focus-visible td:first-child { box-shadow: inset 3px 0 0 var(--focus); }
.table--streams tbody tr.is-stale td { color: var(--muted); }
.table--streams tbody tr.is-stale .cell-model a { color: var(--text-2); }
.cell-model { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cell-model a { text-decoration: none; font-weight: 600; color: var(--text); }
.cell-model a:hover { text-decoration: underline; text-underline-offset: 3px; }
.cell-model .sub { color: var(--muted); font-size: 12px; }
.conn { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.health { display: inline-flex; align-items: center; gap: var(--s2); justify-content: flex-end; }
.meter { width: 40px; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; display: inline-block; }
.meter > span { display: block; height: 100%; width: 100%; border-radius: 2px; background: var(--sev-ok); transform-origin: left; transition: transform 200ms var(--ease); }
.meter.is-warn > span { background: var(--sev-minor); }
.meter.is-bad > span { background: var(--sev-critical); }
.chips { display: inline-flex; gap: var(--s1); }
.chip {
  font-size: 11.5px; line-height: 18px; padding: 0 6px; border-radius: 5px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text-2);
}
.chip--off { color: var(--muted); background: transparent; border-style: dashed; }

.pct-col { width: 34%; min-width: 160px; }
.pct { display: flex; align-items: center; gap: var(--s2); }
.pct__bar { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; min-width: 60px; }
.pct__bar > span { display: block; height: 100%; width: 100%; border-radius: 3px; background: var(--sev-info); transform-origin: left; transition: transform 200ms var(--ease); }
.pct__bar.critical > span { background: var(--sev-critical); }
.pct__bar.major > span { background: var(--sev-major); }
.pct__bar.minor > span { background: var(--sev-minor); }
.pct__num { width: 52px; text-align: right; color: var(--text-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }

.tools { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; min-width: 0; }
.search { position: relative; display: block; max-width: 100%; }
.search input {
  width: 280px; max-width: 100%; height: 34px; padding: 0 10px 0 32px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 13.5px;
  transition: border-color var(--t) ease, box-shadow var(--t) ease;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.search svg {
  position: absolute; left: 10px; top: 50%; width: 14px; height: 14px; margin-top: -7px; pointer-events: none;
  fill: none; stroke: var(--muted); stroke-width: 1.75; stroke-linecap: round;
}
.kbd {
  font: 11px/1 var(--mono); padding: 3px 5px; border-radius: 4px; border: 1px solid var(--border-strong);
  color: var(--muted); background: var(--surface-2);
}

/* ---------- страница модели ---------- */

.model-card { padding: var(--s5); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s4); align-items: center; }
.model-card__name { margin: 0; font-size: 24px; line-height: 1.2; font-weight: 700; letter-spacing: -0.025em; overflow-wrap: anywhere; }
.model-card__meta { margin-top: var(--s2); color: var(--muted); font-size: 13px; display: flex; gap: var(--s3); flex-wrap: wrap; }
.model-card .badges { margin-top: var(--s3); }
.model-card__side { display: grid; justify-items: end; gap: var(--s1); text-align: right; }
.model-card__score { font-size: 40px; line-height: 1; font-weight: 700; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.model-card__score.is-bad { color: var(--sev-critical-text); }
.model-card__score.is-warn { color: var(--sev-major-text); }
.model-card__score.is-ok { color: var(--sev-ok-text); }
.model-card__score-label { color: var(--muted); font-size: 12px; }

.split { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: var(--s5); align-items: start; }
.split--model { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }

.kv { margin: 0; padding: 0 var(--s4) var(--s3); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s5); }
.kv > div { display: flex; justify-content: space-between; gap: var(--s3); padding: 9px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.kv dt { color: var(--text-2); font-size: 13px; }
.kv dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.kv dd.na { color: var(--muted); font-weight: 400; }

.charts-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.charts-tools { display: flex; flex-wrap: wrap; gap: var(--s2); }
.segmented[hidden] { display: none; }
.segmented {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.segmented button {
  border: 0; background: transparent; padding: 5px 14px; border-radius: 7px; cursor: pointer;
  color: var(--text-2); font-size: 13px; font-weight: 550;
  transition: background-color var(--t) ease, color var(--t) ease, transform var(--t) ease;
}
.segmented button:hover { color: var(--text); }
.segmented button:active { transform: scale(0.97); }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.chart-card { padding-bottom: var(--s3); }
.chart-card .card__head { padding-bottom: var(--s1); min-height: 48px; }
.chart-card .unit { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.legend { display: flex; flex-wrap: wrap; gap: 2px var(--s1); padding: 0 var(--s3) var(--s2); min-height: 30px; }
.legend[hidden] { display: none; }
.legend button {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: none;
  padding: 3px 8px 3px 6px; border-radius: 6px; cursor: pointer; font-size: 12.5px; color: var(--text-2);
  transition: background-color var(--t) ease, color var(--t) ease, opacity var(--t) ease;
}
.legend button:hover { background: var(--hover); color: var(--text); }
.legend button[aria-pressed="false"] { opacity: 0.45; }
.legend button[aria-pressed="false"] .swatch { background: transparent !important; box-shadow: inset 0 0 0 1.5px var(--muted); }
.legend__axis { color: var(--muted); font-size: 11.5px; }
.swatch { width: 12px; height: 3px; border-radius: 2px; flex: none; }
.plot { position: relative; margin: 0 var(--s2); height: 220px; touch-action: pan-y; }
.plot canvas { display: block; width: 100%; height: 100%; transition: opacity var(--t) ease; }
.plot__empty {
  position: absolute; inset: 0 0 24px; display: grid; place-items: center; color: var(--muted); font-size: 13px; pointer-events: none;
}
.plot__empty[hidden] { display: none; }
.tooltip {
  position: absolute; top: 0; left: 0; z-index: 5; pointer-events: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop); padding: var(--s2) 10px; font-size: 12.5px; min-width: 160px; max-width: 280px;
}
.tooltip[hidden] { display: none; }
.tooltip__time { color: var(--muted); margin-bottom: var(--s1); font-weight: 550; font-size: 12px; }
.tooltip__row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: var(--s2); align-items: center; padding: 1px 0; }
.tooltip__row .name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tooltip__row .val { font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }
.tooltip__row .val.na { color: var(--muted); font-weight: 400; }
.tooltip__row--total { border-top: 1px solid var(--border); margin-top: 2px; padding-top: 3px; }
.chart-skel { height: 220px; margin: 0 var(--s4) var(--s2); }

.page-foot { display: flex; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; color: var(--muted); font-size: 12px; padding: 0 var(--s1); }

/* ---------- вход ---------- */

.auth {
  display: flex; flex-direction: column;
  background:
    radial-gradient(900px 480px at 50% -8%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    var(--bg);
}
.auth__top {
  display: flex; justify-content: flex-end; align-items: center;
  width: 100%; max-width: 1440px; margin: 0 auto; padding: var(--s4) var(--s5);
}
.auth__main {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s4); padding: var(--s4) var(--s4) 14vh;
}
.auth-card {
  width: 100%; max-width: 384px; padding: 32px 28px 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-pop);
  animation: auth-in 320ms var(--ease);
}
@keyframes auth-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.auth-card__mark { display: flex; justify-content: center; margin-bottom: var(--s4); }
.auth-card__mark .brand__mark { width: 40px; height: 40px; border-radius: 11px; }
.auth-card__mark .brand__mark::before { inset: 12px; }
.auth-card__mark .brand__mark::after { inset: 7px; border-width: 2px; }
.auth-card__title { margin: 0; text-align: center; font-size: 20px; line-height: 1.3; font-weight: 650; letter-spacing: -0.02em; }
.auth-card__sub { margin: 6px 0 0; text-align: center; color: var(--muted); font-size: 13.5px; }

.auth-alert {
  display: flex; gap: 10px; align-items: flex-start; margin-top: var(--s5);
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13.5px; line-height: 1.45; overflow-wrap: anywhere;
  border: 1px solid color-mix(in srgb, var(--sev-critical) 40%, var(--border));
  background: color-mix(in srgb, var(--sev-critical) 8%, var(--surface));
  animation: fade-in var(--t) var(--ease);
}
.auth-alert::before {
  content: "!"; flex: none; width: 18px; height: 18px; border-radius: 50%; margin-top: 1px;
  display: grid; place-items: center; font-weight: 700; font-size: 11px; line-height: 1;
  background: var(--sev-critical); color: #fff;
}
.auth-alert--info {
  border-color: color-mix(in srgb, var(--sev-minor) 45%, var(--border));
  background: color-mix(in srgb, var(--sev-minor) 10%, var(--surface));
}
.auth-alert--info::before { background: var(--sev-minor); color: #1c1400; }
.auth-alert + .auth-alert { margin-top: var(--s2); }

.auth-form { display: grid; gap: var(--s4); margin-top: var(--s5); }
.field { display: grid; gap: 6px; min-width: 0; }
.field__label { font-size: 13px; font-weight: 550; color: var(--text); }
.field__wrap { position: relative; }
.field__input {
  width: 100%; height: 44px; padding: 0 12px; margin: 0;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  /* 16px: iOS не увеличивает страницу при фокусе. */
  font: 16px/1.2 var(--font);
  transition: border-color var(--t) ease, box-shadow var(--t) ease, background-color var(--t) ease;
}
.field__input:hover { border-color: color-mix(in srgb, var(--text) 28%, var(--border-strong)); }
.field__input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.field__input--pw { padding-right: 46px; }
.field__input::-ms-reveal { display: none; }
.field__reveal {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); cursor: pointer;
  transition: color var(--t) ease, background-color var(--t) ease;
}
.field__reveal:hover { color: var(--text); background: var(--hover); }
.field__reveal[hidden], .field__hint[hidden] { display: none; }
.field__reveal svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.field__reveal .field__eye-off, .field__reveal[aria-pressed="true"] .field__eye { display: none; }
.field__reveal[aria-pressed="true"] .field__eye-off { display: block; }
.field__hint { margin: 0; color: var(--sev-minor-text); font-size: 12.5px; }

.btn-primary {
  position: relative; width: 100%; height: 44px; margin-top: var(--s1);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  border: 0; border-radius: var(--radius-sm); background: var(--text); color: var(--surface);
  font-size: 15px; font-weight: 600; letter-spacing: -0.005em; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: opacity var(--t) ease, transform var(--t) ease, background-color var(--t) ease;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.985); }
.btn-primary:disabled { cursor: progress; opacity: 0.75; }
.btn-primary[aria-busy="true"]::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth__foot { margin: 0; color: var(--muted); font-size: 12.5px; text-align: center; }

/* ---------- адаптивность ---------- */

@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpis .kpi--wide { grid-column: span 4; }
  .kpis .kpi--api, .kpis .kpi--pt { grid-column: span 2; }
  .kpis--six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .split, .split--model { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1000px) {
  /* Короткие подписи: полоса остаётся в одну строку до ширины планшета. */
  .hostbar__inner { --hs-gap: var(--s4); }
  .hs__long { display: none; }
}
@media (max-width: 900px) {
  .charts { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .topbar__inner { padding: var(--s2) var(--s4); flex-wrap: wrap; row-gap: var(--s2); }
  .topbar__right { width: 100%; justify-content: space-between; }
  .hostbar__inner { padding: 4px var(--s4); row-gap: 0; line-height: 22px; }
  .hs__spark { display: none; }
  /* На телефоне полоса переносится: разделители в начале строки не нужны. */
  .hs__item + .hs__item::before { display: none; }
  .page { padding: var(--s4) var(--s4) var(--s6); gap: var(--s4); }
  .kpis, .kpis--six { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
  .kpis .kpi--wide, .kpis .kpi--api, .kpis .kpi--pt { grid-column: span 2; }
  .kpi { padding: var(--s3); }
  .kpi__value { font-size: 24px; min-height: 30px; }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .tools, .search { width: 100%; }
  .search input { width: 100%; }
  .model-card { grid-template-columns: minmax(0, 1fr); padding: var(--s4); }
  .model-card__side { display: flex; align-items: baseline; gap: var(--s2); text-align: left; }
  .model-card__score { font-size: 30px; }
  .plot { height: 190px; }
  .kbd { display: none; }
}
@media (max-width: 480px) {
  .freshness__prefix { display: none; }
  .crumbs__home { display: none; }
  .user-menu__name { max-width: 72px; }
  .auth__top { padding: var(--s3) var(--s4); }
  .auth__main { justify-content: flex-start; padding: var(--s2) var(--s4) var(--s6); }
  .auth-card { padding: 24px 20px 20px; border-radius: 14px; }
}
@media (max-width: 400px) {
  /* Узкий телефон: имя — в подсказке, в шапке только значок и «Выйти». */
  .user-menu__name { display: none; }
  .user-menu__who { padding: 0 4px; }
  .user-menu__logout { padding: 0 7px; }
  .user-menu__logout-text {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .live-dot.is-live::after, .skel::after { animation: none; }
}

/* ---------- график по времени, инциденты, доставка ---------- */
:root {
  --band: color-mix(in srgb, var(--sev-critical) 12%, transparent);
  --band-private: color-mix(in srgb, var(--sev-private) 14%, transparent);
}
#timeline-card { margin-bottom: var(--s4); padding-bottom: var(--s3); }
#timeline-card .card__head { flex-wrap: wrap; gap: var(--s2); }
#timeline-card .card__tools { display: flex; flex-wrap: wrap; gap: var(--s2); margin-left: auto; }
/* Два графика: объём сверху (без подписей времени), проблемы стопкой снизу. */
.tl-part--volume .plot { height: 160px; }
.tl-part--levels .plot { height: 150px; }
.tl-part--levels { border-top: 1px dashed var(--grid); margin-top: var(--s1); padding-top: var(--s1); }
.delivery-line { margin: var(--s2) var(--s4) 0; }
.banner--incident {
  margin-bottom: var(--s4);
  border-color: color-mix(in srgb, var(--sev-critical) 45%, var(--border));
  background: color-mix(in srgb, var(--sev-critical) 9%, var(--surface));
}
.banner--incident::before { background: var(--sev-critical); color: #fff; }

/* ---------- значки проблем ---------- */
.pi { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.pb {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px 1px 5px;
  border-radius: 999px; font-size: 12px; line-height: 18px; white-space: nowrap;
  border: 1px solid color-mix(in srgb, currentColor 35%, transparent);
  background: color-mix(in srgb, currentColor 8%, transparent);
}
.pb--critical { color: var(--sev-critical-text); }
.pb--major { color: var(--sev-major-text); }
.pb--minor { color: var(--sev-minor-text); }
.pb--info { color: var(--sev-info-text); }
.pb--incident { border-style: dashed; }
/* Значок проблемы, которая сейчас не наблюдается (уровень по истории). */
.pb--held { background: none; opacity: 0.75; }
.pill__note { margin-left: 6px; font-weight: 500; opacity: 0.8; }

/* ---------- «Текущий статус» по моделям ---------- */
.legend-problems { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 var(--s4) var(--s2); }
.mgroup { border-bottom: 1px solid var(--border); }
.mgroup:last-child { border-bottom: 0; }
.mrow {
  display: grid; grid-template-columns: auto minmax(0, max-content) minmax(0, 1fr) auto;
  align-items: center; gap: var(--s2); padding: var(--s2) var(--s4); cursor: pointer; list-style: none;
}
.mrow::-webkit-details-marker { display: none; }
.mrow:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }
.mrow:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.mrow__name { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow__badges { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.mrow__dur { color: var(--muted); font-size: 12px; white-space: nowrap; }
.mgroup > .status-list { padding: 0 var(--s4) var(--s2) calc(var(--s4) + 14px); }
@media (max-width: 640px) {
  .mrow { grid-template-columns: auto minmax(0, 1fr); }
  .mrow__badges, .mrow__dur { grid-column: 2; }
}
.pb-toggle { all: unset; cursor: pointer; border-radius: 999px; }
.pb-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.pb-toggle[aria-pressed="true"] .pb { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); border-style: solid; }
.mgroup__link { display: inline-block; margin: 0 var(--s4) var(--s1) calc(var(--s4) + 14px); font-size: 12.5px; color: var(--accent); text-decoration: none; }
.mgroup__link:hover { text-decoration: underline; }
.mgroup__who { margin-left: var(--s1); color: var(--muted); font-size: 12px; }

/* ---------- всплывающие подсказки (tooltip.js) ---------- */
.tip {
  position: fixed; z-index: 1000; max-width: min(360px, calc(100vw - 16px));
  padding: 7px 10px; border-radius: 8px; pointer-events: none;
  background: color-mix(in srgb, var(--text) 92%, var(--surface)); color: var(--surface);
  box-shadow: var(--shadow-pop); font-size: 12.5px; line-height: 1.45;
  animation: fade-in 120ms var(--ease);
}
.tip[hidden] { display: none; }
.tip__title { font-weight: 600; margin-bottom: 2px; }
.tip__line + .tip__line { margin-top: 2px; }

/* ---------- связь (проверка канала) и маршрут ---------- */
.hs__probes { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hs__probe {
  all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
  padding: 0 7px; border-radius: 999px; border: 1px solid var(--border); line-height: 20px;
}
.hs__probe:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.hs__probe:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.hs__pdot { width: 7px; height: 7px; border-radius: 50%; background: var(--sev-info); flex: none; }
.hs__probe.is-ok .hs__pdot { background: var(--sev-ok); }
.hs__probe.is-warn .hs__pdot { background: var(--sev-minor); }
.hs__probe.is-fail .hs__pdot { background: var(--sev-critical); }
.hs__probe.is-fail .hs__val { color: var(--sev-critical-text); }
.hs__probe.is-warn .hs__val { color: var(--sev-minor-text); }
.hs__plbl { color: var(--text-2); }
.hs__route {
  flex-basis: 100%; margin-top: var(--s2); padding: var(--s2) var(--s3);
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.hs__route[hidden] { display: none; }
.hs__rhead { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); }
.hs__rclose { all: unset; cursor: pointer; font-size: 18px; line-height: 1; padding: 0 4px; color: var(--muted); }
.hs__rclose:focus-visible { outline: 2px solid var(--focus); }
.hs__rnote { color: var(--muted); font-size: 12px; margin: 2px 0 4px; }
.hs__hops { margin: 0; padding: 0; list-style: none; font-variant-numeric: tabular-nums; }
.hs__hop { display: grid; grid-template-columns: 2.2em minmax(0, 14em) 5.5em auto; gap: var(--s2); font-size: 12.5px; }
.hs__hop.is-silent .hs__hip { color: var(--muted); }
.hs__hop.is-reached .hs__hip { font-weight: 600; }
.hs__httl, .hs__hrtt { color: var(--muted); text-align: right; }
.hs__hmark { color: var(--sev-ok-text); font-size: 11.5px; }

/* ---------- сводка по уровням: причины ---------- */
.summary-reasons { display: flex; flex-wrap: wrap; gap: 4px 8px; }
.summary-reason { display: inline-flex; align-items: center; gap: 3px; }
.summary-reason__n { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 12px; }

.summary-level td { border-bottom: 0; padding-bottom: 2px; }
.summary-reasons-row td { padding-top: 0; white-space: normal; }

/* ---------- Вкладки видов (Обзор · Ковёр · Карта) ---------- */
.views { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.views__tab {
  text-decoration: none; color: var(--text-2); font-size: 13px; font-weight: 550; padding: 4px 10px; border-radius: 7px;
  transition: color var(--t) ease, background-color var(--t) ease;
}
.views__tab:hover { color: var(--text); }
.views__tab[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
@media (max-width: 720px) { .views__tab { padding: 4px 7px; font-size: 12.5px; } }

.btn {
  display: inline-flex; align-items: center; gap: var(--s2); height: 32px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; font-weight: 550;
  cursor: pointer; transition: background-color var(--t) ease;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--text); color: var(--surface); border-color: var(--text); }
.btn--primary:hover { background: var(--text); opacity: 0.9; }
.btn:disabled { opacity: 0.55; cursor: default; }

/* ---------- Ковёр ---------- */
.carpet-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
.carpet-note { color: var(--muted); font-size: 12.5px; margin-left: auto; }
.carpet-legend { display: flex; flex-wrap: wrap; gap: var(--s3); font-size: 12.5px; color: var(--text-2); }
.lg { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.lg__sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; position: static; }
.carpet-card { padding: var(--s2); }
.carpet { position: relative; width: 100%; min-height: 380px; }
.carpet .skel--block { position: absolute; inset: 0; border-radius: var(--radius-sm); }
.cs { position: absolute; box-sizing: border-box; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface-2); }
.cs--match { outline: 2px solid var(--accent); outline-offset: -1px; }
.cs__head {
  position: absolute; left: 0; right: 0; top: 0; height: 18px; padding: 0 6px; display: flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 650; color: var(--text-2); overflow: hidden; white-space: nowrap; cursor: default;
}
.cs__name { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.cs__count { color: var(--muted); font-weight: 550; font-variant-numeric: tabular-nums; }
.cs__bad { flex: none; min-width: 14px; height: 14px; padding: 0 3px; border-radius: 7px; font-size: 10px; line-height: 14px; text-align: center; color: #fff; font-variant-numeric: tabular-nums; }
.cs__bad--critical { background: var(--sev-critical); }
.cs__bad--major { background: var(--sev-major); }
.cs__bad--minor { background: var(--sev-minor); color: #3f2d00; }
.cs__bad--private { background: var(--sev-private); }
.ct {
  position: absolute; box-sizing: border-box; border-radius: 3px; overflow: hidden; display: flex; align-items: center; justify-content: center;
  text-decoration: none; padding: 1px 3px; transition: background-color 400ms ease, opacity var(--t) ease, filter var(--t) ease;
}
.ct[href]:hover { filter: brightness(1.12); outline: 2px solid var(--text); outline-offset: -1px; z-index: 1; }
.ct:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; z-index: 1; }
.ct { padding: 1px 2px; }
/* Кегль задаётся из JS (fitLabel): ник помещается целиком, без многоточия. */
.ct__name { font-weight: 600; line-height: 1.15; white-space: nowrap; overflow: hidden; max-width: 100%; text-align: center; letter-spacing: -0.01em; }
.ct--two .ct__name { white-space: pre; }
.ct--critical { background: var(--sev-critical); color: #fff; }
.ct--major { background: var(--sev-major); color: #fff; }
.ct--minor { background: var(--sev-minor); color: #3f2d00; }
.ct--ok { background: color-mix(in srgb, var(--sev-ok) 78%, #000); color: #fff; }
.ct--offline { background: var(--surface-3); color: var(--muted); background-image: repeating-linear-gradient(135deg, transparent 0 5px, color-mix(in srgb, var(--border-strong) 60%, transparent) 5px 6px); }
.ct--private { background: color-mix(in srgb, var(--sev-private) 82%, #000); color: #fff; }
/* Ещё не проверена (batch): нейтральная плитка без штриховки «не в эфире». */
.ct--pending { background: var(--surface-3); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--muted); background-image: repeating-linear-gradient(90deg, transparent 0 7px, color-mix(in srgb, var(--muted) 18%, transparent) 7px 8px); }
.ct--dim { opacity: 0.18; }
:root[data-theme="dark"] .ct--ok { background: color-mix(in srgb, var(--sev-ok) 55%, #000); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ct--ok { background: color-mix(in srgb, var(--sev-ok) 55%, #000); } }
:root[data-theme="dark"] .ct--private { background: color-mix(in srgb, var(--sev-private) 50%, #000); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ct--private { background: color-mix(in srgb, var(--sev-private) 50%, #000); } }

/* ---------- Карта ---------- */
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--s4); align-items: start; }
@media (max-width: 1000px) { .map-layout { grid-template-columns: minmax(0, 1fr); } }
.map-card { padding: var(--s3); display: grid; gap: var(--s2); }
.map-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
.map-tools .segmented { margin-left: auto; }
.map { position: relative; width: 100%; aspect-ratio: 2 / 1; min-height: 300px; border-radius: var(--radius-sm); overflow: hidden; background: var(--map-sea); touch-action: none; cursor: grab; }
.map.is-dragging { cursor: grabbing; }
.map svg { display: block; width: 100%; height: 100%; }
.map-hint { margin: 0; color: var(--muted); font-size: 12px; }
.map-geoip--warn { color: var(--sev-minor-text); font-weight: 600; }
.mp-land { fill: var(--map-land); stroke: var(--map-border); stroke-width: 0.6; vector-effect: non-scaling-stroke; }
.mp-grat { fill: none; stroke: var(--map-grid); stroke-width: 0.5; vector-effect: non-scaling-stroke; }
.mp-arc { fill: none; stroke-linecap: round; vector-effect: non-scaling-stroke; opacity: 0.75; }
.mp-route { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.mp-hop { fill: var(--surface); stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.mp-node { fill: var(--text); stroke: var(--surface); stroke-width: 2; vector-effect: non-scaling-stroke; }
.mp-studio { stroke: var(--surface); stroke-width: 1.5; vector-effect: non-scaling-stroke; cursor: pointer; }
.mp-studio:hover, .mp-studio.is-active { stroke: var(--text); stroke-width: 2.5; }
.mp-label { font-weight: 600; fill: var(--text); paint-order: stroke; stroke: var(--surface); stroke-linejoin: round; pointer-events: none; } /* размер и обводка — атрибутами, в единицах карты */
.mp--critical { fill: var(--sev-critical); }
.mp--major { fill: var(--sev-major); }
.mp--minor { fill: var(--sev-minor); }
.mp--ok { fill: var(--sev-ok); }
.mp--private { fill: var(--sev-private); }
.mp--pending { fill: var(--muted); }
.mp-arc.mp--critical { stroke: var(--sev-critical); fill: none; }
.mp-arc.mp--major { stroke: var(--sev-major); fill: none; }
.mp-arc.mp--minor { stroke: var(--sev-minor); fill: none; }
.mp-arc.mp--ok { stroke: var(--sev-ok); fill: none; opacity: 0.45; }
.mp-arc.mp--private { stroke: var(--sev-private); fill: none; opacity: 0.45; }
.mp-arc.mp--pending { stroke: var(--muted); fill: none; opacity: 0.45; }
.map-side { padding: var(--s3); display: grid; gap: var(--s2); max-height: calc(100vh - 200px); overflow: hidden; grid-template-rows: auto auto minmax(0, 1fr) auto; }
.map-list { list-style: none; margin: 0; padding: 0; overflow: auto; display: grid; gap: 1px; align-content: start; }
.map-list li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: var(--s2); align-items: center; padding: 5px 6px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.map-list li:hover, .map-list li.is-active { background: var(--hover); }
.map-list__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-list__where { color: var(--muted); font-size: 11.5px; }
.map-list__n { color: var(--text-2); font-variant-numeric: tabular-nums; font-size: 12px; }
.map-list li.map-list__group { display: block; font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding: var(--s2) 6px 2px; cursor: default; }
.map-list li.map-list__group:hover { background: none; }
.map-file { margin: 0; color: var(--muted); font-size: 12px; }
/* Правка справочника студий: кнопка в списке, выбор точки, форма. */
.map-list li.has-edit { grid-template-columns: 10px minmax(0, 1fr) auto auto; }
.map-list__edit {
  border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1;
  padding: 2px 4px; border-radius: 4px;
}
.map-list__edit:hover, .map-list__edit:focus-visible { color: var(--accent); background: var(--surface-3); }
.map-pick {
  display: flex; gap: var(--s2); align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: var(--s2) var(--s3); border-radius: var(--radius-sm); font-size: 13px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--text);
}
.map-pick[hidden] { display: none; }
.map.is-picking { cursor: crosshair; }
.studio-dlg {
  width: min(560px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); padding: 0; box-shadow: var(--shadow-pop);
}
.studio-dlg::backdrop { background: rgba(0, 0, 0, 0.35); }
.studio-form { display: grid; gap: var(--s3); padding: var(--s4); }
.studio-dlg__title { margin: 0; font-size: 16px; font-weight: 650; }
.studio-dlg__sub { margin: -6px 0 0; color: var(--muted); font-size: 12.5px; }
.studio-form__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.studio-form__grid label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12.5px; }
.studio-form__wide { grid-column: 1 / -1; }
.studio-form input, .studio-form select {
  height: 32px; padding: 0 8px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
}
.studio-form input[aria-invalid="true"] { border-color: var(--sev-critical); }
.studio-form__tools { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.studio-dlg__err { margin: 0; color: var(--sev-critical-text); font-size: 13px; }
.studio-dlg__err[hidden] { display: none; }
.studio-dlg__actions { display: flex; gap: var(--s2); justify-content: flex-end; }
.studio-dlg__history { font-size: 12.5px; color: var(--text-2); }
.studio-dlg__history[hidden] { display: none; }
.studio-dlg__history ul { margin: var(--s2) 0 0; padding-left: 18px; display: grid; gap: 4px; }
@media (max-width: 480px) { .studio-form__grid { grid-template-columns: minmax(0, 1fr); } }
:root { --map-sea: #eef3f8; --map-land: #dfe3e8; --map-border: #c3c9d1; --map-grid: #dde5ee; }
:root[data-theme="dark"] { --map-sea: #0f141b; --map-land: #232a33; --map-border: #3a4350; --map-grid: #18202a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --map-sea: #0f141b; --map-land: #232a33; --map-border: #3a4350; --map-grid: #18202a; } }
/* Рядом со вкладками видов на узком экране — только значок бренда. */
@media (max-width: 640px) {
  .brand__text, .crumbs__home { display: none; }
}

/* ---------- PT (passthrough): два видеотрека, маска вторым видеопотоком ---------- */
.pt-badge {
  display: inline-flex; align-items: center; justify-content: center; flex: none; height: 16px; padding: 0 4px; border-radius: 4px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em; line-height: 1; color: var(--pt-text); background: var(--pt-bg);
  border: 1px solid var(--pt-border); vertical-align: 1px; cursor: default;
}
.kpi__label .pt-badge { margin-right: 6px; }
.cell-model__name { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.mrow__who { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }

/* ---------- быстрые ссылки для поддержки (сайт и админка) ---------- */
.ql-group { display: inline-flex; gap: 3px; flex: none; }
.ql {
  font: 600 10px/16px var(--mono); letter-spacing: 0.03em; padding: 0 5px; border-radius: 4px;
  border: 1px solid var(--border-strong); color: var(--text-2); background: var(--surface); text-decoration: none;
  transition: color var(--t) ease, border-color var(--t) ease, background-color var(--t) ease;
}
.ql:hover { color: var(--text); border-color: var(--text-2); background: var(--surface-2); text-decoration: none; }
.ql:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.ql--full { font-family: inherit; font-size: 12px; line-height: 20px; font-weight: 500; letter-spacing: 0; padding: 0 8px; border-radius: 6px; }
.ql--full::after { content: " ↗"; color: var(--muted); }
/* Кнопки копирования ссылок на 2D и VR поток: вид быстрых ссылок, без стрелки «в новой вкладке». */
.ql--copy { cursor: pointer; }
.ql--copy.ql--full::after { content: none; }
.ql--copy[aria-busy="true"] { cursor: progress; }
/* Поток офлайн: aria-disabled + ql--off (не disabled — иначе в Firefox нет подсказки). */
.ql.ql--off { color: var(--muted); border-style: dashed; border-color: var(--border-strong); background: transparent; cursor: not-allowed; }
.ql.ql--err { color: var(--sev-critical-text); border-color: var(--sev-critical); }
.cell-model .ql { opacity: 0.45; transition: opacity var(--t) ease; }
.cell-model .ql:focus-visible, tr:hover .cell-model .ql, tr:focus-within .cell-model .ql { opacity: 1; }
@media (hover: none) { .cell-model .ql { opacity: 1; } }
/* Панель над плиткой ковра: сама плитка — ссылка на карточку, другие ссылки внутрь не вложить. */
.ct-bar {
  position: fixed; z-index: 40; display: flex; align-items: center; gap: var(--s2); padding: 4px 6px 4px 8px;
  border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); box-shadow: var(--shadow-pop);
  font-size: 12.5px; animation: fade-in 120ms var(--ease);
}
.ct-bar[hidden] { display: none; }
.ct-bar__name { font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-bar__card { color: var(--text-2); text-decoration: none; white-space: nowrap; }
.ct-bar__card:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.ct--hit { outline: 3px solid var(--focus); outline-offset: 1px; z-index: 2; animation: pulse 900ms ease 2; }
@media (hover: none) { .ct-bar { display: none; } }
.segmented--sm button { height: 24px; padding: 0 9px; font-size: 12px; }
.legend-problems .segmented { margin-right: var(--s2); }
.ct--pt::after {
  content: ""; position: absolute; top: 0; right: 0; width: 0; height: 0;
  border-style: solid; border-width: 0 12px 12px 0; border-color: transparent var(--pt-mark) transparent transparent;
}

.lg__pt { width: 12px; height: 12px; border-radius: 3px; background: var(--surface-3); position: relative; overflow: hidden; display: inline-block; }
.lg__pt::after { content: ""; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 8px 8px 0; border-color: transparent var(--pt-mark) transparent transparent; }
:root { --pt-text: #5b21b6; --pt-bg: #ede9fe; --pt-border: #c4b5fd; --pt-mark: #6d28d9; }
:root[data-theme="dark"] { --pt-text: #ddd6fe; --pt-bg: #2e1065; --pt-border: #6d28d9; --pt-mark: #c4b5fd; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --pt-text: #ddd6fe; --pt-bg: #2e1065; --pt-border: #6d28d9; --pt-mark: #c4b5fd; } }
.pt-badge--pill { height: 24px; padding: 0 9px; font-size: 12px; border-radius: 999px; letter-spacing: 0.02em; }

/* ---------- Глубокий анализ (страница модели) ---------- */
.deep-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.deep-body { padding: 0 var(--s4) var(--s4); display: grid; gap: var(--s3); }
.deep-state { margin: 0; color: var(--text-2); font-size: 13px; min-height: 18px; }
.deep-state--busy::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%;
  border: 2px solid var(--accent); border-right-color: transparent; animation: spin 0.9s linear infinite; vertical-align: -1px; }
.deep-empty, .deep-note { margin: 0; color: var(--muted); font-size: 13px; }
.deep-report__head { font-size: 13px; color: var(--text-2); }
.deep-verdict { margin: var(--s2) 0 0; font-weight: 650; font-size: 14px; }
.deep-verdict--bad { color: var(--sev-critical-text); }
.deep-verdict--warn { color: var(--sev-minor-text); }
.deep-verdict--ok { color: var(--sev-ok-text); }
.deep-fail { margin: var(--s2) 0 0; color: var(--sev-critical-text); font-size: 13px; }
.deep-findings { list-style: none; margin: var(--s2) 0 0; padding: 0; display: grid; gap: 6px; }
.deep-f { display: grid; grid-template-columns: 84px 170px minmax(0, 1fr); gap: var(--s2); align-items: baseline; font-size: 13px; }
.deep-f__level { font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.03em; }
.deep-f__level--bad { color: var(--sev-critical-text); }
.deep-f__level--warn { color: var(--sev-minor-text); }
.deep-f__level--ok { color: var(--sev-ok-text); }
.deep-f__level--info { color: var(--muted); }
.deep-f__title { font-weight: 600; color: var(--text); }
.deep-f__text { color: var(--text-2); }
@media (max-width: 720px) { .deep-f { grid-template-columns: 76px minmax(0, 1fr); } .deep-f__text { grid-column: 1 / -1; } }
/* Полный лог ffprobe/ffmpeg: свёрнут, разворачивается под выводами. */
.deep-log { margin-top: var(--s2); font-size: 13px; }
.deep-log__summary { cursor: pointer; color: var(--text-2); display: flex; gap: var(--s3); align-items: baseline; flex-wrap: wrap; }
.deep-log__summary::marker { color: var(--muted); }
.deep-log__dl { font-size: 12px; }
.deep-log__text { margin: var(--s2) 0 0; padding: var(--s3); max-height: 420px; overflow: auto; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; color: var(--text-2); }
.deep-history { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.deep-history__item { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  border-radius: 999px; padding: 2px 9px; font: inherit; font-size: 12px; cursor: pointer; }
.deep-history__item.is-active { border-color: var(--accent); color: var(--text); }

/* ---------- Приват: периоды на странице модели ---------- */
.private-periods { display: grid; gap: var(--s2); }
.private-periods[hidden] { display: none; }
.private-periods__list { list-style: none; margin: 0; padding: 0 var(--s3) var(--s3); display: grid; gap: 2px; font-size: 13px; font-variant-numeric: tabular-nums; }
.private-periods__list li { display: flex; gap: var(--s3); align-items: center; padding: 4px 6px; border-radius: 6px; }
.private-periods__list li:hover { background: var(--hover); }
.private-periods__when { color: var(--text); }
.private-periods__dur { color: var(--muted); margin-left: auto; }
.lg__band { width: 12px; height: 12px; border-radius: 3px; display: inline-block; background: var(--band-private); border: 1px solid color-mix(in srgb, var(--sev-private) 45%, transparent); }

/* ---------- Статистика: столбики долей уровней, периоды, разбивка ---------- */
.sbars { display: flex; align-items: flex-end; gap: 3px; height: 190px; padding: 0 var(--s4) var(--s3); overflow-x: auto; }
.sbar {
  flex: 1 1 0; min-width: 14px; max-width: 46px; height: 100%; display: flex; flex-direction: column; align-items: stretch; gap: 4px;
  padding: 0; border: 0; background: none; cursor: pointer; color: var(--muted); font: inherit;
}
.sbar__col {
  flex: 1 1 auto; display: flex; flex-direction: column-reverse; border-radius: 4px 4px 2px 2px; overflow: hidden;
  background: var(--surface-2); outline: 1px solid transparent; outline-offset: 1px; transition: outline-color var(--t) ease;
}
.sbar:hover .sbar__col { outline-color: var(--border-strong); }
.sbar.is-selected .sbar__col { outline: 2px solid var(--accent); }
.sbar:focus-visible { outline: none; }
.sbar:focus-visible .sbar__col { outline: 2px solid var(--focus); }
.sbar.is-empty .sbar__col { background-image: repeating-linear-gradient(135deg, transparent 0 4px, color-mix(in srgb, var(--border-strong) 60%, transparent) 4px 5px); }
.sbar.is-partial .sbar__seg { opacity: 0.7; }
.sbar__seg { display: block; width: 100%; flex: none; }
.sbar--critical { background: var(--sev-critical); }
.sbar--major { background: var(--sev-major); }
.sbar--minor { background: var(--sev-minor); }
.sbar__label { font-size: 11px; line-height: 1; text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sbar.is-selected .sbar__label { color: var(--text); font-weight: 650; }
.sbars__scale { color: var(--muted); }
.table--stats tbody tr[data-start] { cursor: pointer; }
.table--stats tbody tr[data-start]:hover { background: var(--hover); }
.table--stats tbody tr.is-selected { background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.table--stats tbody tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.table--stats .chip { margin-left: var(--s2); }
.table--stats .chip--mode { color: var(--muted); }
.sub-pct { display: inline-block; min-width: 46px; margin-left: 6px; color: var(--muted); font-size: 12px; }
.bd-tools { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.bd-tools .search { flex: 0 1 240px; }
.bd-tools .btn { text-decoration: none; }
.bd-tools .btn[hidden] { display: none; }
.export-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s3); padding: 0 var(--s4) var(--s3); }
.export-form label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12.5px; }
.export-form select, .export-form input {
  height: 32px; padding: 0 8px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
}
/* Диапазон дат статистики: в шапке страницы рядом с единицей периода. */
.stats-head-tools { display: flex; align-items: flex-end; gap: var(--s3); flex-wrap: wrap; justify-content: flex-end; }
.stats-range { display: flex; align-items: flex-end; gap: var(--s2); flex-wrap: wrap; }
.stats-range label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12.5px; }
.stats-range input {
  height: 32px; padding: 0 8px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
}
.stats-range .btn-link[hidden] { display: none; }
.stats-range.is-active input { border-color: var(--accent); }
.table--stats tbody tr.is-total td { font-weight: 600; }
/* Группа «≈ Плохих потоков в час» в разбивке студий: общая шапка и три подколонки. */
.table--stats th.th-group { text-align: center; border-left: 1px solid var(--border); color: var(--muted); font-weight: 600; }
.table--stats th.td-sep, .table--stats td.td-sep { border-left: 1px solid var(--border); }
.table--stats thead tr + tr th .sort { font-weight: 500; }
/* Минимум и максимум периода: те же карточки, значения мельче. */
.peaks-title { margin: var(--s2) 0 0; font-size: 13px; font-weight: 600; color: var(--text-2); }
.kpis--peaks .kpi__value { font-size: 22px; }
@media (max-width: 720px) {
  .stats-head-tools, .stats-range { justify-content: flex-start; }
  .kpis--peaks .kpi__value { font-size: 18px; }
}
.export-note { margin: 0; padding: 0 var(--s4) var(--s4); color: var(--text-2); font-size: 12.5px; line-height: 1.5; }
.stats-notes__list { margin: 0; padding: 0 var(--s4) var(--s4) calc(var(--s4) + 18px); display: grid; gap: 6px; color: var(--text-2); font-size: 13px; line-height: 1.5; }

/* ---------- Единое состояние модели: уровень, доставка, индекс здоровья ---------- */
/* Индекс здоровья — своя нейтральная шкала (не палитра уровней): это не уровень стрима. */
:root { --health-ok: #2563eb; --health-warn: #7c93c9; --health-bad: #94a3b8; }
:root[data-theme="dark"] { --health-ok: #60a5fa; --health-warn: #5b79b8; --health-bad: #64748b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --health-ok: #60a5fa; --health-warn: #5b79b8; --health-bad: #64748b; } }
.meter.health-ok > span { background: var(--health-ok); }
.meter.health-warn > span { background: var(--health-warn); }
.meter.health-bad > span { background: var(--health-bad); }
.model-card__score.health-ok, .model-card__score.health-warn, .model-card__score.health-bad { color: var(--text); }
.model-card__score.health-warn, .model-card__score.health-bad { color: var(--text-2); }
.kpi.health-warn .kpi__value, .kpi.health-bad .kpi__value { color: var(--text-2); }
.model-card__side { cursor: help; }
/* Вне уровня: доставка до монитора и статус API — нейтрально, без цветов важности. */
.sev-group--aside { margin-top: var(--s3); }
.sev-group--aside::before { background: var(--border-strong); }
.sev-group--aside .sev-group__title { color: var(--text-2); font-weight: 600; }
.sev-group--aside .status-item { opacity: 0.9; }
.pill--aside { border-style: dashed; cursor: help; }
.cell-problems { display: inline-flex; align-items: center; gap: 6px; }
.chip--aside { border: 1px dashed var(--border-strong); background: none; color: var(--muted); cursor: help; }
/* Ковёр: новые модели без места в раскладке — полосой над ковром, теми же плитками. */
.carpet-new { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; padding: var(--s2) var(--s3); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.carpet-new[hidden] { display: none; }
.carpet-new__label { font-size: 12.5px; font-weight: 600; color: var(--text-2); cursor: help; white-space: nowrap; }
.carpet-new__tiles { display: flex; flex-wrap: wrap; gap: 3px; }
/* relative, не static: уголок PT (::after) позиционируется от плитки. */
.ct--fresh { position: relative; width: 132px; height: 40px; flex: none; }
/* Страница модели: с четырьмя вкладками шапке тесно — «Все стримы» дублирует вкладку «Обзор» и на средних экранах скрыт. */
.crumbs a { white-space: nowrap; }
@media (max-width: 1360px) { .crumbs a, .crumbs a + .crumbs__sep { display: none; } }
/* Панель ковра — всегда в две строки (легенда; поиск, фильтр, раскладка): появление «Не в эфире», «Приват»
   или пометки о новых моделях не переносит панель и не сдвигает ковёр. */
.carpet-bar .carpet-legend { flex: 1 0 100%; min-height: 20px; }
.carpet-note { white-space: nowrap; }
/* Фильтр по серверу, стране и региону модели и группировка таблицы (attrs-ui.js). Цвета — токены: обе темы. */
.af-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s2); padding: 0 var(--s4) var(--s3); }
.af { position: relative; }
.af__sum {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px 0 11px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  font-size: 12.5px; font-weight: 550; cursor: pointer; list-style: none; user-select: none; white-space: nowrap;
  transition: border-color var(--t) ease, color var(--t) ease, background-color var(--t) ease;
}
.af__sum::-webkit-details-marker { display: none; }
.af__sum::after {
  content: ""; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid currentColor;
  opacity: 0.55; transition: transform var(--t) ease;
}
.af[open] > .af__sum::after { transform: rotate(180deg); }
.af__sum:hover { color: var(--text); border-color: var(--text-2); }
.af__sum:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.af.is-active > .af__sum { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.af__count { min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--accent); color: var(--surface); font-size: 11px; font-weight: 650; line-height: 16px; text-align: center; }
.af__count:empty { display: none; }
.af__pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 220px; max-width: min(340px, calc(100vw - 32px));
  max-height: 300px; overflow: auto; padding: 4px; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); animation: fade-in 120ms var(--ease);
}
.af__pop--end { left: auto; right: 0; }
.af__list { display: grid; }
.af__opt { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--s2); padding: 5px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text); }
.af__opt:hover { background: var(--hover); }
.af__opt input { margin: 0; accent-color: var(--accent); }
.af__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.af__n { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.af__empty { padding: 6px 8px; color: var(--muted); font-size: 12.5px; }
.af__chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.af__chips:empty { display: none; }
.af__chip {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer; font: inherit; font-size: 11.5px; line-height: 20px;
  color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.af__chip:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.af__chip:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.af__x { font-size: 14px; line-height: 1; opacity: 0.75; }
.af__note { color: var(--muted); font-size: 12px; }
.af__note[hidden] { display: none; }
/* Открытый список не обрезается краем карточки (у карточки overflow: hidden ради скруглений). */
.card:has(.af[open]) { overflow: visible; }
.gsel { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.gsel__select {
  height: 28px; padding: 0 6px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 12.5px;
}
.gsel__select:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.table--streams tbody tr.group-row { cursor: default; }
.table--streams tbody tr.group-row > th {
  padding-top: 7px; padding-bottom: 7px; background: var(--surface-2); text-align: left;
  font-size: 12.5px; font-weight: 600; color: var(--text); border-bottom-color: var(--border-strong);
}
.group-row__in { display: inline-flex; align-items: center; gap: var(--s3); }
.group-row__n { color: var(--muted); font-weight: 500; }
.group-row__sev { display: inline-flex; align-items: center; gap: 5px; color: var(--text-2); font-variant-numeric: tabular-nums; cursor: help; }
/* Ковёр: выбор блоков и фильтр по атрибутам — во второй строке панели, рядом с PT (классы обзора). */
.carpet-bar .af-bar { padding: 0; }
