/* =========================================================
   NEXUS — style.css
   CSS variables are the single source of truth for all
   colors, spacing, and typography. Swap track colors here
   when real API data comes in.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;700&family=Geist:wght@300;400;500;600&display=swap');

/* ── Track colors (replace with API values later) ───────── */
:root {
  --track-ai-infra:  #00d4ff;
  --track-fintech:   #f59e0b;
  --track-biotech:   #10b981;
  --track-defense:   #ef4444;
  --track-cleantech: #a78bfa;

  /* ── Core palette ───────────────────────────────────────── */
  --bg-base:        #080c14;
  --bg-surface:     #0d1422;
  --bg-raised:      #111827;
  --bg-hover:       #1a2436;
  --border:         rgba(255,255,255,0.07);
  --border-bright:  rgba(255,255,255,0.15);

  --text-primary:   #e8edf5;
  --text-secondary: #7a8898;
  --text-muted:     #444f60;

  --accent:         #69cbba;
  --accent-dim:     rgba(105, 203, 186, 0.15);

  /* ── Layout ─────────────────────────────────────────────── */
  --sidebar-w:      320px;
  --panel-w:        360px;
  --header-h:       56px;

  /* ── Spacing ────────────────────────────────────────────── */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;

  /* ── Typography ─────────────────────────────────────────── */
  --font-mono: 'Geist Mono', monospace;
--font-body: 'Geist', sans-serif;
  --radius-sm:   6px;
  --radius-md:   10px;

  /* ── Transitions ────────────────────────────────────────── */
  --t-fast:  150ms ease;
  --t-med:   280ms cubic-bezier(0.4,0,0.2,1);
  --t-slow:  420ms cubic-bezier(0.4,0,0.2,1);
}

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

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── App shell ────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-areas:
    "header header"
    "sidebar main";
  height: 100vh;
  width: 100vw;
}

/* ── Header ───────────────────────────────────────────────── */
#header {
  grid-area: header;
  display: flex;
  align-items: center;
  padding: 0 var(--sp-lg);
  gap: var(--sp-md);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

#header .logo {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

#header .logo::before {
  content: '';
  display: block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
}

#header .subtitle {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  margin-left: 2px;
}

#header .header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-md);
}

#node-count {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
}

#node-count span {
  color: var(--accent);
  font-weight: 700;
}

.ipick-logo-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  transition: opacity 0.15s;
  opacity: 0.85;
}
.ipick-logo-link:hover { opacity: 1; }
.ipick-logo {
  height: 22px;
  width: auto;
  display: block;
}
/* dark mode: hide image, show text instead */
.ipick-logo-text {
  display: none;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.04em;
}
.ipick-logo-link {
  background: #ffffff;
  border-radius: 4px;
  padding: 2px 6px;
}
.ipick-logo-text { display: none; }

/* ── Left Sidebar ─────────────────────────────────────────── */
#sidebar {
  grid-area: sidebar;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 50;
}

.sidebar-section {
  padding: var(--sp-md);
  border-bottom: 1px solid var(--border);
}

.sidebar-section:last-child { border-bottom: none; }

/* The tracks section flexes to fill remaining height and lets its inner
   list scroll independently of the legend below it. */
.sidebar-section.tracks-section {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-section.tracks-section #track-list {
  flex: 1 1 0;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding-right: 6px;
}

/* Inline 'select all / clear' controls — sit next to the section label */
.tracks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.tracks-header .sidebar-label {
  margin-bottom: 0;
}
.track-hint {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 6px;
}
.track-controls {
  display: flex;
  gap: 10px;
}
.track-control-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 5px;
  padding: 3px 9px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.track-control-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
html[data-theme="light"] .track-control-btn {
  background: rgba(20,24,40,0.05);
  border-color: rgba(20,24,40,0.3);
}
#pinned-clear-all, #track-clear-all {
  background: none;
  border-color: #ef444466;
  color: #ef4444;
}
#pinned-clear-all:hover, #track-clear-all:hover {
  background: none;
  border-color: #ef4444;
  color: #f87171;
}

.sidebar-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--sp-sm);
}

/* Search */
.search-wrap {
  position: relative;
}

.search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

#search-input {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px 9px 32px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

#search-input::placeholder { color: var(--text-muted); }

#search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Search dropdown */
#search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  z-index: 200;
  /* Cap height to ~45% viewport so long result lists scroll internally
     instead of running off the sidebar. */
  max-height: 45vh;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
/* Group headers sticky so you can see which section you're scrolling */
.search-dropdown-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-surface);
}
.search-dropdown-header {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 7px 12px 4px;
}
.search-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  transition: background var(--t-fast);
}
.search-dropdown-item:hover { background: var(--bg-hover); }
.search-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.search-ticker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.search-name {
  color: var(--text-secondary);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Track Filters */
#track-list, #pinned-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Companies section — scrollable, shares space with tracks */
#pinned-section {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#pinned-list {
  flex: 1 1 0;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding-right: 6px;
}

.pinned-item {
  display: flex;
  flex-direction: column;
}

.pinned-item .track-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.pinned-ticker {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pinned-name {
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pinned-chevron-btn {
  background: none;
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.pinned-chevron-btn:hover { color: var(--text-primary); border-color: rgba(255,255,255,0.35); }
.pinned-chevron-btn.open { transform: rotate(180deg); }

.pinned-dropdown {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  padding: 8px 10px 8px 10px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pinned-dropdown-loading,
.pinned-dropdown-empty {
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 0;
}

.pinned-rel-section {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.pinned-rel-section + .pinned-rel-section {
  margin-top: 10px;
}

.pinned-rel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.pinned-rel-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.pinned-rel-all-btn {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-secondary);
  padding: 1px 5px;
  cursor: pointer;
  line-height: 1.4;
}
.pinned-rel-all-btn:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.pinned-rel-all-btn:disabled { opacity: 0.35; cursor: default; }
.pinned-rel-clear-btn { color: #ef4444; border-color: #ef444466; }
.pinned-rel-clear-btn:hover { color: #f87171; border-color: #ef4444; }
.pinned-rel-btn-group { display: flex; gap: 4px; }

.pinned-rel-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast);
}
.pinned-rel-item:hover { background: var(--bg-hover); }

.pinned-rel-ticker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  flex-shrink: 0;
  min-width: 36px;
}

.pinned-rel-item .conn-add-btn {
  width: 26px;
  height: 26px;
  font-size: 16px;
  margin-left: auto;
}
.pinned-rel-item .conn-add-btn.on-graph {
  font-size: 12px;
  width: 26px;
  height: 26px;
}

.pinned-rel-name {
  font-size: 11px;
  flex: 1;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-item {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast);
  user-select: none;
  border: 1px solid transparent;
}

.track-item:hover { background: var(--bg-hover); }

.track-item.active {
  background: var(--bg-hover);
  border-color: var(--border-bright);
}

.track-item.muted .track-dot { opacity: 0.25; }
.track-item.muted .track-name { color: var(--text-muted); }

.track-toggle-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
  cursor: pointer;
  color: var(--text-muted);
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.track-item.active .track-toggle-btn {
  color: #ef4444;
  border-color: #ef4444;
  font-size: 12px;
}
.track-item.active .track-toggle-btn:hover {
  background: rgba(239,68,68,0.12);
}
.track-item.muted .track-toggle-btn {
  color: #10b981;
  border-color: #10b981;
  font-size: 16px;
}
.track-item.muted .track-toggle-btn:hover {
  background: rgba(16,185,129,0.12);
}

a.track-item {
  display: flex;
  text-decoration: none;
  color: inherit;
}


.track-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: opacity var(--t-fast);
}

.track-name {
  font-size: 14px;
  color: var(--text-primary);
  transition: color var(--t-fast);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* Edge type legend — overlaid on graph canvas, bottom-left */
#edge-legend {
  position: absolute;
  bottom: 20px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  z-index: 10;
  pointer-events: none;
}

.edge-legend-item {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  font-size: 12px;
  color: var(--text-secondary);
}

.edge-swatch {
  width: 22px;
  height: 2px;
  border-radius: 1px;
  flex-shrink: 0;
}

.edge-swatch-arrow {
  width: 28px;
  height: 8px;
  flex-shrink: 0;
}

/* ── Main Graph Canvas ────────────────────────────────────── */
#main {
  grid-area: main;
  position: relative;
  overflow: hidden;
  background: var(--bg-base);
}

#graph-canvas {
  width: 100%;
  height: 100%;
}

/* subtle grid bg */
#main::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

#graph-canvas { position: relative; z-index: 1; }

/* ── Tooltip ──────────────────────────────────────────────── */
#tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 200;
  background: var(--bg-raised);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-md);
  padding: var(--sp-sm) var(--sp-md);
  min-width: 160px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--t-fast), transform var(--t-fast);
  backdrop-filter: blur(8px);
}

#tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.tt-ticker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 2px;
}

.tt-name {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  margin-bottom: 4px;
}

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

/* ── Right Detail Panel ───────────────────────────────────── */
#detail-panel {
  position: fixed;
  top: var(--header-h);
  right: 0;
  width: var(--panel-w);
  height: calc(100vh - var(--header-h));
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  z-index: 80;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--t-slow);
  overflow: hidden;
}

#detail-panel.open {
  transform: translateX(0);
  box-shadow: -16px 0 48px rgba(0,0,0,0.5);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--sp-lg) var(--sp-md) var(--sp-md);
  border-bottom: 1px solid var(--border);
}

.panel-ticker-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 3px 8px;
  border-radius: 4px;
  color: #fff;
  margin-bottom: var(--sp-sm);
  display: inline-block;
}

.panel-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.panel-sector {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

#panel-close {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--t-fast), color var(--t-fast);
}

#panel-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

#panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding: var(--sp-md);
}

.panel-body::-webkit-scrollbar { width: 4px; }
.panel-body::-webkit-scrollbar-track { background: transparent; }
.panel-body::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 2px; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}

.stat-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--sp-sm) var(--sp-md);
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.stat-value.price { color: var(--text-primary); }

.stock-website-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 13px;
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}
.website-arrow {
  line-height: 1;
  font-size: 12px;
  opacity: 0.75;
}
.stock-website-link:hover {
  border-color: rgba(255, 255, 255, 0.4);
}
html[data-theme="light"] .stock-website-link {
  border-color: rgba(0, 0, 0, 0.15);
  color: #1a1d2b;
}
html[data-theme="light"] .stock-website-link:hover {
  border-color: rgba(0, 0, 0, 0.3);
}

.panel-section-title {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: var(--sp-md) 0 var(--sp-sm);
}

.panel-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.track-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--badge-color, var(--text-primary));
  font-weight: 500;
  background: var(--bg-raised);
  border: 1px solid var(--border-bright);
  transition: background var(--t-fast), border-color var(--t-fast);
}

.panel-open-stock {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  opacity: 0.85;
  transition: opacity var(--t-fast);
}
.panel-open-stock:hover { opacity: 1; }

.panel-add-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 5px 10px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.panel-add-btn:hover {
  background: var(--accent);
  color: var(--bg-base);
}

.track-badge--link {
  text-decoration: none;
  cursor: pointer;
}
.track-badge--link:hover {
  background: var(--bg-hover);
  border-color: var(--badge-color, var(--border-bright));
}

/* ── Panel Tabs ───────────────────────────────────────────── */
.panel-tabs {
  display: flex;
  flex-wrap: wrap; /* allow tabs to wrap to next line when necessary */
  gap: 4px;
  margin: var(--sp-md) 0 var(--sp-sm);
  -webkit-overflow-scrolling: touch;
}

.panel-tab-btn {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 9px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all var(--t-fast);
  flex: 0 1 auto; /* allow shrinking and wrapping to next line */
  text-align: center;
  white-space: nowrap;
}

.panel-tab-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.panel-tab-btn.active {
  background: var(--bg-hover);
  border-color: var(--text-primary);
  color: var(--text-primary);
  font-weight: bold;
}

.panel-tab-content {
  display: none;
}

.panel-tab-content.active {
  display: block;
}

.conn-item.tab-item {
  grid-template-columns: 48px 1fr auto;
  padding: 6px 10px;
}

/* connected companies list */
.connections-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conn-item {
  display: grid;
  grid-template-columns: 76px 40px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
  overflow: hidden;
}

.conn-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-bright);
}

.conn-ticker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conn-type {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: capitalize;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conn-name {
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conn-add-btn {
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  color: #10b981;
  background: transparent;
  border: 1px solid #10b981;
  border-radius: 4px;
  cursor: pointer;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
  flex-shrink: 0;
}
.conn-add-btn:hover { background: rgba(16, 185, 129, 0.12); }

.conn-remove-btn {
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  color: #ef4444;
  background: transparent;
  border: 1px solid #ef4444;
  border-radius: 4px;
  cursor: pointer;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
  flex-shrink: 0;
}
.conn-remove-btn:hover { background: rgba(239, 68, 68, 0.12); }

.conn-on-graph {
  font-size: 12px;
  color: #10b981;
  border: 1px solid #10b981;
  border-radius: 4px;
  padding: 2px 6px;
  line-height: 1;
  flex-shrink: 0;
}

/* ── Scrollbar (sidebar) ──────────────────────────────────── */
#sidebar::-webkit-scrollbar,
#track-list::-webkit-scrollbar,
#pinned-list::-webkit-scrollbar { width: 3px; }
#sidebar::-webkit-scrollbar-track,
#track-list::-webkit-scrollbar-track,
#pinned-list::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb,
#track-list::-webkit-scrollbar-thumb,
#pinned-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Animations ───────────────────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 10px var(--accent); }
  50%       { opacity: 0.4; box-shadow: 0 0 4px var(--accent); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  :root {
    --sidebar-w: 260px;
    --panel-w: 300px;
  }
}

@media (max-width: 640px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) 1fr;
    grid-template-areas: "header" "main";
  }
  #sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    width: var(--sidebar-w);
    height: calc(100vh - var(--header-h));
    transform: translateX(-100%);
    transition: transform var(--t-slow);
    z-index: 70;
  }
  #sidebar.open { transform: translateX(0); }
  :root { --panel-w: 100vw; }
}

/* ── Add/Remove graph button states ──────────────────────── */
.panel-add-btn {
  color: #16a34a;
  border-color: #16a34a;
}
.panel-add-btn:hover {
  background: #16a34a;
  color: #fff;
}
.panel-add-btn.on-graph {
  color: #dc2626;
  border-color: #dc2626;
}
.panel-add-btn.on-graph:hover {
  background: #dc2626;
  color: #fff;
}

.conn-add-btn.on-graph {
  color: #dc2626;
  border-color: #dc2626;
  font-size: 12px;
  width: 26px;
  height: 26px;
}
.conn-add-btn.on-graph:hover {
  background: rgba(220, 38, 38, 0.12);
}
