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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f5f5f5;
  color: #222;
  line-height: 1.5;
}

header {
  background: #1a1a2e;
  color: #fff;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 { font-size: 1.25rem; font-weight: 600; }

.tabs {
  display: flex;
  gap: 0;
  background: #fff;
  border-bottom: 2px solid #e0e0e0;
  padding: 0 2rem;
}

.tab {
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  border: none;
  background: none;
  font-size: 0.95rem;
  color: #666;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover { color: #333; }
.tab.active { color: #1a1a2e; border-bottom-color: #1a1a2e; font-weight: 600; }

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem 2rem; }

.search-bar {
  width: 100%;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  margin-bottom: 1rem;
  outline: none;
}
.search-bar:focus { border-color: #1a1a2e; }

.count { font-size: 0.85rem; color: #888; margin-bottom: 0.75rem; }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

th {
  text-align: left;
  padding: 0.6rem 1rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #888;
  background: #fafafa;
  border-bottom: 1px solid #eee;
}

td {
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  border-bottom: 1px solid #f0f0f0;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9f9fc; }

.entity-link {
  color: #1a1a8e;
  cursor: pointer;
  text-decoration: none;
}
.entity-link:hover { text-decoration: underline; }

.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 4px;
  background: #e8e8f0;
  color: #555;
  margin: 0.1rem 0.15rem;
}

.tag.format { background: #e0f0e0; color: #2a6a2a; }

/* Detail modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  justify-content: center;
  align-items: start;
  padding-top: 5vh;
}
.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 10px;
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  padding: 1.5rem 2rem;
}

.modal-close {
  float: right;
  border: none;
  background: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #999;
  line-height: 1;
}
.modal-close:hover { color: #333; }

.modal h2 { font-size: 1.2rem; margin-bottom: 0.25rem; }

.event-link-btn {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.5rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: #1a1a2e;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.15s;
}
.event-link-btn:hover { background: #2a2a4e; }

.modal .entity-type-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 1rem;
}

.modal section { margin-top: 1.25rem; }
.modal section h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  color: #888;
  letter-spacing: 0.03em;
  margin-bottom: 0.5rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1rem;
  font-size: 0.9rem;
}
.detail-grid dt { color: #888; }
.detail-grid dd { color: #222; }

.rel-list { list-style: none; }
.rel-list li {
  padding: 0.35rem 0;
  font-size: 0.9rem;
  border-bottom: 1px solid #f0f0f0;
}
.rel-list li:last-child { border-bottom: none; }
.rel-type { color: #888; font-size: 0.8rem; }

.source-list { list-style: none; }
.source-list li { padding: 0.25rem 0; font-size: 0.85rem; }
.source-list a { color: #1a1a8e; word-break: break-all; }

/* Score column */
.score-cell {
  position: relative;
  width: 70px;
  min-width: 70px;
  text-align: right;
  padding-right: 0.8rem !important;
}

.score-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  opacity: 0.15;
  border-radius: 0 4px 4px 0;
}

.score-num {
  position: relative;
  font-weight: 600;
  font-size: 0.85rem;
}

.score-high .score-bar, .score-high { background-color: #22c55e; }
.score-med .score-bar, .score-med { background-color: #f59e0b; }
.score-low .score-bar, .score-low { background-color: #ef4444; }

.score-high .score-num { color: #16a34a; }
.score-med .score-num { color: #d97706; }
.score-low .score-num { color: #dc2626; }

/* Sortable headers */
th.sortable {
  cursor: pointer;
  user-select: none;
}
th.sortable:hover { color: #333; }

/* Score detail in modal */
.score-detail { margin-bottom: 0.5rem; }

.score-hero {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}
.score-hero.score-high { color: #16a34a; }
.score-hero.score-med { color: #d97706; }
.score-hero.score-low { color: #dc2626; }

.signal-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
}

.signal-label {
  width: 120px;
  color: #666;
  text-transform: capitalize;
}

.signal-track {
  flex: 1;
  height: 8px;
  background: #eee;
  border-radius: 4px;
  overflow: hidden;
}

.signal-fill {
  height: 100%;
  background: #1a1a2e;
  border-radius: 4px;
  transition: width 0.3s;
}

.signal-val {
  width: 30px;
  text-align: right;
  font-weight: 600;
  color: #444;
}

/* Header link (Pipeline/Dashboard cross-link) */
.header-link {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 0.9rem;
}
.header-link:hover { color: #fff; }

/* --- Pipeline Control Panel --- */

.status-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.status-card {
  background: #fff;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border-left: 4px solid #1a1a2e;
}

.status-card.card-warn { border-left-color: #f59e0b; }

.card-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #888;
  margin-bottom: 0.25rem;
}

.card-value {
  font-size: 1.15rem;
  font-weight: 600;
  color: #222;
  margin-bottom: 0.2rem;
}

.card-detail {
  font-size: 0.8rem;
  color: #999;
}

.card-detail .funnel-line { display: block; line-height: 1.4; }
.card-detail .funnel-dim { color: #bbb; }

/* Scraper Health Strip */
.health-strip {
  background: #fff;
  border-radius: 8px;
  padding: 0.75rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 1.5rem;
}

.health-strip-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #888;
  margin-bottom: 0.5rem;
}

.health-strip-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: flex-start;
}

.health-item {
  font-size: 0.85rem;
  color: #444;
  display: flex;
  flex-direction: column;
}

.health-top {
  white-space: nowrap;
}

.health-detail {
  font-size: 0.72rem;
  color: #999;
  white-space: nowrap;
  line-height: 1.4;
}

.health-item .health-name {
  font-weight: 500;
}

.health-item .health-time {
  font-size: 0.8rem;
  margin-left: 0.2rem;
}

.health-fresh .health-time { color: #16a34a; }
.health-stale .health-time { color: #d97706; }
.health-old .health-time { color: #dc2626; }
.health-never .health-time { color: #bbb; }

.health-time-sep {
  font-size: 0.7rem;
  color: #999;
  margin: 0 0.1rem;
}

.health-time-oldest.health-fresh { color: #16a34a; }
.health-time-oldest.health-stale { color: #d97706; }
.health-time-oldest.health-old { color: #dc2626; }

.health-pct {
  font-size: 0.7rem;
  color: #666;
  margin-left: 0.15rem;
}

.health-unscraped {
  font-size: 0.7rem;
  background: #fef3c7;
  color: #92400e;
  padding: 0.1rem 0.35rem;
  border-radius: 9px;
  margin-left: 0.25rem;
  font-weight: 500;
}

/* Panels */
.panel {
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 1.5rem;
}

.panel h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #888;
  margin-bottom: 1rem;
}

/* Action grid */
.action-grid { display: flex; flex-direction: column; gap: 0.75rem; }

.action-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.action-label {
  width: 70px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #444;
}

.action-buttons { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

.action-count {
  font-size: 0.8rem;
  color: #d97706;
  font-weight: 500;
  white-space: nowrap;
}

.last-run {
  font-size: 0.75rem;
  color: #999;
  margin-right: 0.5rem;
}

.btn {
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fafafa;
  color: #333;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover { background: #1a1a2e; color: #fff; border-color: #1a1a2e; }

/* Job history */
.job-list { display: flex; flex-direction: column; gap: 0.5rem; }

.job-empty {
  font-size: 0.9rem;
  color: #999;
  padding: 0.5rem 0;
}

.job-card {
  border: 1px solid #e8e8ee;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  transition: border-color 0.15s;
}

.job-card:hover { border-color: #ccc; }
.job-card.job-active { border-left: 3px solid #3b82f6; }
.job-card.job-done { border-left: 3px solid #16a34a; }
.job-card.job-failed { border-left: 3px solid #dc2626; }
.job-card.job-cancelled { border-left: 3px solid #f59e0b; }

.job-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.job-header:hover { background: #f9f9fc; }
.job-card.expanded .job-header { background: #f5f5fa; }

.job-step {
  font-weight: 600;
  color: #333;
  min-width: 100px;
}

.job-meta {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
}

.job-info {
  color: #666;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-times {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-left: auto;
  flex-shrink: 0;
}

.job-timestamp {
  color: #999;
  font-size: 0.75rem;
  white-space: nowrap;
}

.job-duration {
  color: #666;
  font-size: 0.8rem;
  font-weight: 500;
  min-width: 50px;
  text-align: right;
  white-space: nowrap;
}

.job-expand-hint {
  color: #bbb;
  font-size: 0.75rem;
  transition: transform 0.15s;
}
.job-card.expanded .job-expand-hint { transform: rotate(90deg); }

.job-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.job-ok { color: #16a34a; }
.job-fail { color: #dc2626; }
.job-cancel { color: #f59e0b; }

.job-active .job-step { color: #1a1a2e; }
.job-failed .job-step { color: #dc2626; }
.job-cancelled .job-step { color: #f59e0b; }

.btn-cancel {
  background: none;
  border: 1px solid #ddd;
  border-radius: 4px;
  color: #999;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 2px 6px;
  line-height: 1;
  flex-shrink: 0;
}
.btn-cancel:hover {
  background: #fee2e2;
  border-color: #dc2626;
  color: #dc2626;
}

.job-body {
  padding: 0 0.75rem 0.6rem 0.75rem;
  font-size: 0.85rem;
}

.job-result {
  color: #555;
  padding: 0.25rem 0;
}

.job-error {
  color: #dc2626;
  padding: 0.25rem 0;
}

.job-output {
  font-family: "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  background: #1a1a2e;
  color: #d4d4d8;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  margin-top: 0.4rem;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.show-more-row {
  text-align: center;
  padding: 0.5rem 0;
}

.btn-show-more {
  padding: 0.3rem 1rem;
  font-size: 0.8rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fafafa;
  color: #666;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-show-more:hover { background: #1a1a2e; color: #fff; border-color: #1a1a2e; }

/* Tier controls */
.tier-group { flex-wrap: wrap; }

.tier-count {
  font-size: 0.8rem;
  color: #888;
  font-weight: 400;
}

.tier-input-label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: #888;
}

.tier-input {
  width: 50px;
  padding: 0.25rem 0.4rem;
  font-size: 0.8rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  outline: none;
  text-align: center;
}

.tier-input:focus { border-color: #1a1a2e; }

.tier-estimate {
  font-size: 0.75rem;
  color: #999;
  font-style: italic;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #ddd;
  border-top-color: #1a1a2e;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Filter bar */
.filter-bar {
  background: #fff;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.filter-group-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #888;
  margin-right: 0.25rem;
  white-space: nowrap;
}

.filter-tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  border-radius: 999px;
  border: 1px solid #ddd;
  background: #fafafa;
  color: #555;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
}

.filter-tag:hover { border-color: #999; }

.filter-tag.active,
.filter-tag.include {
  background: #1a1a2e;
  color: #fff;
  border-color: #1a1a2e;
}

.filter-tag.exclude {
  background: #fef2f2;
  color: #dc2626;
  border-color: #dc2626;
  text-decoration: line-through;
}

.filter-date {
  padding: 0.2rem 0.4rem;
  font-size: 0.8rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  outline: none;
  color: #333;
}
.filter-date:focus { border-color: #1a1a2e; }

.filter-clear {
  margin-left: auto;
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  border: none;
  background: none;
  color: #888;
  cursor: pointer;
  text-decoration: underline;
}
.filter-clear:hover { color: #333; }

/* Registration status badges */
.reg-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
}
.reg-badge.reg-sold-out { background: #fef2f2; color: #dc2626; }
.reg-badge.reg-waitlist { background: #fef3c7; color: #d97706; }
.reg-badge.reg-approval { background: #f3e8ff; color: #7c3aed; }
.reg-badge.reg-paid { background: #eff6ff; color: #2563eb; }
.reg-badge.reg-open { background: #dcfce7; color: #16a34a; }

/* Credibility badge in relationship lists */
.credibility-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 3px;
  vertical-align: middle;
}
.credibility-badge.score-high { background: #dcfce7; color: #16a34a; }
.credibility-badge.score-med { background: #fef3c7; color: #d97706; }
.credibility-badge.score-low { background: #fef2f2; color: #dc2626; }

/* --- Scheduler Panel --- */

.scheduler-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.scheduler-header h2 { margin-bottom: 0; }

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #ccc;
  border-radius: 22px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider { background: #16a34a; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

.scheduler-status-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.scheduler-status-label.status-disabled { color: #999; }
.scheduler-status-label.status-active { color: #16a34a; }
.scheduler-status-label.status-waiting { color: #d97706; }

.scheduler-phase {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 0.75rem;
}

.scheduler-phase .spinner { width: 14px; height: 14px; }

.scheduler-info {
  font-size: 0.8rem;
  color: #999;
  margin-bottom: 0.75rem;
}

.scheduler-config {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.scheduler-config label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: #666;
}

.scheduler-config input {
  width: 45px;
  padding: 0.25rem 0.4rem;
  font-size: 0.8rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  outline: none;
  text-align: center;
}

.scheduler-config input:focus { border-color: #1a1a2e; }

.btn-sm {
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fafafa;
  color: #333;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-sm:hover { background: #1a1a2e; color: #fff; border-color: #1a1a2e; }

.scheduler-scraped {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: #999;
}

.scheduler-scraped .scraped-check { color: #16a34a; }

/* --- Timeline --- */
.timeline {
  position: relative;
  padding: 1rem 0;
  max-width: 900px;
  margin: 0 auto;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 20px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #ddd;
}

.timeline-day {
  position: relative;
  margin: 1.5rem 0 1rem;
  padding-left: 3rem;
  z-index: 2;
}

.timeline-day:first-child {
  margin-top: 0;
}

.timeline-day span {
  display: inline-block;
  padding: 0.3rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: #1a1a2e;
  border-radius: 999px;
}

.timeline-item {
  position: relative;
  width: 100%;
  padding: 0 0 0 3rem;
  margin-bottom: 1rem;
}

.timeline-dot {
  position: absolute;
  left: 14px;
  top: 1rem;
  width: 12px;
  height: 12px;
  background: #1a1a2e;
  border: 2px solid #fff;
  border-radius: 50%;
  z-index: 2;
  box-shadow: 0 0 0 2px #ddd;
}

.timeline-card {
  background: #fff;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  text-align: left;
  transition: box-shadow 0.15s;
}

.timeline-card:hover {
  box-shadow: 0 3px 10px rgba(0,0,0,0.12);
}

.timeline-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.timeline-card-header .entity-link {
  font-weight: 600;
  font-size: 0.95rem;
}

.timeline-score {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.timeline-score.score-high { background: #dcfce7; color: #16a34a; }
.timeline-score.score-med { background: #fef3c7; color: #d97706; }
.timeline-score.score-low { background: #fef2f2; color: #dc2626; }

.timeline-card-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: #666;
  margin-bottom: 0.3rem;
}

.timeline-card-tags {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.2rem;
}

.timeline-card-orgs {
  font-size: 0.8rem;
  color: #888;
  margin-top: 0.25rem;
}

/* --- Funding Tab --- */
.summary-strip {
  background: #fff;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: #555;
  font-weight: 500;
}

.funding-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.month-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #f5f5f5;
  padding: 0.75rem 0 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 0.5rem;
}

.funding-card {
  background: #fff;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: box-shadow 0.15s;
}

.funding-card:hover {
  box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

.funding-card-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.round-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.round-seed { background: #dcfce7; color: #16a34a; }
.round-series-ab { background: #dbeafe; color: #2563eb; }
.round-series-c { background: #f3e8ff; color: #7c3aed; }
.round-growth { background: #fef3c7; color: #d97706; }
.round-other { background: #f3f4f6; color: #6b7280; }

.funding-company {
  font-weight: 600;
  font-size: 0.95rem;
  color: #222;
}

.funding-amount {
  margin-left: auto;
  font-weight: 700;
  font-size: 1rem;
  color: #222;
  white-space: nowrap;
}

.funding-card-date {
  font-size: 0.82rem;
  color: #888;
  margin: 0.2rem 0 0.3rem;
}

.funding-investors {
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 0.15rem;
}

.funding-investors .lead {
  font-weight: 600;
}

.funding-investors.secondary {
  color: #888;
  font-size: 0.82rem;
}

.funding-expand-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-size: 0.75rem;
  color: #888;
  cursor: pointer;
  margin-left: 0.25rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.funding-expand-btn:hover {
  background: #1a1a2e;
  color: #fff;
  border-color: #1a1a2e;
}

.funding-use-of-funds {
  font-size: 0.82rem;
  color: #666;
  margin-top: 0.3rem;
  line-height: 1.45;
}

.funding-tags {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-top: 0.3rem;
}

.funding-tag {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  font-size: 0.7rem;
  border-radius: 4px;
  background: #f0f0f8;
  color: #777;
}

.funding-source-link {
  color: #aaa;
  text-decoration: none;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.funding-source-link:hover {
  color: #1a1a8e;
}

.funding-source-badge {
  font-size: 0.7rem;
  padding: 1px 5px;
  border-radius: 3px;
  color: #666;
  background: #f0f0f0;
  flex-shrink: 0;
}
.funding-source-badge.twitter {
  color: #1d9bf0;
  background: #e8f5fd;
}
.funding-source-badge.newswire {
  color: #666;
  background: #f0f0f0;
}
.funding-source-badge.yc {
  color: #f26522;
  background: #fef3ec;
}

/* Funding history in org detail modal */
.funding-history-row {
  display: grid;
  grid-template-columns: auto auto 1fr 2fr;
  gap: 0.5rem;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.85rem;
}

.funding-history-row:last-child { border-bottom: none; }

.funding-history-amount {
  font-weight: 700;
  color: #222;
  white-space: nowrap;
}

.funding-history-date {
  color: #888;
  font-size: 0.82rem;
  white-space: nowrap;
}

.funding-history-investors {
  color: #555;
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: #555;
  cursor: pointer;
  user-select: none;
}

.ai-toggle input {
  accent-color: #1a1a2e;
}

/* --- Profile selector in header --- */
.profile-select {
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}
.profile-select:hover { border-color: rgba(255,255,255,0.5); }
.profile-select option { color: #222; background: #fff; }

/* --- Profile page --- */
.profile-list-item {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s;
  margin-bottom: 0.25rem;
}
.profile-list-item:hover { background: #f0f0f5; }
.profile-list-item.active { background: #e8e8f0; }
.profile-list-name { font-weight: 500; font-size: 0.9rem; }
.profile-list-count { font-size: 0.78rem; color: #999; }

.interest-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.interest-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.82rem;
  border-radius: 999px;
  background: #e8e8f0;
  color: #444;
}
.interest-tag-x {
  border: none;
  background: none;
  color: #999;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0 0.15rem;
}
.interest-tag-x:hover { color: #dc2626; }

/* --- Category cards (profile editor) --- */

.section-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: #888;
  letter-spacing: 0.03em;
  margin-bottom: 0.5rem;
}

.category-card {
  display: inline-block;
  border: 1px solid #d8d8e8;
  border-radius: 8px;
  background: #f8f8fc;
  margin: 0 0.4rem 0.4rem 0;
  vertical-align: top;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.category-card:hover { border-color: #b0b0cc; }

.category-card.expanded {
  display: block;
  margin-bottom: 0.5rem;
}

.category-card-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
}

.category-card-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  user-select: none;
}

.category-card-name:hover { color: #1a1a2e; }

.category-card-count {
  font-size: 0.72rem;
  color: #aaa;
}

.category-card-remove {
  border: none;
  background: none;
  color: #bbb;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.15rem;
  margin-left: 0.15rem;
}
.category-card-remove:hover { color: #dc2626; }

.category-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem 0.6rem 0.5rem;
  border-top: 1px solid #e8e8f0;
}

.category-kw-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.1rem 0.45rem;
  font-size: 0.75rem;
  border-radius: 4px;
  background: #e8e8f0;
  color: #555;
}

.category-kw-x {
  border: none;
  background: none;
  color: #bbb;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0 0.1rem;
}
.category-kw-x:hover { color: #dc2626; }

.category-kw-tag.removed {
  background: none;
  border: 1px dashed #ccc;
  color: #aaa;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, color 0.15s;
}
.category-kw-tag.removed:hover {
  background: #f0f0ff;
  color: #666;
  border-color: #999;
}

.category-card.suggested {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  border: 1px dashed #c0c0d8;
  background: #fff;
  color: #666;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.category-card.suggested:hover {
  background: #f0f0ff;
  border-color: #8888cc;
  color: #333;
}

.extra-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.4rem;
}

/* --- Topic search dropdown --- */

.topic-search-container {
  position: relative;
  max-width: 400px;
}

.topic-search-container input {
  width: 100%;
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  outline: none;
}

.topic-search-container input:focus { border-color: #1a1a2e; }

.topic-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-top: none;
  border-radius: 0 0 6px 6px;
  max-height: 260px;
  overflow-y: auto;
  z-index: 20;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.topic-dropdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.1s;
}

.topic-dropdown-item:hover { background: #f0f0ff; }

.topic-dropdown-item.already {
  color: #aaa;
  background: #fafafa;
}

.topic-dropdown-item.topic-dropdown-empty {
  color: #999;
  cursor: default;
  justify-content: center;
}

.topic-dropdown-name { color: #333; }
.topic-dropdown-item.already .topic-dropdown-name { color: #aaa; }

.topic-dropdown-count {
  font-size: 0.75rem;
  color: #aaa;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

/* --- Org Card Grid --- */
.org-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.org-card {
  background: #fff;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.org-card:hover {
  box-shadow: 0 3px 10px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}

.org-card-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.org-card-tier {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  border-radius: 999px;
  white-space: nowrap;
}

.org-card-group {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 500;
  border-radius: 4px;
  background: #e8e8f0;
  color: #666;
  white-space: nowrap;
}

.org-card-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: #1a1a8e;
}

.org-card-desc {
  font-size: 0.82rem;
  color: #666;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.org-card-details {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.15rem;
}

.org-card-funding {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 4px;
  background: #dcfce7;
  color: #16a34a;
  white-space: nowrap;
}

.org-card-detail-tag {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  font-size: 0.72rem;
  border-radius: 4px;
  background: #f0f0f8;
  color: #777;
  white-space: nowrap;
}

@media (max-width: 1024px) {
  .org-card-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Responsive */
@media (max-width: 768px) {
  header { padding: 0.75rem 1rem; }
  .tabs { padding: 0 1rem; }
  .tab { padding: 0.6rem 1rem; font-size: 0.85rem; }
  .container { padding: 1rem; }
  th, td { padding: 0.5rem 0.6rem; font-size: 0.8rem; }
  .modal { width: 95%; padding: 1rem; }
  .status-cards { grid-template-columns: repeat(2, 1fr); }
  .action-row { flex-wrap: wrap; }
  .filter-bar { flex-direction: column; align-items: flex-start; }
  .filter-clear { margin-left: 0; }

  /* Timeline mobile: tighter spacing */
  .timeline::before { left: 16px; }
  .timeline-item { padding-left: 2.5rem; }
  .timeline-dot { left: 10px; }
  .timeline-day { padding-left: 2.5rem; }

  /* Org cards mobile */
  .org-card-grid { grid-template-columns: 1fr; }

  /* Funding mobile */
  .funding-card-top { flex-wrap: wrap; }
  .funding-amount { margin-left: 0; font-size: 0.9rem; }
}

.load-more-btn {
  display: block;
  margin: 1.5rem auto;
  padding: 0.6rem 1.5rem;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}
.load-more-btn:hover { background: #1d4ed8; }
