:root {
  --bg: #0e1117;
  --panel: #161b22;
  --panel-2: #1c2230;
  --border: #2a3140;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #4f9cff;
  --accent-2: #ffd166;
  --path: #ff5d73;

  /* node type colors */
  --c-product: #4f9cff;
  --c-company: #56d364;
  --c-person: #ff9e64;
  --c-vc_firm: #c586ff;
}

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

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

/* ---------- panels / sidebars ---------- */
.sidebar, .stats {
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px;
}
.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;
  color: transparent;
}
.brand .subtitle { margin: 2px 0 14px; color: var(--muted); font-size: 12px; }

.panel {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
}
.panel-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 8px;
}

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

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

.btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #07101e; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.block { width: 100%; margin-top: 4px; }
.btn.icon { width: 34px; height: 34px; padding: 0; font-size: 16px; line-height: 1; }

.hint { font-size: 12px; color: var(--muted); margin-top: 6px; min-height: 14px; }

/* ---------- type filters ---------- */
.type-filters { display: flex; flex-direction: column; gap: 6px; }
.type-filter {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; user-select: none;
  padding: 4px 6px; border-radius: 6px;
}
.type-filter:hover { background: var(--panel); }
.type-filter input { accent-color: var(--accent); }
.type-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.type-filter .count { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

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

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

.legend {
  position: absolute; left: 12px; bottom: 12px;
  background: rgba(16,20,28,.82);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 5px;
  backdrop-filter: blur(4px);
}
.legend .item { display: flex; align-items: center; gap: 7px; font-size: 12px; }

/* ---------- node info ---------- */
.node-info {
  position: absolute; top: 12px; left: 12px;
  width: 290px; max-height: calc(100% - 24px);
  overflow-y: auto;
  background: rgba(16,20,28,.94);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
.node-info.hidden { display: none; }
.node-info-close {
  position: absolute; top: 8px; right: 10px;
  background: none; border: none; color: var(--muted);
  font-size: 20px; cursor: pointer; line-height: 1;
}
.node-info-close:hover { color: var(--text); }
.ni-name { font-size: 16px; font-weight: 700; margin: 0 24px 4px 0; }
.ni-type-badge {
  display: inline-block; font-size: 11px; padding: 2px 8px;
  border-radius: 20px; color: #07101e; font-weight: 600; margin-bottom: 8px;
}
.ni-desc { color: var(--muted); line-height: 1.5; margin: 6px 0 10px; }
.ni-meta { display: flex; gap: 14px; margin-bottom: 10px; font-size: 12px; }
.ni-meta b { color: var(--accent-2); }
.ni-aliases { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.ni-section-title { font-size: 12px; font-weight: 600; color: var(--muted); margin: 10px 0 6px; }
.ni-rel {
  font-size: 12px; padding: 6px 8px; border-radius: 6px;
  background: var(--panel-2); margin-bottom: 5px; cursor: pointer;
  border: 1px solid transparent;
}
.ni-rel:hover { border-color: var(--accent); }
.ni-rel .rel-type { color: var(--accent); }
.ni-rel .rel-node { font-weight: 600; }
.ni-rel .rel-dir { color: var(--muted); }

/* ---------- stats lists ---------- */
.stats-list { display: flex; flex-direction: column; gap: 3px; max-height: 340px; overflow-y: auto; }
.stat-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 7px; border-radius: 6px; cursor: pointer;
  font-size: 12px; border: 1px solid transparent;
}
.stat-row:hover { background: var(--panel-2); border-color: var(--accent); }
.stat-row .rank { color: var(--muted); width: 18px; text-align: right; font-variant-numeric: tabular-nums; }
.stat-row .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-row .val { color: var(--accent-2); font-variant-numeric: tabular-nums; font-weight: 600; }
.stat-row .type-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ---------- path result ---------- */
.path-result { font-size: 12px; margin-top: 4px; min-height: 16px; line-height: 1.5; }
.path-status {
  display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 4px;
  margin-bottom: 6px; font-weight: 600;
}
.path-status.ok { background: var(--c-company); color: #07101e; }
.path-status.unreachable { background: #ffb454; color: #07101e; }
.path-status.same { background: var(--accent); color: #07101e; }
.path-status.invalid { background: var(--path); color: #fff; }
.path-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.path-node {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 5px; padding: 3px 7px; cursor: pointer;
}
.path-node:hover { border-color: var(--path); color: var(--path); }
.path-arrow { color: var(--muted); }

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