:root {
  --navy: #0B1F3A; --blue: #1D4ED8; --blue-deep: #1E40AF; --cyan: #06B6D4;
  --ink: #0F172A; --slate: #475569; --mist: #F4F7FB; --line: #E2E8F0; --card: #FFFFFF;
  --green: #0F7A40; --amber: #B45309; --red: #B91C1C;
  --green-bg: #E7F6EC; --amber-bg: #FEF3E2; --red-bg: #FDECEC; --blue-bg: #E8EEFD;
  --radius: 12px; --radius-card: 20px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --navy: #071426; --blue: #60A5FA; --blue-deep: #93C5FD; --ink: #F1F5F9; --slate: #94A3B8;
    --mist: #0A1424; --line: #1E2A3D; --card: #0F1B2E;
    --green: #34D399; --amber: #FBBF24; --red: #F87171;
    --green-bg: #0B2A1C; --amber-bg: #2E2208; --red-bg: #331313; --blue-bg: #13233F;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--mist); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--card); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 0 0 12px; }
p { margin: 0 0 12px; }
.muted { color: var(--slate); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }
.side { background: var(--navy); color: #fff; padding: 20px 12px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { font-weight: 700; font-size: 16px; padding: 4px 12px 18px; letter-spacing: 0.01em; }
.brand span { display: block; font-weight: 400; font-size: 12px; opacity: 0.7; }
.nav a { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 8px 12px; border-radius: var(--radius); color: #DCE6F5; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,0.08); text-decoration: none; }
.nav a[aria-current="page"] { background: rgba(255,255,255,0.14); color: #fff; }
.nav .count { background: #B91C1C; color: #fff; border-radius: 999px; font-size: 12px; padding: 1px 8px; }
.nav hr { border: 0; border-top: 1px solid rgba(255,255,255,0.12); margin: 12px; }
.content { min-width: 0; }
.top { display: flex; justify-content: flex-end; align-items: center; gap: 12px; padding: 12px 28px; border-bottom: 1px solid var(--line); background: var(--card); }
main { padding: 28px; max-width: 1400px; }
main:focus { outline: none; }
.head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 20px; margin-bottom: 20px; }
.card.narrow { max-width: 460px; }
.center { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 20px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 18px 20px; }
.tile .num { font-size: 30px; font-weight: 700; line-height: 1.1; }
.tile .lab { color: var(--slate); font-size: 13px; }
.tile.bad .num { color: var(--red); }
.tile.warn .num { color: var(--amber); }
.tile.good .num { color: var(--green); }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { border-color: var(--blue); text-decoration: none; }
.btn.primary { background: #1D4ED8; border-color: #1D4ED8; color: #fff; }
.btn.primary:hover { background: #1E40AF; }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); }
.btn.sm { min-height: 36px; padding: 4px 12px; font-size: 13px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 12px; min-height: 44px; width: 100%; }
textarea { min-height: 120px; resize: vertical; }
textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; min-height: 260px; white-space: pre; }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: #1D4ED8; }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.row > * { flex: 1 1 160px; }
.row > .fit { flex: 0 0 auto; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 15px; min-height: 44px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.filters > * { flex: 0 1 240px; }

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--card); margin-bottom: 20px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
td.wrap { white-space: normal; min-width: 240px; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--slate); background: var(--mist); }
tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover { background: var(--mist); }
.empty { padding: 28px; text-align: center; color: var(--slate); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; background: var(--slate); }
.dot.on { background: var(--green); }
.dot.off { background: var(--red); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--blue-bg); color: var(--blue); }
.badge.critical { background: var(--red-bg); color: var(--red); }
.badge.warning { background: var(--amber-bg); color: var(--amber); }
.badge.ok { background: var(--green-bg); color: var(--green); }
.badge.grey { background: var(--mist); color: var(--slate); border: 1px solid var(--line); }

.bar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: #1D4ED8; border-radius: 999px; }
.bar.warn > i { background: var(--amber); }
.bar.bad > i { background: var(--red); }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 14px; min-height: 44px; font: inherit; font-weight: 600; color: var(--slate); cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--blue); border-bottom-color: var(--blue); }

dl.kv { display: grid; grid-template-columns: minmax(130px, 200px) 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--slate); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
pre.out { background: #0B1220; color: #E2E8F0; padding: 14px; border-radius: var(--radius); overflow: auto; max-height: 420px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 12px; }
.chart { width: 100%; height: 120px; display: block; }
.chart path.line { fill: none; stroke: #1D4ED8; stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart path.area { fill: #1D4ED8; opacity: 0.12; }
.chart line { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.notice { border-left: 4px solid var(--amber); background: var(--amber-bg); padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.notice.bad { border-color: var(--red); background: var(--red-bg); }
.notice.info { border-color: var(--blue); background: var(--blue-bg); }

dialog { border: 1px solid var(--line); border-radius: var(--radius-card); padding: 24px; width: min(640px, calc(100vw - 32px)); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(7, 20, 38, 0.55); }
dialog .actions { justify-content: flex-end; margin-top: 16px; }
#toast { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 60; }
#toast div { background: var(--navy); color: #fff; padding: 12px 16px; border-radius: var(--radius); max-width: 420px; box-shadow: 0 8px 24px rgba(0,0,0,0.25); }
#toast div.err { background: #991B1B; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 12px; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav hr { display: none; }
  main { padding: 16px; }
  .top { padding: 10px 16px; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .nav a { transition: background-color 0.15s, border-color 0.15s; }
}
a.tile { color: inherit; display: block; }
a.tile:hover { text-decoration: none; border-color: var(--blue); }
.btn.wide { width: 100%; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
