:root {
  --bg: #08111f;
  --bg-elevated: #0f1b2e;
  --bg-panel: rgba(15, 27, 46, 0.82);
  --bg-panel-strong: rgba(10, 20, 35, 0.96);
  --line: rgba(147, 180, 214, 0.14);
  --line-strong: rgba(147, 180, 214, 0.3);
  --text: #e8f1fb;
  --muted: #89a1ba;
  --accent: #5be7c4;
  --accent-warm: #f0b35f;
  --danger: #f27777;
  --shadow: 0 18px 54px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(91, 231, 196, 0.12), transparent 28%),
    radial-gradient(circle at bottom right, rgba(240, 179, 95, 0.12), transparent 24%),
    linear-gradient(145deg, #050a13 0%, #091423 52%, #0a1528 100%);
}

button,
input,
select {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.rail {
  padding: 28px 22px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(6, 13, 24, 0.95), rgba(10, 20, 34, 0.88));
  backdrop-filter: blur(20px);
}

.rail__brand {
  margin-bottom: 32px;
}

.rail__eyebrow,
.workspace__eyebrow,
.panel__eyebrow,
.section-label,
.stat-card__label,
.control-label,
.workspace__meta,
.panel__caption,
#page-indicator {
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rail__title {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.rail__nav {
  display: grid;
  gap: 10px;
  margin-bottom: 28px;
}

.tab-button,
.toggle-button,
.pager-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.tab-button:hover,
.toggle-button:hover,
.pager-button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.tab-button.is-active,
.toggle-button.is-active {
  background: linear-gradient(135deg, rgba(91, 231, 196, 0.18), rgba(91, 231, 196, 0.06));
  border-color: rgba(91, 231, 196, 0.4);
}

.toggle-group {
  display: grid;
  gap: 8px;
}

.toggle-group.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.rail__section {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.control-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.workspace {
  padding: 26px 30px 30px;
}

.workspace__header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 22px;
}

.workspace__header h1,
.panel h2 {
  margin: 8px 0 0;
  font-size: 30px;
  letter-spacing: -0.04em;
}

.panel h2 {
  font-size: 22px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card,
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.stat-card {
  padding: 18px 18px 16px;
}

.stat-card__value {
  margin-top: 12px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.05em;
}

.tab-panel {
  display: none;
}

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

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(320px, 0.9fr);
  gap: 18px;
}

.panel-grid--scraping {
  grid-template-columns: 1fr;
}

.panel {
  overflow: hidden;
}

.panel__header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.map-toolbar {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.segmented-control {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

.segmented-control__button {
  border: 0;
  color: var(--muted);
  background: transparent;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}

.segmented-control__button.is-active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(91, 231, 196, 0.18), rgba(91, 231, 196, 0.06));
}

.segmented-control.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.panel--map {
  min-height: 640px;
}

#map {
  height: 560px;
  width: 100%;
  background: #08111f;
}

.atlas-cluster-wrap,
.atlas-pin-wrap {
  background: transparent;
  border: 0;
}

.atlas-cluster {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  color: #07121f;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid rgba(232, 241, 251, 0.18);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(10px);
}

.atlas-cluster.is-small {
  background: radial-gradient(circle at 30% 30%, rgba(240, 179, 95, 0.96), rgba(240, 179, 95, 0.78));
}

.atlas-cluster.is-medium {
  background: radial-gradient(circle at 30% 30%, rgba(91, 231, 196, 0.96), rgba(91, 231, 196, 0.78));
}

.atlas-cluster.is-large {
  background: radial-gradient(circle at 30% 30%, rgba(141, 242, 219, 0.98), rgba(91, 231, 196, 0.82));
  width: 50px;
  height: 50px;
  font-size: 13px;
}

.atlas-cluster span {
  transform: translateY(0.5px);
}

.atlas-pin {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 35%, #ffd8a1, #f0b35f 58%, #b8741d 100%);
  border: 1px solid rgba(232, 241, 251, 0.36);
  box-shadow:
    0 0 0 4px rgba(240, 179, 95, 0.16),
    0 6px 18px rgba(0, 0, 0, 0.35);
}

.atlas-pin.is-exact {
  width: 8px;
  height: 8px;
  border-color: rgba(255, 232, 199, 0.55);
  box-shadow:
    0 0 0 1px rgba(240, 179, 95, 0.12),
    0 0 0 4px rgba(240, 179, 95, 0.06);
  opacity: 0.72;
}

.atlas-pin.is-multi {
  width: 22px;
  height: 22px;
  box-shadow:
    0 0 0 5px rgba(240, 179, 95, 0.2),
    0 8px 22px rgba(0, 0, 0, 0.35);
}

.atlas-pin.is-multi span {
  color: #07121f;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-weight: 700;
}

.map-popup-card,
.map-popup-stack {
  min-width: 240px;
}

.map-popup-card {
  display: grid;
  gap: 4px;
}

.map-popup-card__focus {
  margin-top: 8px;
  color: #9cb3cb;
}

.map-popup-stack__title {
  margin-bottom: 10px;
  font-weight: 600;
}

.map-popup-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}

.map-popup-list__item {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.map-popup-list__name {
  font-weight: 600;
}

.map-popup-list__meta {
  color: #9cb3cb;
  font-size: 13px;
}

.map-popup-list__status {
  color: #cbd9e8;
  font-size: 12px;
}

.map-popup-list__focus {
  color: #9cb3cb;
  font-size: 13px;
}

.leaderboard {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.leaderboard-item {
  padding: 14px 14px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
}

.leaderboard-item__top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.leaderboard-item__name {
  font-weight: 700;
}

.leaderboard-item__count {
  color: var(--accent);
  font-family: "IBM Plex Mono", monospace;
}

.leaderboard-item__meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
}

.results-table th,
.results-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.results-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-panel-strong);
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sort-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}

.sort-button.is-active {
  color: var(--text);
}

.sort-button.is-active[data-dir="asc"]::after {
  content: " ↑";
}

.sort-button.is-active[data-dir="desc"]::after {
  content: " ↓";
}

.name-cell {
  display: grid;
  gap: 6px;
}

.name-cell__title {
  font-weight: 700;
}

.name-cell__sub {
  color: var(--muted);
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-family: "IBM Plex Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pill--company {
  color: var(--accent);
  border-color: rgba(91, 231, 196, 0.28);
  background: rgba(91, 231, 196, 0.08);
}

.pill--non-company {
  color: var(--accent-warm);
  border-color: rgba(240, 179, 95, 0.28);
  background: rgba(240, 179, 95, 0.08);
}

.link-button {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid rgba(232, 241, 251, 0.3);
}

.link-button:hover {
  border-bottom-color: rgba(232, 241, 251, 0.75);
}

.table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px 20px;
}

.progress-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 18px 20px 10px;
}

.progress-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
}

.run-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin: 18px 20px 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
}

.run-banner__title {
  font-weight: 700;
}

.run-banner__meta {
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.progress-meter {
  height: 16px;
  margin: 6px 20px 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
}

.progress-meter__bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(91, 231, 196, 0.4), rgba(91, 231, 196, 0.95));
  transition: width 220ms ease;
}

.leaflet-container {
  background: #07101c;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #0f1b2e;
  color: var(--text);
}

.leaflet-control-attribution {
  background: rgba(8, 17, 31, 0.84);
  color: var(--muted);
}

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

  .rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stats-grid,
  .panel-grid,
  .progress-grid {
    grid-template-columns: 1fr;
  }
}
