:root {
  color-scheme: light;
  --bg0: #dce8f5;
  --bg1: #f7fbff;
  --panel: rgba(255, 255, 255, 0.76);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --line: rgba(71, 85, 105, 0.22);
  --text: #0f172a;
  --muted: #64748b;
  --ok: #047857;
  --warn: #b45309;
  --bad: #dc2626;
  --accent: #0284c7;
  --violet: #7c3aed;
  --shadow: 0 22px 55px rgba(15, 23, 42, 0.16);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 14%, rgba(255, 255, 255, 0.9), transparent 34%),
    radial-gradient(circle at 84% 18%, rgba(125, 211, 252, 0.35), transparent 28%),
    radial-gradient(circle at 72% 78%, rgba(167, 139, 250, 0.22), transparent 34%),
    linear-gradient(135deg, var(--bg1) 0%, var(--bg0) 48%, #c3d1e3 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.22) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.48;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 28px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(255,255,255,0.88), rgba(238, 246, 255, 0.64));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.35);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, p { margin: 0; }
h1 { font-size: clamp(24px, 3vw, 38px); font-weight: 850; letter-spacing: -0.04em; }
h2 { font-size: 16px; font-weight: 820; }
.subline { margin-top: 5px; color: var(--muted); font-size: 13px; }

.nav-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.nav-link {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.18);
}
.nav-link.ghost { background: rgba(255,255,255,0.72); color: var(--text); border: 1px solid var(--line); }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.metric-card, .panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px) saturate(1.35);
}
.metric-card::before, .panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255,255,255,0.62), transparent 42%, rgba(148,163,184,0.08));
}
.metric-card > *, .panel > * { position: relative; z-index: 1; }
.metric-card.main { padding: 16px; min-height: 232px; display: grid; grid-template-rows: auto 1fr auto; }
.card-head, .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head span { color: var(--muted); font-weight: 850; text-transform: uppercase; font-size: 12px; letter-spacing: .08em; }

.state-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.72);
  color: var(--muted);
}
.state-pill.ok { color: var(--ok); background: rgba(209,250,229,0.8); border-color: rgba(4,120,87,.22); }
.state-pill.warn { color: var(--warn); background: rgba(254,243,199,0.82); border-color: rgba(180,83,9,.24); }
.state-pill.bad { color: var(--bad); background: rgba(254,226,226,0.82); border-color: rgba(220,38,38,.24); }
.state-pill.neutral { color: #475569; }

.gauge {
  --value: 0;
  width: 144px;
  height: 144px;
  margin: 14px auto 8px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--accent) calc(var(--value) * 1%), rgba(148, 163, 184, .22) 0);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.7), 0 16px 32px rgba(2, 132, 199, .14);
}
.gauge-inner {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  background: rgba(255,255,255,0.92);
  box-shadow: inset 0 0 20px rgba(15, 23, 42, .05);
}
.gauge-inner strong { font-size: 28px; line-height: 1; }
.gauge-inner span { color: var(--muted); font-size: 12px; font-weight: 800; margin-top: 4px; }

.big-number { align-self: center; justify-self: center; display: flex; align-items: flex-end; gap: 5px; }
.big-number strong { font-size: 56px; line-height: .9; letter-spacing: -.06em; }
.big-number span { margin-bottom: 8px; color: var(--muted); font-weight: 850; }
.bar { height: 10px; border-radius: 999px; background: rgba(148,163,184,.24); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--violet)); border-radius: inherit; transition: width .25s ease; }
.hint { margin-top: 8px; color: var(--muted); font-size: 12px; }
.mini-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; }
.mini-meta b { color: var(--text); }

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 12px;
  margin-top: 12px;
}
.panel { padding: 16px; }
.panel-head p { margin-top: 2px; color: var(--muted); font-size: 12px; }
.chart-panel { min-height: 340px; }
#systemChart { width: 100%; height: 260px; margin-top: 14px; border-radius: 14px; background: rgba(255,255,255,.56); border: 1px solid var(--line); }

.network-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.network-box, .link-box, .count-row, .stream-row {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.62);
  padding: 12px;
}
.network-box span, .link-box span { display: block; color: var(--muted); font-size: 12px; font-weight: 820; text-transform: uppercase; }
.network-box strong, .link-box strong { display: block; margin-top: 4px; font-size: 22px; }
.network-box small, .link-box small { color: var(--muted); font-size: 12px; }

.kv-grid { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 9px 12px; margin-top: 14px; font-size: 13px; }
.kv-grid span { color: var(--muted); font-weight: 760; }
.kv-grid strong { overflow-wrap: anywhere; }
.robot-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.link-box.ok { border-color: rgba(4,120,87,.24); background: rgba(209,250,229,.58); }
.link-box.warn { border-color: rgba(180,83,9,.25); background: rgba(254,243,199,.58); }
.link-box.bad { border-color: rgba(220,38,38,.25); background: rgba(254,226,226,.58); }
.counts { display: grid; gap: 8px; margin-top: 12px; }
.count-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.count-row span { color: var(--muted); }

.stream-list { display: grid; gap: 8px; margin-top: 14px; }
.stream-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; }
.stream-main strong { display: block; font-size: 13px; }
.stream-main small { display: block; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stream-row .frames { font-weight: 850; font-size: 13px; }
.stream-row .age { min-width: 58px; text-align: right; color: var(--muted); font-size: 12px; }
.stream-row.live { border-color: rgba(4,120,87,.25); }

.raw-panel { grid-column: 1 / -1; }
pre { margin: 12px 0 0; max-height: 300px; overflow: auto; padding: 14px; border-radius: 14px; background: #0f172a; color: #dbeafe; font-size: 12px; line-height: 1.5; }

@media (max-width: 1100px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .shell { width: min(100vw - 18px, 1480px); padding-top: 9px; }
  .hero, .card-head, .panel-head { align-items: flex-start; flex-direction: column; }
  .summary-grid, .network-grid, .robot-links { grid-template-columns: 1fr; }
  .metric-card.main { min-height: 210px; }
}
