/* Full-page topology: the graph is the page, statistics float over it. */
body.topo-page { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.topbar.slim { position: relative; padding: 8px 16px; flex: none; }
.topbar.slim .brand { gap: 12px; min-width: 0; }
.graph-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The stage is <main>: undo the detail page's main { max-width; padding; grid }. */
body.topo-page main.stage {
  flex: 1; height: auto; min-height: 0; width: 100%; max-width: none; margin: 0; padding: 0; display: block; position: relative;
}
:root { --bar-track: #dfe9f6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bar-track: #26364d; } }
:root[data-theme="dark"] { --bar-track: #26364d; }
.svc-row .bar, .stack { background: var(--bar-track); }

/* ---------- HUD panel ---------- */
.hud {
  position: absolute; left: 16px; top: 16px; bottom: 16px; width: 348px; z-index: 5;
  display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  cursor: default; user-select: text;
}
.hud[hidden] { display: none; }
.hud-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 4px 16px; }
.hud-title { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.hud-collapse { border: 0; background: transparent; color: var(--ink-2); font-size: 18px; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.hud-collapse:hover { background: var(--surface-2); }
.hud-open {
  position: absolute; left: 16px; top: 16px; z-index: 5; font: inherit; font-size: 13px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}
.hud-open[hidden] { display: none; }
.hud-body { overflow-y: auto; padding: 4px 14px 14px 16px; display: grid; gap: 12px; grid-auto-rows: max-content; }

.hud-hero { display: flex; align-items: center; gap: 14px; }
.ring-wrap { position: relative; width: 104px; height: 104px; flex: none; }
.ring { width: 100%; height: 100%; }
.ring-track { fill: none; stroke: var(--surface-2); stroke-width: 10; }
.ring-arc { fill: none; stroke-width: 10; stroke-linecap: butt; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-center b { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.ring-center span { font-size: 11px; color: var(--muted); }
.hero-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.hero-rps b { font-size: 34px; font-weight: 650; letter-spacing: -0.03em; line-height: 1; }
.hero-rps span { color: var(--muted); font-size: 13px; margin-left: 4px; }
.hero-legend { display: grid; gap: 3px; font-size: 12px; color: var(--ink-2); }
.hero-legend span { display: inline-flex; align-items: center; gap: 6px; }
.hero-legend .st { font-style: normal; }

.hud-card { display: grid; gap: 6px; }
.hud-card[hidden] { display: none; }
.hud-label { display: flex; align-items: baseline; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink); min-width: 0; }
.hud-hint { font-weight: 400; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-total { margin-left: auto; font-size: 12px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hud-chart { position: relative; height: 96px; }

.hud-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.hud-kpis div { background: var(--surface-2); border-radius: 10px; padding: 7px 9px; display: flex; flex-direction: column; min-width: 0; }
.hud-kpis span { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-kpis b { font-size: 15px; font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hud-kpis b span { font-size: inherit; color: inherit; }
.hud-kpis b .bad { color: var(--critical-text); }

.svc-bars, .db-bars { display: grid; gap: 2px; }
.svc-row {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) 50px 38px 40px 52px; align-items: center; gap: 6px;
  font: inherit; font-size: 11px; color: var(--ink-2); text-align: left;
  background: transparent; border: 0; border-radius: 6px; padding: 4px; cursor: pointer;
}
.svc-row:hover { background: var(--surface-2); }
.svc-row .swatch { width: 10px; height: 10px; border-radius: 3px; }
.svc-n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.svc-row b { font-weight: 600; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.svc-row .bar { height: 6px; border-radius: 3px; background: var(--bar-track); overflow: hidden; }
.svc-row .fill { display: block; height: 100%; border-radius: 3px; background: var(--series-1); transition: width 0.6s ease; }
.svc-row .fill.warn { background: var(--warning); }
.svc-row .fill.crit { background: var(--critical); }
.svc-row .bar.mem .fill { background: var(--ink-2); opacity: 0.55; }
.db-row { grid-template-columns: 16px minmax(0, 1fr) 90px 56px; }
.db-ic { width: 16px; height: 16px; color: var(--series-1); }
.db-ic svg { width: 16px; height: 16px; display: block; }

/* ---------- tools (bottom-right) ---------- */
.tools { position: absolute; right: 16px; bottom: 16px; z-index: 4; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.tools .legend-box { position: static; }
.tools .zoom .icon-btn { background: var(--surface); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08); }

/* ---------- live event ticker (bottom, beside the HUD) ---------- */
.ticker {
  position: absolute; left: 384px; bottom: 16px; z-index: 4; display: flex; flex-direction: column-reverse; gap: 6px;
  width: min(520px, calc(100% - 760px)); pointer-events: none; align-items: flex-start;
}
.hud[hidden] ~ .ticker { left: 16px; }
.event {
  pointer-events: auto; display: flex; align-items: center; gap: 8px; text-align: left; max-width: 100%;
  font: inherit; font-size: 12px; color: var(--ink); cursor: pointer;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px 5px 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  animation: ev-in 0.35s ease-out; transition: opacity 1s;
}
.event.old { opacity: 0.55; }
.event i { font-style: normal; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 800; color: #fff; background: var(--muted); flex: none; }
.ev-error i { background: var(--critical); }
.ev-warn i { background: var(--warning); color: #3d2a00; }
.ev-good i { background: var(--good); }
.ev-up i, .ev-down i { background: var(--series-1); }
.ev-time { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.ev-more { color: var(--muted); }
.event span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@keyframes ev-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- critical nodes pulse ---------- */
.node.service.crit { animation: crit-pulse 1.8s ease-in-out infinite; }
@keyframes crit-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--critical) 45%, transparent), var(--node-shadow); }
  50% { box-shadow: 0 0 0 8px transparent, var(--node-shadow); }
}
@media (prefers-reduced-motion: reduce) {
  .node.service.crit, .event { animation: none; }
}

@media (max-width: 1100px) {
  .ticker { display: none; }
  .tools .legend-box { display: none; }
  .graph-sub { display: none; }
}
@media (max-width: 700px) {
  .hud { right: 16px; width: auto; }
}
