html,
body {
  height: 100%;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: #1d1b18;
  background: #f4efe6;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --panel-bg: rgba(247, 242, 233, 0.97);
  --section-bg: rgba(255, 252, 246, 0.95);
  --border: rgba(74, 52, 34, 0.16);
  --text-soft: #605646;
  --accent: #a85e1b;
  --accent-deep: #6b3b13;
  --blue: #0e5a8a;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 430px);
  height: 100%;
  position: relative;
}

.layout.chartsWide {
  grid-template-columns: minmax(0, 0.8fr) minmax(560px, 760px);
}

#map {
  height: 100%;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 238, 210, 0.35), transparent 30%),
    linear-gradient(180deg, #e3ece8 0%, #d5e0da 100%);
}

.panel {
  grid-column: 2;
  grid-row: 1;
  overflow: auto;
  padding: 18px;
  border-left: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(255, 250, 241, 0.98), rgba(245, 238, 226, 0.98)),
    var(--panel-bg);
}

.panelSideTab {
  grid-column: 2;
  grid-row: 1;
  justify-self: start;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  transform: translateX(-40%);
  margin-top: 0;
  min-height: 52px;
  min-width: 34px;
  padding: 8px 6px;
  border-radius: 12px 0 0 12px;
  border: 2px solid rgba(74, 52, 34, 0.28);
  border-right: none;
  background: linear-gradient(180deg, #fff3d7, #dfa95b);
  color: #2f241b;
  box-shadow: 0 10px 24px rgba(71, 46, 18, 0.18);
  z-index: 30;
  overflow: visible;
}

.panelSideTab:hover {
  background: linear-gradient(180deg, #ffe8bf, #d59642);
}

.panelSideTabArrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255, 252, 246, 0.72);
  border: 1px solid rgba(74, 52, 34, 0.18);
  font-size: 13px;
  line-height: 1;
  flex: 0 0 auto;
}

.panelSideTabText {
  display: none;
}

.hero {
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-deep);
  font-weight: 700;
}

.title {
  margin: 0;
  font-size: 31px;
  line-height: 1.02;
  letter-spacing: -0.03em;
}

.lead {
  margin-top: 10px;
}

.hint {
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.45;
}

.section {
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--section-bg);
  box-shadow: 0 10px 30px rgba(77, 53, 24, 0.05);
}

.section h3 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.sectionHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sectionHeader h3 {
  margin: 0;
}

.sectionBody {
  margin-top: 12px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

label {
  font-size: 12px;
  font-weight: 700;
  color: #3c3025;
}

select,
input[type="range"],
button {
  font: inherit;
}

select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(74, 52, 34, 0.18);
  background: #fffdf8;
}

.selection-line {
  margin-top: 12px;
}

.selection-stat {
  margin-top: 4px;
  font-weight: 700;
  color: #433528;
}

.sliderRow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.sliderValue {
  white-space: nowrap;
  font-size: 12px;
  color: #463a2d;
  font-variant-numeric: tabular-nums;
}

.mapToggleRow {
  margin-top: 10px;
  justify-content: flex-start;
}

.mapToggleRow span {
  flex: 1 1 auto;
}

.chartActions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 12px;
}

button {
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(74, 52, 34, 0.18);
  background: linear-gradient(180deg, #fffdf8, #f3e8d4);
  color: #352a21;
  cursor: pointer;
}

button:hover {
  background: linear-gradient(180deg, #fff7ea, #efdcb8);
}

.chartTitle {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  color: #2f241b;
}

.chartSpacer {
  height: 14px;
}

.chartCanvasWrap {
  position: relative;
  height: 280px;
}

.timeseriesControls {
  display: grid;
  gap: 12px;
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid rgba(74, 52, 34, 0.12);
  border-radius: 14px;
  background: rgba(255, 249, 239, 0.75);
}

.toggleRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  font-weight: 700;
  color: #3c3025;
}

.toggleRow input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-deep);
}

.datasetToggleList {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dataset-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid rgba(74, 52, 34, 0.16);
  border-radius: 999px;
  background: #fffdf8;
  font-size: 12px;
  font-weight: 600;
  color: #3d3127;
}

.dataset-toggle input[type="checkbox"] {
  margin: 0;
  accent-color: var(--blue);
}

canvas {
  max-width: 100%;
  max-height: 100%;
}

.legend {
  min-width: 190px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 252, 246, 0.96);
  border: 1px solid rgba(74, 52, 34, 0.16);
  box-shadow: 0 12px 28px rgba(45, 30, 16, 0.12);
}

.legend .title {
  font-size: 13px;
  margin: 0 0 4px;
}

.legend .units {
  font-size: 11px;
  color: var(--text-soft);
}

.legend .bar {
  width: 220px;
  max-width: 100%;
  height: 12px;
  margin: 8px 0 6px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.legend .labels {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
}

.leaflet-control-zoom a {
  background: rgba(255, 252, 246, 0.96);
  color: #3d2f24;
  border-bottom-color: rgba(74, 52, 34, 0.16);
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 50vh auto;
  }

  .layout.chartsWide {
    grid-template-columns: 1fr;
  }

  .panelSideTab {
    grid-column: 1;
    grid-row: 2;
    justify-self: end;
    align-self: start;
    transform: none;
    margin-top: 10px;
    margin-right: 12px;
    min-width: 36px;
    min-height: 36px;
    padding: 7px;
    border-radius: 999px;
    border-right: 2px solid rgba(74, 52, 34, 0.28);
  }

  .panelSideTabArrow {
    width: 18px;
    height: 18px;
    font-size: 12px;
  }

  .panel {
    grid-column: 1;
    grid-row: 2;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .chartCanvasWrap {
    height: 240px;
  }
}

@media (max-width: 640px) {
  .panel {
    padding: 12px;
  }

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

  .field-wide {
    grid-column: auto;
  }

  .title {
    font-size: 26px;
  }

  .toggleRow {
    align-items: flex-start;
  }
}
