:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4d;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #f59e0b;
  --trip: #f59e0b;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.brand h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.tagline {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.trip-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--trip);
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.08);
}

.trip-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--trip);
}

.trip-dates {
  font-weight: 600;
  font-size: 0.95rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  height: calc(100vh - 120px);
  min-height: 420px;
}

.sidebar {
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 1rem 1.1rem;
  background: var(--surface);
}

.sidebar-section {
  margin-bottom: 1.25rem;
}

.sidebar h2 {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.filter-trip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
  margin-bottom: 0.85rem;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}

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

.loc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.loc-item {
  margin-bottom: 0.5rem;
}

.loc-btn {
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  transition: border-color 0.15s, background 0.15s;
}

.loc-btn:hover,
.loc-btn.active {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.06);
}

.loc-btn .name {
  font-weight: 600;
  display: block;
}

.loc-btn .meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.loc-btn .trip-tag {
  display: inline-block;
  margin-top: 0.25rem;
  padding: 0.1rem 0.35rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--trip);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 3px;
}

.disclaimer {
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--muted);
  margin: 1rem 0 0.5rem;
}

.updated {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0;
}

.map-wrap {
  position: relative;
  min-height: 300px;
}

#map {
  width: 100%;
  height: 100%;
  background: #1a1a1a;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 0.65rem 1.25rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}

.site-footer p {
  margin: 0;
}

/* Leaflet popup dark theme */
.leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
}

.leaflet-popup-tip {
  background: var(--surface);
}

.popup h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.popup .company {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.popup dl {
  margin: 0.5rem 0 0;
  font-size: 0.82rem;
}

.popup dt {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  margin-top: 0.45rem;
}

.popup dd {
  margin: 0.15rem 0 0;
  line-height: 1.4;
}

.popup .visit {
  margin-top: 0.5rem;
  padding: 0.45rem;
  background: rgba(245, 158, 11, 0.1);
  border-radius: 4px;
  font-size: 0.78rem;
}

.popup a {
  color: #60a5fa;
}

.popup-badges {
  margin: 0.35rem 0 0.5rem;
}

.popup-badges .badge {
  font-size: 0.65rem;
  margin-right: 0.25rem;
}

/* Navigation */
.site-nav {
  display: flex;
  gap: 0.35rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.25rem 0.75rem;
}

.nav-btn {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.nav-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.nav-btn.active {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.1);
}

.view-panel.hidden {
  display: none !important;
}

.panel-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem;
}

.panel-intro {
  margin-bottom: 1rem;
}

.panel-intro h2 {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
}

.panel-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.filter-bar label {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.filter-bar select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  min-width: 140px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-inv-direct {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.badge-inv-partial {
  background: rgba(234, 179, 8, 0.15);
  color: #fde047;
  border: 1px solid rgba(234, 179, 8, 0.35);
}

.badge-inv-indirect {
  background: rgba(139, 156, 179, 0.15);
  color: var(--muted);
  border: 1px dashed var(--border);
}

.badge-phase-active {
  border: 2px solid #22c55e;
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.08);
}

.badge-phase-idea {
  border: 2px dotted #a855f7;
  color: #e9d5ff;
  background: rgba(168, 85, 247, 0.08);
}

.badge-phase-advisory {
  border: 2px solid #3b82f6;
  color: #bfdbfe;
  background: rgba(59, 130, 246, 0.08);
}

.badge-phase-winding_down {
  border: 2px dashed #f59e0b;
  color: #fde68a;
  background: rgba(245, 158, 11, 0.08);
}

.badge-phase-dormant {
  border: 2px dotted var(--muted);
  color: var(--muted);
  background: transparent;
}

.badge-phase-severed {
  color: var(--muted);
  text-decoration: line-through;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.badge-impact-scale_up {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}

.badge-impact-scale_down {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.badge-impact-structural {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.badge-impact-neutral {
  background: rgba(139, 156, 179, 0.15);
  color: var(--muted);
}

.badge-tech {
  background: rgba(96, 165, 250, 0.12);
  color: #93c5fd;
  border: 1px solid rgba(96, 165, 250, 0.25);
  margin: 0.1rem 0.15rem 0.1rem 0;
}

.tech-cell {
  min-width: 120px;
}

.tech-cell .badge {
  display: inline-block;
  margin-bottom: 0.15rem;
}

.filter-select-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  margin-bottom: 0.85rem;
}

.filter-select-label select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.popup-tech {
  margin: 0.35rem 0 0.5rem;
}

.indicator-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
}

.ind-block .badge {
  margin-left: 0.25rem;
}

/* Entity table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.entity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.entity-table th {
  text-align: left;
  padding: 0.65rem 0.75rem;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}

.entity-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.entity-row:hover {
  background: rgba(255, 255, 255, 0.02);
}

.entity-row.entity-phase-severed td {
  opacity: 0.75;
}

.entity-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.role-cell {
  max-width: 180px;
  font-size: 0.78rem;
  color: var(--muted);
}

.cat-tag {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: capitalize;
}

.meta {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Timeline */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--border);
  margin-left: 0.5rem;
}

.timeline-item {
  position: relative;
  padding: 0 0 1.25rem 1.25rem;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 0.35rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
}

.timeline-item.impact-scale_up::before {
  background: #22c55e;
}

.timeline-item.impact-scale_down::before {
  background: #ef4444;
}

.timeline-item.impact-structural::before {
  background: #3b82f6;
}

.timeline-item time {
  font-size: 0.75rem;
  color: var(--muted);
}

.timeline-body h3 {
  margin: 0.25rem 0 0.35rem;
  font-size: 1rem;
}

.timeline-meta {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.timeline-body p {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  line-height: 1.45;
}

.timeline-body a {
  color: #60a5fa;
}

code {
  font-size: 0.85em;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}

.site-footer a {
  color: #60a5fa;
}

.journal-grid {
  display: grid;
  gap: 1.25rem;
}

.journal-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  background: var(--surface);
}

.journal-card time {
  font-size: 0.75rem;
  color: var(--muted);
}

.journal-loc {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.25rem 0;
}

.journal-card h3 {
  margin: 0.35rem 0 0.5rem;
  font-size: 1.1rem;
}

.journal-card p {
  margin: 0.35rem 0;
  line-height: 1.5;
  font-size: 0.9rem;
}

.journal-img {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: 8px;
  margin-top: 0.65rem;
}

.journal-video {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  margin-top: 0.65rem;
  border-radius: 8px;
  overflow: hidden;
}

.journal-video iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.journal-empty {
  color: var(--muted);
  font-size: 0.95rem;
}

@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
  }

  .sidebar {
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .map-wrap {
    height: 55vh;
  }
}
