:root {
  --bg: #0e1116;
  --bg-soft: #161b22;
  --bg-panel: #1b212b;
  --border: #2a323d;
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --accent: #4c9aff;
  --product: #4c9aff;
  --person: #3fb950;
  --company: #f0883e;
  --vc_firm: #bc8cff;
  --danger: #ff6b6b;
  --ok: #3fb950;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: baseline; gap: 10px; }
.logo { font-weight: 700; font-size: 18px; letter-spacing: 0.5px; }
.subtitle { color: var(--text-dim); font-size: 13px; }

.layout { display: flex; height: calc(100% - 53px); }

.sidebar {
  width: 340px;
  min-width: 340px;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.hint { margin: 0 0 8px; font-size: 12px; color: var(--text-dim); }

.text-input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.text-input:focus { border-color: var(--accent); }

.search-meta { margin-top: 6px; font-size: 12px; color: var(--text-dim); min-height: 16px; }

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

.path-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.path-label { width: 32px; font-size: 12px; color: var(--text-dim); flex: none; }
.path-row .text-input { flex: 1; }

.btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; width: 100%; margin-top: 4px; }
.btn-ghost { background: transparent; }
.btn-icon { width: 34px; height: 34px; padding: 0; font-size: 16px; line-height: 1; }

.path-result {
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
  min-height: 20px;
  word-break: break-word;
}
.path-result .path-node {
  display: inline-block;
  padding: 3px 8px;
  margin: 3px 4px 3px 0;
  border-radius: 6px;
  background: rgba(76,154,255,0.15);
  border: 1px solid var(--accent);
  cursor: pointer;
}
.path-result .path-arrow { color: var(--text-dim); margin: 0 2px; }
.path-result .status-ok { color: var(--ok); }
.path-result .status-bad { color: var(--danger); }

.stats-top { margin: 0; padding-left: 0; list-style: none; counter-reset: rank; }
.stats-top li {
  counter-increment: rank;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.stats-top li:nth-child(odd) { background: rgba(255,255,255,0.03); }
.stats-top li:hover { background: rgba(76,154,255,0.12); }
.stats-top li::before {
  content: counter(rank);
  width: 20px;
  flex: none;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.stats-top .rank-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-top .rank-degree {
  flex: none;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
}

.stats-rows { display: flex; flex-direction: column; gap: 4px; }
.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  background: rgba(255,255,255,0.03);
}
.stat-row:hover { background: rgba(76,154,255,0.12); }
.stat-row .stat-name { display: flex; align-items: center; gap: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-row .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.stat-row .stat-count { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }

.graph-area { position: relative; flex: 1; overflow: hidden; }
#graph-canvas { display: block; width: 100%; height: 100%; cursor: grab; }
#graph-canvas.dragging { cursor: grabbing; }

.graph-hud {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}
.hud-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(22,27,34,0.85);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
}
.hud-legend .item { display: flex; align-items: center; gap: 6px; }
.hud-legend .dot { width: 10px; height: 10px; border-radius: 50%; }
.hud-zoom { display: flex; gap: 6px; }

.node-info {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 300px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  background: rgba(27,33,43,0.96);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.node-info.hidden { display: none; }
.node-info .ni-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.node-info .ni-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.node-info .ni-name { font-size: 16px; font-weight: 700; }
.node-info .ni-type {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.node-info .ni-meta { display: flex; gap: 14px; margin: 8px 0; font-size: 12px; color: var(--text-dim); }
.node-info .ni-desc { font-size: 13px; line-height: 1.5; color: var(--text); margin-bottom: 10px; }
.node-info .ni-aliases { font-size: 12px; color: var(--text-dim); margin-bottom: 10px; }
.node-info .ni-aliases span { display: inline-block; margin: 2px 4px 2px 0; padding: 1px 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; }
.node-info h3 { font-size: 12px; color: var(--text-dim); margin: 10px 0 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.node-info .ni-rel { font-size: 12px; padding: 4px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.node-info .ni-rel:hover { color: var(--accent); }
.node-info .ni-rel .rel-type { color: var(--accent); }
.node-info .ni-close { position: absolute; top: 8px; right: 10px; cursor: pointer; color: var(--text-dim); font-size: 16px; }

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text-dim);
  font-size: 15px;
  z-index: 5;
}
.loading.hidden { display: none; }
