:root {
  --bg: #0e1117;
  --panel: #161b22;
  --panel-2: #1c2230;
  --border: #2a3140;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #58a6ff;

  --type-product: #4f9dff;
  --type-company: #ff8c42;
  --type-person: #4ecb71;
  --type-vc_firm: #c77dff;
  --path: #ffd43b;
}

* { 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;
  overflow: hidden;
}

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

aside {
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px;
}
#sidebar-right { border-right: none; border-left: 1px solid var(--border); }

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

.panel {
  margin-top: 16px;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.panel h2 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
}

.field { margin-bottom: 12px; }
.field > label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--text-dim);
}

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

.search-row { display: flex; gap: 6px; }
.search-row input { flex: 1; }
#search-clear {
  width: 34px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
#search-clear:hover { color: var(--text); border-color: var(--accent); }

.suggest {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}
.suggest li {
  padding: 6px 9px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.suggest li:hover { background: var(--panel-2); }
.suggest .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.suggest .sid { color: var(--text-dim); font-size: 11px; margin-left: auto; }

.type-filters { display: flex; flex-direction: column; gap: 6px; }
.type-filters label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}
.type-filters .dot { width: 11px; height: 11px; border-radius: 50%; }
.type-filters .cnt { margin-left: auto; color: var(--text-dim); font-size: 12px; }

button {
  font-family: inherit;
  cursor: pointer;
}
.primary {
  width: 100%;
  padding: 8px;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #06101f;
  font-weight: 600;
  font-size: 13px;
}
.primary:hover { filter: brightness(1.08); }
.primary-outline {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
}
.primary-outline:hover { border-color: var(--accent); color: var(--accent); }

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

.legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: rgba(20,25,34,0.85);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.legend .item { display: flex; align-items: center; gap: 6px; }
.legend .dot { width: 11px; height: 11px; border-radius: 50%; }

#zoom-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#zoom-controls button {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: rgba(20,25,34,0.85);
  color: var(--text);
  border-radius: 8px;
  font-size: 18px;
}
#zoom-controls button:hover { border-color: var(--accent); color: var(--accent); }

.hover-tip {
  position: absolute;
  pointer-events: none;
  background: rgba(8,11,16,0.95);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  max-width: 260px;
  z-index: 5;
}

/* Node info */
.node-info .hint { color: var(--text-dim); font-size: 13px; }
.node-info .title { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
.node-info .title .dot { width: 12px; height: 12px; border-radius: 50%; }
.node-info .title .name { font-size: 16px; font-weight: 600; }
.node-info .badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  margin-left: 4px;
}
.node-info .desc { color: var(--text); font-size: 13px; line-height: 1.5; margin: 8px 0; }
.node-info .kv { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.node-info .kv b { color: var(--text); }
.node-info h3 { font-size: 12px; color: var(--text-dim); margin: 10px 0 6px; text-transform: uppercase; }
.neighbors { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; }
.neighbors li {
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 5px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.neighbors li:hover { border-color: var(--accent); }
.neighbors .rel { color: var(--accent); font-size: 11px; }
.neighbors .dir { color: var(--text-dim); }

/* Stats */
.stats-list { display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto; }
.stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
}
.stat-row.clickable { cursor: pointer; }
.stat-row.clickable:hover { border-color: var(--accent); background: var(--bg); }
.stat-row .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.stat-row .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-row .val {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
}
.stat-row .bar {
  height: 5px;
  background: var(--accent);
  border-radius: 3px;
  flex: none;
}

/* Path result */
.path-result { margin-top: 10px; font-size: 13px; }
.path-result .status { margin-bottom: 8px; font-weight: 600; }
.path-result .status.ok { color: var(--type-person); }
.path-result .status.unreachable { color: var(--type-company); }
.path-result .status.same { color: var(--accent); }
.path-result .status.invalid { color: #ff6b6b; }
.path-chain { display: flex; flex-direction: column; gap: 4px; }
.path-node {
  padding: 5px 8px;
  border: 1px solid var(--path);
  border-radius: 6px;
  background: rgba(255,212,59,0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.path-node:hover { background: rgba(255,212,59,0.16); }
.path-node .idx {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--path);
  color: #1a1400;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.path-node .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.path-arrow { text-align: center; color: var(--path); font-size: 12px; line-height: 0.6; }

/* Loading */
.loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(8,11,16,0.9);
  color: var(--text);
  z-index: 100;
  font-size: 15px;
}
.loading.hidden { display: none; }
.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

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