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

:root {
  --bg: #08131f;
  --panel: rgba(10, 22, 36, 0.86);
  --panel-border: rgba(221, 237, 255, 0.18);
  --text: #edf6ff;
  --muted: #9fb7d2;
  --accent: #ffd46a;
  --accent-2: #4ee3c3;
  --danger: #ff6b6b;
  --edge-gap: 12px;
  --top-nav-height: 78px;
  --bottom-panel-height: 248px;
  --panel-bottom-gap: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  background: radial-gradient(1100px 600px at 10% -10%, #244469 0%, transparent 55%),
    radial-gradient(900px 580px at 95% 8%, #2a584e 0%, transparent 58%),
    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 34px rgba(0, 0, 0, 0.34);
}

.top-nav {
  position: fixed;
  top: var(--edge-gap);
  left: 14px;
  right: 14px;
  min-height: var(--top-nav-height);
  z-index: 20;
  border-radius: 13px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

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

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

.status-wrap {
  min-width: min(320px, 35vw);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

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

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

.boundary-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3382ca, #4ee3c3, #ffd46a);
  transition: width 0.32s ease;
}

.left-panel,
.right-panel {
  position: fixed;
  top: calc(var(--edge-gap) + var(--top-nav-height) + 8px);
  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: 350px;
}

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

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

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

.left-panel h3,
.right-panel h3,
.chart-wrap h3 {
  margin: 0 0 10px;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #d8e9ff;
}

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

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

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

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

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

.info-accordion summary {
  cursor: pointer;
  list-style: none;
  padding: 9px 10px;
  font-weight: 600;
  font-size: 0.82rem;
}

.info-accordion summary::-webkit-details-marker {
  display: none;
}

.info-accordion > div,
.info-accordion > ul {
  margin: 0;
  padding: 0 10px 10px;
}

.source-list {
  margin: 0;
  padding-left: 16px;
  display: grid;
  gap: 7px;
}

.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(5, 12, 20, 0.45);
  color: var(--text);
  font-size: 0.92rem;
}

.switch-label {
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-size: 0.87rem !important;
}

.switch-label input {
  width: 18px;
  height: 18px;
}

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

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

.legend-bar {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #1c2a46, #296ca9, #4ee3c3, #ffd46a, #ff7c59);
}

.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;
}

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

.lite-empty {
  margin: 14px 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.lite-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.lite-row-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.76rem;
  color: #d8eaff;
}

.lite-bar {
  height: 7px;
  margin-top: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.lite-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2d73af, #4ee3c3, #ffd46a);
}

.lite-rate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.lite-rate-grid article {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
}

.lite-rate-grid p {
  margin: 0;
  font-size: 0.69rem;
  color: var(--muted);
}

.lite-rate-grid strong {
  display: block;
  margin-top: 3px;
  font-size: 0.84rem;
}

.tooltip {
  position: fixed;
  z-index: 31;
  pointer-events: none;
  transform: translate(-50%, -108%);
  min-width: 230px;
  max-width: 300px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(8, 17, 29, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.42);
  font-size: 0.78rem;
}

.tooltip.hidden {
  display: none;
}

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

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

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

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

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(4, 10, 18, 0.92);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.loading-screen.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.spinner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  animation: spin 1.1s linear infinite;
}

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

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

  .left-panel {
    width: 315px;
  }

  .right-panel {
    width: 260px;
  }

  .top-nav h1 {
    font-size: 1.12rem;
  }
}

@media (max-width: 980px) {
  html,
  body {
    overflow: auto;
  }

  #map {
    position: relative;
    height: 52vh;
    min-height: 340px;
  }

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

  .top-nav {
    min-height: 0;
    flex-direction: column;
  }

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

  .boundary-progress {
    width: 100%;
  }

  .left-panel,
  .right-panel {
    max-height: none;
  }

  .bottom-panel {
    display: block;
  }

  .chart-wrap + .chart-wrap {
    margin-top: 14px;
  }

  .chart {
    height: 220px;
  }
}
