:root {
  --bg: #0A0B0D;
  --card: #15171B;
  --well: #0F1114;
  --line: #23262C;
  --ink: #F2F4F7;
  --ink-2: #C7CCD4;
  --muted: #8B93A1;
  --ok: #2FD3A6;
  --warn: #FF8A3D;
  --bad: #FF5C5C;
  --accent: #2FD3A6;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
button, input { font: inherit; color: inherit; }
button {
  cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  border-radius: 999px; padding: 7px 14px; font-size: 13px;
}
button:hover { color: var(--ink); }
button.primary { background: var(--accent); border-color: var(--accent); color: #06110D; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.err { color: var(--bad); font-size: 13px; margin: 0; }

/* вход */
.login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; padding: 22px 20px; }
.login-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.login-head h1 { font-size: 18px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); }
input {
  background: var(--well); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; font-size: 16px;
  color: var(--ink); outline: none; width: 100%;
}
input:focus { border-color: var(--accent); }
.login-card .primary, .pass-form .primary { padding: 11px 14px; font-size: 15px; border-radius: 12px; }

/* страница */
main {
  max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px;
  padding: calc(env(safe-area-inset-top) + 16px) 16px max(28px, env(safe-area-inset-bottom));
}
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.top .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.top .btns { display: flex; gap: 6px; flex-shrink: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 14px 16px; min-width: 0; }
.card > h2 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card > h2 .muted { font-size: 12px; font-weight: 400; }

.status { display: flex; gap: 10px; align-items: flex-start; border-radius: 16px; padding: 11px 14px; font-size: 14px; border: 1px solid var(--line); background: var(--card); }
.status .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.status.ok .dot { background: var(--ok); box-shadow: 0 0 0 4px #2FD3A622; }
.status.bad { border-color: #FF5C5C55; background: #FF5C5C12; }
.status.bad .dot { background: var(--bad); box-shadow: 0 0 0 4px #FF5C5C22; }
.status.warn { border-color: #FF8A3D55; background: #FF8A3D12; }
.status.warn .dot { background: var(--warn); }
.status ul { margin: 4px 0 0; padding-left: 16px; color: var(--ink-2); font-size: 13px; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 12px 13px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; white-space: nowrap; }
.tile .v small { font-size: 13px; font-weight: 400; color: var(--muted); }
.tile .s { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.net-v { display: flex; flex-direction: column; gap: 2px; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--well); }
.bar > span { display: block; height: 100%; min-width: 0; }
.bar.big { height: 14px; border-radius: 7px; gap: 2px; background: transparent; }
.bar.big > span:first-child { border-radius: 7px 0 0 7px; }
.bar.big > span:last-child { border-radius: 0 7px 7px 0; }

/* проекты */
.projects { display: flex; flex-direction: column; }
.proj { border-top: 1px solid var(--line); }
.proj:first-child { border-top: 0; }
.proj-head { width: 100%; border: 0; border-radius: 0; background: transparent; padding: 11px 0; display: flex; flex-direction: column; gap: 7px; text-align: left; color: var(--ink); }
.proj-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.proj-title .dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.proj-title b { font-weight: 600; font-size: 15px; white-space: nowrap; }
.proj-title .note { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.proj-title .chev { color: var(--muted); flex-shrink: 0; transition: transform .15s; }
.proj.open .chev { transform: rotate(90deg); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; white-space: nowrap; flex-shrink: 0; }
.badge.bad { background: #FF5C5C22; color: var(--bad); }
.badge.ok { background: #2FD3A61A; color: var(--ok); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding-left: 18px; }
.stat { display: flex; flex-direction: column; min-width: 0; }
.stat .k { font-size: 11px; color: var(--muted); }
.stat .v { font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 500; }
.proj.total .proj-head { cursor: default; }
.proj.total .proj-title b { font-size: 15px; }
.proj-body { padding: 0 0 12px 18px; display: flex; flex-direction: column; gap: 10px; }
.ctrs { display: flex; flex-direction: column; gap: 0; background: var(--well); border-radius: 12px; border: 1px solid var(--line); }
.ctr { padding: 8px 11px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ctr:first-child { border-top: 0; }
.ctr-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; min-width: 0; }
.ctr-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ctr-num { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; flex-shrink: 0; }
.ctr-sub { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.ctr-sub .bad { color: var(--bad); }
.ctr-sub .warn { color: var(--warn); }
.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; font-size: 13px; }
.kv .k { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv .v { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* диск */
.legend { display: flex; flex-direction: column; margin-top: 12px; }
.leg { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 2px 9px; align-items: baseline; padding: 7px 0; border-top: 1px solid var(--line); }
.leg:first-child { border-top: 0; }
.leg .dot { width: 10px; height: 10px; border-radius: 3px; align-self: center; }
.leg .t { font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leg .v { font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.leg .n { grid-column: 2 / 4; font-size: 12px; color: var(--muted); }
.forecast { margin-top: 10px; font-size: 13px; color: var(--ink-2); background: var(--well); border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px; }
details.images { margin-top: 10px; }
details.images summary { cursor: pointer; font-size: 13px; color: var(--ink-2); padding: 4px 0; }
details.images .kv { margin-top: 6px; }

/* графики */
.chips { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; margin-bottom: 4px; }
.chips button { padding: 6px 0; font-size: 12.5px; white-space: nowrap; }
.chips button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chart-block { margin-top: 14px; }
.chart-block h3 { font-size: 13px; font-weight: 500; color: var(--ink-2); margin-bottom: 6px; display: flex; justify-content: space-between; gap: 8px; }
.chart-block h3 .muted { font-weight: 400; font-size: 12px; }
.chart { position: relative; height: 150px; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ylab, .chart .xlab { fill: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.chart .cursor { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 2 3; }
.tip {
  position: absolute; top: 0; z-index: 2; pointer-events: none; min-width: 140px; max-width: 220px;
  background: #1C1F24F2; border: 1px solid var(--line); border-radius: 10px; padding: 7px 9px; font-size: 12px;
  box-shadow: 0 6px 20px #0008;
}
.tip .tt { color: var(--muted); margin-bottom: 3px; }
.tip .tr { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.tip .tr i { width: 8px; height: 8px; border-radius: 2px; }
.tip .tr span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tip .tr b { font-weight: 500; font-variant-numeric: tabular-nums; }
.keys { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: 12px; color: var(--ink-2); }
.keys span { display: inline-flex; align-items: center; gap: 5px; }
.keys i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.keys i.line { height: 2px; width: 12px; border-radius: 1px; }
.nodata { height: 150px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; background: var(--well); border-radius: 12px; text-align: center; padding: 0 16px; }

/* события */
.events { display: flex; flex-direction: column; }
.ev { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.ev:first-child { border-top: 0; }
.ev .t { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ev .w { min-width: 0; overflow-wrap: anywhere; }
.ev .w b { font-weight: 500; }
.ev .w .dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.ev.down .w .x, .ev.unhealthy .w .x, .ev.gone .w .x { color: var(--bad); }
.ev.restart .w .x { color: var(--warn); }
.more { margin-top: 8px; }

dialog { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 20px; padding: 0; width: min(380px, calc(100vw - 32px)); }
dialog::backdrop { background: #000A; }
.pass-form { display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.row-btns { display: flex; gap: 8px; justify-content: flex-end; }
.loading { color: var(--muted); text-align: center; padding: 60px 0; }
