:root {
  --bg: #0b0d12;
  --panel: #12161f;
  --panel-2: #1a2030;
  --border: #2a3348;
  --text: #e8ecf4;
  --muted: #8b95a8;
  --accent: #6c8cff;
  --accent-2: #a78bfa;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --product: #60a5fa;
  --company: #f472b6;
  --person: #34d399;
  --vc_firm: #fbbf24;
  --radius: 10px;
  --font: "SF Pro Text", "PingFang SC", "Helvetica Neue", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

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

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.panel {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.panel h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 10px;
}

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

input:focus {
  border-color: var(--accent);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}

button {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

button:hover { opacity: 0.9; }
button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  margin-top: 6px;
}

.type-filters {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.type-filters label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.type-filters .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.search-results {
  margin-top: 8px;
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.search-results button.hit {
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 400;
}

.search-results button.hit:hover {
  background: rgba(108, 140, 255, 0.15);
}

.search-results .hit-type {
  color: var(--muted);
  font-size: 11px;
  margin-left: 6px;
}

.path-result {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.5;
  min-height: 24px;
  color: var(--muted);
  word-break: break-all;
}

.path-result[data-bench-path-status="ok"] { color: var(--ok); }
.path-result[data-bench-path-status="unreachable"] { color: var(--warn); }
.path-result[data-bench-path-status="same"] { color: var(--warn); }
.path-result[data-bench-path-status="invalid"] { color: var(--err); }

.path-result .path-node {
  display: inline-block;
  background: rgba(108, 140, 255, 0.18);
  border: 1px solid rgba(108, 140, 255, 0.35);
  color: var(--text);
  border-radius: 4px;
  padding: 1px 6px;
  margin: 2px 2px;
  font-size: 11px;
}

.path-result .path-arrow {
  color: var(--muted);
  margin: 0 2px;
}

.node-detail {
  font-size: 13px;
  line-height: 1.55;
}

.node-detail.empty { color: var(--muted); font-size: 12px; }

.node-detail .name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.node-detail .meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.node-detail .desc {
  color: #c5cddc;
  margin-bottom: 10px;
  font-size: 12px;
}

.node-detail .rels {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  max-height: 180px;
  overflow-y: auto;
}

.node-detail .rel-item {
  font-size: 11px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(42, 51, 72, 0.5);
  cursor: pointer;
}

.node-detail .rel-item:hover { color: var(--accent); }

.node-detail .badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  margin-right: 4px;
  color: var(--muted);
}

.actions { padding: 10px; }

.main {
  display: grid;
  grid-template-rows: 1fr auto;
  min-width: 0;
  min-height: 0;
}

.canvas-wrap {
  position: relative;
  min-height: 0;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(108,140,255,0.08), transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(167,139,250,0.06), transparent 50%),
    var(--bg);
}

#graph-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#graph-canvas.dragging { cursor: grabbing; }

.canvas-hint {
  position: absolute;
  left: 12px;
  bottom: 10px;
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
  background: rgba(11, 13, 18, 0.6);
  padding: 4px 8px;
  border-radius: 6px;
}

.stats-bar {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1.4fr;
  gap: 0;
  border-top: 1px solid var(--border);
  background: var(--panel);
  max-height: 220px;
  overflow: hidden;
}

.stats-block {
  padding: 10px 14px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  min-height: 0;
}

.stats-block:last-child { border-right: none; }

.stats-block h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
  position: sticky;
  top: 0;
  background: var(--panel);
  padding-bottom: 4px;
}

.stats-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stats-list .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  gap: 8px;
}

.stats-list .row:hover {
  background: rgba(108, 140, 255, 0.12);
}

.stats-list .rank {
  color: var(--muted);
  width: 18px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.stats-list .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-list .deg {
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stats-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stats-chips .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}

.stats-chips .chip .count {
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stats-chips.relations .chip {
  font-size: 11px;
  padding: 3px 8px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

@media (max-width: 960px) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { max-height: 40vh; }
  .stats-bar { grid-template-columns: 1fr; max-height: 160px; }
}
