:root {
  color-scheme: light;
  --ink: #17211c;
  --muted: #5c6760;
  --line: #d7dfd7;
  --panel: #ffffff;
  --surface: #f4f7f2;
  --accent: #2f6f4e;
  --accent-dark: #1f4f38;
  --sky: #dcecf2;
  --soil: #8c5f3d;
  --warn: #fff3cf;
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

.shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
}

.side {
  background: #102019;
  color: #f4f7f2;
  padding: 24px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  font-weight: 700;
}

.brand small {
  display: block;
  color: #b9c8bd;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav a {
  border-radius: 8px;
  color: #dce7df;
  padding: 10px 12px;
  text-decoration: none;
}

.nav a.active,
.nav a:hover {
  background: #20372c;
  color: #ffffff;
}

.content {
  min-width: 0;
  max-width: 100%;
  padding: 36px;
}

.hero {
  min-height: 56vh;
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 44px;
  background:
    linear-gradient(135deg, rgba(47, 111, 78, 0.88), rgba(23, 33, 28, 0.72)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 900 500'%3E%3Crect width='900' height='500' fill='%23dcecf2'/%3E%3Cpath d='M0 370 C180 300 280 410 450 330 S710 270 900 330 V500 H0Z' fill='%238c5f3d'/%3E%3Cpath d='M0 280 C210 220 310 300 500 240 S730 160 900 210 V500 H0Z' fill='%232f6f4e' opacity='.82'/%3E%3Cg stroke='%23ffffff' stroke-opacity='.36'%3E%3Cpath d='M80 0 760 500'/%3E%3Cpath d='M230 0 900 470'/%3E%3Cpath d='M0 120 700 500'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  color: #ffffff;
}

.hero h1,
.page-header h1,
.panel h1 {
  margin: 0;
  font-size: 42px;
  letter-spacing: 0;
}

.lead {
  max-width: 680px;
  font-size: 22px;
  margin: 0;
}

.eyebrow {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

.hero .eyebrow {
  color: #d7f3df;
}

.notice,
.status {
  display: inline-block;
  width: fit-content;
  border: 1px solid rgba(23, 33, 28, 0.15);
  border-radius: 8px;
  background: var(--warn);
  color: #493815;
  padding: 8px 10px;
  font-weight: 600;
}

.status.error {
  background: #fde7df;
  color: #8b2d18;
}

.status.success {
  background: #e2f5e8;
  color: #19512d;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.provider-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 9px 14px;
  text-decoration: none;
  font-weight: 650;
  text-align: center;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  padding: 8px 12px;
}

.band,
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.band article,
.panel,
.security-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 22px;
}

.panel.narrow {
  max-width: 680px;
}

.page-header {
  margin-bottom: 24px;
}

.page-header p {
  color: var(--muted);
  margin: 8px 0 0;
}

.panel h2,
.band h2 {
  margin-top: 0;
}

.security-note {
  margin-top: 16px;
  border-color: #e8d081;
  background: #fff9df;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.form-stack label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 650;
}

.form-stack input,
.form-stack textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  font: inherit;
  padding: 10px 12px;
}

.lot-map-shell {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 12px;
}

.lot-map-shell:fullscreen {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #f4f7f2;
  padding: 16px;
}

.map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.lot-map {
  width: 100%;
  min-height: 440px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dcecf2;
}

.lot-map-shell:fullscreen .lot-map {
  min-height: 0;
  height: calc(100vh - 150px);
}

.lot-map .leaflet-control-attribution {
  font-size: 11px;
}

.satellite-map-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.spatio-satellite-map {
  width: 100%;
  min-height: 620px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dcecf2;
}

.satellite-map-large {
  min-height: min(72vh, 760px);
}

.map-layer-status {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 6px;
}

.map-layer-controls label,
.scene-navigator label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.map-layer-controls select {
  min-width: min(360px, 72vw);
}

.scene-navigator {
  display: grid;
  grid-template-columns: auto auto minmax(220px, 1fr) auto auto;
  gap: 6px;
  align-items: end;
  min-width: 0;
}

.scene-navigator label {
  gap: 4px;
}

.scene-navigator select {
  min-height: 36px;
  padding: 7px 10px;
}

.scene-navigator select {
  min-width: 0;
  width: 100%;
}

.icon-button {
  aspect-ratio: 1;
  min-height: 36px;
  min-width: 36px;
  padding: 0;
}

.nav-icon {
  display: block;
  height: 14px;
  position: relative;
  width: 18px;
}

.nav-icon::before,
.nav-icon::after {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.nav-icon::before {
  border-bottom: 7px solid transparent;
  border-top: 7px solid transparent;
}

.nav-icon.previous::before,
.nav-icon.first::before {
  border-right: 11px solid var(--ink);
  left: 3px;
}

.nav-icon.next::before,
.nav-icon.last::before {
  border-left: 11px solid var(--ink);
  right: 3px;
}

.nav-icon.first::after,
.nav-icon.last::after {
  background: var(--ink);
  height: 14px;
  width: 3px;
}

.nav-icon.first::after {
  left: 0;
}

.nav-icon.last::after {
  right: 0;
}

.map-layer-toolbar {
  display: flex;
  justify-content: flex-end;
}

.layer-picker {
  position: relative;
}

.layer-picker-menu {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 32px rgba(20, 42, 31, 0.16);
  display: grid;
  gap: 8px;
  min-width: 260px;
  padding: 12px;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 500;
}

.layer-picker-menu strong {
  color: var(--green);
  font-size: 12px;
  text-transform: uppercase;
}

.layer-picker-menu label {
  align-items: center;
  display: flex;
  gap: 8px;
  font-weight: 650;
}

.layer-picker-menu label.disabled {
  color: var(--muted);
}

.map-layer-help {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  margin: -2px 0 0;
}

.map-layer-stack {
  display: grid;
  gap: 8px;
}

.map-layer-row {
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(0, 1fr) auto;
  min-width: 0;
  padding: 8px 10px;
}

.map-layer-row-head {
  align-items: center;
  display: flex;
  gap: 8px;
  grid-column: 1 / -1;
  justify-content: space-between;
  min-width: 0;
}

.layer-name-button {
  background: transparent;
  border: 0;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 0;
  text-align: left;
}

.map-layer-row input[type="range"] {
  accent-color: var(--blue);
  min-width: 0;
  width: 100%;
}

.map-layer-opacity {
  align-self: center;
  color: var(--ink);
  font-weight: 700;
  justify-self: end;
  min-width: 44px;
  text-align: right;
}

.map-layer-row .layer-state {
  grid-column: 1 / -1;
  justify-self: stretch;
  text-align: center;
}

.layer-color-legend {
  align-items: center;
  display: grid;
  gap: 4px 8px;
  grid-column: 1 / -1;
  grid-template-columns: auto minmax(80px, 1fr) auto;
}

.layer-color-legend span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.layer-color-legend small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  grid-column: 1 / -1;
  line-height: 1.25;
}

.layer-color-ramp {
  background: var(--legend-gradient);
  border: 1px solid rgba(20, 42, 31, 0.18);
  border-radius: 999px;
  height: 10px;
  min-width: 0;
}

.layer-row-actions {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
  justify-content: flex-end;
}

.layer-action-button {
  align-self: center;
  height: 30px;
  justify-self: end;
  min-height: 30px;
  min-width: 30px;
  width: 30px;
}

.level-icon {
  display: block;
  height: 16px;
  position: relative;
  width: 16px;
}

.level-icon::before {
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  content: "";
  left: 1px;
  position: absolute;
}

.level-icon.up::before {
  border-bottom: 10px solid var(--ink);
  top: 2px;
}

.level-icon.down::before {
  border-top: 10px solid var(--ink);
  top: 4px;
}

.trash-icon {
  display: block;
  height: 16px;
  position: relative;
  width: 14px;
}

.trash-icon::before {
  border: 2px solid var(--ink);
  border-top: 0;
  bottom: 0;
  content: "";
  left: 2px;
  position: absolute;
  right: 2px;
  top: 5px;
}

.trash-icon::after {
  border-top: 2px solid var(--ink);
  box-shadow: 4px -3px 0 -1px var(--ink), 8px -3px 0 -1px var(--ink);
  content: "";
  left: 0;
  position: absolute;
  right: 0;
  top: 2px;
}

.job-progress {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf7;
}

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

.job-progress progress {
  width: 100%;
  height: 12px;
  accent-color: var(--green);
}

.job-progress span,
.job-progress small {
  color: var(--muted);
}

.modal-backdrop {
  align-items: center;
  background: rgba(12, 24, 18, 0.48);
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  padding: 18px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 1200;
}

.modal-panel {
  max-height: min(88vh, 720px);
  max-width: 560px;
  overflow: auto;
  width: min(100%, 560px);
}

.modal-panel h2 {
  margin-top: 0;
}

.modal-panel .actions {
  justify-content: flex-end;
}

.spatio-satellite-map .leaflet-control-attribution {
  font-size: 11px;
}

.preview dl {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px;
}

.preview dt {
  color: var(--muted);
  font-weight: 700;
}

.preview dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.lot-detail {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 8px 10px;
}

.lot-detail dt {
  color: var(--muted);
  font-weight: 700;
}

.lot-detail dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.limit-panel {
  margin-bottom: 16px;
}

.limit-panel ul {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  list-style: none;
  padding: 0;
}

.limit-panel li {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--sky);
  padding: 10px;
  font-weight: 700;
}

.limit-result {
  border-radius: 8px;
  padding: 10px;
  font-weight: 700;
}

.limit-result.allowed {
  background: #e2f5e8;
  color: #19512d;
}

.limit-result.blocked {
  background: #fde7df;
  color: #8b2d18;
}

.satellite-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: 16px;
  margin-top: 24px;
}

.satellite-preview {
  display: grid;
  gap: 16px;
}

.satellite-preview-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.layer-canvas {
  display: grid;
  place-items: center;
  min-height: 260px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #ffffff;
  font-size: 28px;
  font-weight: 800;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.32);
}

.layer-preview-image {
  width: 100%;
  height: 100%;
  min-height: 260px;
  object-fit: cover;
}

.layer-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.layer-state {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  background: #f6f7f3;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.layer-state.state-rendered {
  background: #e4f5df;
  color: #245d35;
}

.layer-state.state-blocked {
  background: #fde7df;
  color: #8b2d18;
}

.layer-state.state-pending {
  background: #fff3cf;
  color: #735414;
}

.layer-state.state-placeholder {
  background: #eef1ed;
  color: #5c6760;
}

.layer-actions {
  margin-top: 0;
}

.comparison-panel {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.comparison-header,
.comparison-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  justify-content: space-between;
}

.comparison-controls label {
  display: grid;
  min-width: 180px;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.comparison-frame {
  display: grid;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 10px;
}

.comparison-image,
.comparison-empty {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.comparison-image {
  object-fit: cover;
}

.comparison-empty {
  display: grid;
  place-items: center;
  background: #eef1ed;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
  padding: 12px;
}

.comparison-delta {
  margin-top: 0;
}

.alert-severity {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  font-weight: 800;
}

.alert-high {
  background: #fde7df;
  color: #8b2d18;
}

.alert-medium {
  background: #fff3cf;
  color: #735414;
}

.alert-low {
  background: #e4f5df;
  color: #245d35;
}

.alert-info {
  background: #eef1ed;
  color: #5c6760;
}

.layer-canvas.true_color {
  background:
    linear-gradient(35deg, rgba(31, 79, 56, 0.76), rgba(220, 236, 242, 0.52)),
    repeating-linear-gradient(145deg, #315f3f 0 22px, #7fa56a 22px 44px, #8c5f3d 44px 62px);
}

.layer-canvas.false_color {
  background:
    linear-gradient(35deg, rgba(150, 43, 82, 0.72), rgba(47, 111, 78, 0.46)),
    repeating-linear-gradient(145deg, #9f255a 0 22px, #de995a 22px 44px, #285b83 44px 62px);
}

.layer-canvas.ndvi {
  background:
    linear-gradient(35deg, rgba(25, 81, 45, 0.75), rgba(255, 243, 207, 0.45)),
    repeating-linear-gradient(145deg, #245d35 0 24px, #81a64f 24px 48px, #d0bb57 48px 72px);
}

.layer-canvas.ndmi {
  background:
    linear-gradient(35deg, rgba(33, 72, 100, 0.76), rgba(220, 236, 242, 0.42)),
    repeating-linear-gradient(145deg, #254a6b 0 24px, #3b8a8d 24px 48px, #a8c7a0 48px 72px);
}

.layer-canvas.evi,
.layer-canvas.savi {
  background:
    linear-gradient(35deg, rgba(37, 93, 53, 0.76), rgba(255, 243, 207, 0.38)),
    repeating-linear-gradient(145deg, #214f39 0 24px, #77a658 24px 48px, #c9d46a 48px 72px);
}

.layer-canvas.barren_soil {
  background:
    linear-gradient(35deg, rgba(140, 95, 61, 0.78), rgba(255, 249, 223, 0.38)),
    repeating-linear-gradient(145deg, #7a5835 0 24px, #c79352 24px 48px, #d7dfd7 48px 72px);
}

.layer-canvas.moisture_index,
.layer-canvas.moisture_stress {
  background:
    linear-gradient(35deg, rgba(37, 74, 107, 0.78), rgba(220, 236, 242, 0.45)),
    repeating-linear-gradient(145deg, #24476a 0 24px, #2f8f90 24px 48px, #79b887 48px 72px);
}

.layer-canvas.agriculture {
  background:
    linear-gradient(35deg, rgba(31, 79, 56, 0.7), rgba(33, 72, 100, 0.45)),
    repeating-linear-gradient(145deg, #4d6643 0 24px, #7f7a3a 24px 48px, #326b86 48px 72px);
}

.layer-canvas.custom {
  background:
    linear-gradient(35deg, rgba(92, 103, 96, 0.82), rgba(215, 223, 215, 0.45)),
    repeating-linear-gradient(145deg, #5c6760 0 24px, #8d9790 24px 48px, #d7dfd7 48px 72px);
}

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

.data-list li {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 10px;
}

.data-list span,
.data-list small {
  color: var(--muted);
}

.layer-list-preview {
  width: 100%;
  max-width: 180px;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
}

@media (max-width: 760px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .side {
    position: static;
    padding: 16px;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content {
    max-width: 100vw;
    overflow-x: hidden;
    padding: 16px;
  }

  .hero {
    padding: 28px 22px;
  }

  .hero h1,
  .page-header h1,
  .panel h1 {
    font-size: 34px;
  }

  .band,
  .grid,
  .form-grid,
  .limit-panel ul,
  .satellite-grid {
    grid-template-columns: 1fr;
  }

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

  .satellite-preview-header {
    align-items: stretch;
    flex-direction: column;
  }

  .map-actions {
    justify-content: stretch;
  }

  .map-actions .button {
    flex: 1 1 150px;
  }

  .lot-map {
    min-height: 360px;
  }

  .spatio-satellite-map,
  .satellite-map-large {
    min-height: 460px;
  }

  .map-layer-status {
    align-items: flex-start;
  }

  .map-layer-controls select {
    min-width: 0;
    width: 100%;
  }

  .scene-navigator {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
  }

  .scene-navigator label {
    grid-column: 1 / -1;
    order: -1;
  }

  .scene-navigator .button {
    min-width: 0;
    min-height: 34px;
    padding-inline: 0;
    width: 100%;
  }

  .map-layer-toolbar {
    justify-content: stretch;
  }

  .layer-picker,
  .layer-picker > .button {
    width: 100%;
  }

  .layer-picker-menu {
    left: 0;
    min-width: 0;
    right: 0;
    width: 100%;
  }

  .map-layer-row {
    align-items: start;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .layer-action-button {
    height: 30px;
    min-height: 30px;
    min-width: 30px;
    width: 30px;
  }

  .modal-backdrop {
    align-items: flex-start;
    padding: 12px;
  }

  .modal-panel {
    max-height: calc(100vh - 24px);
  }

  .modal-panel .actions {
    align-items: stretch;
    flex-direction: column;
  }
}
