:root {
  color-scheme: light;
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-strong: #eef2f1;
  --ink: #1d2328;
  --muted: #65717a;
  --line: #d9dfdc;
  --accent: #33566b;
  --rl: #00843d;
  --rl-theory: #c51b7d;
  --neuro-rl: #6a3d9a;
  --robotics: #e66100;
  --shadow: 0 18px 42px rgba(35, 45, 50, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto 18px;
  max-width: 1500px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 2.4vw, 2.55rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.topnav {
  display: flex;
  gap: 8px;
}

.topnav a,
.back-link {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
  padding: 10px 14px;
  text-decoration: none;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  max-width: 1500px;
  margin: 0 auto 16px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 850;
  line-height: 1;
}

.stat-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.75fr);
  gap: 16px;
  max-width: 1500px;
  margin: 0 auto;
  align-items: stretch;
}

.map-pane,
.list-pane {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.map-pane {
  position: relative;
}

#lab-map {
  height: min(72vh, 780px);
  min-height: 610px;
  width: 100%;
}

.legend {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 700;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  max-width: calc(100% - 28px);
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legend span,
.domain-pill,
.focus-tag,
.tag-row span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 800;
  padding: 6px 9px;
  white-space: nowrap;
}

.legend-dot,
.domain-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--domain-colour, var(--accent));
  display: inline-block;
  flex: 0 0 auto;
}

.list-pane {
  display: flex;
  flex-direction: column;
  max-height: min(72vh, 780px);
  min-height: 610px;
}

.controls {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 11px;
}

.filter-stack {
  display: grid;
  gap: 9px;
  margin-bottom: 10px;
}

.filter-group {
  display: grid;
  gap: 5px;
}

.filter-label,
.field-box span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 850;
  line-height: 1;
  text-transform: uppercase;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 6px 9px;
}

.filter-button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.field-box {
  display: grid;
  gap: 5px;
}

.field-box input,
.filter-group select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 8px 10px;
}

.field-box input:focus,
.filter-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(51, 86, 107, 0.16);
}

.lab-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding: 10px;
}

.lab-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.lab-card.active {
  border-color: var(--active-colour, var(--accent));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--active-colour, var(--accent)) 18%, transparent);
}

.lab-topline,
.lab-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
}

.lab-topline {
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.lab-name {
  margin: 0 0 2px;
  font-size: 1rem;
  line-height: 1.25;
}

.lab-pi,
.lab-location {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.focus-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 9px 0;
}

.focus-tag {
  background: var(--surface-strong);
  font-size: 0.68rem;
  padding: 3px 7px;
}

.lab-actions a,
.map-focus {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 850;
  padding: 6px 9px;
  text-decoration: none;
}

.lab-marker {
  display: grid;
  place-items: center;
}

.marker-shape {
  background: var(--marker-colour, var(--accent));
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(20, 28, 32, 0.35);
  display: block;
  height: 20px;
  width: 20px;
}

.leaflet-popup-content {
  margin: 12px 14px;
}

.popup-title {
  margin: 0 0 2px;
  font-weight: 850;
}

.popup-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.popup-focus {
  margin: 8px 0 0;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 750;
}

.popup-pro {
  margin: 6px 0 0;
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1.35;
}

.popup-pro {
  color: #1d6b3a;
}

.popup-pro strong {
  font-weight: 850;
}

.proscons {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.proscons-col {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px 14px;
}

.proscons-col h2 {
  margin: 0 0 8px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.proscons-col.pros h2 {
  color: #1d6b3a;
}

.proscons-col ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.proscons-col li {
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.4;
}

@media (max-width: 560px) {
  .proscons {
    grid-template-columns: 1fr;
  }
}

.content-page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 18px 48px;
}

.content-page h1 {
  margin: 0 0 18px;
}

.content-page table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.content-page th,
.content-page td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

.content-page th {
  background: var(--surface-strong);
  font-size: 0.82rem;
}

.lab-profile {
  display: grid;
  gap: 14px;
}

.lab-profile .back-link {
  justify-self: start;
}

.profile-meta,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.profile-meta span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  padding: 7px 10px;
}

.source-line {
  color: var(--muted);
  font-weight: 800;
}

.ai-disclaimer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  margin: 4px 0 0;
  padding-top: 14px;
}

.map-disclaimer {
  max-width: 1500px;
  margin: 16px auto 0;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 16px;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  #lab-map,
  .list-pane {
    min-height: 430px;
    max-height: none;
  }

  #lab-map {
    height: 58vh;
  }

  .list-pane {
    height: auto;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 10px;
  }

  .stats-grid {
    gap: 8px;
  }

  .stat {
    padding: 10px;
  }

  .lab-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .lab-actions a,
  .map-focus {
    width: 100%;
  }
}
