/* ── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #111827;
  color: #f9fafb;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
button {
  cursor: pointer;
  border: none;
  font-family: inherit;
  font-size: 13px;
}
.hidden { display: none !important; }

/* ── Nav bar ─────────────────────────────────────────── */
#nav {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  height: 54px;
  background: #1f2937;
  border-bottom: 1px solid #374151;
  flex-shrink: 0;
  z-index: 10;
}
#nav-title {
  font-weight: 700;
  font-size: 16px;
  color: #60a5fa;
  margin-right: auto;
  letter-spacing: -0.3px;
}
#company-filter {
  background: #374151;
  color: #f9fafb;
  border: 1px solid #4b5563;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  max-width: 220px;
  cursor: pointer;
}
#company-filter:focus { outline: 2px solid #60a5fa; }
#clear-filter-btn {
  background: #374151;
  color: #9ca3af;
  border: 1px solid #4b5563;
  border-radius: 6px;
  padding: 6px 12px;
}
#clear-filter-btn:hover { background: #4b5563; color: #f9fafb; }
#upload-btn {
  background: #2563eb;
  color: #fff;
  border-radius: 6px;
  padding: 7px 14px;
  font-weight: 600;
}
#upload-btn:hover { background: #1d4ed8; }
#file-input { display: none; }

/* ── Search ───────────────────────────────────────────── */
#search-container {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 160px;
  max-width: 280px;
}
#search-input {
  width: 100%;
  background: #374151;
  color: #f9fafb;
  border: 1px solid #4b5563;
  border-radius: 6px;
  padding: 6px 28px 6px 10px;
  font-size: 13px;
  font-family: inherit;
}
#search-input::placeholder { color: #6b7280; }
#search-input:focus { outline: 2px solid #60a5fa; border-color: transparent; }
#search-clear {
  position: absolute;
  right: 6px;
  background: none;
  color: #6b7280;
  font-size: 12px;
  padding: 2px;
  line-height: 1;
}
#search-clear:hover { color: #f9fafb; }
#search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  list-style: none;
  z-index: 50;
  overflow: hidden;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
}
.search-result-item:hover { background: #374151; }
.search-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.search-badge-person { background: #1e3a5f; color: #60a5fa; }
.search-badge-company { background: #1a3a2a; color: #34d399; }
.search-result-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.search-result-label {
  font-size: 13px;
  color: #f9fafb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-sub {
  font-size: 11px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#how-to-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #374151;
  color: #9ca3af;
  border: 1px solid #4b5563;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
}
#how-to-btn:hover { background: #4b5563; color: #f9fafb; }

/* ── Insights bar ────────────────────────────────────── */
#insights-bar {
  padding: 7px 20px;
  background: #1f2937;
  border-bottom: 1px solid #374151;
  font-size: 12.5px;
  color: #9ca3af;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#insights-bar strong { color: #d1d5db; }

/* ── Demo banner ─────────────────────────────────────── */
#demo-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  background: #78350f;
  border-bottom: 1px solid #92400e;
  font-size: 13px;
  color: #fde68a;
  flex-shrink: 0;
}
#demo-banner span { flex: 1; }
#demo-upload-btn {
  background: #f59e0b;
  color: #1c1917;
  border-radius: 6px;
  padding: 5px 12px;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}
#demo-upload-btn:hover { background: #d97706; }

/* ── Graph container ─────────────────────────────────── */
#graph-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #0f172a;
}

/* ── Drop zone overlay ───────────────────────────────── */
#drop-zone {
  position: absolute;
  inset: 0;
  background: rgba(37, 99, 235, 0.15);
  border: 3px dashed #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  pointer-events: none;
}
#drop-zone-label {
  font-size: 22px;
  font-weight: 600;
  color: #93c5fd;
}

/* ── Loading overlay ─────────────────────────────────── */
#loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 30;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #374151;
  border-top-color: #60a5fa;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-overlay p { color: #9ca3af; font-size: 14px; }

/* ── Error overlay ───────────────────────────────────── */
#error-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}
#error-box {
  background: #1f2937;
  border: 1px solid #ef4444;
  border-radius: 12px;
  padding: 28px 32px;
  max-width: 440px;
  width: 90%;
  text-align: center;
}
#error-box h2 { color: #f87171; margin-bottom: 10px; font-size: 18px; }
#error-box p { color: #9ca3af; font-size: 13.5px; line-height: 1.6; margin-bottom: 16px; }
#error-box .instructions {
  text-align: left;
  background: #111827;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
#error-box .instructions p { color: #d1d5db; font-size: 12.5px; margin-bottom: 8px; }
#error-box .instructions ol { padding-left: 18px; }
#error-box .instructions li { color: #9ca3af; font-size: 12.5px; margin-bottom: 4px; }
#retry-btn {
  background: #2563eb;
  color: #fff;
  border-radius: 6px;
  padding: 8px 20px;
  font-weight: 600;
}
#retry-btn:hover { background: #1d4ed8; }

/* ── Profile card ────────────────────────────────────── */
#profile-card {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 230px;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  padding: 18px 20px;
  z-index: 15;
}
#card-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  color: #6b7280;
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
}
#card-close:hover { color: #f9fafb; }
#card-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #374151;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}
#card-name {
  font-size: 15px;
  font-weight: 700;
  color: #f9fafb;
  margin-bottom: 4px;
  padding-right: 20px;
}
#card-position { font-size: 12px; color: #9ca3af; margin-bottom: 2px; }
#card-company { font-size: 12.5px; color: #60a5fa; font-weight: 600; margin-bottom: 10px; }
#card-connected {
  font-size: 11.5px;
  color: #6b7280;
  border-top: 1px solid #374151;
  padding-top: 8px;
}
#card-url {
  display: block;
  margin-top: 10px;
  font-size: 12px;
  color: #60a5fa;
  text-decoration: none;
  font-weight: 600;
}
#card-url:hover { text-decoration: underline; }
.card-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

/* ── D3 graph elements ───────────────────────────────── */
.node-circle {
  cursor: pointer;
  transition: opacity 0.2s;
}
.node-label {
  font-size: 10px;
  fill: #cbd5e1;
  pointer-events: none;
  transition: opacity 0.2s;
  text-anchor: middle;
  dominant-baseline: hanging;
}
.link {
  stroke: #334155;
  stroke-opacity: 0.6;
  transition: opacity 0.2s;
}
.link.company-link {
  stroke: #475569;
  stroke-dasharray: 3 3;
  stroke-opacity: 0.4;
}
.dimmed { opacity: 0.08 !important; }

/* ── How-to modal ────────────────────────────────────── */
#howto-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
#howto-box {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 14px;
  padding: 32px 36px;
  max-width: 480px;
  width: 90%;
  position: relative;
}
#howto-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  color: #6b7280;
  font-size: 16px;
  padding: 2px 4px;
}
#howto-close:hover { color: #f9fafb; }
#howto-box h2 {
  font-size: 17px;
  color: #f9fafb;
  margin-bottom: 20px;
  padding-right: 24px;
}
#howto-box ol {
  padding-left: 20px;
  margin-bottom: 24px;
}
#howto-box li {
  color: #9ca3af;
  font-size: 13.5px;
  line-height: 1.6;
  margin-bottom: 8px;
}
#howto-box li strong { color: #d1d5db; }
#howto-upload-btn {
  background: #2563eb;
  color: #fff;
  border-radius: 6px;
  padding: 8px 20px;
  font-weight: 600;
  width: 100%;
}
#howto-upload-btn:hover { background: #1d4ed8; }

/* ── Footer ──────────────────────────────────────────── */
#footer {
  text-align: center;
  padding: 6px;
  font-size: 11px;
  color: #4b5563;
  background: #0f172a;
  flex-shrink: 0;
  border-top: 1px solid #1f2937;
}
#footer a { color: #6b7280; text-decoration: none; }
#footer a:hover { color: #9ca3af; text-decoration: underline; }
.footer-divider { margin: 0 6px; }
