:root {
  --ink: #171614;
  --muted: #68635d;
  --paper: #ffffff;
  --panel: rgba(255, 255, 255, 0.96);
  --line: rgba(28, 26, 23, 0.11);
  --line-strong: rgba(28, 26, 23, 0.18);
  --accent: #8f3d31;
  --accent-soft: #f1e6d8;
  --shadow: 0 12px 32px rgba(20, 19, 17, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body,
.atlas-shell,
.map-stage,
#map {
  width: 100%;
  height: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Aptos", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
}

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

#map {
  position: absolute;
  inset: 0;
  background: #f8f7f4;
}

.control-panel,
.info-card {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.control-panel {
  position: absolute;
  z-index: 2;
  top: 18px;
  left: 18px;
  bottom: 18px;
  width: min(320px, calc(100vw - 36px));
  padding: 18px 18px 16px;
  overflow: auto;
}

.info-stack {
  position: absolute;
  z-index: 2;
  top: 18px;
  right: 18px;
  display: grid;
  gap: 12px;
  width: min(310px, calc(100vw - 36px));
}

.info-card {
  padding: 16px 16px 14px;
}

.masthead {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.card-label,
.section-head h2,
.layer-section h3 {
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.eyebrow,
.card-label {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 700;
  color: #8b7e70;
}

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.subtitle {
  margin-bottom: 0;
  color: #4e4943;
  font-size: 13px;
  line-height: 1.58;
}

.panel-section {
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
}

.panel-section:first-of-type {
  margin-top: 0;
}

.section-head {
  margin-bottom: 10px;
}

.section-head h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  color: #7d746b;
}

.layer-section + .layer-section {
  margin-top: 14px;
}

.layer-section h3 {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 700;
  color: #9a8f84;
}

.layer-button,
.utility-button,
.clear-button {
  appearance: none;
  width: 100%;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease;
}

.layer-button {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 11px 12px;
  margin-bottom: 8px;
  text-align: left;
  font-size: 12px;
  line-height: 1.35;
}

.layer-button:hover,
.utility-button:hover,
.clear-button:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.layer-button.active {
  border-color: #1f1d1a;
  background: #1f1d1a;
  color: #fffdf8;
}

.utility-button {
  padding: 10px 12px;
  margin-bottom: 10px;
  text-align: left;
  font-size: 12px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  color: #3f3a35;
  font-size: 12px;
}

.toggle-row input {
  width: 14px;
  height: 14px;
  accent-color: #34302b;
}

.legend {
  display: grid;
  gap: 7px;
}

.legend-title {
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #433f3a;
}

.legend-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.swatch {
  width: 18px;
  height: 11px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.status-note {
  margin: 16px 0 0;
  color: #5a554f;
  font-size: 12px;
  line-height: 1.55;
}

.summary-card h2,
.detail-card h3,
.note-card h3 {
  margin-bottom: 12px;
  font-size: 16px;
  line-height: 1.15;
}

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

.metric-grid div {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.metric-grid dt {
  font-size: 24px;
  line-height: 1;
}

.metric-grid dd {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.layer-note {
  margin-bottom: 0;
  color: #4d4842;
  font-size: 12px;
  line-height: 1.58;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.clear-button {
  width: auto;
  padding: 8px 10px;
  font-size: 11px;
  color: #4d4842;
}

.selection-empty,
.selected-tract-title,
.detail-list {
  font-size: 12px;
}

.selection-empty,
.selected-tract-title {
  color: #56514b;
  line-height: 1.5;
}

.selected-tract-title {
  margin-bottom: 12px;
  font-weight: 600;
  color: #24211d;
}

.detail-list {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
}

.detail-list dt {
  color: var(--muted);
}

.detail-list dd {
  margin: 0;
  text-align: right;
  color: #2a2622;
}

.deck-tooltip {
  position: absolute;
  z-index: 4;
  max-width: 290px;
  padding: 12px 13px;
  border: 1px solid rgba(24, 22, 20, 0.14);
  background: rgba(25, 23, 20, 0.94);
  color: #fbfaf7;
  box-shadow: 0 18px 36px rgba(18, 17, 15, 0.18);
  font-size: 12px;
  line-height: 1.5;
  pointer-events: none;
}

.deck-tooltip strong {
  color: #ffe6be;
}

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

  .map-stage {
    min-height: 100svh;
    padding: 10px 10px 14px;
  }

  #map {
    position: relative;
    min-height: 68svh;
    border: 1px solid var(--line);
  }

  .control-panel,
  .info-stack {
    position: relative;
    top: auto;
    right: auto;
    left: auto;
    bottom: auto;
    width: auto;
  }

  .control-panel {
    margin-top: 12px;
    max-height: none;
  }

  .info-stack {
    margin-top: 12px;
  }
}
