:root {
  --bg: #f4efe5;
  --panel: rgba(255, 251, 245, 0.9);
  --panel-strong: rgba(255, 252, 247, 0.98);
  --line: rgba(60, 70, 76, 0.12);
  --shadow: 0 18px 42px rgba(43, 52, 58, 0.12);
  --text: #182227;
  --muted: #5d6b71;
  --teal: #0d6779;
  --teal-soft: #d8edf1;
  --orange: #d87433;
  --orange-soft: #f5e3d2;
  --sand: #e6ddcf;
  --density-a: #fff8c9;
  --density-b: #dff3b2;
  --density-c: #8ac7c2;
  --density-d: #2b7f92;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.75), transparent 32%),
    linear-gradient(180deg, #f6f2e9 0%, #efe6d8 100%);
}

button,
input {
  font: inherit;
}

.page-shell {
  max-width: 1880px;
  width: min(1880px, 100%);
  margin: 0 auto;
  height: 100vh;
  padding: 16px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hero-bar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 0;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--teal);
}

.hero-bar h1 {
  margin: 0;
  font-size: clamp(1.9rem, 3.5vw, 2.85rem);
  line-height: 1.02;
}

.hero-copy {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.chip-button {
  border: 0;
  border-radius: 999px;
  padding: 11px 17px;
  background: linear-gradient(135deg, var(--teal) 0%, #1c8093 100%);
  color: white;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.chip-button.secondary {
  background: white;
  color: var(--text);
}

.chip-button:hover {
  transform: translateY(-1px);
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(308px, 356px) minmax(0, 1fr) minmax(292px, 336px);
  grid-template-areas: "sidebar-left map sidebar-right";
  gap: 18px;
  min-height: 0;
  flex: 1;
}

.sidebar,
.map-panel {
  min-height: 0;
  min-width: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
  padding-right: 4px;
}

.sidebar-left {
  grid-area: sidebar-left;
  padding-right: 6px;
}

.map-panel {
  grid-area: map;
}

.sidebar-right {
  grid-area: sidebar-right;
  padding-left: 4px;
  overflow: hidden;
}

.panel,
.map-panel {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--orange-soft);
  color: #7b481f;
}

.status-pill.subtle {
  background: var(--teal-soft);
  color: var(--teal);
}

.panel-icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--teal);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(43, 52, 58, 0.08);
  transition: transform 140ms ease, background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.panel-icon-button:hover {
  transform: translateY(-1px);
}

.panel-icon-button span {
  font-size: 0.95rem;
  line-height: 1;
}

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

.metric-card {
  padding: 14px;
  border-radius: 16px;
  background: var(--panel-strong);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.metric-value {
  display: block;
  font-size: 1.36rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.35;
}

.layer-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.layer-group-title {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 2px;
}

.layer-toggle {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--panel-strong);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.layer-toggle input {
  accent-color: var(--teal);
  width: 18px;
  height: 18px;
}

.layer-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.layer-meta strong {
  font-size: 0.94rem;
}

.layer-meta span {
  color: var(--muted);
  font-size: 0.8rem;
}

.layer-hint {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--teal);
}

.layer-toggle.is-muted {
  opacity: 0.62;
}

.inventory-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inventory-card {
  border-radius: 16px;
  padding: 14px;
  background: var(--panel-strong);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.inventory-topline {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.inventory-card h3 {
  margin: 0;
  font-size: 0.95rem;
}

.inventory-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.84rem;
}

.inventory-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.inventory-tag {
  font-size: 0.74rem;
  border-radius: 999px;
  padding: 5px 8px;
  background: #f3eee6;
  color: var(--muted);
}

.selection-empty,
.selection-card {
  color: var(--muted);
  line-height: 1.6;
}

.detail-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 0;
}

.selection-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

#selection-content {
  flex: 0 0 auto;
  min-height: auto;
  overflow: visible;
  padding-right: 0;
}

.selection-card h3 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 1rem;
}

.selection-card p {
  margin: 0 0 14px;
}

.selection-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.selection-fact {
  min-width: 0;
  padding: 10px;
  border-radius: 14px;
  background: #f6f0e7;
}

.selection-fact strong {
  display: block;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 4px;
}

.selection-fact span {
  display: block;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chart-wrap {
  display: none;
  flex: 0 0 auto;
  margin-top: 14px;
  padding-top: 12px;
  min-height: 180px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.chart-wrap.is-visible {
  display: block;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 200px !important;
}

.map-panel {
  position: relative;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.map-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-radius: 14px;
  background: var(--panel-strong);
  border: 1px solid rgba(0, 0, 0, 0.05);
  padding: 12px 14px;
  color: var(--muted);
  font-size: 0.84rem;
}

.toolbar-card strong {
  color: var(--text);
}

.toolbar-card.compact {
  justify-content: center;
  color: var(--teal);
  font-weight: 800;
}

#map {
  flex: 1;
  min-height: 0;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.7), transparent 28%),
    linear-gradient(180deg, #eef3ef 0%, #e6ede7 100%);
}

.legend-panel {
  flex: 0 0 auto;
  padding-bottom: 18px;
  transition: padding 180ms ease, box-shadow 180ms ease;
}

.legend-panel.is-collapsed {
  padding-bottom: 14px;
}

.legend-panel.is-collapsed .panel-heading {
  margin-bottom: 0;
}

.legend-panel.is-collapsed .panel-icon-button span {
  transform: rotate(-90deg);
  display: inline-block;
}

.legend-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 420px;
  opacity: 1;
  overflow: hidden;
  transition: max-height 180ms ease, opacity 140ms ease;
}

.legend-panel.is-collapsed .legend-list {
  max-height: 0;
  opacity: 0;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.79rem;
  color: var(--muted);
  border-radius: 14px;
  padding: 8px 10px;
  background: var(--panel-strong);
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
}

.legend-swatch.bro-cluster {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(179, 73, 45, 0.78);
  background: rgba(233, 118, 87, 0.44);
  box-shadow: 0 0 0 1px rgba(233, 118, 87, 0.2);
}

.legend-swatch.bro-well {
  width: 10px;
  height: 10px;
  border: 2px solid rgba(255, 248, 236, 0.95);
  background: rgba(17, 150, 138, 0.92);
  box-shadow: 0 0 0 1px rgba(17, 150, 138, 0.22);
}

.legend-swatch.waterinfo {
  background: #2d6cdf;
}

.legend-swatch.knmi {
  background: #d14f7a;
}

.legend-swatch.guf {
  background: #6c58c9;
}

.legend-swatch.legacy {
  border-radius: 4px;
  border: 2px dashed #212121;
  background: transparent;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: rgba(255, 252, 247, 0.96);
}

.popup-card h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.popup-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.bro-well-canvas-layer {
  pointer-events: none;
}

#map.leaflet-container {
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.7), transparent 28%),
    linear-gradient(180deg, #eef3ef 0%, #e6ede7 100%);
}

@media (min-width: 921px) {
  body {
    overflow: hidden;
  }
}

@media (max-width: 1600px) {
  .page-shell {
    max-width: 1780px;
    width: min(1780px, 100%);
    padding-inline: 18px;
  }

  .layout-grid {
    grid-template-columns: minmax(288px, 332px) minmax(0, 1fr) minmax(276px, 316px);
    gap: 16px;
  }
}

@media (max-width: 1360px) {
  .layout-grid {
    grid-template-columns: minmax(268px, 304px) minmax(0, 1fr) minmax(258px, 292px);
    gap: 14px;
  }

  .panel {
    padding: 14px;
  }
}

@media (max-width: 1120px) {
  .page-shell {
    max-width: none;
    width: 100%;
    padding-inline: 16px;
  }

  .layout-grid {
    grid-template-columns: minmax(244px, 272px) minmax(0, 1fr) minmax(236px, 264px);
    gap: 12px;
  }

  .toolbar-card {
    padding: 11px 12px;
  }
}

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

  .page-shell {
    height: auto;
    min-height: 100vh;
  }

  .layout-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "map"
      "sidebar-left"
      "sidebar-right";
    flex: initial;
  }

  .sidebar {
    overflow: visible;
    padding: 0;
  }

  .sidebar-left {
    order: 2;
  }

  .sidebar-right {
    order: 3;
  }

  .map-panel {
    order: 1;
    min-height: 66vh;
  }
}

@media (max-width: 760px) {
  .page-shell {
    height: auto;
    padding: 16px;
  }

  .hero-bar {
    flex-direction: column;
    align-items: stretch;
  }

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

  #map {
    min-height: 60vh;
  }
}
