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

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel2: #1c2330;
  --border: #2d3646;
  --text: #dce3ec;
  --muted: #8b98a9;
  --accent: #58a6ff;
  --c-product: #58a6ff;
  --c-company: #f0883e;
  --c-person: #3fb950;
  --c-vc: #d2a8ff;
}

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

#app { display: flex; }

/* ---------- sidebar ---------- */
#sidebar {
  width: 340px;
  min-width: 340px;
  height: 100%;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#brand { padding: 16px 16px 12px; border-bottom: 1px solid var(--border); }
#brand h1 { font-size: 18px; letter-spacing: 1px; }
#brand p { color: var(--muted); font-size: 12px; margin-top: 4px; }

#tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab {
  flex: 1; padding: 10px 0; background: none; border: none;
  color: var(--muted); cursor: pointer; font-size: 13px;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.panel { display: none; padding: 14px 16px; overflow-y: auto; flex: 1; }
.panel.active { display: block; }

.group-label {
  font-size: 12px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .5px; margin: 14px 0 6px;
}
.panel .group-label:first-child { margin-top: 0; }

.field { position: relative; margin-bottom: 8px; }
.field input {
  width: 100%; padding: 8px 30px 8px 10px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-size: 13px; outline: none;
}
.field input:focus { border-color: var(--accent); }
#search-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px;
  padding: 4px;
}
#search-clear:hover { color: var(--text); }

#search-results { list-style: none; 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(--panel2); }
#search-results .sub { color: var(--muted); font-size: 11px; margin-left: auto; }

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

#type-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.type-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 14px; cursor: pointer; user-select: none;
  border: 1px solid var(--border); background: var(--panel2); font-size: 12px;
}
.type-chip.off { opacity: .35; }

.wide-btn {
  width: 100%; margin-top: 12px; padding: 9px 0;
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: 13px;
}
.wide-btn:hover { border-color: var(--accent); }
.wide-btn.primary { background: #1f4b7a; border-color: #2f6cad; }
.wide-btn.primary:hover { background: #245a93; }

.hidden { display: none !important; }

#detail-card {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
}
#detail-card .d-name { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
#detail-card .d-desc { color: var(--muted); font-size: 12px; margin-top: 6px; line-height: 1.6; }
#detail-card .d-kv { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 12px; }
#detail-card .d-kv b { color: var(--accent); font-weight: 600; }
#detail-card .d-alias { margin-top: 6px; font-size: 11px; color: var(--muted); }

#neighbor-list { list-style: none; }
#neighbor-list li {
  padding: 6px 8px; border-radius: 5px; cursor: pointer; font-size: 12px;
  display: flex; align-items: center; gap: 7px;
}
#neighbor-list li:hover { background: var(--panel2); }
#neighbor-list .rel {
  color: var(--muted); font-size: 10px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
  margin-left: auto; flex-shrink: 0;
}

/* ---------- path result ---------- */
#path-result { margin-top: 12px; }
.path-msg {
  padding: 10px 12px; border-radius: 6px; font-size: 13px;
  border: 1px solid var(--border); background: var(--panel2); line-height: 1.6;
}
.path-msg.err { border-color: #b8574f; color: #ffb3ad; }
.path-msg.warn { border-color: #b3862d; color: #f2cf87; }
.path-msg.ok { border-color: #2f6f45; color: #9ae2b3; }
.path-seq { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.path-node {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 10px; cursor: pointer; font-size: 13px;
}
.path-node:hover { border-color: var(--accent); }
.path-node .idx { color: var(--muted); font-size: 11px; width: 18px; }
.path-arrow { color: var(--muted); text-align: center; font-size: 11px; }

/* ---------- stats ---------- */
#stats-top .stat-row, #stats-types .stat-row, #stats-relations .stat-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: 5px; font-size: 13px;
}
#stats-top .stat-row { cursor: pointer; }
#stats-top .stat-row:hover { background: var(--panel2); }
.stat-row .bar-wrap { flex: 1; height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; }
.stat-row .bar { height: 100%; background: var(--accent); border-radius: 3px; }
.stat-row .num { color: var(--accent); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.stat-row .lbl { min-width: 92px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#stats-relations .stat-row .lbl { min-width: 118px; font-family: ui-monospace, monospace; font-size: 12px; }

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

#legend {
  position: absolute; top: 12px; left: 12px;
  background: rgba(22,27,34,.85); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; font-size: 12px;
  display: flex; flex-direction: column; gap: 5px; pointer-events: none;
}
#legend .row { display: flex; align-items: center; gap: 7px; }

#hint {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  color: var(--muted); font-size: 11px; pointer-events: none;
  background: rgba(13,17,23,.6); padding: 3px 10px; border-radius: 10px;
}

#tooltip {
  position: absolute; pointer-events: none; z-index: 10;
  background: rgba(22,27,34,.95); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px; font-size: 12px; max-width: 260px;
}
#tooltip .t-type { color: var(--muted); font-size: 11px; }
