:root {
  --bg: #020617;
  --panel: rgba(10, 15, 32, 0.88);
  --panel-soft: rgba(15, 23, 42, 0.86);
  --stroke: rgba(96, 165, 250, 0.22);
  --stroke-soft: rgba(255, 255, 255, 0.06);
  --text: #e5eefb;
  --muted: #9fb2d1;
  --accent: #22c55e;
  --accent-2: #38bdf8;
  --warning: #facc15;
  --danger: #f87171;
  --shadow: 0 22px 54px rgba(2, 6, 23, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, #0f172a 0%, #020617 45%, #01030a 100%);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
}

body {
  height: 100dvh;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
  height: 100dvh;
  padding: 14px;
  overflow: hidden;
}

.glass-panel {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.94), rgba(5, 10, 26, 0.88));
  border: 1px solid var(--stroke);
  border-radius: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.sidebar,
.main-area,
.map-panel,
.analytics-panel,
.content-grid {
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: calc(100dvh - 28px);
  padding: 18px;
  overflow: hidden;
}

.sidebar-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
  scrollbar-width: thin;
}

.sidebar-scroll::-webkit-scrollbar {
  width: 8px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}

.brand-block {
  padding: 18px;
  border: 1px solid var(--stroke-soft);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
}

.brand-topline,
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  color: var(--muted);
}

.brand-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 14px;
  align-items: center;
}

.brand-logo {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  border-radius: 16px;
  padding: 6px;
}

.brand-logo--rs {
  background: rgba(255,255,255,0.92);
}

.brand-logo--amg {
  background: rgba(255,255,255,0.03);
}

.brand-caption {
  margin-top: 12px;
  color: #dbe9ff;
  font-size: 13px;
  line-height: 1.45;
}

.sidebar-section {
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.section-title {
  font-size: 18px;
  font-weight: 800;
}

.section-subtitle {
  color: var(--muted);
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.4;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}

.text-input {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 14px;
  background: rgba(2, 6, 23, 0.78);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}

.text-input:focus {
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 8px;
}

.icon-btn,
.ghost-btn,
.primary-btn,
.secondary-btn {
  border: none;
  cursor: pointer;
  transition: 0.18s ease;
}

.icon-btn:hover,
.ghost-btn:hover,
.primary-btn:hover,
.secondary-btn:hover {
  transform: translateY(-1px);
}

.icon-btn {
  border-radius: 14px;
  background: linear-gradient(180deg, #1d4ed8, #0f172a);
  color: #fff;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.range-input {
  width: 100%;
}

.range-value {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.button-stack {
  display: grid;
  gap: 12px;
}

.primary-btn,
.secondary-btn {
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  font-weight: 700;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.primary-btn {
  background: linear-gradient(135deg, #22c55e, #15803d);
  color: #fff;
  box-shadow: 0 14px 28px rgba(34, 197, 94, 0.24);
}

.secondary-btn {
  background: linear-gradient(135deg, #0ea5e9, #1d4ed8);
  color: #fff;
  box-shadow: 0 14px 28px rgba(14, 165, 233, 0.22);
}

.status-box {
  flex: 0 0 auto;
  font-size: 13px;
  line-height: 1.5;
  color: #d8e4f8;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(14, 165, 233, 0.1);
  border: 1px solid rgba(14, 165, 233, 0.28);
}

.main-area {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: calc(100dvh - 28px);
  overflow: hidden;
}

.topbar {
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  flex: 0 0 auto;
}

.topbar h1 {
  margin: 6px 0 0;
  font-size: clamp(26px, 2vw, 36px);
  line-height: 1.08;
}

.topbar-right {
  display: flex;
  gap: 10px;
}

.metric-card {
  min-width: 170px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}

.metric-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.75fr);
  gap: 14px;
  flex: 1 1 auto;
  overflow: hidden;
}

.map-panel,
.analytics-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex: 0 0 auto;
}

.panel-title {
  font-size: 18px;
  font-weight: 700;
}

.panel-title--small {
  margin-top: 18px;
}

.panel-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ghost-btn {
  padding: 10px 14px;
  border-radius: 14px;
  color: var(--text);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}

.map-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06);
  background: #07101f;
}

.map {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.map-crs-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 10;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.78);
  border: 1px solid rgba(255,255,255,0.10);
  color: #dbe9ff;
  font-size: 12px;
  backdrop-filter: blur(8px);
}

.analytics-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
  scrollbar-width: thin;
}

.analytics-scroll::-webkit-scrollbar {
  width: 8px;
}

.analytics-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}

.summary-empty,
.summary-card {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--muted);
}

.summary-card strong {
  color: #fff;
}

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.kpi-card {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}

.kpi-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.chart-wrap {
  margin-top: 14px;
  background: rgba(255,255,255,0.02);
  border-radius: 18px;
  padding: 8px;
  min-height: 220px;
  max-height: 250px;
}

#timeseriesChart {
  width: 100% !important;
  height: 220px !important;
  display: block;
}

.ol-control button {
  background: rgba(15, 23, 42, 0.86) !important;
}

.ol-attribution {
  background: rgba(2, 6, 23, 0.72) !important;
  border-radius: 12px 0 0 0;
}

.ol-attribution button,
.ol-zoom button {
  color: #fff !important;
}

@media (max-width: 1440px) {
  .app-shell {
    grid-template-columns: 290px 1fr;
  }

  .metric-card {
    min-width: 150px;
    padding: 14px 16px;
  }

  .brand-grid {
    grid-template-columns: 82px 1fr;
  }

  .topbar h1 {
    font-size: clamp(24px, 1.8vw, 32px);
  }
}

@media (max-width: 1180px) {
  .content-grid {
    grid-template-columns: minmax(0, 1fr) 330px;
  }

  .topbar {
    padding: 16px 18px;
  }

  .toolbar-actions {
    gap: 8px;
  }

  .ghost-btn {
    padding: 9px 12px;
  }
}

@media (max-width: 980px) {
  html,
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100dvh;
  }

  .sidebar,
  .main-area {
    height: auto;
  }

  .main-area {
    overflow: visible;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-right {
    width: 100%;
  }

  .metric-card {
    width: 100%;
  }

  .map-wrap {
    min-height: 420px;
  }

  .analytics-panel {
    min-height: 420px;
  }
}