* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: #1e1e1e;
  background: #fafafa;
}

body { display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid #e0e0e0;
  background: #fff;
  flex-shrink: 0;
}

.brand { font-weight: 600; font-size: 15px; }
.stats { color: #666; font-size: 12px; }
.status { color: #888; font-size: 12px; min-width: 80px; text-align: right; }
.spacer { flex: 1; }

.view-toggle {
  display: inline-flex;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  overflow: hidden;
}
.view-toggle button {
  background: #fff;
  border: none;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  border-right: 1px solid #d0d0d0;
}
.view-toggle button:last-child { border-right: none; }
.view-toggle button:hover { background: #f5f5f5; }
.view-toggle button.active {
  background: #4a86e8;
  color: #fff;
}

/* Shared control-group layout used by hierarchy + cluster header controls. */
.hierarchy-controls,
.cluster-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.hierarchy-controls .btn-group,
.cluster-controls .btn-group {
  display: inline-flex;
  align-items: center;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  overflow: hidden;
}
.hierarchy-controls .btn-group-label,
.cluster-controls .btn-group-label {
  font-size: 11px;
  color: #888;
  padding: 0 6px;
  border-right: 1px solid #d0d0d0;
  background: #f5f5f5;
}
.hierarchy-controls .btn-group button,
.cluster-controls .btn-group button {
  background: #fff;
  border: none;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  border-right: 1px solid #d0d0d0;
}
.hierarchy-controls .btn-group button:last-child,
.cluster-controls .btn-group button:last-child { border-right: none; }
.hierarchy-controls .btn-group button:hover,
.cluster-controls .btn-group button:hover { background: #f5f5f5; }
.hierarchy-controls .btn-group button.active,
.cluster-controls .btn-group button.active {
  background: #4a86e8;
  color: #fff;
}

.sidebar-actions {
  margin: 8px 0 12px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sidebar-actions .btn-link {
  background: #eef3fb;
  border: 1px solid #c5d4ed;
  color: #2855a3;
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}
.sidebar-actions .btn-link:hover {
  background: #dde7f7;
}

#search {
  width: 280px;
  padding: 6px 10px;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  font-size: 13px;
}

main {
  flex: 1;
  display: flex;
  min-height: 0;
}

#cy {
  flex: 1;
  position: relative;
  background: #fff;
  border-right: 1px solid #e0e0e0;
}

#sidebar {
  width: 380px;
  padding: 16px;
  overflow-y: auto;
  background: #fafafa;
  flex-shrink: 0;
}

#sidebar h3 { margin: 0 0 4px 0; font-size: 15px; font-weight: 600; }
#sidebar .meta { color: #666; font-size: 12px; margin-bottom: 12px; }
#sidebar code { background: #f0f0f0; padding: 1px 4px; border-radius: 3px; font-size: 12px; }
#sidebar pre {
  background: #f4f4f4;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 12px;
  overflow-x: auto;
  max-height: 280px;
  margin: 8px 0 16px 0;
}
#sidebar h4 { margin: 16px 0 4px 0; font-size: 13px; color: #444; text-transform: uppercase; letter-spacing: 0.5px; }
#sidebar ul { padding: 0; margin: 0 0 12px 0; list-style: none; }
#sidebar li {
  padding: 4px 6px;
  margin: 2px 0;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
}
#sidebar li:hover { background: #eef; }
#sidebar li small { color: #888; display: block; }

.hint { color: #888; font-size: 13px; }
.error { color: #c33; font-size: 13px; padding: 8px; background: #fee; border-radius: 4px; }
