:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --s5: #e87ba4;
  --s6: #008300;
  --s7: #4a3aa7;
  --s8: #e34948;
  --good: #0ca30c;
  --good-ink: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --accent: #2a78d6;
  --wash: rgba(42, 120, 214, 0.08);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #222220;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --good-ink: #0ca30c;
    --accent: #3987e5;
    --wash: rgba(57, 135, 229, 0.12);
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #222220;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --good-ink: #0ca30c;
  --accent: #3987e5;
  --wash: rgba(57, 135, 229, 0.12);
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
h1 { font-size: 20px; margin: 0; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 600; color: var(--ink-2); }

/* ---------- кнопки и поля ---------- */
.btn {
  font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  padding: 7px 14px; border-radius: 8px; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; min-width: 0;
}
input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: grid; gap: 4px; color: var(--ink-2); font-size: 13px; }

/* ---------- вход ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 340px; display: grid; gap: 14px; padding: 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
}
.err { color: var(--critical); margin: 0; min-height: 1em; }
.brand { font-weight: 700; font-size: 16px; display: flex; gap: 8px; align-items: center; }
.brand-mark { color: var(--accent); }

/* ---------- каркас ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 12px;
  background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 16px;
}
.side .brand { padding: 0 8px; }
nav { display: grid; gap: 2px; }
nav .sec { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 4px; }
nav a {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; color: var(--ink-2);
}
nav a:hover { background: var(--surface-2); text-decoration: none; }
nav a.active { background: var(--wash); color: var(--ink); font-weight: 600; }
nav a .dot { margin-left: auto; }
.side-foot { margin-top: auto; display: flex; gap: 6px; padding: 0 4px; }
.main { min-width: 0; }
.top {
  display: flex; align-items: center; gap: 12px; padding: 16px 28px;
  position: sticky; top: 0; background: var(--page); z-index: 5; border-bottom: 1px solid var(--border);
}
.top-right { margin-left: auto; font-size: 12px; }
.menu-btn { display: none; }
.view { padding: 22px 28px 60px; display: grid; gap: 20px; max-width: 1500px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 20; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .menu-btn { display: inline-block; }
  .top { padding: 12px 16px; }
  .view { padding: 16px 16px 60px; }
}

/* ---------- блоки ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px;
  box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head .right { margin-left: auto; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
@media (max-width: 520px) { .g2, .g3 { grid-template-columns: 1fr; } }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.tile .label { color: var(--ink-2); font-size: 12.5px; }
.tile .value { font-size: 26px; font-weight: 650; margin-top: 2px; line-height: 1.2; }
.tile .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; border: 0; background: var(--surface); color: var(--ink-2); padding: 5px 11px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--wash); color: var(--ink); font-weight: 600; }

/* ---------- статусы ---------- */
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap; }
.st::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.st.good::before { background: var(--good); }
.st.warn::before { background: var(--warning); }
.st.serious::before { background: var(--serious); }
.st.crit::before { background: var(--critical); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.good { background: var(--good); } .dot.warn { background: var(--warning); } .dot.crit { background: var(--critical); }

.alert-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); align-items: start; }
.alert-row:first-child { border-top: 0; }
.alert-row .txt { white-space: pre-line; word-break: break-word; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; }
.badge.crit { color: var(--critical); border-color: currentColor; }
.badge.warn { color: #b77a00; border-color: currentColor; }
.badge.ok { color: var(--good-ink); border-color: currentColor; }
.badge.info { color: var(--ink-2); }
:root[data-theme="dark"] .badge.warn { color: var(--warning); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge.warn { color: var(--warning); } }

/* ---------- серверы ---------- */
.srv-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.srv-head a { color: var(--ink); font-weight: 650; }
.srv-head .muted { margin-left: auto; font-size: 12px; }
.meter { display: grid; grid-template-columns: 58px 1fr 92px; gap: 10px; align-items: center; margin: 7px 0; font-size: 12.5px; }
.meter .bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.meter .fill { height: 100%; border-radius: 4px; background: var(--s1); }
.meter .fill.warn { background: var(--warning); }
.meter .fill.crit { background: var(--critical); }
.meter .num { color: var(--ink-2); }

/* ---------- таблицы ---------- */
.tbl-wrap { overflow-x: auto; margin: 0 -4px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--wash); }
td.path { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.ua { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.clickable { cursor: pointer; }

/* ---------- графики ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .cross { stroke: var(--axis); stroke-width: 1; }
.chart .hit { fill: transparent; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }

.tip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,.18); min-width: 120px;
}
.tip .t { color: var(--ink-2); margin-bottom: 4px; }
.tip .r { display: flex; align-items: center; gap: 8px; }
.tip .r i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.tip .r b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.note { font-size: 12.5px; color: var(--ink-2); }
.pill { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); font-size: 12px; margin: 1px 2px 1px 0; }
.err-box { color: var(--critical); font-size: 12.5px; }
