:root {
  --bg: #fafaf9; --panel: #ffffff; --fg: #1c1917; --muted: #78716c; --line: #e7e5e4; --soft: #f5f5f4;
  --accent: #2563eb; --accent-fg: #ffffff; --ok: #16a34a; --warn: #d97706; --bad: #dc2626;
  --radius: 8px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0a09; --panel: #161311; --fg: #f5f5f4; --muted: #a8a29e; --line: #292524; --soft: #1c1917;
    --accent: #60a5fa; --accent-fg: #0c0a09; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h2 { font-size: 16px; margin-bottom: 12px; }
h3 { font-size: 14px; }
h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }
.right { margin-left: auto; }
.nowrap { white-space: nowrap; }

/* каркас */
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1240px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 24px; height: 52px; }
.brand { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.brand i { width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--accent); position: relative; display: inline-block; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.nav a:hover { color: var(--fg); text-decoration: none; background: var(--soft); }
.nav a.on { color: var(--fg); background: var(--soft); font-weight: 550; }
.conn { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
main { max-width: 1240px; margin: 0 auto; padding: 24px 20px 60px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; }

/* элементы */
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }
.dot.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 12px; }
.tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .k { color: var(--muted); font-size: 12px; }
.tile .v { font-size: 22px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .s { color: var(--muted); font-size: 12px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.cols { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } .top-in { gap: 12px; } }

button, .btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--fg); padding: 6px 12px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover:not(:disabled) { background: var(--soft); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
button.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
button.danger { color: var(--bad); }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); padding: 4px 8px; }
button.ghost:hover:not(:disabled) { color: var(--fg); }
button.sm { padding: 3px 8px; font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; }
.seg button.on { background: var(--soft); font-weight: 600; }

input[type=text], input[type=password], input[type=number], input[type=url], select, textarea {
  font: inherit; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea { min-height: 96px; resize: vertical; font-family: var(--mono); font-size: 13px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; margin-bottom: 4px; }
.field small { display: block; color: var(--muted); margin-top: 3px; font-size: 12px; }
.field.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field.inline > span { margin: 0; }
.field.inline small { flex-basis: 100%; margin: 0 0 0 24px; }
.form.two { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); column-gap: 20px; }
.form h4 { grid-column: 1 / -1; }
.req { color: var(--bad); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; cursor: pointer; background: transparent; color: var(--muted); }
.chip.on { background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: var(--accent); color: var(--fg); }
.chip-add { display: inline-flex; gap: 4px; }
.chip-add input { width: 110px; padding: 3px 8px; border-radius: 999px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.empty { color: var(--muted); padding: 28px 8px; text-align: center; }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.badge.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.stat-line { display: flex; align-items: center; gap: 8px; }
.sub { color: var(--muted); font-size: 12px; }
.bar { height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

.log { max-height: 360px; overflow-y: auto; font-family: var(--mono); font-size: 12px; }
.log div { padding: 3px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 8px; }
.log div:last-child { border: 0; }
.log .t { color: var(--muted); flex: none; }
.log .a { color: var(--accent); flex: none; }
.log .warning { color: var(--warn); } .log .error { color: var(--bad); } .log .match { color: var(--ok); font-weight: 600; }
svg.chart { width: 100%; height: 90px; display: block; }
svg.chart rect.a { fill: var(--line); } svg.chart rect.m { fill: var(--accent); }

/* модалка, тосты, вход */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; z-index: 20; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { max-width: 880px; }
.modal-h { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-b { padding: 18px; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
#toasts { position: fixed; top: 64px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 30; max-width: 360px; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 14px; box-shadow: 0 6px 24px rgba(0,0,0,.15); }
.toast.ok { border-left-color: var(--ok); } .toast.bad { border-left-color: var(--bad); } .toast.match { border-left-color: var(--ok); font-weight: 550; }
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login .card { width: 100%; max-width: 340px; }
.err { color: var(--bad); font-size: 13px; margin-top: 8px; min-height: 18px; }
