/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-deep:    #0d1117;
  --bg-panel:   #161b27;
  --bg-card:    #1e2636;
  --bg-hover:   #252f42;
  --border:     #2d3748;
  --text:       #e2e8f0;
  --text-muted: #718096;
  --accent:     #00d4c8;
  --accent-dim: #00a89e;
  --danger:     #ff6b6b;
  --warn:       #f59f00;
  --ok:         #51cf66;
  --blue:       #4dabf7;
  --purple:     #cc5de8;
  --radius:     6px;
  --panel-w:    268px;
}

html, body {
  height: 100%;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 13px;
  background: var(--bg-deep);
  color: var(--text);
  overflow: hidden;
}

/* ── Top bar ───────────────────────────────────────────────────────────────── */
#topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  height: 48px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.brand {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.dataset-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dataset-controls label {
  color: var(--text-muted);
  white-space: nowrap;
}

#dataset-select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 8px;
  border-radius: var(--radius);
  font-size: 13px;
  min-width: 220px;
  cursor: pointer;
}

#dataset-select:focus { outline: 1px solid var(--accent); }

#status-bar {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 12px;
}

/* ── Main layout ───────────────────────────────────────────────────────────── */
#layout {
  display: flex;
  height: calc(100vh - 48px);
  overflow: hidden;
}

/* ── Side panels ───────────────────────────────────────────────────────────── */
#left-panel, #right-panel {
  width: var(--panel-w);
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#left-panel  { border-right: 1px solid var(--border); }
#right-panel { border-left: 1px solid var(--border); }

.panel-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ── Metric cards ──────────────────────────────────────────────────────────── */
#metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.metric-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Checkboxes ────────────────────────────────────────────────────────────── */
.check-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 0;
  cursor: pointer;
  border-radius: 4px;
}

.check-row:hover { color: var(--text); }

.check-row input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }

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

.check-label { flex: 1; }

.check-count {
  font-size: 11px;
  color: var(--text-muted);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 11px;
  padding: 4px 0;
  margin-right: 8px;
}

.link-btn:hover { text-decoration: underline; }

/* ── Slider ────────────────────────────────────────────────────────────────── */
.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

/* ── Lens radio buttons ────────────────────────────────────────────────────── */
.radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s;
}

.radio-row:hover { background: var(--bg-hover); }
.radio-row.active { background: var(--bg-card); }

.radio-row input[type="radio"] { accent-color: var(--accent); cursor: pointer; }

.radio-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
}

.radio-row.active .radio-dot { opacity: 1; }

#lens-legend {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── Graph wrapper ─────────────────────────────────────────────────────────── */
#graph-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg-deep);
}

#cy {
  position: absolute;
  inset: 0;
}

/* ── Graph overlay buttons ─────────────────────────────────────────────────── */
#graph-overlay {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 5;
}

#graph-overlay button {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

#graph-overlay button:hover { background: var(--bg-hover); border-color: var(--accent); }

#ego-clear-btn { color: var(--warn); border-color: var(--warn); }

/* ── Tooltip ───────────────────────────────────────────────────────────────── */
#tooltip {
  position: absolute;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  pointer-events: none;
  z-index: 20;
  max-width: 220px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

#tooltip-name { font-weight: 600; margin-bottom: 3px; }
#tooltip-dept { color: var(--accent); font-size: 12px; margin-bottom: 4px; }
#tooltip-meta { color: var(--text-muted); font-size: 11px; line-height: 1.5; }

/* ── Loading overlay ───────────────────────────────────────────────────────── */
#loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(13,17,23,0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 30;
}

#loading-overlay[hidden] { display: none; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#loading-msg { color: var(--text-muted); font-size: 13px; }

/* ── Node info ─────────────────────────────────────────────────────────────── */
.node-attr-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.node-attr-row:last-child { border-bottom: none; }

.node-attr-key { color: var(--text-muted); }
.node-attr-val { font-weight: 500; }

.node-attr-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.node-attr-bar:last-child { border-bottom: none; }

.bar-track {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s;
}

.hint {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
