:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2330;
  --border: #2a3340;
  --text: #e6edf3;
  --text-dim: #9aa7b5;
  --accent: #58a6ff;
  --accent-2: #f0b429;

  --c-product: #58a6ff;
  --c-company: #3fb950;
  --c-person: #f78166;
  --c-vc_firm: #bc8cff;
  --c-path: #ffd33d;
}

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

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

/* ---------- sidebars ---------- */
#sidebar, #stats {
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
}
#stats {
  border-right: none;
  border-left: 1px solid var(--border);
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 1px;
  background: linear-gradient(90deg, var(--accent), var(--c-vc_firm));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand .subtitle { margin: 2px 0 0; color: var(--text-dim); font-size: 13px; }
.brand .meta { margin: 6px 0 0; color: var(--text-dim); font-size: 12px; }

.panel {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.panel:first-of-type { border-top: none; }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); margin: 0 0 10px; }
.hint { font-size: 12px; color: var(--text-dim); margin: 0 0 8px; }

.row { display: flex; gap: 6px; margin-bottom: 8px; align-items: center; }

input[type="text"] {
  flex: 1;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
}
input[type="text"]:focus { outline: none; border-color: var(--accent); }

.btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0d1117; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { color: var(--text-dim); }
.btn.block { width: 100%; }
.btn.tiny { padding: 6px 10px; font-size: 15px; line-height: 1; }

/* ---------- search results ---------- */
.search-results {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.search-results li {
  padding: 7px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.search-results li:last-child { border-bottom: none; }
.search-results li:hover { background: var(--panel-2); }
.search-results .empty { color: var(--text-dim); cursor: default; }

/* ---------- type filters ---------- */
.type-filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.type-filter {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; padding: 6px 8px; border-radius: 6px; background: var(--panel-2);
  border: 1px solid var(--border);
}
.type-filter input { accent-color: var(--accent); }
.type-filter .swatch { width: 12px; height: 12px; border-radius: 3px; }
.type-filter .tf-count { margin-left: auto; color: var(--text-dim); font-size: 12px; }

.dot {
  width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto;
  display: inline-block;
}

/* ---------- path result ---------- */
.path-result { margin-top: 8px; font-size: 13px; }
.path-result .status { padding: 6px 8px; border-radius: 6px; margin-bottom: 8px; font-size: 12px; }
.path-result .status.ok { background: rgba(63,185,80,.15); color: #56d364; }
.path-result .status.unreachable { background: rgba(247,129,102,.15); color: #ff9c85; }
.path-result .status.same { background: rgba(240,180,41,.15); color: var(--accent-2); }
.path-result .status.invalid { background: rgba(248,81,73,.15); color: #ff7b72; }
.path-chain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.path-chain li {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; background: var(--panel-2); border-radius: 6px; cursor: pointer;
}
.path-chain li:hover { background: var(--border); }
.path-chain .idx { color: var(--accent-2); font-weight: 600; font-size: 12px; min-width: 18px; }
.path-arrow { color: var(--text-dim); text-align: center; font-size: 11px; }

/* ---------- stage ---------- */
#stage { position: relative; overflow: hidden; background:
    radial-gradient(circle at 50% 40%, #10161f 0%, #0d1117 70%); }
#graph-canvas { display: block; width: 100%; height: 100%; cursor: grab; }
#graph-canvas.dragging { cursor: grabbing; }

.canvas-toolbar {
  position: absolute; top: 14px; right: 14px;
  display: flex; flex-direction: column; gap: 6px;
}

.legend {
  position: absolute; left: 14px; bottom: 14px;
  background: rgba(22,27,34,.85); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px;
  backdrop-filter: blur(4px); font-size: 12px;
}
.legend .li { display: flex; align-items: center; gap: 8px; }

/* ---------- node info ---------- */
.node-info {
  position: absolute; top: 14px; left: 14px; width: 300px; max-height: calc(100% - 28px);
  overflow-y: auto;
  background: rgba(22,27,34,.96); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; backdrop-filter: blur(6px);
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
.node-info .close {
  position: absolute; top: 8px; right: 10px; background: none; border: none;
  color: var(--text-dim); font-size: 22px; cursor: pointer; line-height: 1;
}
.node-info .close:hover { color: var(--text); }
.node-info h3 { margin: 0 30px 8px 0; font-size: 17px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; border: 1px solid var(--border); color: var(--text-dim); }
.badge.type { color: #0d1117; font-weight: 600; }
.ni-desc { font-size: 13px; color: var(--text-dim); line-height: 1.5; margin: 0 0 10px; }
.ni-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 0 0 6px; }
.ni-stats dt { color: var(--text-dim); font-size: 11px; }
.ni-stats dd { margin: 0 0 4px; font-weight: 600; }
.ni-section { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.ni-section h4 { margin: 0 0 8px; font-size: 13px; color: var(--text-dim); }
.ni-neighbors { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; }
.ni-neighbors li {
  padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 12px;
  display: flex; align-items: center; gap: 8px;
}
.ni-neighbors li:hover { background: var(--panel-2); }
.ni-neighbors .rel { color: var(--accent-2); font-size: 11px; }
.ni-neighbors .dir { color: var(--text-dim); }

/* ---------- stats lists ---------- */
.stats-top { list-style: none; margin: 0; padding: 0; counter-reset: rank; }
.stats-top li {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; cursor: pointer;
  font-size: 13px;
}
.stats-top li:hover { background: var(--panel-2); }
.stats-top .rank { color: var(--accent-2); font-weight: 700; min-width: 20px; }
.stats-top .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-top .deg { color: var(--text-dim); font-variant-numeric: tabular-nums; }

.stats-list { list-style: none; margin: 0; padding: 0; }
.stats-list li {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px;
  font-size: 13px; cursor: default;
}
.stats-list li .count { margin-left: auto; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.stats-list li.clickable { cursor: pointer; }
.stats-list li.clickable:hover { background: var(--panel-2); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
