:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f1e8;
  color: #18221e;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  height: 100vh;
  background: #eef1ea;
}

.map-stage {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}

.map {
  position: absolute;
  inset: 0;
  background: #dfe8dc;
}

.leaflet-container {
  width: 100%;
  height: 100%;
  font-family: inherit;
  overflow: hidden;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-right .leaflet-control {
  margin-right: 10px;
}

.leaflet-bottom .leaflet-control {
  margin-bottom: 10px;
}

.topbar {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  z-index: 700;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}

.topbar div {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(24, 34, 30, 0.14);
  box-shadow: 0 16px 36px rgba(22, 31, 27, 0.14);
  backdrop-filter: blur(12px);
  border-radius: 8px;
}

.topbar p {
  margin: 0 0 3px;
  color: #657066;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2.6vw, 2rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  color: #0f5132;
  background: rgba(228, 246, 235, 0.95);
  border: 1px solid rgba(15, 81, 50, 0.24);
  font-size: 0.83rem;
  font-weight: 800;
}

.status.loading {
  color: #6f4f12;
  background: rgba(255, 244, 216, 0.95);
}

.legend {
  position: absolute;
  left: 18px;
  bottom: 20px;
  z-index: 700;
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(24, 34, 30, 0.14);
  box-shadow: 0 14px 30px rgba(22, 31, 27, 0.12);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #47534a;
  font-size: 0.78rem;
  font-weight: 800;
}

.legend i {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.control-panel {
  position: relative;
  z-index: 800;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  padding: 22px;
  background: #faf9f4;
  border-left: 1px solid rgba(24, 34, 30, 0.14);
  box-shadow: -14px 0 42px rgba(22, 31, 27, 0.12);
  overflow-y: auto;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(24, 34, 30, 0.12);
}

.icon {
  color: #316a47;
  font-size: 1.3rem;
}

.panel-header span:not(.icon) {
  display: block;
  color: #657066;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.panel-header strong {
  display: block;
  margin-top: 1px;
  font-size: 1.42rem;
}

.field {
  display: grid;
  gap: 10px;
}

.field label,
.sources strong {
  color: #48534b;
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

input[type="range"] {
  width: 100%;
  accent-color: #316a47;
}

.month-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.month-row button,
.segmented button,
.soil-toggle {
  min-height: 38px;
  border: 1px solid rgba(24, 34, 30, 0.16);
  color: #2d3831;
  background: #fffef9;
  cursor: pointer;
  border-radius: 8px;
  font-weight: 800;
}

.month-row button {
  font-size: 0.78rem;
}

.month-row button.active,
.segmented button.active,
.soil-toggle.active {
  color: #ffffff;
  border-color: #2d5b40;
  background: #316a47;
}

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

.segmented button,
.soil-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  padding: 0 12px;
}

.soil-toggle {
  width: 100%;
}

.inspector {
  display: grid;
  gap: 12px;
  padding-top: 4px;
}

.inspector-title {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #415047;
  font-size: 0.92rem;
  font-weight: 800;
}

#details {
  display: grid;
  gap: 12px;
}

.loading-card,
.empty-state,
.score-band,
.metric,
.sources {
  border: 1px solid rgba(24, 34, 30, 0.13);
  background: #ffffff;
  border-radius: 8px;
}

.loading-card {
  padding: 12px;
  color: #6f4f12;
  font-size: 0.9rem;
  font-weight: 800;
}

.score-band {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: 4px;
  padding: 14px;
}

.score-band span {
  color: #657066;
  font-weight: 900;
  text-transform: uppercase;
}

.score-band strong {
  color: #1c5b38;
  font-size: 3rem;
  line-height: 1;
}

.score-band small {
  color: #657066;
  font-weight: 900;
}

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

.metric {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 8px;
  align-items: center;
  min-height: 78px;
  padding: 12px;
}

.metric-icon {
  color: #316a47;
}

.metric span:not(.metric-icon) {
  color: #657066;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.metric strong {
  grid-column: 1 / -1;
  color: #18221e;
  font-size: 1.35rem;
}

.metric small {
  margin-left: 3px;
  color: #657066;
  font-size: 0.8rem;
}

.component-bars {
  display: grid;
  gap: 9px;
}

.component-bars div {
  display: grid;
  grid-template-columns: 86px 1fr 32px;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 800;
}

.component-bars span {
  color: #657066;
  text-transform: capitalize;
}

.component-bars i {
  display: block;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4e1d5;
}

.component-bars b {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: #316a47;
}

.soil-summary {
  margin: 0;
  padding: 12px;
  color: #4e5a52;
  background: #f2f4ec;
  border-radius: 8px;
  font-size: 0.86rem;
  line-height: 1.45;
}

.empty-state {
  display: grid;
  justify-items: start;
  gap: 10px;
  padding: 16px;
  color: #4e5a52;
}

.large-icon {
  font-size: 1.7rem;
}

.empty-state p {
  margin: 0;
  line-height: 1.45;
}

.sources {
  display: grid;
  gap: 8px;
  padding: 12px;
  margin-top: auto;
}

.sources a {
  color: #255a3c;
  font-weight: 800;
  text-decoration: none;
}

.sources a:hover {
  text-decoration: underline;
}

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

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100%;
  }

  .map-stage {
    min-height: 58vh;
  }

  .control-panel {
    min-height: auto;
    border-left: 0;
    border-top: 1px solid rgba(24, 34, 30, 0.14);
  }
}

@media (max-width: 560px) {
  .topbar {
    left: 10px;
    right: 10px;
    top: 10px;
  }

  .topbar h1 {
    font-size: 1.08rem;
  }

  .status {
    min-height: 30px;
    padding: 0 9px;
    font-size: 0.74rem;
  }

  .legend {
    left: 10px;
    bottom: 10px;
    flex-wrap: wrap;
  }

  .control-panel {
    padding: 16px;
  }

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