:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2330;
  --border: #2a3140;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #4dabf7;
  --accent-dim: #1f3a52;

  --t-product: #4dabf7;
  --t-company: #ffa94d;
  --t-person: #b197fc;
  --t-vc_firm: #ff6b6b;
  --path: #ffe066;
}

* { box-sizing: border-box; }

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

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

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

#brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 1px;
}
.subtitle { margin: 2px 0 0; color: var(--accent); font-size: 13px; }
.meta { margin: 6px 0 0; color: var(--muted); font-size: 12px; }

.panel {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.panel h2 { margin: 0 0 10px; font-size: 14px; color: var(--text); }
.panel h3 { margin: 14px 0 6px; font-size: 12px; color: var(--muted); font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 8px; }

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

.btn {
  padding: 8px 12px;
  background: var(--accent-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}
.btn:hover { background: #26445e; border-color: var(--accent); }
.btn-block { width: 100%; }
.btn-small { padding: 4px 10px; font-size: 12px; }

/* search results */
#search-results {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 180px;
  overflow-y: auto;
}
#search-results li {
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
#search-results li:hover { background: var(--panel-2); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.res-id { color: var(--muted); font-size: 11px; margin-left: auto; }

/* type filters */
.type-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.type-filters label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
}

/* node info */
.node-info .hint { color: var(--muted); font-size: 12px; }
.node-info .ni-title { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.node-info .ni-type { font-size: 11px; color: var(--muted); }
.node-info .ni-desc { margin: 8px 0; color: #c9d1d9; font-size: 12px; line-height: 1.5; }
.node-info .ni-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.node-info .ni-stats span {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 6px; font-size: 11px; color: var(--muted);
}
.ni-neighbors { list-style: none; margin: 6px 0 0; padding: 0; max-height: 220px; overflow-y: auto; }
.ni-neighbors li {
  padding: 5px 6px; border-radius: 5px; cursor: pointer;
  font-size: 12px; display: flex; align-items: center; gap: 6px;
}
.ni-neighbors li:hover { background: var(--panel-2); }
.rel-tag { color: var(--accent); font-size: 10px; }
.rel-dir { color: var(--muted); font-size: 10px; }

/* stats */
.stats-list { margin: 0; padding-left: 22px; }
.stats-list li { padding: 3px 0; cursor: pointer; font-size: 13px; }
.stats-list li:hover { color: var(--accent); }
.stats-list .deg { color: var(--muted); float: right; }

.stats-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.stats-chips .chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 9px; font-size: 12px;
}
.stats-chips .chip b { color: var(--text); }

.stats-relations { display: flex; flex-direction: column; gap: 3px; }
.stats-relations .rel-row {
  display: flex; justify-content: space-between;
  padding: 3px 8px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 5px; font-size: 12px;
}
.stats-relations .rel-row .c { color: var(--accent); font-variant-numeric: tabular-nums; }

/* path result */
.path-result { margin-top: 10px; font-size: 12px; }
.path-result .status { font-weight: 600; margin-bottom: 6px; }
.path-result.ok .status { color: #69db7c; }
.path-result.same .status { color: var(--accent); }
.path-result.unreachable .status { color: #ffa94d; }
.path-result.invalid .status { color: #ff6b6b; }
.path-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.path-chain .pnode {
  background: var(--accent-dim); border: 1px solid var(--accent);
  border-radius: 4px; padding: 3px 7px; cursor: pointer;
}
.path-chain .pnode:hover { background: #26445e; }
.path-chain .arrow { color: var(--muted); }

/* ---------- Stage ---------- */
#stage { flex: 1; position: relative; overflow: hidden; }
#canvas { display: block; width: 100%; height: 100%; cursor: grab; }
#canvas:active { cursor: grabbing; }

#toolbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 16px;
  padding: 8px 14px;
  background: linear-gradient(180deg, rgba(13,17,23,0.92), rgba(13,17,23,0));
  z-index: 5; pointer-events: none;
}
#toolbar .btn { pointer-events: auto; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; }
.legend .lg { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.controls-hint { color: var(--muted); font-size: 12px; margin-left: auto; }

.tooltip {
  position: absolute; z-index: 6; pointer-events: none;
  background: rgba(22,27,34,0.96); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 9px; font-size: 12px; max-width: 260px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--muted); font-size: 14px; z-index: 10;
}
.loading.done { display: none; }
