:root {
  --bg: #f4f5f7; --card: #ffffff; --line: #e6e8ec; --text: #1d2026; --muted: #6b7280; --soft: #f0f1f4; --hover: #f6f7f9;
  --ok: #2f9e5b; --warn: #d4900f; --crit: #d64545; --unknown: #9aa0a6; --nodata: #e3e5e9;
  --ok-bg: #e9f6ee; --warn-bg: #fdf4e3; --crit-bg: #fdecec; --accent: #4c6ef5;
  --c-sbp: #4c6ef5; --c-sbp_auto: #8c6ad8; --c-x10: #13a594; --c-telegram_stars: #e0a526; --c-cryptopay: #8a8f98;
  --top-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121418; --card: #1a1d23; --line: #2a2e36; --text: #e8eaee; --muted: #9097a3; --soft: #23272e; --hover: #20242b;
    --nodata: #2c3038; --ok-bg: #15261b; --warn-bg: #2c2414; --crit-bg: #311a1a;
  }
}
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top-h) + 12px); scroll-behavior: smooth; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.link { text-decoration: none; color: var(--muted); }
.link:hover { color: var(--text); }
h2 { font-size: 16px; margin: 0; font-weight: 600; }
h3 { font-size: 12px; margin: 18px 0 6px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.show-sm { display: none; }
.seg .sm { display: none; }

/* ---------- top bar */
.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
  padding-top: env(safe-area-inset-top); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.top-in { display: flex; align-items: center; justify-content: space-between; height: var(--top-h); gap: 12px; padding: 0 20px; max-width: 1440px; margin: 0 auto; }
.brand { font-weight: 600; font-size: 15px; white-space: nowrap; display: flex; align-items: center; gap: 9px; }
.top-right { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.ghost { border: 0; background: transparent; cursor: pointer; padding: 6px 8px; border-radius: 8px; color: var(--muted); white-space: nowrap; }
.ghost:hover { background: var(--soft); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 6px 11px; cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--soft); color: var(--text); font-weight: 600; }
.stale { color: var(--crit) !important; font-weight: 600; }

/* ---------- layout */
.layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 24px; max-width: 1440px; margin: 0 auto; padding: 20px; }
.side { position: sticky; top: calc(var(--top-h) + 20px); align-self: start; display: grid; gap: 2px; }
.side a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--text); text-decoration: none; font-size: 13.5px; }
.side a:hover { background: var(--hover); }
.side a.on { background: var(--card); box-shadow: 0 0 0 1px var(--line); font-weight: 600; }
.s-name { flex: 1; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; color: #fff; background: var(--warn); }
.badge.crit { background: var(--crit); } .badge.ok { background: var(--muted); }
main { min-width: 0; }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; background: var(--unknown); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.crit { background: var(--crit); }
.dot.none { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
.dot.big { width: 13px; height: 13px; }

/* ---------- summary */
.banner { border-radius: 14px; padding: 18px 20px; background: var(--card); border: 1px solid var(--line); }
.banner.ok { background: var(--ok-bg); border-color: transparent; }
.banner.warn { background: var(--warn-bg); border-color: transparent; }
.banner.crit { background: var(--crit-bg); border-color: transparent; }
.banner-title { font-size: 21px; font-weight: 650; display: flex; align-items: center; gap: 10px; }
.banner-sub { color: var(--muted); margin: 2px 0 0 23px; }
.problems { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; margin-top: 14px; }
.problem { display: flex; align-items: flex-start; gap: 10px; text-align: left; padding: 11px 12px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--card); box-shadow: 0 0 0 1px var(--line); }
.problem:hover { box-shadow: 0 0 0 1px var(--muted); }
.problem .dot { margin-top: 5px; }
.p-body { display: grid; gap: 1px; flex: 1; min-width: 0; }
.p-name { font-weight: 600; }
.p-meta { font-size: 12.5px; color: var(--muted); }
.p-value { font-size: 13px; }
.chev { color: var(--muted); flex: none; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 14px 0 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; text-align: left; }
button.kpi { cursor: pointer; }
button.kpi:hover { border-color: var(--muted); }
.kpi.warn { box-shadow: inset 3px 0 0 var(--warn); }
.kpi-label { color: var(--muted); font-size: 12.5px; }
.kpi-value { font-size: 22px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.up { color: var(--ok); } .down { color: var(--crit); }

/* ---------- cards & rows */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.count { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.count.crit { color: var(--crit); font-weight: 600; } .count.warn { color: var(--warn); font-weight: 600; }

.rows { display: grid; }
.row { border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row.flash { animation: flash 1.8s ease-out; }
@keyframes flash { from { background: var(--soft); } to { background: transparent; } }
.r-main { display: grid; grid-template-columns: 12px minmax(180px, 1.1fr) minmax(150px, 1.3fr) minmax(160px, 1fr) 14px; gap: 12px;
  align-items: center; width: 100%; padding: 9px 4px; border: 0; background: transparent; text-align: left; cursor: pointer; border-radius: 8px; }
.r-main:hover { background: var(--hover); }
.r-name { font-weight: 550; }
.row.bad .r-name { font-weight: 650; }
.r-since { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.r-value { font-variant-numeric: tabular-nums; }
.r-more { margin: 0 4px 10px 28px; padding: 10px 12px; border-radius: 10px; background: var(--soft); font-size: 13px; }
.r-more p { margin: 3px 0; }
.bar { display: flex; gap: 1px; height: 20px; align-items: stretch; }
.bar i { flex: 1; border-radius: 1.5px; background: var(--nodata); min-width: 1px; }
.bar i.s0 { background: var(--ok); opacity: .5; } .bar i.s1 { background: var(--unknown); }
.bar i.s2 { background: var(--warn); } .bar i.s3 { background: var(--crit); }
.more-ok { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 4px; border: 0; border-top: 1px dashed var(--line);
  background: transparent; color: var(--muted); cursor: pointer; text-align: left; border-radius: 0 0 8px 8px; }
.rows > .more-ok:first-child { border-top: 0; }
.more-ok:hover { color: var(--text); background: var(--hover); }

/* ---------- payments */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 8px 8px; border-top: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 500; color: var(--muted); font-size: 12.5px; border-top: 0; }
th:first-child, td:first-child { text-align: left; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }
.fill-sbp { fill: var(--c-sbp); background: var(--c-sbp); } .fill-sbp_auto { fill: var(--c-sbp_auto); background: var(--c-sbp_auto); }
.fill-x10 { fill: var(--c-x10); background: var(--c-x10); } .fill-telegram_stars { fill: var(--c-telegram_stars); background: var(--c-telegram_stars); }
.fill-cryptopay { fill: var(--c-cryptopay); background: var(--c-cryptopay); }
.scroll { overflow-x: auto; }
.chart-box { margin-top: 12px; }
.chart-box summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 4px 0; }
.chart { width: 100%; height: 170px; display: block; margin-top: 6px; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.two { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; }

.nodes { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 16px; margin: 6px 0 8px; font-size: 13px; }
.node { display: flex; align-items: center; gap: 8px; padding: 3px 0; min-width: 0; }
.n-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.n-on { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.node.off { color: var(--muted); }

/* ---------- incidents */
.inc { display: grid; grid-template-columns: 12px 1fr auto; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); align-items: start; }
h3 + .inc { border-top: 0; }
.inc .dot { margin-top: 5px; }
.inc-body { min-width: 0; }
.inc-when { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.inc-when .live { color: var(--crit); font-weight: 600; }
.linklike { border: 0; background: none; padding: 0; cursor: pointer; text-align: left; }
.linklike:hover { text-decoration: underline; }
.empty { color: var(--muted); padding: 6px 0; }

.tip { position: fixed; z-index: 30; max-width: 360px; background: var(--text); color: var(--bg); padding: 7px 10px; border-radius: 8px;
  font-size: 12.5px; pointer-events: none; }
.foot { font-size: 12.5px; margin: 8px 0 calc(40px + env(safe-area-inset-bottom)); }

/* ---------- login */
.login { display: grid; place-items: center; min-height: 100vh; }
.login-box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: min(360px, 92vw); display: grid; gap: 14px; }
.login-box h1 { font-size: 18px; margin: 0 0 4px; }
.login-box label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.login-box input { font: inherit; padding: 10px 11px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.login-box button { font: inherit; font-weight: 600; padding: 11px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer; }
.err { color: var(--crit); margin: 0; }

/* ---------- tablet / phone */
@media (max-width: 1100px) {
  .r-main { grid-template-columns: 12px minmax(160px, 1fr) minmax(140px, 1.2fr) 14px; }
  .r-main .bar { display: none; }
  .row.open .r-more::before { content: none; }
}
@media (max-width: 900px) {
  :root { --top-h: 52px; }
  html { scroll-padding-top: calc(var(--top-h) + 56px + env(safe-area-inset-top)); }
  .layout { grid-template-columns: 1fr; padding: 0 12px 12px; gap: 0; }
  .side { position: sticky; top: calc(var(--top-h) + env(safe-area-inset-top)); z-index: 9; display: flex; overflow-x: auto; gap: 6px; padding: 10px 0; margin: 0 -12px 12px;
    padding-left: 12px; padding-right: 12px; background: var(--bg); scrollbar-width: none; }
  .side::-webkit-scrollbar { display: none; }
  .side a { flex: none; padding: 6px 10px; background: var(--card); box-shadow: 0 0 0 1px var(--line); white-space: nowrap; }
  .side a.on { box-shadow: 0 0 0 1.5px var(--text); }
  .two { grid-template-columns: 1fr; }
  .hide-sm { display: none !important; }
  .show-sm { display: inline; }
  .top-in { padding: 0 12px; }
  .brand .muted { display: none; }
}
@media (max-width: 600px) {
  .r-main { grid-template-columns: 12px 1fr 14px; row-gap: 2px; }
  .r-main .r-value { grid-column: 2; grid-row: 2; color: var(--muted); font-size: 13px; }
  .r-more { margin-left: 4px; }
  .card { padding: 14px 14px; border-radius: 12px; }
  .problems { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-value { font-size: 19px; }
  #updated { display: none; }
  .seg .lg { display: none; } .seg .sm { display: inline; }
  .seg button { padding: 6px 9px; }
  .banner-title { font-size: 19px; }
}
