@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Source+Sans+3:wght@400;500;600;700&display=swap');

:root {
  --bg: #070c16;
  --panel: rgba(14, 20, 35, 0.88);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #ecf2ff;
  --muted: #9eb2d3;
  --accent: #f8b84d;
  --danger: #ff6262;
  --ok: #39d0a3;
  --edge-gap: 12px;
  --bottom-panel-height: 246px;
  --panel-bottom-gap: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: 'Source Sans 3', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

#map {
  position: fixed;
  inset: 0;
}

.glass {
  backdrop-filter: blur(12px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
}

.top-nav {
  position: fixed;
  top: 12px;
  left: 14px;
  right: 14px;
  z-index: 20;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.top-nav h1 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  font-family: 'Space Grotesk', sans-serif;
}

.top-nav p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.sources-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}

.status-wrap {
  min-width: 240px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.boundary-status {
  font-size: 0.76rem;
  color: #d6e5ff;
  text-align: right;
}

.boundary-progress {
  width: min(270px, 32vw);
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.boundary-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2c82b1, #f4bf4f, #f37a3f);
  transition: width 0.35s ease;
}

.left-panel,
.right-panel {
  position: fixed;
  top: 96px;
  bottom: calc(var(--edge-gap) + var(--bottom-panel-height) + var(--panel-bottom-gap));
  z-index: 18;
  border-radius: 12px;
  padding: 14px;
  overflow: auto;
}

.left-panel {
  left: 14px;
  width: 330px;
}

.right-panel {
  right: 14px;
  width: 280px;
}

.left-panel section + section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.left-panel h2 {
  margin: 0;
  font-size: 1.16rem;
}

.left-panel h3,
.right-panel h3 {
  margin: 0 0 10px;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #d7e4ff;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.8rem;
  line-height: 1.45;
}

a {
  color: #9bd8ff;
}

.metric-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.metric-card {
  padding: 9px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.metric-label {
  font-size: 0.72rem;
  color: var(--muted);
}

.metric-value {
  margin-top: 2px;
  font-size: 0.98rem;
  font-weight: 700;
}

.industry-list {
  display: grid;
  gap: 8px;
}

.industry-item {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
}

.industry-item .name {
  font-size: 0.84rem;
  font-weight: 600;
}

.industry-item .meta {
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--muted);
}

.right-panel label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
  font-size: 0.76rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.right-panel select,
.right-panel input {
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 8px;
  padding: 9px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  font-size: 0.9rem;
}

.legend {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.legend-title {
  margin: 0 0 8px;
  font-size: 0.74rem;
  text-transform: uppercase;
  color: var(--muted);
}

.legend-bar {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #233252, #2c82b1, #f4bf4f, #f37a3f, #d62839);
}

.legend-scale {
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
}

.bottom-panel {
  position: fixed;
  left: var(--edge-gap);
  right: var(--edge-gap);
  bottom: var(--edge-gap);
  z-index: 18;
  height: var(--bottom-panel-height);
  border-radius: 12px;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  animation: rise-in 0.5s ease both;
}

.chart-wrap h3 {
  margin: 0 0 8px;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: #d7e4ff;
}

.chart {
  width: 100%;
  height: 190px;
}

.tooltip {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  transform: translate(-50%, -110%);
  min-width: 220px;
  max-width: 290px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(14, 20, 35, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.42);
  font-size: 0.78rem;
}

.tooltip.hidden {
  display: none;
}

.tooltip .title {
  font-size: 0.9rem;
  font-weight: 700;
}

.tooltip .line {
  margin-top: 3px;
  color: var(--muted);
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  background: #070c16;
}

.loading-screen.done {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

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

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

ul {
  margin: 0;
  padding-left: 18px;
}

li + li {
  margin-top: 4px;
}

ol {
  margin: 0;
  padding-left: 18px;
}

.info-accordion + .info-accordion {
  margin-top: 8px;
}

.info-accordion {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 10px;
}

.info-accordion summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: #deebff;
}

.info-accordion[open] summary {
  margin-bottom: 8px;
}

.info-accordion p {
  margin: 0 0 8px;
}

.info-accordion p:last-child {
  margin-bottom: 0;
}

@media (max-width: 1200px) {
  :root {
    --bottom-panel-height: 236px;
  }

  .left-panel,
  .right-panel {
    bottom: calc(var(--edge-gap) + var(--bottom-panel-height) + var(--panel-bottom-gap));
  }

  .left-panel {
    width: 300px;
  }

  .right-panel {
    width: 250px;
  }
}

@media (max-width: 960px) {
  body {
    overflow: auto;
  }

  .top-nav {
    flex-direction: column;
    align-items: stretch;
  }

  .status-wrap {
    min-width: 0;
    width: 100%;
    align-items: flex-start;
  }

  .boundary-status {
    text-align: left;
  }

  .boundary-progress {
    width: 100%;
  }

  .top-nav,
  .left-panel,
  .right-panel,
  .bottom-panel {
    position: static;
    margin: 10px;
    width: auto;
    max-height: none;
  }

  #map {
    position: relative;
    width: calc(100% - 20px);
    height: 54vh;
    margin: 10px;
    border-radius: 12px;
    overflow: hidden;
  }

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

  .chart {
    height: 240px;
  }
}

@media (max-width: 680px) {
  .top-nav,
  .left-panel,
  .right-panel,
  .bottom-panel {
    margin: 8px;
    padding: 10px;
  }

  #map {
    width: calc(100% - 16px);
    margin: 8px;
    height: 46vh;
  }

  .left-panel h2 {
    font-size: 1.04rem;
  }

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

  .chart {
    height: 210px;
  }
}
