:root {
  --bg: #0d1017;
  --bg-2: #141925;
  --bg-3: #1b2230;
  --border: #2a3344;
  --text: #e6ebf2;
  --text-dim: #8a96a8;
  --accent: #ff5c7a;
  --accent-2: #4ea1ff;

  --c-product: #4ea1ff;
  --c-company: #36d399;
  --c-person: #fbbd23;
  --c-vc_firm: #c084fc;
  --c-path: #ff4d4d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ---------- Sidebar ---------- */
#sidebar {
  width: 330px;
  min-width: 330px;
  height: 100%;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px;
}

.sb-head h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 1px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.subtitle { margin: 4px 0 10px; color: var(--text-dim); font-size: 11px; }

.panel {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
}
.panel-title { font-weight: 600; margin-bottom: 8px; font-size: 12px; color: #cdd6e3; }
.hint { color: var(--text-dim); font-size: 11px; margin: 0 0 8px; line-height: 1.5; }

input[type="text"], select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 8px;
  font-size: 12px;
  outline: none;
}
input[type="text"]:focus, select:focus { border-color: var(--accent-2); }

.fld { display: block; margin-bottom: 8px; font-size: 11px; color: var(--text-dim); }
.fld input { margin-top: 4px; }

.btn {
  background: linear-gradient(90deg, var(--accent), #ff7a93);
  color: #fff; border: none; border-radius: 6px;
  padding: 8px 10px; font-size: 12px; cursor: pointer; font-weight: 600;
}
.btn:hover { filter: brightness(1.08); }
.btn-block { width: 100%; }

.search-results { margin-top: 8px; max-height: 180px; overflow-y: auto; }
.search-results .sr-item {
  padding: 6px 8px; border-radius: 5px; cursor: pointer;
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
}
.search-results .sr-item:hover { background: var(--bg); }
.sr-name { font-weight: 600; }
.sr-type { font-size: 10px; color: var(--text-dim); }

.path-result { margin-top: 10px; font-size: 12px; line-height: 1.6; }
.path-result .pr-ok { color: var(--c-path); font-weight: 600; }
.path-result .pr-warn { color: var(--c-person); font-weight: 600; }
.path-result .pr-err { color: #ff8080; font-weight: 600; }
.path-chain { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; align-items: center; }
.path-chain .pc-node {
  background: var(--bg); border: 1px solid var(--c-path); color: var(--text);
  border-radius: 12px; padding: 3px 9px; font-size: 11px; cursor: pointer;
}
.path-chain .pc-arrow { color: var(--text-dim); }

/* ---------- Stats ---------- */
.stats-list .sl-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 8px; border-radius: 5px; cursor: pointer; gap: 8px;
}
.stats-list .sl-row:hover { background: var(--bg); }
.sl-rank { color: var(--text-dim); width: 18px; }
.sl-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-deg { font-weight: 700; color: var(--accent-2); }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stats-grid .sg-item {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px; font-size: 11px;
  display: flex; flex-direction: column; gap: 2px;
}
.sg-item .sg-key { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-item .sg-val { font-weight: 700; font-size: 13px; }
.sg-item.clickable { cursor: pointer; }
.sg-item.clickable:hover { border-color: var(--accent-2); }

/* ---------- Stage ---------- */
#stage { position: relative; flex: 1; height: 100%; overflow: hidden; background:
  radial-gradient(circle at 30% 20%, #161d2b 0, var(--bg) 60%); }
#graph { width: 100%; height: 100%; display: block; cursor: grab; }
#graph.panning { cursor: grabbing; }

.legend {
  position: absolute; top: 12px; left: 12px; z-index: 5;
  background: rgba(20,25,37,.85); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; display: flex; gap: 14px; flex-wrap: wrap;
}
.legend .lg { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); }
.legend .dot { width: 11px; height: 11px; border-radius: 50%; }

.zoom-ctl { position: absolute; right: 14px; bottom: 14px; z-index: 5; display: flex; flex-direction: column; gap: 6px; }
.zoom-ctl button {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: rgba(20,25,37,.9); color: var(--text); font-size: 16px; cursor: pointer;
}
.zoom-ctl button:hover { border-color: var(--accent-2); }

/* ---------- SVG elements ---------- */
.edge { stroke: #2f3a4d; stroke-width: 1; }
.edge.hl { stroke: var(--c-path); stroke-width: 2.5; }
.edge.dim { stroke: #1a2130; }

.node-circle { stroke: #0d1017; stroke-width: 1.2; cursor: pointer; }
.node-label {
  fill: var(--text); font-size: 9px; pointer-events: none;
  text-anchor: middle; paint-order: stroke; stroke: #0d1017; stroke-width: 2.5px;
  display: none;
}
.node.showlabel .node-label { display: block; }
.node.selected .node-circle { stroke: #fff; stroke-width: 2.5; }
.node.neighbor .node-circle { stroke: var(--accent-2); stroke-width: 2; }
.node.path .node-circle { stroke: var(--c-path); stroke-width: 3; }
.node.searchhit .node-circle { stroke: #fff; stroke-width: 2.5; }
.node.dim { opacity: 0.12; }
.node.faded { opacity: 0.25; }

/* ---------- Detail panel ---------- */
.detail {
  position: absolute; top: 12px; right: 12px; width: 300px; max-height: 80%;
  overflow-y: auto; z-index: 6; background: rgba(20,25,37,.96);
  border: 1px solid var(--border); border-radius: 10px; padding: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.detail.hidden { display: none; }
.detail-close {
  position: absolute; top: 6px; right: 8px; background: none; border: none;
  color: var(--text-dim); font-size: 20px; cursor: pointer; line-height: 1;
}
.detail-close:hover { color: #fff; }
.detail h2 { margin: 0 0 4px; font-size: 16px; }
.detail .d-type {
  display: inline-block; font-size: 10px; padding: 2px 8px; border-radius: 10px;
  margin-bottom: 8px; color: #0d1017; font-weight: 700;
}
.detail .d-desc { color: #cdd6e3; line-height: 1.6; margin: 6px 0; font-size: 12px; }
.detail .d-meta { display: flex; gap: 14px; font-size: 11px; color: var(--text-dim); margin: 6px 0; }
.detail .d-meta b { color: var(--accent-2); font-size: 14px; }
.detail .d-aliases { font-size: 11px; color: var(--text-dim); margin: 6px 0; }
.detail .d-sec-title { font-size: 11px; color: var(--text-dim); margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .5px; }
.detail .nb { padding: 5px 8px; border-radius: 6px; background: var(--bg); margin-bottom: 4px; cursor: pointer; font-size: 11px; }
.detail .nb:hover { border: 1px solid var(--accent-2); }
.detail .nb .nb-rel { color: var(--text-dim); font-size: 10px; }
.detail .nb .nb-dir { color: var(--c-person); font-size: 10px; margin-left: 4px; }

.loaderr {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #ff8080; padding: 30px; text-align: center; line-height: 1.7;
}
.loaderr.hidden { display: none; }
