:root {
  --bg: #0e1116;
  --bg-soft: #161b22;
  --bg-panel: #1b222c;
  --line: #2a3441;
  --text: #e6edf3;
  --text-dim: #97a3b2;
  --accent: #4da3ff;
  --accent-2: #ffb454;

  /* 节点类型配色 */
  --t-product: #4da3ff;
  --t-company: #ffb454;
  --t-person: #5ad19a;
  --t-vc_firm: #c084fc;
  --path: #ff4d6d;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

#app {
  display: grid;
  grid-template-columns: 1fr 360px;
  height: 100vh;
}

/* ---------- 图谱舞台 ---------- */
#stage { position: relative; overflow: hidden; background:
  radial-gradient(circle at 30% 20%, #14202e 0%, var(--bg) 60%); }
#graph { display: block; width: 100%; height: 100%; cursor: grab; }
#graph.grabbing { cursor: grabbing; }

.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 15px; z-index: 30;
  background: rgba(14,17,22,.6);
}
.overlay.hidden { display: none; }

/* 顶部工具条 */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 16px;
  background: linear-gradient(180deg, rgba(14,17,22,.92), rgba(14,17,22,0));
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.brand { font-size: 15px; letter-spacing: .5px; color: var(--text-dim); }
.brand b { color: var(--accent); }
.tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.search-wrap { position: relative; }
#search {
  width: 240px; padding: 8px 30px 8px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  font-size: 13px;
}
#search:focus { outline: none; border-color: var(--accent); }
#search-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; color: var(--text-dim);
  cursor: pointer; font-size: 12px; padding: 4px;
}
#search-results {
  position: absolute; top: 40px; left: 0; right: 0; margin: 0; padding: 4px;
  list-style: none; background: var(--bg-panel); border: 1px solid var(--line);
  border-radius: 8px; max-height: 300px; overflow-y: auto; z-index: 40;
  display: none;
}
#search-results.show { display: block; }
#search-results li {
  padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px;
  display: flex; align-items: center; gap: 8px;
}
#search-results li:hover { background: var(--bg-soft); }
#search-results .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
#search-results .meta { color: var(--text-dim); font-size: 11px; margin-left: auto; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters label {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  padding: 5px 9px; border-radius: 7px; font-size: 12px;
  background: var(--bg-soft); border: 1px solid var(--line);
  user-select: none;
}
.filters label.off { opacity: .4; }
.filters .dot { width: 9px; height: 9px; border-radius: 50%; }
.filters input { display: none; }

.btn {
  padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 13px;
  background: var(--bg-soft); border: 1px solid var(--line); color: var(--text);
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #041627; border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }

/* 图例 */
#legend {
  position: absolute; left: 16px; bottom: 16px; z-index: 15;
  display: flex; gap: 14px; flex-wrap: wrap; padding: 8px 12px;
  background: rgba(27,34,44,.85); border: 1px solid var(--line);
  border-radius: 8px; font-size: 12px; color: var(--text-dim);
}
#legend .item { display: inline-flex; align-items: center; gap: 6px; }
#legend .dot { width: 10px; height: 10px; border-radius: 50%; }

/* 缩放控件 */
#zoom-controls {
  position: absolute; right: 16px; bottom: 16px; z-index: 15;
  display: flex; flex-direction: column; gap: 6px;
}
#zoom-controls button {
  width: 36px; height: 36px; border-radius: 8px; cursor: pointer;
  background: var(--bg-panel); border: 1px solid var(--line); color: var(--text);
  font-size: 16px;
}
#zoom-controls button:hover { border-color: var(--accent); }

/* 节点信息面板 */
#node-panel {
  position: absolute; top: 60px; left: 16px; width: 300px; z-index: 18;
  background: var(--bg-panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.panel.hidden { display: none; }
.panel-close {
  position: absolute; top: 10px; right: 10px; border: none; background: transparent;
  color: var(--text-dim); cursor: pointer; font-size: 14px;
}
#node-body .n-type {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px;
  color: #041627; font-weight: 600; margin-bottom: 8px;
}
#node-body h3 { margin: 4px 0 8px; font-size: 18px; }
#node-body .desc { color: var(--text-dim); font-size: 13px; line-height: 1.6; margin-bottom: 10px; }
#node-body .stat-row { display: flex; gap: 16px; font-size: 12px; color: var(--text-dim); margin-bottom: 12px; }
#node-body .stat-row b { color: var(--text); }
#node-body .aliases { font-size: 12px; color: var(--text-dim); margin-bottom: 12px; }
#node-body h4 { font-size: 13px; margin: 10px 0 6px; color: var(--text-dim); }
#node-body .neighbors { max-height: 240px; overflow-y: auto; }
#node-body .nb {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px;
  cursor: pointer; font-size: 12px;
}
#node-body .nb:hover { background: var(--bg-soft); }
#node-body .nb .rel { color: var(--accent-2); font-size: 11px; }
#node-body .nb .arrow { color: var(--text-dim); }
#node-body .nb .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* ---------- 侧栏 ---------- */
#sidebar {
  background: var(--bg-soft); border-left: 1px solid var(--line);
  overflow-y: auto; padding: 16px;
}
.side-block { margin-bottom: 22px; }
.side-block h2 { font-size: 14px; margin: 0 0 10px; color: var(--text); }

.path-form { display: flex; flex-direction: column; gap: 8px; }
.path-form input {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg-panel); color: var(--text); font-size: 13px;
}
.path-form input:focus { outline: none; border-color: var(--accent); }

.path-result { margin-top: 10px; font-size: 13px; }
.path-result .msg { padding: 8px 10px; border-radius: 8px; font-size: 12px; }
.path-result .msg.ok { background: rgba(90,209,154,.12); color: var(--t-person); }
.path-result .msg.warn { background: rgba(255,180,84,.12); color: var(--accent-2); }
.path-result .msg.err { background: rgba(255,77,109,.14); color: var(--path); }
.path-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.path-chain .pnode {
  padding: 5px 9px; border-radius: 7px; background: var(--bg-panel);
  border: 1px solid var(--line); cursor: pointer; font-size: 12px;
  display: inline-flex; align-items: center; gap: 6px;
}
.path-chain .pnode:hover { border-color: var(--path); }
.path-chain .pnode .dot { width: 8px; height: 8px; border-radius: 50%; }
.path-chain .sep { color: var(--text-dim); }

.stats-top { margin: 0; padding-left: 0; list-style: none; counter-reset: rank; }
.stats-top li {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 7px;
  cursor: pointer; font-size: 13px;
}
.stats-top li:hover { background: var(--bg-panel); }
.stats-top li .rank {
  width: 20px; height: 20px; border-radius: 50%; background: var(--bg-panel);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-dim); flex: none;
}
.stats-top li .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.stats-top li .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-top li .deg { color: var(--accent); font-weight: 600; }

.stats-grid { display: flex; flex-direction: column; gap: 4px; }
.stats-grid .row {
  display: flex; align-items: center; gap: 8px; font-size: 12px;
  padding: 5px 8px; border-radius: 6px; background: var(--bg-panel);
}
.stats-grid .row .dot { width: 9px; height: 9px; border-radius: 50%; }
.stats-grid .row .k { flex: 1; color: var(--text-dim); }
.stats-grid .row .v { color: var(--text); font-weight: 600; }

@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 60vh 40vh; }
  #sidebar { border-left: none; border-top: 1px solid var(--line); }
}
