:root {
  color-scheme: dark;
  --page: #080c18;
  --surface: #0f1628;
  --surface-2: #131b30;
  --raise: #172038;
  --line: #1b2439;
  --line-2: #243049;
  --grid: #1a2338;
  --axis: #2b3652;

  --ink: #e8edf7;
  --ink-2: #a3aec5;
  --ink-3: #6c7791;

  --accent: #2f6bff;
  --accent-ink: #8fb0ff;
  --s1: #3d7cff;
  --s2: #e0643a;
  --good: #2fb36f;
  --warn: #e9a23b;
  --bad: #e5484d;
  --signal: #f5c518;

  --r: 12px;
  --sans: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--ink); }
body {
  font: 400 13px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--ink-3); }
.dim { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- login */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 28px 28px;
}
.login-card img { width: 44px; height: 44px; display: block; margin-bottom: 20px; }
.login-card h1 { font-size: 18px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
.login-card p { margin: 0 0 22px; color: var(--ink-2); }
.login-card label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.field {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  background: var(--page);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12px;
}
.field:focus { outline: none; border-color: var(--accent); }
.btn {
  height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font-weight: 500;
}
.btn:hover { background: #2a5fe6; }
.btn[disabled] { opacity: 0.6; cursor: default; }
.login-card .btn { width: 100%; margin-top: 14px; }
.login-error { color: var(--bad); font-size: 12px; margin-top: 10px; min-height: 18px; }

/* ---------------------------------------------------------------- shell */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(8, 12, 24, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top-inner, .wrap { max-width: 1440px; margin: 0 auto; padding: 0 24px; }
.top-inner { height: 56px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 24px; height: 24px; border-radius: 6px; }
.brand b { font-weight: 600; letter-spacing: 0.08em; font-size: 12px; }
.brand span { color: var(--ink-3); }
.brand .host { color: var(--ink-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }

.live { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 12px; white-space: nowrap; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.live.err i { background: var(--bad); }
.live.busy i { animation: blink 0.9s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; }
.seg button {
  height: 26px;
  min-width: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed='true'] { background: var(--raise); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.seg button .count { color: var(--ink-3); margin-left: 6px; font-variant-numeric: tabular-nums; }

.ghost {
  white-space: nowrap;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
}
.ghost:hover { color: var(--ink); border-color: var(--line-2); }

main.wrap { padding-top: 20px; padding-bottom: 48px; display: grid; gap: 16px; transition: opacity 0.2s; }
main.loading { opacity: 0.55; }

.notice {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r);
  padding: 10px 14px;
  color: var(--ink-2);
  font-size: 12px;
}
.notice.err { border-color: rgba(229, 72, 77, 0.35); color: #f2a7a9; }

/* ---------------------------------------------------------------- stats */

.stats {
  display: grid;
  grid-template-columns: 1.35fr repeat(5, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.stat { padding: 16px 18px 14px; border-left: 1px solid var(--line); min-width: 0; display: flex; flex-direction: column; }
.stat:first-child { border-left: 0; }
.stat-label { color: var(--ink-2); font-size: 12px; display: flex; align-items: center; gap: 8px; }
.stat-value { font-size: 28px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.15; margin-top: 8px; }
.stat-value small { font-size: 13px; color: var(--ink-3); font-weight: 400; margin-left: 4px; letter-spacing: 0; }
.stat.hero .stat-value { font-size: 48px; letter-spacing: -0.03em; line-height: 1; margin-top: 10px; }
.stat-sub { color: var(--ink-3); font-size: 12px; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-sub b { color: var(--ink-2); font-weight: 500; }
.stat .spark { margin-top: auto; padding-top: 10px; height: 38px; }
.spark svg { display: block; width: 100%; height: 28px; overflow: visible; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px rgba(47, 179, 111, 0.15); }

/* ---------------------------------------------------------------- cards */

.row { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.row.wide { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; display: flex; flex-direction: column; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px 0; min-height: 44px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: -0.005em; }
.card-head .sub { color: var(--ink-3); font-size: 12px; }
.card-head .tools { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 12px 18px 16px; min-width: 0; }
.card-body.flush { padding: 8px 0 6px; }

.legend { display: flex; gap: 14px; color: var(--ink-2); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 2px; width: 14px; border-radius: 2px; }

.link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--ink-3);
  font-size: 12px;
}
.link:hover { color: var(--ink); }

/* ---------------------------------------------------------------- charts */

.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .tick { fill: var(--ink-3); font: 400 11px var(--sans); font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .base { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .band { fill: transparent; }
.chart .band.on { fill: rgba(255, 255, 255, 0.035); }
.chart .xhair { stroke: var(--ink-3); stroke-width: 1; shape-rendering: crispEdges; }
.chart .blank { fill: rgba(255, 255, 255, 0.015); }
.chart .blank-label { fill: var(--ink-3); font: 400 11px var(--sans); }
.table-view { max-height: 228px; overflow-y: auto; }
.chart-empty { height: 200px; display: grid; place-items: center; color: var(--ink-3); font-size: 12px; }

.tip {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  min-width: 140px;
  background: #0a1020;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  font-size: 12px;
  visibility: hidden;
}
.tip.on { visibility: visible; }
.tip-t { color: var(--ink-3); margin-bottom: 4px; white-space: nowrap; }
.tip-r { display: flex; align-items: center; gap: 8px; white-space: nowrap; line-height: 1.7; }
.tip-r i { width: 10px; height: 2px; border-radius: 2px; flex: none; }
.tip-r b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-r span { color: var(--ink-2); }

/* ---------------------------------------------------------------- tables */

.scroll-x { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-weight: 500;
  color: var(--ink-3);
  font-size: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { padding-left: 18px; }
th:last-child, td:last-child { padding-right: 18px; }
th.r, td.r { text-align: right; white-space: nowrap; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: rgba(255, 255, 255, 0.02); }
tbody tr.click:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.cell-main { color: var(--ink); max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-sub { color: var(--ink-3); font-family: var(--mono); font-size: 11px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; }
.method {
  display: inline-block;
  min-width: 44px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-2);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  padding: 0 5px;
  text-align: center;
  margin-right: 8px;
}
.meter { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.meter .bar { width: 72px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; flex: none; }
.meter .bar i { display: block; height: 100%; background: var(--s1); border-radius: 2px; }
.bad-ink { color: #f08a8d; }
.warn-ink { color: #f0c37a; }
.good-ink { color: #6fd6a0; }

.status { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex: none; }
.status.on i { background: var(--good); }
.status.off i { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-3); }
.status.revoked i { background: var(--bad); }
.status em { font-style: normal; color: var(--ink-3); }

.toolbar { display: flex; gap: 10px; align-items: center; }
.search {
  height: 30px;
  width: 220px;
  padding: 0 10px;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
}
.search:focus { outline: none; border-color: var(--line-2); }
.empty { padding: 28px 18px; color: var(--ink-3); text-align: center; }
.more { padding: 10px 18px 4px; }

/* ---------------------------------------------------------------- feed */

.feed { max-height: 460px; overflow-y: auto; }
.ev { display: grid; grid-template-columns: 62px 16px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 8px 18px; border-bottom: 1px solid var(--line); }
.ev:last-child { border-bottom: 0; }
.ev time { color: var(--ink-3); font-family: var(--mono); font-size: 11px; padding-top: 1px; }
.ev .k { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; background: var(--ink-3); }
.ev .k.good { background: var(--good); }
.ev .k.bad { background: var(--bad); }
.ev .k.info { background: var(--s1); }
.ev .k.hollow { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-3); }
.ev-body { min-width: 0; }
.ev-what { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-who { color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-side { text-align: right; color: var(--ink-3); font-size: 12px; white-space: nowrap; }

/* ---------------------------------------------------------------- facts */

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; }
.fact { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; }
.fact:nth-child(odd) { padding-right: 16px; }
.fact:nth-child(even) { padding-left: 16px; border-left: 1px solid var(--line); }
.fact span { color: var(--ink-2); }
.fact b { font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-title { font-size: 12px; color: var(--ink-3); margin: 18px 0 4px; display: flex; align-items: center; gap: 8px; }
.section-title:first-child { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-2); border-radius: 999px; padding: 2px 9px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.chip b { color: var(--ink); font-weight: 500; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- drawer */

.scrim { position: fixed; inset: 0; background: rgba(3, 6, 14, 0.55); z-index: 20; opacity: 0; transition: opacity 0.18s; }
.scrim.on { opacity: 1; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line-2);
  z-index: 21;
  display: flex;
  flex-direction: column;
  transform: translateX(16px);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.drawer.on { transform: none; opacity: 1; }
.drawer-head { padding: 18px 20px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.drawer-head .grow { flex: 1; min-width: 0; }
.drawer-head h3 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.drawer-head .id { margin-top: 4px; display: flex; gap: 8px; align-items: center; color: var(--ink-3); }
.drawer-body { overflow-y: auto; padding: 16px 20px 28px; flex: 1; }
.x { margin-left: auto; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--ink-2); font-size: 16px; line-height: 1; flex: none; }
.x:hover { color: var(--ink); border-color: var(--line-2); }
.list { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); min-width: 0; }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prio { width: 3px; align-self: stretch; border-radius: 2px; background: var(--ink-3); flex: none; }
.prio.p0 { background: var(--bad); }
.prio.p1 { background: var(--warn); }
.prio.p2 { background: var(--s1); }
.code { font-family: var(--mono); font-size: 11px; color: var(--ink-2); min-width: 44px; }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat:nth-child(4) { border-left: 0; }
  .stat:nth-child(n + 4) { border-top: 1px solid var(--line); }
  .row.wide, .row { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .top-inner, .wrap { padding: 0 14px; }
  .brand .host, .brand span, .brand b { display: none; }
  .top-inner { gap: 10px; }
  .seg button { min-width: 34px; padding: 0 7px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat { border-left: 0 !important; border-top: 1px solid var(--line); }
  .stat:nth-child(even) { border-left: 1px solid var(--line) !important; }
  .stat:nth-child(-n + 2) { border-top: 0; }
  .stat.hero .stat-value { font-size: 40px; }
  .search { width: 100%; }
  .facts { grid-template-columns: 1fr; }
  .fact:nth-child(even) { padding-left: 0; border-left: 0; }
  .fact:nth-child(odd) { padding-right: 0; }
  .live span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
