:root {
  color-scheme: light;
  --page: #f6f6f3;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --good: #0ca30c;
  --good-ink: #006300;
  --warn: #fab219;
  --warn-ink: #8a5a00;
  --bad: #d03b3b;
  --bad-ink: #b02a2a;
  --good-bg: #e7f5e7;
  --warn-bg: #fdf3dc;
  --bad-bg: #fbe9e9;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 2px 8px rgba(0, 0, 0, .04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242423;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --good-ink: #3cc43c;
    --warn-ink: #fab219;
    --bad-ink: #ef6b6b;
    --good-bg: #13260f;
    --warn-bg: #2d2410;
    --bad-bg: #331616;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #242423; --text: #ffffff; --text-2: #c3c2b7;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10); --accent: #3987e5;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
  --good-ink: #3cc43c; --warn-ink: #fab219; --bad-ink: #ef6b6b;
  --good-bg: #13260f; --warn-bg: #2d2410; --bad-bg: #331616; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- шапка ---------- */
header.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.top-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 20px; height: 56px;
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; text-decoration: none; }
.logo svg { color: var(--bad); }
nav.menu { display: flex; gap: 4px; flex: 1; }
nav.menu a {
  text-decoration: none; padding: 6px 12px; border-radius: 8px; color: var(--text-2);
}
nav.menu a.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
nav.menu a:hover { color: var(--text); }
.top-actions { display: flex; gap: 8px; align-items: center; }

main { max-width: 1200px; margin: 0 auto; padding: 24px 16px 60px; }

/* ---------- кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
  padding: 7px 14px; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad-ink); }
.btn.small { padding: 3px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--text-2); }
label.field small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--axis); border-radius: 8px; background: var(--surface);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 70px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-line { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }

/* ---------- статусы ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600;
  padding: 2px 9px 2px 7px; border-radius: 999px; white-space: nowrap;
}
.badge svg { flex: none; }
.s-ok { background: var(--good-bg); color: var(--good-ink); }
.s-warn { background: var(--warn-bg); color: var(--warn-ink); }
.s-down { background: var(--bad-bg); color: var(--bad-ink); }
.s-unknown, .s-paused { background: var(--surface-2); color: var(--text-2); }

/* ---------- обзор ---------- */
.banner {
  display: flex; align-items: center; gap: 16px; padding: 18px 22px; border-radius: 14px; margin-bottom: 20px;
}
.banner .big { font-size: 22px; font-weight: 700; }
.banner .sub { color: var(--text-2); }
.banner.s-ok .big { color: var(--good-ink); }
.banner.s-down .big { color: var(--bad-ink); }
.banner.s-warn .big { color: var(--warn-ink); }
.banner .icon { flex: none; }

.problems { display: grid; gap: 10px; margin-bottom: 28px; }
.problem {
  display: flex; align-items: center; gap: 14px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--bad);
  border-radius: 10px; box-shadow: var(--shadow);
}
.problem.warn { border-left-color: var(--warn); }
.problem.acked { opacity: .65; }
.acked-box { margin: -14px 0 28px; }
.acked-box summary { cursor: pointer; color: var(--text-2); font-size: 14px; padding: 6px 0; }
.acked-box .problems { margin: 8px 0 0; }
.problem .what { flex: 1; min-width: 0; }
.problem .what b a { text-decoration: none; }
.problem .what b a:hover { text-decoration: underline; }
.problem .msg { color: var(--text-2); }
.problem .dur { color: var(--muted); font-size: 13px; white-space: nowrap; text-align: right; }

.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar h2 { margin: 0; font-size: 18px; flex: 1; }
.toolbar input[type=search] { width: 240px; }

h3.group { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 22px 0 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.tile {
  display: block; text-decoration: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); border-top: 4px solid var(--axis);
}
.tile:hover { border-color: var(--axis); }
.tile.st-ok { border-top-color: var(--good); }
.tile.st-warn { border-top-color: var(--warn); }
.tile.st-down { border-top-color: var(--bad); }
.tile .name { font-weight: 700; font-size: 16px; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .addr { color: var(--muted); font-size: 13px; margin-bottom: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .summary { font-size: 13px; color: var(--text-2); margin-top: 8px; }
.dots { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.dot { width: 10px; height: 10px; border-radius: 3px; background: var(--axis); }
.dot.ok { background: var(--good); } .dot.warn { background: var(--warn); } .dot.down { background: var(--bad); }

.group-count { font-weight: 400; margin-left: 4px; }
.list-card { padding: 4px 8px; margin-bottom: 8px; }
table.hosts tr[data-href] { cursor: pointer; }
table.hosts tr[data-href]:hover td { background: var(--surface-2); }
table.hosts td { padding: 8px 10px; }
table.hosts td:first-child { width: 1%; }
table.hosts a { text-decoration: none; }
table.hosts .dots { margin-top: 0; max-width: 160px; }
table.hosts .note { color: var(--text-2); font-size: 14px; }
table.hosts .note.has-bad { color: var(--text); }
table.hosts tr.row-down .note { color: var(--bad-ink); }
.pct { font-variant-numeric: tabular-nums; }
.pct.warnv { color: var(--warn-ink); font-weight: 600; }
.pct.bad { color: var(--bad-ink); font-weight: 700; }

.empty {
  text-align: center; padding: 50px 20px; background: var(--surface); border: 1px dashed var(--axis); border-radius: 14px;
}
.empty h2 { margin-top: 0; }
.empty p { color: var(--text-2); max-width: 520px; margin: 8px auto 20px; }

/* ---------- карточки / узел ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 14px; font-size: 17px; display: flex; align-items: center; gap: 10px; }
.card h2 .spacer { flex: 1; }
.host-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.host-head h1 { margin: 0; font-size: 26px; }
.host-head .meta { color: var(--text-2); margin-top: 4px; }
.host-head .left { flex: 1; min-width: 240px; }
.host-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { color: var(--muted); text-decoration: none; font-size: 14px; display: inline-block; margin-bottom: 8px; }
.back:hover { color: var(--text); }
.notes { white-space: pre-wrap; color: var(--text-2); background: var(--surface-2); padding: 10px 12px; border-radius: 8px; margin-top: 10px; font-size: 14px; }

table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
table.list td { padding: 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
table.list tr:last-child td { border-bottom: none; }
table.list .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.list .nowrap { white-space: nowrap; }
table.list .sub { color: var(--muted); font-size: 12px; }
table.list .acts { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }

.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; }
.stat .k { font-size: 12px; color: var(--text-2); }
.stat .v { font-size: 24px; font-weight: 700; }
.stat .v small { font-size: 13px; font-weight: 400; color: var(--muted); }
.disk { display: grid; grid-template-columns: minmax(80px, 180px) 1fr 150px; gap: 12px; align-items: center; margin: 6px 0; font-size: 14px; }
.disk .bar { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.disk .bar i { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.disk .bar i.warn { background: var(--warn); } .disk .bar i.down { background: var(--bad); }
.disk .txt { color: var(--text-2); font-variant-numeric: tabular-nums; text-align: right; }
.disk .mnt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

pre.cmd {
  background: var(--surface-2); padding: 10px 12px; border-radius: 8px; overflow-x: auto; font-size: 13px;
  font-family: ui-monospace, Consolas, monospace; margin: 6px 0 12px; white-space: pre-wrap; word-break: break-all;
}
.hint { color: var(--text-2); font-size: 14px; }
.tabs { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 2px; }
.tabs button { border: none; background: transparent; padding: 4px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.tabs button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

/* ---------- графики ---------- */
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); gap: 16px; }
.chart { position: relative; }
.chart .ctitle { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.chart .csub { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis-text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .endlabel { font-size: 11px; fill: var(--text-2); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.tip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .12); border-radius: 8px; padding: 7px 10px; font-size: 12px; z-index: 5;
  white-space: nowrap; min-width: 120px;
}
.tip .t { color: var(--muted); margin-bottom: 3px; }
.tip .r { display: flex; align-items: center; gap: 6px; }
.tip .r b { margin-left: auto; padding-left: 10px; font-variant-numeric: tabular-nums; }
.tip .sw { width: 8px; height: 8px; border-radius: 2px; }
.nodata { color: var(--muted); font-size: 13px; padding: 30px 0; text-align: center; background: var(--surface-2); border-radius: 8px; }

/* ---------- модальные окна ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 16px; z-index: 50; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 520px; padding: 22px 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
.modal h2 { margin: 0 0 16px; font-size: 20px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.error { color: var(--bad-ink); background: var(--bad-bg); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.ok-msg { color: var(--good-ink); background: var(--good-bg); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.tpl-grid label {
  border: 1px solid var(--axis); border-radius: 10px; padding: 8px 10px; cursor: pointer; font-size: 14px;
  display: flex; gap: 8px; align-items: flex-start;
}
.tpl-grid label:has(input:checked) { border-color: var(--accent); outline: 1px solid var(--accent); }
.tpl-grid small { display: block; color: var(--muted); font-size: 12px; }

/* ---------- вход ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.login h1 { margin: 0 0 4px; display: flex; align-items: center; gap: 10px; }
.login h1 svg { color: var(--bad); }
.login p { color: var(--text-2); margin: 0 0 20px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--page);
  padding: 10px 18px; border-radius: 10px; z-index: 100; font-size: 14px;
}

@media (max-width: 720px) {
  .top-inner { gap: 10px; }
  .logo span { display: none; }
  nav.menu a { padding: 6px 8px; }
  .top-actions .btn-label { display: none; }
  .charts { grid-template-columns: 1fr; }
  .row2, .tpl-grid { grid-template-columns: 1fr; }
  .toolbar input[type=search] { width: 100%; }
  .disk { grid-template-columns: 90px 1fr; }
  .disk .txt { grid-column: 1 / -1; text-align: left; margin-top: -4px; }
  .problem { flex-wrap: wrap; }
  .hide-sm { display: none; }
  main { padding-top: 16px; }
}

/* модель и версии на обзоре */
.fw-lag { color: var(--warn-ink); font-weight: 600; }
.tile .addr.info { margin-top: -8px; }
table.hosts .info-cell { max-width: 260px; }
