:root {
  --blue: #0072bd;
  --orange: #d95319;
  --ink: #111;
  --muted: #5d6670;
  --line: #d8dde3;
  --panel: #f7f9fb;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: #fff;
}
.app { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
header {
  padding: 18px 26px 14px;
  border-bottom: 1px solid var(--line);
  background: white;
}
h1 { margin: 0 0 12px; font-size: 28px; line-height: 1.15; font-weight: 800; }
.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  align-items: end;
}
label { display: grid; gap: 6px; font-size: 12px; font-weight: 700; color: #27313b; }
select, input[type="range"] { width: 100%; }
select {
  height: 34px;
  border: 1px solid #b9c2cc;
  border-radius: 4px;
  background: white;
  font-size: 14px;
  padding: 0 8px;
}
button {
  height: 34px;
  border: 1px solid #8aa9c6;
  border-radius: 4px;
  background: var(--blue);
  color: white;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
button:hover { filter: brightness(.95); }
.value { color: var(--blue); font-weight: 800; font-variant-numeric: tabular-nums; }
main { display: grid; grid-template-columns: minmax(0, 1fr) 330px; min-height: 0; }
.canvas-wrap { position: relative; min-height: 720px; overflow: hidden; }
svg { width: 100%; height: 100%; min-height: 720px; display: block; background: white; }
aside { border-left: 1px solid var(--line); background: var(--panel); padding: 18px; overflow: auto; }
.stat {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.stat strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.legend { margin-top: 18px; display: grid; gap: 8px; font-size: 13px; color: #27313b; }
.legend-row { display: flex; align-items: center; gap: 9px; }
.swatch-line { width: 42px; height: 0; border-top: 5px solid var(--blue); }
.swatch-line.neg { border-top-color: var(--orange); border-top-style: dashed; }
.swatch-dot { width: 16px; height: 16px; border-radius: 50%; background: #808080; }
.hint { margin-top: 18px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.data-note {
  margin-top: 14px;
  padding: 8px 10px;
  background: #fff8e6;
  border: 1px solid #e8d9a0;
  border-radius: 4px;
  color: #6b5900;
  font-size: 12px;
  line-height: 1.4;
}

/* nodes */
.node circle {
  stroke: white;
  stroke-width: 1.7;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.12));
  transition: opacity .12s;
}
.node { cursor: pointer; outline: none; }
.node:focus-visible circle { stroke: #111; stroke-dasharray: 3 2; stroke-width: 2.5; }
.node.selected circle { stroke: #111; stroke-width: 3; }
.node text {
  fill: white;
  font-size: 10px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}
.node.dim circle { opacity: .22; }
.node.dim text { opacity: .25; }

/* edges */
.edge {
  fill: none;
  stroke: var(--blue);
  stroke-linecap: round;
  opacity: .43;
  transition: opacity .12s;
}
.edge.neg { stroke: var(--orange); stroke-dasharray: 6 4; }
.edge.hidden, .edge-label.hidden { display: none; }
.edge-label {
  fill: var(--blue);
  font-size: 7px;
  font-weight: 700;
  paint-order: stroke;
  stroke: white;
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
}
.edge-label.neg { fill: var(--orange); }

.title { font-size: 18px; font-weight: 800; text-anchor: middle; }
.subtitle { fill: #20262d; font-size: 13px; font-weight: 700; text-anchor: middle; }
.datastamp { fill: #8a929b; font-size: 10px; text-anchor: middle; }
.empty-msg { fill: var(--muted); font-size: 15px; font-weight: 700; text-anchor: middle; }
.panel-title { font-size: 13px; font-weight: 800; text-anchor: middle; }

.tooltip {
  position: fixed;
  pointer-events: none;
  background: rgba(17, 24, 39, .94);
  color: white;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.35;
  max-width: 300px;
  display: none;
  z-index: 5;
}
.loading {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.7);
  font-weight: 800;
  color: var(--muted);
}
.loading.on { display: flex; }

@media (max-width: 980px) {
  main { grid-template-columns: 1fr; }
  aside { border-left: 0; border-top: 1px solid var(--line); }
  .canvas-wrap, svg { min-height: 92vw; }
}
