/* Статус-страница VagonERA. Классика уровня Linear / Better Stack: графит, одна акцентная лазурь,
   цвет только по смыслу (работает / внимание / сбой / нет данных). Тема — по системной настройке. */
:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --bg-sunk: #eef0f3;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --line: #e3e6eb;
  --line-strong: #d3d8df;
  --text: #11151c;
  --text-2: #4a5361;
  --text-3: #6b7482;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --accent-soft: #e8f0fe;
  --ok: #18864b;
  --ok-soft: #e3f4ea;
  --ok-bar: #2fb36b;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --warn-bar: #e8a33a;
  --bad: #c8312b;
  --bad-soft: #fde8e7;
  --bad-bar: #e5534b;
  --none: #9aa3af;
  --none-bar: #d5dae1;
  --shadow: 0 1px 2px rgba(17, 21, 28, .05), 0 4px 16px -8px rgba(17, 21, 28, .12);
  --shadow-pop: 0 12px 40px -12px rgba(17, 21, 28, .35), 0 2px 6px rgba(17, 21, 28, .08);
  --radius: 10px;
  --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0c0e12;
    --bg-sunk: #08090c;
    --surface: #13161c;
    --surface-2: #171b22;
    --line: #232832;
    --line-strong: #2f3541;
    --text: #e8ebf0;
    --text-2: #a6aebb;
    --text-3: #8a93a1;
    --accent: #5b9dff;
    --accent-ink: #07111f;
    --accent-soft: #14233a;
    --ok: #4cc98a;
    --ok-soft: #0f2a1d;
    --ok-bar: #34b673;
    --warn: #f0b45a;
    --warn-soft: #2d2210;
    --warn-bar: #d99632;
    --bad: #ff7a72;
    --bad-soft: #351514;
    --bad-bar: #e5534b;
    --none: #6b7482;
    --none-bar: #2a303b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px -10px rgba(0, 0, 0, .6);
    --shadow-pop: 0 16px 48px -12px rgba(0, 0, 0, .7), 0 2px 8px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 var(--font); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
a { color: var(--accent); text-underline-offset: 3px; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round; }

/* ---------- кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: 500 13px/1 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); filter: brightness(1.06); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: var(--bad); border-color: var(--bad); filter: brightness(1.06); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-quiet:hover { background: var(--bg-sunk); border-color: transparent; color: var(--text); }
.btn-icon { width: 32px; padding: 0; }
.btn.is-busy svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

label { display: grid; gap: 6px; font-weight: 500; font-size: 13px; color: var(--text-2); }
input {
  height: 40px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: 15px var(--font); caret-color: var(--accent);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--text-3); }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- вход и настройка ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; box-shadow: var(--shadow);
}
.auth-card h1 { margin: 22px 0 6px; font-size: 22px; letter-spacing: -.02em; line-height: 1.2; }
.auth-lead { margin: 0 0 20px; color: var(--text-2); }
.stack { display: grid; gap: 14px; }
.stack .btn { height: 40px; margin-top: 6px; font-size: 14px; }
.form-error { margin: 0 0 16px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--bad-soft); color: var(--bad); font-weight: 500; }
.totp-box { display: grid; gap: 10px; padding: 14px; border-radius: var(--radius-sm);
  background: var(--bg-sunk); border: 1px solid var(--line); }
.totp-box p { margin: 0; color: var(--text-2); font-size: 13px; }
.totp-secret { font: 600 15px/1.5 var(--mono); letter-spacing: .04em; color: var(--text) !important;
  word-break: break-all; user-select: all; }
.recovery { columns: 2; margin: 0 0 20px; padding-left: 22px; font: 600 15px/1.9 var(--mono); user-select: all; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  background:
    linear-gradient(135deg, transparent 46%, var(--surface) 46% 54%, transparent 54%),
    var(--accent);
}

/* ---------- каркас панели ---------- */
.app { max-width: 1240px; margin: 0 auto; padding: 0 20px 48px; }
.boot { padding: 80px 0; text-align: center; color: var(--text-3); }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  margin: 0 -20px; padding: 12px 20px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { margin-right: auto; }
.topbar .brand small { font-weight: 450; color: var(--text-3); font-size: 13px; margin-left: 2px; }
.updated { color: var(--text-3); font-size: 12.5px; white-space: nowrap; }
.updated.is-stale { color: var(--warn); font-weight: 500; }

.summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; padding: 28px 0 22px; }
.summary h1 { margin: 0; font-size: 24px; line-height: 1.2; letter-spacing: -.025em; font-weight: 650; }
.summary h1 .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 10px;
  vertical-align: 2px; background: var(--ok-bar); box-shadow: 0 0 0 4px var(--ok-soft); }
.summary h1.is-warn .dot { background: var(--warn-bar); box-shadow: 0 0 0 4px var(--warn-soft); }
.summary h1.is-bad .dot { background: var(--bad-bar); box-shadow: 0 0 0 4px var(--bad-soft); }
.facts { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--text-2); margin: 0; padding: 0; list-style: none; }
.facts b { color: var(--text); font-weight: 600; }
.facts li { display: inline-flex; align-items: center; gap: 5px; }
.facts .due { display: inline-block; padding: 2px 10px 2px 8px; border-radius: 12px; background: var(--bg-sunk); }
.facts .due svg { vertical-align: -3px; margin-right: 5px; }
.facts .due.warn { background: var(--warn-soft); color: var(--warn); }
.facts .due.bad { background: var(--bad-soft); color: var(--bad); }
.facts .due.warn b, .facts .due.bad b { color: inherit; }

.section { margin-top: 26px; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.section-head h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.section-head .count { color: var(--text-3); font-size: 13px; }
.section-head .spacer { margin-left: auto; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; }
.bill .sub { max-width: 46ch; }

/* ---------- таблица мониторов ---------- */
.grid-head, .row { display: grid; align-items: center; gap: 14px; padding: 0 16px; }
.nodes .grid-head, .nodes .row {
  grid-template-columns: minmax(170px, 1.4fr) 140px 52px minmax(220px, 1.1fr) 96px 196px minmax(120px, .75fr) 32px;
}
.grid-head { height: 36px; background: var(--surface-2); border-bottom: 1px solid var(--line);
  color: var(--text-3); font-size: 12px; font-weight: 550; }
.grid-head .num, .row .num { text-align: right; }
.row { min-height: 60px; border-bottom: 1px solid var(--line); transition: background .15s; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row.is-bad { background: color-mix(in srgb, var(--bad-soft) 55%, var(--surface)); }
.row.is-warn { background: color-mix(in srgb, var(--warn-soft) 45%, var(--surface)); }
.cell-label { display: none; }

.name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.name strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc { flex: none; display: inline-grid; place-items: center; width: 26px; height: 18px; border-radius: 4px;
  background: var(--bg-sunk); border: 1px solid var(--line); color: var(--text-2); font: 600 10.5px/1 var(--font);
  letter-spacing: .02em; }
.sub { color: var(--text-3); font-size: 12.5px; }

.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px 0 7px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.none { background: var(--bg-sunk); color: var(--text-3); }

.meters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.meter { display: grid; gap: 4px; font-size: 12px; color: var(--text-3); }
.meter b { color: var(--text); font-weight: 600; font-size: 12.5px; }
.meter > span { white-space: nowrap; }
.c-online.is-zero b { color: var(--text-3); font-weight: 500; }
.meter .track { height: 4px; border-radius: 2px; background: var(--bg-sunk); overflow: hidden; }
.meter .fill { height: 100%; border-radius: 2px; background: var(--text-3); }
.meter.hot .fill { background: var(--warn-bar); }
.meter.crit .fill { background: var(--bad-bar); }

.reach { display: flex; gap: 6px; }
.reach span { display: inline-grid; place-items: center; height: 22px; padding: 0 7px; border-radius: 5px;
  font-size: 11.5px; font-weight: 600; background: var(--bg-sunk); color: var(--text-3); }
.reach .on { background: var(--ok-soft); color: var(--ok); }
.reach .off { background: var(--bad-soft); color: var(--bad); }
.reach .na { background: none; box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--text-3); font-weight: 500; }
.reach-note { margin-top: 5px; font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.strip { display: grid; gap: 6px; min-width: 0; }
.bars { display: flex; gap: 2px; height: 22px; align-items: stretch; }
.bars i { flex: 1; min-width: 2px; border-radius: 2px; background: var(--none-bar); }
.bars i.ok { background: var(--ok-bar); }
.bars i.bad { background: var(--bad-bar); }
.bars i.ev { position: relative; }
.bars i.ev::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent); transform: translateX(-50%); }
.strip-meta { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-3); }
.strip-meta b { color: var(--text-2); font-weight: 600; }

/* ---------- меню действий и диалог ---------- */
.menu { position: relative; }
.menu-pop {
  position: fixed; z-index: 20; min-width: 230px; padding: 6px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-pop);
  transform-origin: top right; animation: pop .14s cubic-bezier(.2, .9, .3, 1);
}
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(-2px); } }
.menu-pop button { display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); font: 500 13px var(--font);
  text-align: left; cursor: pointer; }
.menu-pop button:hover, .menu-pop button:focus-visible { background: var(--bg-sunk); outline: none; }
.menu-pop button.danger { color: var(--bad); }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }

dialog { width: min(440px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line-strong);
  border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop); }
dialog::backdrop { background: rgba(8, 10, 14, .45); backdrop-filter: blur(2px); }
dialog[open] { animation: pop .18s cubic-bezier(.2, .9, .3, 1); }
.dlg { padding: 22px; }
.dlg h3 { margin: 0 0 8px; font-size: 17px; letter-spacing: -.015em; }
.dlg p { margin: 0 0 20px; color: var(--text-2); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast { position: fixed; z-index: 30; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 11px 16px; border-radius: var(--radius); font-weight: 500;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-pop); animation: rise .2s ease-out; }
.toast.is-bad { background: var(--bad); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 6px); } }

/* ---------- роутеры, инфраструктура, оплата ---------- */
.list-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row.is-bad { background: color-mix(in srgb, var(--bad-soft) 55%, var(--surface)); }
.list-row .details.is-stale { color: var(--warn); }
/* роутеры — карточками в ряд; сторожа — плиткой, линии между ними рисует фон сквозь зазор */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--line) !important; border-radius: var(--radius); box-shadow: var(--shadow); }
.card.is-warn { background: color-mix(in srgb, var(--warn-soft) 45%, var(--surface)); }
.panel.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1px; background: var(--line); }
.tiles .list-row { border: 0; background: var(--surface); }
.tiles .list-row.is-bad { background: color-mix(in srgb, var(--bad-soft) 55%, var(--surface)); }
.list-row .line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.list-row .details { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--text-2); font-size: 12.5px; }
.list-row .details b { color: var(--text); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; grid-column: 1 / -1; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 6px;
  background: var(--bg-sunk); border: 1px solid var(--line); font-size: 12px; color: var(--text-2); }
.chip b { color: var(--text); font-weight: 600; }
.chip.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.chip.bad b { color: var(--bad); }

table.bill { width: 100%; border-collapse: collapse; }
.bill th, .bill td { padding: 11px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.bill th { height: 36px; padding-block: 0; background: var(--surface-2); color: var(--text-3); font-size: 12px; font-weight: 550; }
.bill tr:last-child td { border-bottom: 0; }
.bill td.num, .bill th.num { text-align: right; white-space: nowrap; }
.bill .sub { display: block; margin-top: 2px; }
.bill tr.soon td { background: color-mix(in srgb, var(--warn-soft) 50%, var(--surface)); }
.bill tr.overdue td { background: color-mix(in srgb, var(--bad-soft) 60%, var(--surface)); }

.foot { margin-top: 32px; display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--text-3); font-size: 12.5px; }
.foot .errs { color: var(--warn); font-weight: 500; }

/* ---------- узкие экраны ---------- */
@media (max-width: 1100px) {
  .nodes .grid-head { display: none; }
  .nodes .row { grid-template-columns: 1fr auto; grid-template-areas:
    "name menu" "status online" "meters meters" "warp reach" "strip strip"; gap: 10px 14px; padding: 14px 16px; }
  .nodes .c-name { grid-area: name; } .nodes .c-status { grid-area: status; }
  .nodes .c-online { grid-area: online; text-align: right; } .nodes .c-meters { grid-area: meters; }
  .nodes .c-warp { grid-area: warp; } .nodes .c-reach { grid-area: reach; justify-self: end; }
  .nodes .c-strip { grid-area: strip; } .nodes .c-menu { grid-area: menu; justify-self: end; }
  .cell-label { display: inline; color: var(--text-3); font-size: 12px; margin-right: 6px; }
}
@media (max-width: 560px) {
  .app { padding: 0 16px 40px; }
  .topbar { margin: 0 -16px; padding: 10px 16px; }
  .topbar .brand small, .updated-full { display: none; }
  .summary { padding: 20px 0 16px; }
  .summary h1 { font-size: 20px; }
  .topbar .btn-label { display: none; }
  .topbar .btn:not(.btn-icon) { width: 32px; padding: 0; }
  /* оплата на телефоне — стопкой: сервер и срок в первой строке, сумма и дата под ними */
  .bill thead { display: none; }
  .bill tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px;
    border-bottom: 1px solid var(--line); }
  .bill tr:last-child { border-bottom: 0; }
  .bill td { padding: 0; border: 0; background: none !important; }
  .bill tr.soon { background: color-mix(in srgb, var(--warn-soft) 50%, var(--surface)); }
  .bill tr.overdue { background: color-mix(in srgb, var(--bad-soft) 60%, var(--surface)); }
  .bill td:nth-child(1) { grid-column: 1; grid-row: 1 / span 2; }
  .bill .c-hoster { display: none; }
  .bill td:nth-child(3) { grid-column: 2; grid-row: 2; color: var(--text-2); }
  .bill td:nth-child(4) { grid-column: 2; grid-row: 3; color: var(--text-3); font-size: 12.5px; }
  .bill td:nth-child(5) { grid-column: 2; grid-row: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
