:root {
  color-scheme: dark;
  --ink: #f5f0e7;
  --muted: #afa99f;
  --panel: rgba(18, 22, 19, 0.92);
  --panel-soft: rgba(27, 34, 29, 0.84);
  --line: rgba(255, 255, 255, 0.12);
  --soybean: #f4b942;
  --palm-oil: #ef6a5b;
  --olive: #84a94b;
  --accent: #d9ff77;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body, .app-shell, .map-stage, #map {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #0f1411;
  color: var(--ink);
}

.map-stage {
  position: relative;
  isolation: isolate;
}

#map {
  z-index: 0;
  background: #101914;
}

.leaflet-control-attribution {
  background: rgba(13, 17, 14, .78) !important;
  color: #c6c1b8;
}

.leaflet-control-attribution a { color: var(--accent); }

.crop-overlay {
  position: absolute;
  inset: 0;
  z-index: 450;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 1;
}

.brand-card,
.control-panel,
.map-footer,
.panel-toggle {
  position: absolute;
  z-index: 700;
}

.brand-card {
  top: 22px;
  left: 24px;
  max-width: 410px;
  padding: 17px 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(15, 20, 17, .95), rgba(28, 36, 30, .82));
  backdrop-filter: blur(16px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .3);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .15em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 5px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(25px, 3vw, 38px);
  font-weight: 500;
  letter-spacing: -.035em;
}

.brand-card > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.control-panel {
  top: 22px;
  right: 22px;
  width: min(340px, calc(100vw - 44px));
  max-height: calc(100vh - 78px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: 0 22px 60px rgba(0, 0, 0, .38);
  transition: transform .25s ease, opacity .25s ease;
}

.control-panel.is-hidden {
  transform: translateX(calc(100% + 34px));
  opacity: 0;
  pointer-events: none;
}

.control-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 15px;
}

.control-heading h2 {
  margin: 0;
  font-size: 20px;
}

.back-home {
  display: inline-block;
  padding: 6px 9px;
  border: 1px solid rgba(217, 255, 119, .35);
  border-radius: 8px;
  background: rgba(217, 255, 119, .07);
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.35;
  text-decoration: none;
  white-space: nowrap;
}

.back-home:hover,
.back-home:focus-visible {
  border-color: rgba(217, 255, 119, .8);
  background: rgba(217, 255, 119, .14);
  outline: none;
}

.gate-home {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-block;
  margin: 0;
  padding: 7px 9px;
  font-size: 10px;
  text-align: center;
}

.exit-app {
  padding: 6px 9px;
  border: 1px solid rgba(239, 106, 91, .35);
  border-radius: 8px;
  background: rgba(239, 106, 91, .08);
  color: #ff9d93;
  font: inherit;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
}

.exit-app:hover,
.exit-app:focus-visible {
  border-color: rgba(239, 106, 91, .8);
  background: rgba(239, 106, 91, .16);
  outline: none;
}

fieldset {
  min-width: 0;
  margin: 0 0 17px;
  padding: 0;
  border: 0;
}

legend {
  width: 100%;
  margin-bottom: 8px;
  color: #d9d5ce;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

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

.layer-switch legend { grid-column: 1 / -1; }

.layer-switch label {
  display: block;
  cursor: pointer;
}

.layer-switch input,
.crop-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.layer-switch label > span {
  display: block;
  height: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, .035);
}

.layer-switch input:checked + span {
  border-color: rgba(217, 255, 119, .55);
  background: rgba(217, 255, 119, .09);
  box-shadow: inset 0 0 0 1px rgba(217, 255, 119, .1);
}

.basemap-switch label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.basemap-switch select {
  width: 100%;
  min-height: 39px;
  padding: 0 34px 0 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: var(--panel-soft);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.basemap-switch select:focus {
  border-color: rgba(217, 255, 119, .55);
}

label strong, label small {
  display: block;
}

label strong { font-size: 12px; }
label small { margin-top: 3px; color: var(--muted); font-size: 10px; }

.crop-list {
  display: grid;
  gap: 7px;
}

.crop-option {
  display: grid;
  grid-template-columns: 14px 1fr;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, .03);
  cursor: pointer;
  transition: opacity .2s, border-color .2s, background .2s;
}

.crop-option:has(input:not(:checked)) { opacity: .42; }
.crop-option:has(input:checked) { background: rgba(255, 255, 255, .06); }
.crop-option.soybean:has(input:checked) { border-color: rgba(244, 185, 66, .5); }
.crop-option.palm-oil:has(input:checked) { border-color: rgba(239, 106, 91, .5); }
.crop-option.olive:has(input:checked) { border-color: rgba(132, 169, 75, .55); }

.crop-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 12px currentColor;
}

.soybean .crop-swatch { color: var(--soybean); background: var(--soybean); }
.palm-oil .crop-swatch { color: var(--palm-oil); background: var(--palm-oil); }
.olive .crop-swatch { color: var(--olive); background: var(--olive); }

.legend {
  padding-top: 3px;
  border-top: 1px solid var(--line);
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  margin: 12px 0 5px;
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
}

.legend-gradient {
  --legend-low: #fff1c7;
  --legend-high: #7a4d08;
  height: 7px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--legend-low), var(--legend-high));
  transition: background .2s ease;
}

.legend p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.hover-control {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, .035);
  cursor: pointer;
}

.hover-control > span:first-child {
  min-width: 0;
}

.hover-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  transition: background .18s ease;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #d5d0c8;
  transition: transform .18s ease, background .18s ease;
}

.hover-control input:checked + .toggle-track {
  background: rgba(217, 255, 119, .42);
}

.hover-control input:checked + .toggle-track .toggle-thumb {
  transform: translateX(16px);
  background: var(--accent);
}

.hover-control:has(input:focus-visible) {
  border-color: rgba(217, 255, 119, .7);
}

.cell-tooltip {
  position: absolute;
  z-index: 650;
  display: none;
  min-width: 190px;
  max-width: 260px;
  padding: 10px 11px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 10px;
  background: rgba(13, 17, 14, .94);
  color: var(--ink);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .34);
  backdrop-filter: blur(12px);
  pointer-events: none;
}

.cell-tooltip.is-visible {
  display: block;
}

.tooltip-heading {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.tooltip-row {
  display: grid;
  grid-template-columns: 9px 1fr auto;
  align-items: center;
  gap: 7px;
  padding: 3px 0;
  font-size: 11px;
}

.tooltip-swatch {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.tooltip-value {
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.tooltip-coordinates {
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  color: #8d887f;
  font-size: 9px;
}

.viewport-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .2);
  color: #d2cec5;
  font-size: 11px;
}

.promo-card {
  display: grid;
  gap: 9px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.promo-card img {
  display: block;
  width: 100%;
  height: 58px;
  object-fit: contain;
  border-radius: 8px;
  background: #101010;
}

.promo-card a {
  display: block;
  padding: 10px 12px;
  border: 1px solid rgba(57, 148, 220, .52);
  border-radius: 10px;
  background: rgba(57, 148, 220, .12);
  color: #69baff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
}

.promo-card a:hover,
.promo-card a:focus-visible {
  border-color: #69baff;
  background: rgba(57, 148, 220, .22);
  color: #b8deff;
  outline: none;
}

.status-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.panel-toggle {
  top: 24px;
  right: 24px;
  display: none;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
}

.map-footer {
  right: 22px;
  bottom: 10px;
  left: 22px;
  display: flex;
  gap: 12px;
  color: rgba(245, 240, 231, .65);
  font-size: 9px;
  letter-spacing: .06em;
  text-transform: uppercase;
  pointer-events: none;
}

.human-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 20% 20%, rgba(132, 169, 75, .15), transparent 35%),
    radial-gradient(circle at 80% 70%, rgba(244, 185, 66, .1), transparent 32%),
    rgba(10, 14, 11, .96);
  transition: opacity .35s ease, visibility .35s;
}

.human-gate.is-verified {
  opacity: 0;
  visibility: hidden;
}

.gate-card {
  position: relative;
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(29, 37, 31, .98), rgba(16, 21, 18, .98));
  box-shadow: 0 26px 90px rgba(0, 0, 0, .48);
}

.gate-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  margin-bottom: 18px;
  border-radius: 50%;
  background: rgba(217, 255, 119, .1);
  color: var(--accent);
  font-size: 22px;
}

.gate-card h2 {
  margin-bottom: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 31px;
  font-weight: 500;
}

.gate-card > p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.5;
}

.captcha-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-top: 18px;
}

.captcha-cell {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 10px;
  background: #050505;
  color: #fff;
  font: inherit;
  font-size: clamp(25px, 8vw, 36px);
  font-weight: 750;
  line-height: 1;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.captcha-cell:hover {
  border-color: rgba(217, 255, 119, .6);
}

.captcha-cell:focus-visible {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(217, 255, 119, .15);
}

.captcha-cell.is-selected {
  border-color: var(--accent);
  box-shadow:
    inset 0 0 0 3px rgba(217, 255, 119, .72),
    0 0 18px rgba(217, 255, 119, .12);
  transform: scale(.97);
}

.captcha-submit {
  width: 100%;
  min-height: 46px;
  margin-top: 12px;
  padding: 0 17px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #15200f;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.captcha-submit:disabled {
  cursor: wait;
  opacity: .45;
}

.gate-error {
  min-height: 17px;
  margin: 6px 0 0;
  color: #ff9187;
  font-size: 11px;
}

.gate-card > small {
  display: block;
  margin-top: 14px;
  color: #817c74;
  font-size: 9px;
  line-height: 1.4;
}

.bot-trap {
  position: absolute !important;
  left: -10000px !important;
}

@media (max-width: 760px) {
  .brand-card {
    top: 12px;
    left: 12px;
    max-width: calc(100vw - 110px);
    padding: 12px 14px;
  }

  .brand-card .eyebrow,
  .brand-card > p:last-child { display: none; }
  .brand-card h1 { margin: 0; font-size: 22px; }
  .control-panel { top: 62px; right: 12px; max-height: calc(100vh - 108px); }
  .panel-toggle { display: block; top: 12px; right: 12px; }
  .map-footer { right: 12px; bottom: 7px; left: 12px; }
  .map-footer span:last-child { display: none; }
  .gate-card { padding: 24px; }
}
