:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f8fafb;
  --surface-soft: #eef6f7;
  --text: #18232b;
  --strong: #101820;
  --muted: #647782;
  --border: #d9e2e7;
  --border-strong: #c7d4dc;
  --accent: #216f86;
  --success: #2b8a57;
  --success-soft: #edf8f1;
  --danger: #aa3f3f;
  --danger-soft: #fff0ef;
  --unknown: #7a8790;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
}

.nodeBoard {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 12px 18px 24px;
}

.formError {
  border: 1px solid var(--danger);
  border-left: 4px solid var(--danger);
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  padding: 10px 12px;
  font-size: 14px;
}

.summaryGrid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.statCard,
.topologyPanel,
.detailPanel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.statCard {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-height: 32px;
  padding: 6px 10px;
}

.statCard span,
.statCard small {
  color: var(--muted);
  font-size: 12px;
}

.statCard strong {
  color: var(--strong);
  font-size: 15px;
  line-height: 1.1;
}

.topologyPanel,
.detailPanel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.snapshotHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.topologyPanel h2,
.detailPanel h2 {
  margin: 0;
  color: var(--strong);
  font-size: 18px;
  letter-spacing: 0;
}

.sectionBlock {
  display: grid;
  gap: 8px;
  padding-top: 4px;
}

.sectionBlock h3 {
  margin: 0;
  color: var(--strong);
  font-size: 14px;
}

.topologyCanvas {
  height: calc(100vh - 170px);
  min-height: 560px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-muted) 88%, transparent), var(--surface-soft));
}

.topologySvg {
  width: 100%;
  height: 100%;
}

.topologyCanvas .empty {
  display: grid;
  place-items: center;
  height: 100%;
}

.topologyNode {
  cursor: pointer;
}

.topologyNode rect:first-child {
  fill: var(--surface);
  stroke: var(--border);
}

.topologyNode.selected rect:first-child {
  stroke: var(--accent);
  stroke-width: 2;
}

.topologyNode .nodeAccent {
  fill: var(--unknown);
  stroke: none;
}

.topologyNode.online .nodeAccent,
.topologyNode.online .nodeStatus {
  fill: var(--success);
}

.topologyNode .nodeStatus {
  fill: var(--unknown);
}

.topologyNode .nodeTitle {
  fill: var(--strong);
  font-size: 13px;
  font-weight: 700;
}

.topologyNode .nodeSub {
  fill: var(--muted);
  font-size: 10px;
}

.topologyEdge line {
  stroke: var(--unknown);
  stroke-width: 2.5;
}

.topologyEdge.dimmed line {
  opacity: 0.1;
}

.topologyEdge.related line {
  stroke-width: 3.5;
}

.topologyEdge.healthy line {
  stroke: var(--success);
}

.topologyEdge.down line {
  stroke: var(--danger);
}

.topologyEdgeLabel {
  fill: var(--strong);
  font-size: 11px;
  pointer-events: none;
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 4px;
  text-anchor: middle;
}

.topologyEdgeLabel.lossy {
  fill: var(--danger);
}

.statusList {
  display: grid;
  gap: 8px;
}

.statusRow > div,
.nodeSnapshot {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.statusRow strong,
.nodeSnapshot strong {
  color: var(--strong);
}

.statusRow small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.statusRow {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 10px 12px;
}

.statusPill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 24px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-style: normal;
  line-height: 1.2;
  white-space: nowrap;
}

.statusPill.healthy {
  border-color: color-mix(in srgb, var(--success) 68%, var(--border));
  background: var(--success-soft);
  color: var(--success);
}

.statusPill.unknown {
  background: var(--surface);
  color: var(--unknown);
}

.infoGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.infoGrid div,
.nodeSnapshot {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 10px;
}

.infoGrid dt {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.infoGrid dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--strong);
  font-size: 13px;
}

.empty {
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

@media (max-width: 700px) {
  .nodeBoard {
    padding: 10px 14px 18px;
  }

  .infoGrid {
    grid-template-columns: 1fr;
  }

  .topologyCanvas {
    height: 560px;
  }

  .statCard strong {
    font-size: 20px;
  }

  .statusRow {
    display: grid;
  }
}
