:root {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --bg-panel: #161b22;
  --border: #2a313c;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #4f9dff;
  --accent-soft: rgba(79, 157, 255, 0.15);

  --c-product: #4f9dff;
  --c-person: #ff9f43;
  --c-company: #2ed573;
  --c-vc_firm: #c56cf0;
}

* { 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", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
}

body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  z-index: 10;
}

.brand { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.brand-mark {
  font-weight: 700;
  font-size: 18px;
  background: linear-gradient(90deg, #4f9dff, #c56cf0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub { color: var(--text-dim); font-size: 13px; }

.search-wrap { position: relative; flex: 0 1 320px; min-width: 200px; display: flex; align-items: center; }
#search-input {
  width: 100%;
  padding: 7px 30px 7px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  outline: none;
}
#search-input:focus { border-color: var(--accent); }
.icon-btn {
  position: absolute;
  right: 6px;
  width: 22px; height: 22px;
  border: none; background: transparent; color: var(--text-dim);
  font-size: 18px; line-height: 1; cursor: pointer; border-radius: 4px;
}
.icon-btn:hover { color: var(--text); background: var(--border); }

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  max-height: 320px;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 30;
}
.search-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: pointer;
}
.search-item:hover, .search-item.active { background: var(--accent-soft); }
.search-item .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.search-item .s-name { font-weight: 500; }
.search-item .s-id { color: var(--text-dim); font-size: 12px; margin-left: auto; }
.search-empty { padding: 10px 12px; color: var(--text-dim); }

.type-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.type-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg);
  cursor: pointer; user-select: none; font-size: 13px;
}
.type-chip .dot { width: 10px; height: 10px; border-radius: 50%; }
.type-chip.off { opacity: 0.4; }
.type-chip .cnt { color: var(--text-dim); font-size: 12px; }

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.graph-meta { color: var(--text-dim); font-size: 12px; margin-right: 4px; white-space: nowrap; }

.btn {
  padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); cursor: pointer; font-size: 13px; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #04101f; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.1); }

/* ---------- Layout ---------- */
.layout { flex: 1; display: flex; min-height: 0; }

.canvas-wrap { position: relative; flex: 1; min-width: 0; background: radial-gradient(circle at 50% 40%, #11161d 0%, #0d1117 70%); }
#graph { display: block; width: 100%; height: 100%; cursor: grab; }
#graph.grabbing { cursor: grabbing; }

.legend {
  position: absolute; left: 12px; bottom: 12px;
  display: flex; flex-direction: column; gap: 5px;
  background: rgba(13,17,23,0.7); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; backdrop-filter: blur(4px);
}
.legend .row { display: flex; align-items: center; gap: 7px; color: var(--text-dim); }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; }

.hint {
  position: absolute; right: 12px; bottom: 12px;
  color: var(--text-dim); font-size: 12px;
  background: rgba(13,17,23,0.6); padding: 5px 9px; border-radius: 6px;
  border: 1px solid var(--border);
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 360px; flex: none;
  overflow-y: auto;
  background: var(--bg-soft);
  border-left: 1px solid var(--border);
  padding: 14px;
  display: flex; flex-direction: column; gap: 14px;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.panel h2 {
  margin: 0 0 10px; font-size: 13px; font-weight: 600;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em;
}

/* node info */
.node-info.empty { color: var(--text-dim); font-size: 13px; }
.node-head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.node-head .dot { width: 13px; height: 13px; border-radius: 50%; flex: none; }
.node-head .n-name { font-size: 17px; font-weight: 700; }
.node-head .n-type {
  margin-left: auto; font-size: 11px; padding: 2px 8px; border-radius: 12px;
  border: 1px solid var(--border); color: var(--text-dim);
}
.node-desc { color: var(--text); font-size: 13px; line-height: 1.5; margin: 6px 0 10px; }
.node-metrics { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.metric {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; color: var(--text-dim);
}
.metric b { display: block; color: var(--text); font-size: 15px; }
.node-aliases { font-size: 12px; color: var(--text-dim); margin-bottom: 10px; }
.node-aliases span { display: inline-block; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 1px 7px; margin: 2px 3px 2px 0; }

.sub-title { font-size: 12px; color: var(--text-dim); margin: 8px 0 6px; }
.neighbor-list { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow-y: auto; }
.neighbor {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 8px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.neighbor:hover { background: var(--accent-soft); }
.neighbor .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.neighbor .rel { margin-left: auto; font-size: 11px; color: var(--text-dim); }
.neighbor .dir { color: var(--text-dim); font-size: 11px; width: 14px; text-align: center; }

/* path */
.path-inputs { display: flex; align-items: center; gap: 6px; }
.path-inputs input {
  flex: 1; min-width: 0; padding: 7px 9px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); outline: none;
}
.path-inputs input:focus { border-color: var(--accent); }
.path-inputs .arrow { color: var(--text-dim); }
.path-actions { display: flex; gap: 8px; margin-top: 8px; }
.path-tip { color: var(--text-dim); font-size: 12px; margin: 8px 0 0; line-height: 1.5; }
.path-tip code { background: var(--bg); padding: 1px 5px; border-radius: 4px; color: var(--accent); }

.path-result { margin-top: 10px; font-size: 13px; }
.path-result .status-msg { padding: 8px 10px; border-radius: 8px; line-height: 1.5; }
.status-ok { background: rgba(46,213,115,0.12); border: 1px solid rgba(46,213,115,0.4); }
.status-bad { background: rgba(255,107,107,0.12); border: 1px solid rgba(255,107,107,0.4); }
.status-warn { background: rgba(255,159,67,0.12); border: 1px solid rgba(255,159,67,0.4); }
.path-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 8px; }
.path-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--accent-soft); border: 1px solid var(--accent);
  color: var(--text); padding: 3px 9px; border-radius: 16px; cursor: pointer; font-size: 12px;
}
.path-chip:hover { filter: brightness(1.2); }
.path-chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.path-sep { color: var(--text-dim); }
.path-len { color: var(--text-dim); font-size: 12px; margin-top: 6px; }

/* stats */
.stats-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.stats-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px; font-size: 13px;
}
.stats-list li.clickable { cursor: pointer; }
.stats-list li.clickable:hover { background: var(--accent-soft); }
.stats-list .rank { color: var(--text-dim); width: 20px; text-align: right; font-variant-numeric: tabular-nums; }
.stats-list .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.stats-list .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-list .val { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.stats-list .bar {
  height: 6px; border-radius: 3px; background: var(--accent); opacity: 0.7;
}
.stats-list code { color: var(--accent); font-size: 12px; }

@media (max-width: 820px) {
  body { overflow: auto; }
  .layout { flex-direction: column; }
  .canvas-wrap { height: 60vh; }
  .sidebar { width: 100%; border-left: none; border-top: 1px solid var(--border); }
}
