:root {
  --ink: #20251f;
  --muted: #6b7269;
  --line: #d8ddd4;
  --paper: #f7f8f3;
  --paper-strong: #ffffff;
  --accent: #6c7f43;
  --accent-dark: #3d4f24;
  --footer: #1e251b;
  --footer-muted: #b9c4af;
  --shadow: 0 12px 28px rgba(31, 40, 28, 0.16);
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
}

button,
input { font: inherit; }

button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: 75% 25%;
  grid-template-rows: 94% 6%;
  width: 100vw;
  height: 100vh;
  min-width: 0;
  min-height: 0;
}

.map-stage {
  position: relative;
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #e8ece5;
}

#viewDiv {
  position: absolute;
  inset: 0;
}

.side-panel {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--paper);
  scrollbar-width: thin;
}

.panel-header,
.panel-section {
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-header {
  background: var(--paper-strong);
}

.panel-kicker {
  margin: 0 0 7px;
  color: #d97706;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.panel-header h1 {
  margin: 0;
  color: #173a63;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(18px, 1.35vw, 27px);
  line-height: 1.03;
  letter-spacing: -.02em;
}

.panel-header p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

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

.section-heading h2 {
  margin: 0;
  font-size: 9px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #79984d;
  box-shadow: 0 0 0 3px rgba(121, 152, 77, .14);
}

.status-dot.is-off {
  color: var(--muted);
}

.status-dot.is-off::before {
  background: #a8aea4;
  box-shadow: none;
}

.switch-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.switch-row > span:first-child {
  min-width: 0;
}

.switch-row strong,
.switch-row small {
  display: block;
}

.switch-row strong {
  font-size: 12px;
}

.switch-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch {
  position: relative;
  flex: 0 0 38px;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #bdc3b8;
  transition: background .18s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .22);
  transition: transform .18s ease;
}

.switch-row input:checked + .switch {
  background: var(--accent);
}

.switch-row input:checked + .switch::after {
  transform: translateX(16px);
}

.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.text-button:disabled {
  opacity: .35;
  cursor: default;
}

.empty-selection {
  padding: 14px;
  border: 1px dashed #cbd2c5;
  border-radius: 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  background: rgba(255,255,255,.65);
}

.selection-content h3 {
  margin: 0 0 12px;
  color: #c41f1a;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.18;
}

#unitDetails {
  margin: 0;
}

#unitDetails > div {
  display: grid;
  grid-template-columns: minmax(94px, 40%) minmax(0, 60%);
  align-items: start;
  gap: 10px;
  padding: 5px 0;
  border-top: 1px solid var(--line);
}

#unitDetails dt {
  margin: 0;
  color: #8a8f88;
  font-size: 9px;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: .03em;
  text-transform: uppercase;
}

#unitDetails dd {
  margin: 0;
  color: #111111;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.map-tools {
  position: absolute;
  z-index: 5;
  right: 16px;
  top: 16px;
  display: grid;
  grid-template-columns: 38px 38px auto;
  gap: 7px;
}

.map-tools button {
  height: 38px;
  border: 1px solid rgba(45, 52, 42, .18);
  border-radius: 10px;
  background: rgba(255,255,255,.94);
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(31, 40, 28, .12);
  font-size: 19px;
  font-weight: 700;
}

.map-tools .map-tools__reset {
  padding: 0 12px;
  font-size: 11px;
  letter-spacing: .04em;
}

.map-status {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(30, 37, 27, .9);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  box-shadow: var(--shadow);
  transition: opacity .2s ease, visibility .2s ease;
}

.map-status.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.site-footer {
  grid-column: 1 / -1;
  grid-row: 2;
  display: grid;
  grid-template-columns: minmax(260px, .8fr) minmax(420px, 1.7fr) minmax(320px, 1fr);
  align-items: center;
  gap: 24px;
  min-width: 0;
  padding: 6px 24px;
  background: var(--footer);
  color: #fff;
}

.footer-map-control {
  display: flex;
  align-items: center;
  min-width: 0;
  padding-right: 22px;
  border-right: 1px solid rgba(255,255,255,.14);
}

.footer-map-control__copy {
  min-width: 0;
}

.footer-map-control__copy strong {
  display: block;
  overflow: hidden;
  color: #fff;
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.footer-label {
  display: block;
  margin-bottom: 3px;
  color: #d7e4cd;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.footer-label--enhanced {
  color: #ef4444;
}

.footer-slider {
  min-width: 0;
  padding: 0 26px;
}

.footer-slider .footer-label {
  text-align: center;
}

.footer-slider__control {
  position: relative;
  height: 26px;
  display: flex;
  align-items: center;
}

.footer-slider__control input[type="range"] {
  position: relative;
  z-index: 3;
  width: 100%;
  height: 20px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}

.footer-slider__control input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 999px;
  background: rgba(255,255,255,.5);
}

.footer-slider__control input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -6.5px;
  border: 2px solid #fff;
  border-radius: 50%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--accent);
  box-shadow: 0 1px 5px rgba(0,0,0,.35);
}

.footer-slider__control input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 999px;
  background: rgba(255,255,255,.5);
}

.footer-slider__control input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 5px rgba(0,0,0,.35);
}

.footer-slider__stops {
  position: absolute;
  z-index: 2;
  left: 7px;
  right: 7px;
  top: 50%;
  display: flex;
  justify-content: space-between;
  transform: translateY(-50%);
  pointer-events: none;
}

.footer-slider__stops span {
  width: 7px;
  height: 7px;
  border: 1px solid rgba(255,255,255,.85);
  border-radius: 50%;
  background: var(--footer);
  box-shadow: 0 0 0 2px rgba(30,37,27,.55);
}

.footer-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  color: var(--footer-muted);
  font-size: 9px;
  line-height: 1.35;
  text-align: right;
}

.footer-meta span {
  white-space: nowrap;
}

.footer-meta b {
  margin-right: 5px;
  color: #eef4ea;
  font-size: 8px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.esri-attribution {
  background: rgba(255,255,255,.92) !important;
}

@media (max-width: 1000px) {
  .app-shell {
    grid-template-columns: 75% 25%;
  }
}

@media (max-width: 720px) {
  html,
  body {
    overflow: auto;
  }

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

  .map-stage {
    grid-column: 1;
    grid-row: 1;
  }

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

  .site-footer {
    grid-column: 1;
    grid-row: 3;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 16px 18px;
  }

  .footer-map-control {
    padding-right: 0;
    padding-bottom: 12px;
    border-right: 0;
    border-bottom: 1px solid rgba(255,255,255,.14);
  }

  .footer-meta {
    justify-content: flex-start;
  }

  .map-brand {
    max-width: calc(100vw - 132px);
  }
}


.footer-slider .footer-label strong {
  color: #ffffff;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: none;
}


/* Methodology control and modal */
.methodology-button {
  position: absolute;
  z-index: 7;
  left: 16px;
  top: 16px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(45, 52, 42, .18);
  border-radius: 10px;
  background: rgba(255,255,255,.94);
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(31, 40, 28, .12);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .03em;
}

.methodology-button:hover,
.methodology-button:focus-visible {
  background: #fff;
  outline: 2px solid rgba(108, 127, 67, .28);
  outline-offset: 2px;
}

.methodology-modal[hidden] { display: none; }

.methodology-modal {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
}

.methodology-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 24, 17, .48);
  backdrop-filter: blur(2px);
}

.methodology-modal__dialog {
  position: relative;
  width: min(760px, calc(100vw - 32px));
  max-height: min(78vh, 760px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-strong);
  box-shadow: 0 24px 70px rgba(18, 24, 17, .32);
}

.methodology-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
}

.methodology-modal__kicker {
  margin: 0 0 4px;
  color: #d97706;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.methodology-modal__header h2 {
  margin: 0;
  color: #6c7f43;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
}

.methodology-modal__close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0 0 6px;
}

.methodology-modal__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 10px 22px;
  background: #f3f5ee;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}

.methodology-modal__meta strong {
  margin-right: 5px;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-size: 9px;
}

.methodology-modal__body {
  overflow-y: auto;
  padding: 18px 22px 24px;
  color: #2d332b;
  font-size: 12px;
  line-height: 1.55;
}

.methodology-modal__body p { margin: 0 0 14px; }
.methodology-modal__body h3 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.methodology-modal__body ul { margin: 0 0 16px 18px; padding: 0; }
.methodology-modal__body li { margin: 0 0 5px; }
.methodology-modal__body code { padding: 1px 4px; border-radius: 4px; background: #eef1e8; font-size: .95em; }

@media (max-width: 720px) {
  .methodology-button { left: 10px; top: 10px; }
  .methodology-modal { padding: 12px; }
  .methodology-modal__dialog { max-height: 86vh; }
}


/* Bottom-left map display controls */
.map-bottom-controls {
  position: absolute;
  z-index: 8;
  left: 16px;
  bottom: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 32px);
}

.map-control-button,
.hillshade-control {
  min-height: 38px;
  border: 1px solid rgba(45, 52, 42, .18);
  border-radius: 10px;
  background: rgba(255,255,255,.95);
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(31, 40, 28, .12);
}

.map-control-button {
  padding: 0 13px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .03em;
}

.map-control-button:hover:not(:disabled),
.map-control-button:focus-visible {
  background: #fff;
}

.map-control-button:disabled {
  opacity: .52;
  cursor: default;
}

.legend-control {
  position: relative;
}

.map-legend-panel[hidden] { display: none; }

.map-legend-panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  width: min(320px, calc(100vw - 48px));
  max-height: min(52vh, 430px);
  overflow: hidden;
  border: 1px solid rgba(45, 52, 42, .18);
  border-radius: 12px;
  background: rgba(255,255,255,.98);
  box-shadow: var(--shadow);
}

.map-legend-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
}

.map-legend-panel__header strong {
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.map-legend-panel__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.map-legend-filter {
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f5f7f2;
  color: var(--accent-dark);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.map-legend-filter:hover:not(:disabled),
.map-legend-filter:focus-visible {
  background: #eef2e8;
}

.map-legend-filter:disabled {
  opacity: .55;
  cursor: default;
}

.map-legend-close {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.map-legend-items {
  max-height: calc(min(52vh, 430px) - 49px);
  overflow-y: auto;
  padding: 8px 10px 10px;
}


.map-legend-empty {
  padding: 10px 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.map-legend-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  color: #2b302a;
  font-size: 10px;
  line-height: 1.25;
}

.map-legend-swatch {
  width: 18px;
  height: 13px;
  border: 1px solid rgba(25,25,25,.5);
  border-radius: 2px;
}

.hillshade-control {
  display: grid;
  grid-template-columns: auto minmax(92px, 140px) 34px;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 11px;
}

.hillshade-control > span {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.hillshade-control input[type="range"] {
  width: 128px;
  accent-color: var(--accent);
}

.hillshade-control output {
  min-width: 32px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-align: right;
}

@media (max-width: 720px) {
  .map-bottom-controls {
    left: 10px;
    bottom: 28px;
    gap: 6px;
  }

  .hillshade-control {
    grid-template-columns: auto 82px 31px;
    gap: 6px;
  }

  .hillshade-control input[type="range"] { width: 82px; }
}
