/* Мониторинг 1С — панель.
   Оформление «пульт»: спокойные поверхности с волосяной рамкой, плотная сетка, цвет только там,
   где он что-то значит. На телефоне — одна колонка и нижнее меню, на широком экране — боковое
   меню и сетка во всю ширину. В Telegram поверхности и текст берутся из его темы.
   Цвета рядов и статусов — собственные, проверенные на различимость; от темы они не зависят. */
:root {
  color-scheme: light;

  --page: var(--tg-theme-secondary-bg-color, #f3f4f7);
  --surface: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --surface-2: #f1f2f6;
  --surface-3: #e9ebf0;
  --text: var(--tg-theme-text-color, #0d1017);
  --text-2: #555b68;
  --muted: #8b909c;
  --grid: #e7e9ef;
  --axis: #cbcfd9;
  --border: rgba(13, 16, 23, 0.09);
  --border-2: rgba(13, 16, 23, 0.16);
  --hover: rgba(13, 16, 23, 0.045);
  --accent: var(--tg-theme-button-color, #2a6fdb);
  --accent-ink: var(--tg-theme-button-text-color, #ffffff);
  --accent-wash: rgba(42, 111, 219, 0.10);
  --shadow: 0 0 0 1px var(--border), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-pop: 0 0 0 1px var(--border), 0 12px 32px rgba(16, 24, 40, 0.14);

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-other: #b5b3aa;
  --series-0: var(--series-other);
  --track: #dbe8fa;

  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-text: #006300;
  --warning-text: #7a5200;
  --critical-text: #a32222;
  --good-wash: rgba(12, 163, 12, 0.11);
  --warning-wash: rgba(250, 178, 25, 0.18);
  --critical-wash: rgba(208, 59, 59, 0.10);

  --radius: 14px;
  --radius-s: 10px;
  --gap: 12px;
  --nav-h: 62px;
  --side-w: 0px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@supports (color: color-mix(in srgb, red, blue)) {
  :root {
    --surface-2: color-mix(in srgb, var(--text) 4.5%, var(--surface));
    --surface-3: color-mix(in srgb, var(--text) 8%, var(--surface));
    --text-2: color-mix(in srgb, var(--text) 66%, var(--surface));
    --muted: color-mix(in srgb, var(--text) 46%, var(--surface));
    --grid: color-mix(in srgb, var(--text) 8%, var(--surface));
    --axis: color-mix(in srgb, var(--text) 20%, var(--surface));
    --border: color-mix(in srgb, var(--text) 10%, transparent);
    --border-2: color-mix(in srgb, var(--text) 18%, transparent);
    --hover: color-mix(in srgb, var(--text) 5%, transparent);
    --accent-wash: color-mix(in srgb, var(--accent) 11%, transparent);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: var(--tg-theme-secondary-bg-color, #0b0d12);
  --surface: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #14171e));
  --text: var(--tg-theme-text-color, #f3f5f9);
  --shadow: 0 0 0 1px var(--border);
  --shadow-pop: 0 0 0 1px var(--border-2), 0 16px 40px rgba(0, 0, 0, 0.5);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-other: #5a5955;
  --track: #1c3f6e;
  --good-text: #3fce3f;
  --warning-text: #fab219;
  --critical-text: #f08080;
  --good-wash: rgba(12, 163, 12, 0.18);
  --warning-wash: rgba(250, 178, 25, 0.16);
  --critical-wash: rgba(208, 59, 59, 0.22);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: var(--tg-theme-secondary-bg-color, #0b0d12);
    --surface: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #14171e));
    --text: var(--tg-theme-text-color, #f3f5f9);
    --shadow: 0 0 0 1px var(--border);
    --shadow-pop: 0 0 0 1px var(--border-2), 0 16px 40px rgba(0, 0, 0, 0.5);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-other: #5a5955;
    --track: #1c3f6e;
    --good-text: #3fce3f;
    --warning-text: #fab219;
    --critical-text: #f08080;
    --good-wash: rgba(12, 163, 12, 0.18);
    --warning-wash: rgba(250, 178, 25, 0.16);
    --critical-wash: rgba(208, 59, 59, 0.22);
  }
}
/* Запасные значения для старых движков без color-mix: тёмная тема. */
@supports not (color: color-mix(in srgb, red, blue)) {
  :root[data-theme="dark"] {
    --surface-2: #1c2028;
    --surface-3: #252a34;
    --text-2: #b6bac4;
    --muted: #8a8f9a;
    --grid: #232832;
    --axis: #3a3f4a;
    --border: rgba(255, 255, 255, 0.09);
    --border-2: rgba(255, 255, 255, 0.16);
    --hover: rgba(255, 255, 255, 0.06);
    --accent-wash: rgba(57, 135, 229, 0.16);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
[hidden] { display: none !important; }

body {
  background: var(--page);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

#app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 14px calc(var(--nav-h) + var(--safe-b) + 28px);
}

h1 { font-size: 19px; line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 15.5px; line-height: 1.3; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h3 { font-size: 14px; margin: 0; font-weight: 600; }
p { margin: 0; }
.sub { color: var(--text-2); font-size: 13px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- шапка ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 -14px 8px;
  padding: 12px 14px 10px;
  background: var(--page);
}
@supports (backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px)) {
  .top {
    background: color-mix(in srgb, var(--page) 84%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    backdrop-filter: saturate(1.4) blur(14px);
  }
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-text { min-width: 0; }
.brand-text .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: var(--accent-wash);
}
.brand-mark.ok { color: var(--good-text); background: var(--good-wash); }
.brand-mark.warn { color: var(--warning-text); background: var(--warning-wash); }
.brand-mark.crit { color: var(--critical-text); background: var(--critical-wash); }
.brand-mark svg { width: 19px; height: 19px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.icon-btn {
  width: 38px;
  height: 38px;
  flex: none;
  border: 0;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--border);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--text-2);
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.spin svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.filters {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 1px 1px 2px;
}
.filters::-webkit-scrollbar { display: none; }
.seg { display: inline-flex; flex: none; background: var(--surface-2); border-radius: 10px; padding: 3px; box-shadow: inset 0 0 0 1px var(--border); }
.seg button {
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 7px;
  cursor: pointer;
  min-height: 30px;
  white-space: nowrap;
  transition: color 0.12s, background 0.12s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgba(0, 0, 0, 0.08); }
.seg.wide { display: flex; }
.seg.wide button { flex: 1 1 0; }

/* Панель фильтров внутри раздела: переключатели, выпадающие списки, поиск. */
.filterbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filterbar .grow { flex: 1 1 auto; }
.select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: 10px;
  min-height: 36px;
  padding: 6px 30px 6px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M6 8l4 4 4-4' fill='none' stroke='%23888e9b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center / 16px;
  box-shadow: inset 0 0 0 1px var(--border);
  cursor: pointer;
  max-width: 100%;
}
.search {
  border: 0;
  border-radius: 10px;
  min-height: 36px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  min-width: 0;
  width: 220px;
  max-width: 100%;
}
.search::placeholder { color: var(--muted); }
.toggle-chip {
  border: 0;
  border-radius: 999px;
  min-height: 32px;
  padding: 4px 12px 4px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}
.toggle-chip i { width: 9px; height: 9px; border-radius: 3px; background: var(--series-other); flex: none; }
.toggle-chip[aria-pressed="true"] { color: var(--text); background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--border-2); }
.toggle-chip[aria-pressed="false"] { opacity: 0.62; }
.toggle-chip[aria-pressed="false"] i { background: var(--axis) !important; }

/* ---------- период: быстрые варианты и «свой период» ---------- */
.range { display: inline-flex; gap: 6px; align-items: center; flex: none; }
.range-btn {
  border: 0;
  border-radius: 10px;
  min-height: 36px;
  padding: 5px 12px 5px 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}
.range-btn .ic { width: 16px; height: 16px; }
.range-btn:hover { color: var(--text); }
.range-btn.on { color: var(--accent); background: var(--accent-wash); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent); }
.range-panel {
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  display: grid;
  gap: 10px;
}
.range-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.range-fields { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.range-fields .field-row { margin-top: 0; flex: 1 1 200px; }
.range-actions { display: flex; gap: 8px; }
.field.sm { min-height: 38px; padding: 7px 10px; font-size: 14px; }

/* ---------- схема взаимоблокировки ---------- */
.dl-graph-wrap { overflow-x: auto; }
.dl-graph { display: block; max-width: none; height: auto; }
.dl-graph .dl-node rect { fill: var(--accent-wash); stroke: color-mix(in srgb, var(--series-1) 55%, transparent); stroke-width: 1.2; }
.dl-graph .dl-node.victim rect { fill: var(--critical-wash); stroke: var(--critical); }
.dl-graph .dl-res rect { fill: var(--surface-2); stroke: var(--border-2); stroke-width: 1; }
.dl-graph .dl-node.ghost rect { fill: transparent; stroke-dasharray: 5 4; }
.dl-graph .dl-title { fill: var(--text); font-size: 13px; font-weight: 650; }
.dl-graph .dl-sub { fill: var(--text-2); font-size: 12px; }
.dl-graph .dl-label { fill: var(--text-2); font-size: 12px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.dl-graph .dl-label.wait { fill: var(--series-2); }
.dl-graph .dl-edge { fill: none; stroke-width: 2; }
.dl-graph .dl-edge.hold { stroke: var(--series-1); }
.dl-graph .dl-edge.wait { stroke: var(--series-2); stroke-dasharray: 6 4; }
.dl-graph .dl-arrow.hold { fill: var(--series-1); }
.dl-graph .dl-arrow.wait { fill: var(--series-2); }

/* ---------- строка текущей операции ---------- */
.ticker {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  width: 100%;
  border: 0;
  text-align: left;
  margin-bottom: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  background: var(--accent-wash);
  color: var(--text);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.ticker.done { background: var(--good-wash); }
.ticker.failed { background: var(--critical-wash); }
.ticker.waiting { background: var(--warning-wash); }
.ticker .t-ico { flex: none; display: grid; place-items: center; width: 18px; height: 18px; }
.ticker .t-main { min-width: 0; flex: 1 1 auto; display: flex; gap: 8px; align-items: baseline; }
.ticker .t-title { font-weight: 650; font-size: 13.5px; white-space: nowrap; flex: none; }
.ticker .t-text { color: var(--text-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ticker .t-time { flex: none; font-variant-numeric: tabular-nums; font-weight: 650; font-size: 13px; }
.ticker.running::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 40%;
  background: var(--accent);
  border-radius: 2px;
  animation: run 1.6s ease-in-out infinite;
}
@keyframes run { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }

/* ---------- меню: внизу на телефоне, сбоку на широком экране ---------- */
.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  padding: 6px 8px calc(6px + var(--safe-b));
  background: var(--surface);
  box-shadow: 0 -1px 0 var(--border);
}
@supports (backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px)) {
  .nav {
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    -webkit-backdrop-filter: saturate(1.5) blur(18px);
    backdrop-filter: saturate(1.5) blur(18px);
  }
}
.nav-brand, .nav-foot, .nav-label { display: none; }
.nav-inner { display: flex; width: 100%; max-width: 600px; }
.nav-item {
  flex: 1 1 0;
  min-width: 0;
  border: 0;
  background: none;
  padding: 5px 2px 3px;
  border-radius: 10px;
  display: grid;
  justify-items: center;
  gap: 2px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
}
.nav-item .ic { width: 22px; height: 22px; }
.nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.nav-item[aria-current="page"] { color: var(--accent); }
.nav-item:active { background: var(--hover); }
.nav-badge {
  position: absolute;
  top: 0;
  left: calc(50% + 6px);
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--critical);
  color: #fff;
  font-size: 11px;
  line-height: 17px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---------- карточки и сетка ---------- */
.stack { display: grid; gap: var(--gap); min-width: 0; grid-template-columns: minmax(0, 1fr); }
/* Появление играет только при переходе в раздел: при обновлении данных страница не мигает. */
#view.enter > .stack { animation: rise 0.2s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.grid-2 { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.cols { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); align-items: start; }
.cols > * { min-width: 0; }
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}
.card.inset { background: var(--surface-2); box-shadow: none; border-radius: 12px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head .sub { margin-top: 2px; }
.card-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.section-title { margin: 14px 4px 2px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.section-label {
  margin: 12px 4px 0;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

/* ---------- состояние: строка вместо плаката ---------- */
.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  padding: 14px 16px 14px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.banner::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--axis); }
.banner.ok::before { background: var(--good); }
.banner.warn::before { background: var(--warning); }
.banner.crit::before { background: var(--critical); }
.banner .b-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--surface-2); }
.banner.ok .b-ico { background: var(--good-wash); }
.banner.warn .b-ico { background: var(--warning-wash); }
.banner.crit .b-ico { background: var(--critical-wash); }
.banner .b-ico .status-icon { width: 22px; height: 22px; margin: 0; }
.banner .b-main { min-width: 0; flex: 1 1 260px; }
.banner .b-title { font-size: 18px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; }
.banner .b-text { color: var(--text-2); font-size: 13.5px; margin-top: 3px; overflow-wrap: anywhere; }

.kpis { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 13px 14px; min-width: 0; position: relative; }
.kpi .k-label { color: var(--text-2); font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .k-value { font-size: 24px; line-height: 1.15; font-weight: 700; letter-spacing: -0.025em; margin-top: 5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .k-value small { font-size: 13px; font-weight: 600; color: var(--text-2); letter-spacing: 0; margin-left: 3px; }
.kpi .k-note { color: var(--muted); font-size: 12px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi.warn .k-value { color: var(--warning-text); }
.kpi.crit .k-value { color: var(--critical-text); }
.kpi .spark-mini { position: absolute; right: 12px; top: 12px; width: 72px; height: 26px; opacity: 0.9; }
.kpi .spark-mini svg { width: 100%; height: 100%; display: block; }

/* Прежний большой блок оставлен для совместимости: теперь это та же строка состояния. */
.hero-card { border-radius: var(--radius); padding: 16px; background: var(--surface); box-shadow: var(--shadow); }
.hero-main { display: flex; align-items: center; gap: 16px; }
.hero-state { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 650; color: var(--text-2); }
.hero-state svg { width: 16px; height: 16px; }
.hero-title { font-size: 20px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.hero-sub { font-size: 13.5px; color: var(--text-2); margin-top: 4px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.hero-stat { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.hero-stat b { display: block; font-size: 18px; line-height: 1.2; font-weight: 700; white-space: nowrap; }
.hero-stat span { display: block; font-size: 12px; color: var(--text-2); margin-top: 1px; }

/* ---------- кольцевые индикаторы ---------- */
.ring { position: relative; width: 76px; height: 76px; flex: none; }
.ring svg { width: 100%; height: 100%; display: block; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; stroke-linecap: round; }
.ring .trk { stroke: var(--surface-3); }
.ring .arc { stroke: var(--series-1); transition: stroke-dashoffset 0.6s ease; }
.ring.warn .arc { stroke: var(--warning); }
.ring.crit .arc { stroke: var(--critical); }
.ring.good .arc { stroke: var(--good); }
.ring-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.ring.lg { width: 92px; height: 92px; }
.ring.lg .ring-label { font-size: 20px; }
.ring.sm { width: 52px; height: 52px; }
.ring.sm circle { stroke-width: 8; }
.ring.sm .ring-label { font-size: 13px; }
.ring.on-color .trk { stroke: var(--surface-3); }
.ring.on-color .arc { stroke: var(--series-1); }
.gauges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 14px; }
.gauge { display: grid; justify-items: center; gap: 6px; text-align: center; min-width: 0; }
.gauge-name { font-size: 13px; font-weight: 600; }
.gauge-note { font-size: 12px; color: var(--text-2); margin-top: -4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* Показатель сервера: подпись, число, шкала, пояснение. */
.metrics { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 12px; }
.metric { background: var(--surface-2); border-radius: 12px; padding: 11px 12px 12px; min-width: 0; }
.metric .m-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.metric .m-name { color: var(--text-2); font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric .m-value { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.metric .m-value.warn { color: var(--warning-text); }
.metric .m-value.crit { color: var(--critical-text); }
.metric .meter { margin-top: 9px; height: 6px; }
.metric .m-note { color: var(--muted); font-size: 11.5px; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.stat b { display: block; font-size: 17px; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stat span { display: block; font-size: 12px; color: var(--text-2); margin-top: 1px; }
.spark-wide { margin-top: 14px; }
.spark-wide svg { display: block; width: 100%; height: 56px; }
.spark-wide .sp-line { fill: none; stroke: var(--series-1); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.spark-wide .sp-area { fill: var(--series-1); opacity: 0.13; }
.spark-cap { display: flex; justify-content: space-between; color: var(--muted); font-size: 11.5px; margin-top: 3px; gap: 8px; }

.server-head { display: flex; align-items: center; gap: 11px; margin-bottom: 14px; min-width: 0; }
.server-ico { width: 38px; height: 38px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; color: var(--text-2); flex: none; }
.server-head .names { min-width: 0; flex: 1 1 auto; }
.server-head .names .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- статусы: всегда значок + подпись ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 650;
  white-space: nowrap;
  flex: none;
}
.chip svg { width: 14px; height: 14px; flex: none; }
.chip.ok { background: var(--good-wash); color: var(--good-text); }
.chip.warn { background: var(--warning-wash); color: var(--warning-text); }
.chip.crit { background: var(--critical-wash); color: var(--critical-text); }
.chip.info, .chip.off { background: var(--surface-2); color: var(--text-2); }

.status-icon { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.status-icon.ok { color: var(--good); }
.status-icon.warn { color: var(--warning); }
.status-icon.crit { color: var(--critical); }
.status-icon.info, .status-icon.off { color: var(--muted); }

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
  vertical-align: 1px;
  white-space: nowrap;
}

/* ---------- плитки ---------- */
.tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.tiles.wide { grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); }
.tile { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 13px 14px; min-width: 0; }
.tile .label { color: var(--text-2); font-size: 12px; font-weight: 600; display: flex; align-items: center; }
.tile .value { font-size: 24px; line-height: 1.15; font-weight: 700; margin-top: 5px; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; }
.tile .note { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- шкала ---------- */
.meter { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 4px; background: var(--series-1); transition: width 0.4s ease; }
.meter.warn { background: var(--warning-wash); }
.meter.warn > i { background: var(--warning); }
.meter.crit { background: var(--critical-wash); }
.meter.crit > i { background: var(--critical); }
.meter.plain { background: var(--surface-3); }
.meter.plain > i.s0 { background: var(--series-other); }
.meter.plain > i.s2 { background: var(--series-2); }
.meter.plain > i.s3 { background: var(--series-3); }
.meter.plain > i.s4 { background: var(--series-4); }

/* ---------- списки ---------- */
.list { display: grid; }
.row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 11px;
  padding: 12px 0;
  border-top: 1px solid var(--grid);
  min-width: 0;
}
.row:first-child { border-top: 0; padding-top: 2px; }
.row:last-child { padding-bottom: 2px; }
.row-main { min-width: 0; }
.row-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-weight: 650; overflow-wrap: anywhere; }
.row-detail { color: var(--text-2); font-size: 13px; margin-top: 3px; overflow-wrap: anywhere; }
.row-detail.reason { color: var(--critical-text); }
.row-detail.reason.warn { color: var(--warning-text); }
.row-end { display: flex; align-items: center; gap: 8px; }

.bubble { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--text-2); }
.bubble.accent { background: var(--accent-wash); color: var(--accent); }
.bubble.ok { background: var(--good-wash); color: var(--good-text); }
.bubble.warn { background: var(--warning-wash); color: var(--warning-text); }
.bubble.crit { background: var(--critical-wash); color: var(--critical-text); }
.bubble .ic { width: 18px; height: 18px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; color: var(--accent); font-weight: 700; font-size: 13px; background: var(--accent-wash); }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px 16px; margin: 0; }
.kv dt { color: var(--text-2); font-size: 12px; }
.kv dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--grid); }
.setting:first-child { border-top: 0; padding-top: 2px; }
.setting .s-name { font-weight: 600; }
.setting .s-note { color: var(--text-2); font-size: 12.5px; margin-top: 1px; }
.time-input {
  border: 0;
  border-radius: 10px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  padding: 8px 10px;
  min-height: 40px;
  font-variant-numeric: tabular-nums;
}
.switch {
  width: 46px;
  height: 28px;
  flex: none;
  border: 0;
  border-radius: 14px;
  background: var(--axis);
  position: relative;
  cursor: pointer;
  transition: background 0.18s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.18s;
}
.switch[aria-checked="true"] { background: var(--good); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

/* ---------- полоса дней ---------- */
.days { display: flex; gap: 2px; margin-top: 8px; }
.day { flex: 1 1 0; min-width: 0; height: 22px; border: 0; padding: 0; border-radius: 4px; background: var(--surface-2); cursor: default; position: relative; }
.day.full { background: var(--series-1); }
.day.diff { background: var(--series-2); }
.day.log { background: var(--series-3); }
.day.snap { background: transparent; box-shadow: inset 0 0 0 2px var(--axis); }
.day.none::after { content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; background: var(--axis); }
.day:hover, .day:focus-visible { filter: brightness(1.12); }
.days-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 3px; font-variant-numeric: tabular-nums; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--text-2); font-size: 12.5px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.legend i.s1 { background: var(--series-1); }
.legend i.s2 { background: var(--series-2); }
.legend i.s3 { background: var(--series-3); }
.legend i.s4 { background: var(--series-4); }
.legend i.s5 { background: var(--series-5); }
.legend i.s6 { background: var(--series-6); }
.legend i.s7 { background: var(--series-7); }
.legend i.s0 { background: var(--series-other); }
.legend i.line { height: 3px; border-radius: 2px; width: 14px; }
.legend i.snap { box-shadow: inset 0 0 0 2px var(--axis); }
.legend i.none { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.legend b { font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- графики ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .col:hover .mark, .chart .col:focus .mark { filter: brightness(1.12); }
.chart .col:focus { outline: none; }
.chart .value-label { fill: var(--text-2); font-size: 11px; font-weight: 600; }
.chart .f1 { fill: var(--series-1); }
.chart .f2 { fill: var(--series-2); }
.chart .f3 { fill: var(--series-3); }
.chart .f4 { fill: var(--series-4); }
.chart .f5 { fill: var(--series-5); }
.chart .f6 { fill: var(--series-6); }
.chart .f7 { fill: var(--series-7); }
.chart .f0 { fill: var(--series-other); }
.chart .l1 { stroke: var(--series-1); fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .area1 { fill: var(--series-1); opacity: 0.12; }
.chart .dot1 { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .cross { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .band { fill: var(--critical); opacity: 0.10; }
.chart .band.warn { fill: var(--warning); opacity: 0.14; }
.chart .mark-line { stroke: var(--critical); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 28px 12px; }
.st1 { stroke: var(--series-1); } .st2 { stroke: var(--series-2); } .st3 { stroke: var(--series-3); }
.st4 { stroke: var(--series-4); } .st5 { stroke: var(--series-5); } .st6 { stroke: var(--series-6); }
.st7 { stroke: var(--series-7); } .st0 { stroke: var(--series-other); }
.fl1 { fill: var(--series-1); } .fl2 { fill: var(--series-2); } .fl3 { fill: var(--series-3); }
.fl4 { fill: var(--series-4); } .fl5 { fill: var(--series-5); } .fl6 { fill: var(--series-6); }
.fl7 { fill: var(--series-7); } .fl0 { fill: var(--series-other); }
.bg1 { background: var(--series-1); } .bg2 { background: var(--series-2); } .bg3 { background: var(--series-3); }
.bg4 { background: var(--series-4); } .bg5 { background: var(--series-5); } .bg6 { background: var(--series-6); }
.bg7 { background: var(--series-7); } .bg0 { background: var(--series-other); }

.hbar { display: grid; grid-template-columns: minmax(84px, 34%) 1fr auto; gap: 6px 10px; align-items: center; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.hbar .bar { display: flex; gap: 2px; height: 12px; min-width: 0; }
.hbar .bar i { display: block; height: 100%; min-width: 2px; }
.hbar .bar i.s1 { background: var(--series-1); }
.hbar .bar i.s2 { background: var(--series-2); }
.hbar .bar i.s3 { background: var(--series-3); }
.hbar .bar i.s4 { background: var(--series-4); }
.hbar .bar i.s5 { background: var(--series-5); }
.hbar .bar i.s6 { background: var(--series-6); }
.hbar .bar i.s7 { background: var(--series-7); }
.hbar .bar i.s0 { background: var(--series-other); }
.hbar .bar i:first-child { border-radius: 4px 0 0 4px; }
.hbar .bar i:last-child { border-radius: 0 4px 4px 0; }
.hbar .bar i:only-child { border-radius: 4px; }
.hbar .val { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.hbar .sub-row { grid-column: 1 / -1; color: var(--text-2); font-size: 12px; margin: -2px 0 8px; font-variant-numeric: tabular-nums; }

.hbar.stacked { grid-template-columns: 1fr auto; }
.hbar.stacked .name { grid-column: 1 / -1; white-space: normal; overflow-wrap: anywhere; margin-top: 4px; }
.hbar.stacked .sub-row { margin-top: -3px; }

.parts { display: flex; gap: 2px; height: 12px; border-radius: 4px; overflow: hidden; }
.parts i { display: block; height: 100%; min-width: 2px; }
.parts i.s1 { background: var(--series-1); }
.parts i.s2 { background: var(--series-2); }
.parts i.s3 { background: var(--series-3); }
.parts i.s0 { background: var(--series-other); }
.parts i.free { background: var(--surface-3); }

.spark { width: 84px; height: 24px; flex: none; }
.spark path { fill: none; stroke: var(--axis); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }

.tooltip {
  position: fixed;
  z-index: 70;
  max-width: 300px;
  pointer-events: none;
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  box-shadow: var(--shadow-pop);
  padding: 9px 11px;
  font-size: 12.5px;
}
.tooltip .tt-title { color: var(--text-2); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.tooltip .tt-row { display: flex; align-items: center; gap: 14px; justify-content: space-between; }
.tooltip .tt-key { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tooltip .tt-key i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; flex: none; }
.tooltip .tt-val { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 18px);
  transform: translateX(-50%);
  z-index: 80;
  width: max-content;
  max-width: min(440px, calc(100vw - 32px));
  background: #1b1f29;
  color: #fff;
  border-radius: 12px;
  padding: 11px 15px;
  font-size: 14px;
  font-weight: 550;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}
.toast.bad { background: #8e1b1b; }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; margin: 8px -4px 0; padding: 0 4px; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: right; padding: 8px 8px; border-top: 1px solid var(--grid); white-space: nowrap; font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-weight: 650; border-top: 0; font-size: 11.5px; letter-spacing: 0.02em; }
th:first-child, td:first-child { text-align: left; font-weight: 600; position: sticky; left: 0; background: var(--surface); }
tbody tr:hover td { background: var(--hover); }
tbody tr:hover td:first-child { background: color-mix(in srgb, var(--text) 5%, var(--surface)); }

/* ---------- кнопки ---------- */
.link { border: 0; background: none; padding: 6px 4px; color: var(--accent); font-size: 13px; font-weight: 650; cursor: pointer; }
.btn {
  border: 0;
  border-radius: 11px;
  padding: 10px 16px;
  min-height: 44px;
  font-weight: 650;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: filter 0.12s, transform 0.08s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(0.98); }
.btn.ghost { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.btn.danger { background: var(--critical-wash); color: var(--critical-text); }
.btn.sm { min-height: 36px; padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; filter: none; }
.btn .ic { width: 18px; height: 18px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

code, .mono {
  font: 12.5px/1.4 var(--mono);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 2px 6px;
  overflow-wrap: anywhere;
}

/* ---------- экран доступа и пустые состояния ---------- */
.gate { max-width: 440px; margin: 44px auto 0; text-align: center; }
.gate .emoji { font-size: 46px; line-height: 1; margin-bottom: 14px; }
.gate h2 { font-size: 21px; margin-bottom: 8px; }
.gate p { color: var(--text-2); }
.gate .btn { margin-top: 18px; width: 100%; }
.gate .id { margin-top: 16px; font-size: 13px; color: var(--text-2); }
.empty { color: var(--text-2); text-align: center; padding: 22px 12px; }
.loading { opacity: 0.55; transition: opacity 0.15s; }

.skeleton { border-radius: var(--radius); background: var(--surface); height: 120px; position: relative; overflow: hidden; box-shadow: var(--shadow); }
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--hover), transparent);
  animation: sweep 1.2s infinite;
}
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ---------- глубокая аналитика и управление ---------- */
.dot-key { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; flex: none; background: var(--series-other); }
.dot-key.lg { width: 11px; height: 11px; border-radius: 3px; margin: 5px 0 0; }
.dot-key.s1 { background: var(--series-1); } .dot-key.s2 { background: var(--series-2); }
.dot-key.s3 { background: var(--series-3); } .dot-key.s4 { background: var(--series-4); }

.db-link { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-align: left; min-height: 28px; }
.db-link.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.row-btn { width: 100%; border: 0; border-top: 1px solid var(--grid); background: none; font: inherit; color: inherit; text-align: left; cursor: pointer;
  grid-template-columns: auto minmax(0, 1fr) auto; }
.row-btn:first-child { border-top: 0; }
.row-btn:hover { background: var(--hover); }
.row-btn .chev { align-self: center; color: var(--muted); font-size: 22px; line-height: 1; padding-left: 4px; }
.link.back { padding: 2px 0; font-size: 14px; }

.query-text { margin-top: 6px; padding: 8px 10px; border-radius: 9px; background: var(--surface-2); color: var(--text-2);
  font-family: var(--mono); font-size: 11.5px; line-height: 1.45;
  overflow-wrap: anywhere; white-space: pre-wrap; }
/* У обрезанного текста нижний отступ сделан рамкой: иначе в отступе видна верхушка следующей строки. */
.query-text.clamp, .query-text.clamp2 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; padding-bottom: 0; border-bottom: 8px solid var(--surface-2); }
.query-text.clamp { -webkit-line-clamp: 3; }
.query-text.clamp2 { -webkit-line-clamp: 2; }

.role-pick { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; margin-top: 6px; box-shadow: inset 0 0 0 1px var(--border); }
.role-pick button { flex: 1 1 0; border: 0; background: none; border-radius: 7px; min-height: 36px; padding: 6px 8px;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.role-pick button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgba(0, 0, 0, 0.08); cursor: default; }
.role-pick button.armed { background: var(--warning-wash); color: var(--warning-text); }

body.sheet-open { overflow: hidden; }
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-back { position: absolute; inset: 0; background: rgba(6, 8, 12, 0.5); }
.sheet-panel { position: relative; width: 100%; max-width: 580px; max-height: 92vh; overflow-y: auto; background: var(--surface);
  border-radius: 20px 20px 0 0; padding: 8px 16px calc(18px + var(--safe-b)); box-shadow: var(--shadow-pop);
  animation: lift 0.22s ease-out; }
.sheet-panel.wide { max-width: 860px; }
@keyframes lift { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: -8px;
  background: var(--surface); padding: 12px 0 8px; z-index: 1; }
.sheet-head h2 { font-size: 17px; margin: 0; }
.sheet-head .icon-btn span { font-size: 24px; line-height: 1; }
.sheet-body { display: flex; flex-direction: column; gap: 4px; }

.field-row { display: flex; flex-direction: column; gap: 5px; margin-top: 12px; color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.field-row[hidden] { display: none; }
.field { border: 1.5px solid transparent; border-radius: 11px; background: var(--surface-2); color: var(--text); font: inherit;
  font-size: 16px; padding: 11px 13px; min-height: 46px; width: 100%; box-shadow: inset 0 0 0 1px var(--border); }
.field:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: none; }

.choice { display: grid; gap: 8px; margin-top: 4px; }
.choice-item { border: 1.5px solid var(--grid); border-radius: 12px; background: none; padding: 11px 13px; text-align: left; font: inherit;
  color: var(--text); cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.choice-item span { color: var(--text-2); font-size: 12.5px; line-height: 1.4; }
.choice-item[aria-checked="true"] { border-color: var(--accent); background: var(--accent-wash); }

.btn.danger-solid { background: var(--critical); color: #fff; }
.choice-item.small { padding: 9px 12px; }
.choice-item.small span { font-size: 12px; }
.field-label { margin-top: 14px; margin-bottom: 4px; color: var(--text-2); font-size: 12.5px; font-weight: 600; }
textarea.field { resize: vertical; min-height: 128px; line-height: 1.4; font-size: 15px; }
.check-row { display: flex; gap: 10px; align-items: center; margin-top: 14px; font-size: 14px; }
.check-row input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.seg.wrap { flex-wrap: wrap; }
.seg.wrap button { flex: 1 1 30%; }
.svc-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 6px; font-size: 13px; }
.svc-line > span:first-child { min-width: 86px; font-weight: 600; }
.svc-line .muted { color: var(--text-2); font-size: 12.5px; }
.row-detail.mono { font-family: var(--mono); font-size: 11.5px; }
.result { display: flex; gap: 10px; align-items: flex-start; border-radius: 12px; padding: 12px; }
.result.ok { background: var(--good-wash); } .result.warn { background: var(--warning-wash); } .result.crit { background: var(--critical-wash); }
.result .status-icon { margin-top: 1px; }

.steps { display: grid; gap: 12px; margin-top: 6px; }
.step { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.step i { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 2px var(--axis); }
.step.done { color: var(--text-2); }
.step.done i { background: var(--good); box-shadow: none; }
.step.now { color: var(--text); font-weight: 650; }
.step.now i { background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 8%, transparent); } }

/* Лента этапов: вертикальная линия, время и длительность справа, пояснение под названием. */
.steps.timeline { gap: 0; position: relative; }
.steps.timeline .step { align-items: flex-start; padding: 7px 0; position: relative; }
.steps.timeline .step i { margin-top: 4px; position: relative; z-index: 1; }
.steps.timeline .step:not(:last-child)::before { content: ""; position: absolute; left: 5.5px; top: 18px; bottom: -6px; width: 1px; background: var(--axis); }
.steps.timeline .step.done:not(:last-child)::before { background: color-mix(in srgb, var(--good) 55%, var(--axis)); }
.step.bad { color: var(--text); }
.step.bad i { background: var(--critical); box-shadow: none; }
.step-main { flex: 1; min-width: 0; }
.step-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.step-head > span:first-child { min-width: 0; }
.step-time { color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
.step-note { color: var(--muted); font-size: 12.5px; font-weight: 400; margin-top: 2px; overflow-wrap: anywhere; }
.op-clock { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; color: var(--text-2); }
.op-clock b { font-size: 24px; color: var(--text); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.op-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent); border-top-color: var(--accent); animation: spin 0.9s linear infinite; flex: none; }

/* ---------- хроника ---------- */
.feed { display: grid; }
.feed-day { position: sticky; top: 0; z-index: 1; padding: 10px 2px 6px; color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; }
.feed-item {
  display: grid;
  grid-template-columns: 52px 18px minmax(0, 1fr);
  gap: 0 8px;
  width: 100%;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  padding: 0;
  cursor: pointer;
  position: relative;
}
.feed-item:hover .f-body { background: var(--hover); }
.feed-item .f-time { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; padding-top: 11px; text-align: right; }
.feed-item .f-rail { position: relative; }
.feed-item .f-rail::before { content: ""; position: absolute; left: 8.5px; top: 0; bottom: 0; width: 1px; background: var(--grid); }
.feed-item:first-of-type .f-rail::before { top: 14px; }
.feed-item:last-of-type .f-rail::before { bottom: calc(100% - 22px); }
.feed-item .f-dot { position: absolute; left: 3px; top: 13px; width: 12px; height: 12px; border-radius: 50%; background: var(--axis); box-shadow: 0 0 0 3px var(--surface); }
.feed-item.warn .f-dot { background: var(--warning); }
.feed-item.crit .f-dot { background: var(--critical); }
.feed-item.info .f-dot { background: var(--series-1); }
.feed-item.open .f-dot { animation: pulse-dot 1.4s ease-in-out infinite; }
@keyframes pulse-dot { 50% { box-shadow: 0 0 0 3px var(--surface), 0 0 0 7px color-mix(in srgb, var(--critical) 25%, transparent); } }
.feed-item .f-body { padding: 8px 10px 10px; border-radius: 10px; min-width: 0; margin: 2px 0; }
.feed-item .f-title { font-weight: 650; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; overflow-wrap: anywhere; }
.feed-item .f-text { color: var(--text-2); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.feed-item .f-meta { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 6px; }

.facts { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.fact { background: var(--surface-2); border-radius: 10px; padding: 9px 11px; min-width: 0; }
.fact b { display: block; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fact span { display: block; color: var(--text-2); font-size: 11.5px; margin-top: 1px; }

.culprit { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 9px 0; border-top: 1px solid var(--grid); align-items: baseline; }
.culprit:first-child { border-top: 0; padding-top: 2px; }
.culprit .c-name { font-weight: 650; overflow-wrap: anywhere; min-width: 0; }
.culprit .c-val { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.culprit .c-note { grid-column: 1 / -1; color: var(--text-2); font-size: 12.5px; overflow-wrap: anywhere; }
.culprit .c-bar { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; margin-top: 4px; }
.culprit .c-bar i { display: block; height: 100%; background: var(--series-1); border-radius: 2px; }

/* Строка запроса в истории: доля процессора полосой, цифры в ряд. */
.q-row { display: grid; gap: 4px; padding: 12px 0; border-top: 1px solid var(--grid); width: 100%; border-left: 0; border-right: 0; border-bottom: 0;
  background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.q-row:first-child { border-top: 0; padding-top: 2px; }
.q-row:hover { background: var(--hover); }
.q-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.q-share { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 52px; }
.q-nums { display: flex; flex-wrap: wrap; gap: 2px 14px; color: var(--text-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.q-nums b { color: var(--text); font-weight: 650; }

/* ---------- узкие экраны ---------- */
@media (max-width: 520px) {
  .metric { padding: 10px 10px 11px; }
  .metric .m-head { flex-direction: column; align-items: flex-start; gap: 1px; }
  .metric .m-value { font-size: 19px; }
  .ticker { align-items: flex-start; }
  .ticker .t-main { flex-direction: column; gap: 0; }
  .ticker .t-text { white-space: normal; }
}

/* ---------- широкие экраны ---------- */
@media (min-width: 640px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .tiles.wide { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 760px) {
  .sheet { align-items: center; }
  .sheet-panel { border-radius: 18px; padding: 10px 22px 22px; }
  #app { padding-left: 20px; padding-right: 20px; }
  .top { margin: 0 -20px 8px; padding-left: 20px; padding-right: 20px; }
  .feed-item { grid-template-columns: 62px 18px minmax(0, 1fr); }
}

@media (min-width: 1100px) {
  :root { --side-w: 236px; --nav-h: 0px; --gap: 14px; }
  body { font-size: 14px; }
  #app { max-width: none; margin: 0 0 0 var(--side-w); padding: 0 28px 40px; }
  .top { margin: 0 -28px 10px; padding: 16px 28px 12px; }
  .top-row { gap: 20px; }
  h1 { font-size: 21px; }
  .brand-mark { display: none; }
  .filters { margin-top: 12px; flex-wrap: wrap; overflow: visible; }

  .nav {
    top: 0;
    right: auto;
    width: var(--side-w);
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: 18px 12px 14px;
    box-shadow: 1px 0 0 var(--border);
    background: var(--surface);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .nav-brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; min-width: 0; }
  .nav-brand .brand-mark { display: grid; width: 34px; height: 34px; }
  .nav-brand b { display: block; font-size: 14px; line-height: 1.2; letter-spacing: -0.01em; }
  .nav-brand span { display: block; color: var(--muted); font-size: 11.5px; }
  .nav-label { display: block; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; padding: 10px 10px 6px; }
  .nav-inner { flex-direction: column; max-width: none; gap: 2px; }
  .nav-item {
    flex: none;
    display: flex;
    align-items: center;
    justify-items: start;
    gap: 11px;
    padding: 9px 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-2);
    border-radius: 9px;
  }
  .nav-item .ic { width: 19px; height: 19px; }
  .nav-item:hover { background: var(--hover); color: var(--text); }
  .nav-item[aria-current="page"] { background: var(--accent-wash); color: var(--accent); }
  .nav-badge { position: static; margin-left: auto; }
  .nav-foot { display: block; margin-top: auto; padding: 12px 10px 2px; border-top: 1px solid var(--grid); min-width: 0; }
  .nav-foot b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-foot span { display: block; color: var(--muted); font-size: 12px; }

  .toast { bottom: 24px; left: calc(50% + var(--side-w) / 2); }
  .card { padding: 18px; }
  .grid-2 { grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); }
  .cols.c-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols.c-7-5 { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
  .cols.c-5-7 { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
  .cols.c-8-4 { grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); }
  .cols.c-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); }
  .spark-wide svg { height: 72px; }
  .tiles.wide { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .feed-day { position: static; }
}

@media (min-width: 1500px) {
  .cols.c-3w { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Действия с долгим запросом: строка — пояснение слева, кнопка справа; на телефоне кнопка под текстом */
.actions-box { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--critical) 30%, transparent); }
.action-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; align-items: center; padding: 10px 0; border-top: 1px solid var(--grid); }
.action-row:first-of-type { border-top: 0; }
.action-row .btn-row { margin: 0; }
@media (max-width: 600px) { .action-row { grid-template-columns: 1fr; } }

/* «Куда что отправлять»: две группы с назначением */
.route-box { border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; margin-top: 10px; background: var(--surface); }
.route-head { display: flex; gap: 12px; align-items: center; }
.route-current { font-weight: 650; margin-top: 2px; overflow-wrap: anywhere; }
.route-list { margin: 10px 0 4px; padding-left: 18px; color: var(--text-2); font-size: 13px; line-height: 1.5; }
.route-sql { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--grid); }
.route-pick { margin-top: 10px; }
.route-chat { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--grid); }
.route-chat .c-title { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
@media (max-width: 600px) { .route-sql { grid-template-columns: auto minmax(0, 1fr); } .route-sql .btn { grid-column: 2; justify-self: start; } }

/* Текст запроса можно выделить и скопировать долгим нажатием (в Telegram тоже) */
.query-text { -webkit-user-select: text; user-select: text; cursor: text; }
.query-text.clamp { cursor: pointer; }

/* Строка-кнопка в списке (rphost): открывает подробности */
.culprit-btn { width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--grid); cursor: pointer; }
.culprit-btn:hover { background: var(--hover); }

/* Автоматика: порог правила и переключатель рядом */
.auto-rule-ctl { display: flex; align-items: center; gap: 8px; flex: none; }

/* Слоёная диаграмма и опорные линии */
.stack { stroke: none; opacity: 0.85; }
.stack.fl0 { fill: var(--series-0); } .stack.fl1 { fill: var(--series-1); } .stack.fl2 { fill: var(--series-2); }
.stack.fl3 { fill: var(--series-3); } .stack.fl4 { fill: var(--series-4); } .stack.fl5 { fill: var(--series-5); }
.stack.fl7 { fill: var(--series-7); }
.stack-edge { fill: none; stroke: var(--surface); stroke-width: 1.5; }
.ref-line { stroke: var(--text-2); stroke-width: 1.5; stroke-dasharray: 6 4; }
.ref-line.warn { stroke: var(--warning); } .ref-line.crit { stroke: var(--critical); }
.ref-label { font-size: 11px; font-weight: 600; fill: var(--text-2); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.ref-label.warn { fill: var(--warning-text); } .ref-label.crit { fill: var(--critical-text); }

/* Подпись к группе фильтров в шапке (обзор: графики и бэкапы — разные периоды) */
.filter-cap { align-self: center; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-left: 4px; }
.parts .s4, .legend .s4 { background: var(--series-4); }
