:root {
  --ink: #172026;
  --muted: #62707a;
  --line: #d8e0e4;
  --panel: #f8faf9;
  --green: #4ac26b;
  --gold: #d7ad21;
  --orange: #df6c1f;
  --red: #d72f25;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background: #edf2f4;
}

.shell {
  display: grid;
  grid-template-columns: minmax(300px, 360px) 1fr;
  min-height: 100vh;
}

.shell[hidden] {
  display: none;
}

.shell.is-info-view {
  grid-template-columns: minmax(0, 1fr);
}

.shell.is-info-view .panel {
  width: min(1120px, calc(100vw - 48px));
  margin: 0 auto;
  border-right: 0;
}

.shell.is-info-view .map-wrap {
  display: none;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: auto;
}

.eyebrow {
  margin: 0 0 8px;
  color: #286e45;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.05;
}

h2 {
  font-size: 15px;
}

.lede {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.control-block {
  display: grid;
  gap: 8px;
}

.control-block[hidden] {
  display: none;
}

label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select,
button {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cbd5da;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

button {
  cursor: pointer;
  font-weight: 700;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.secondary-btn {
  width: auto;
  min-width: 72px;
  padding: 0 12px;
  border-color: #cbd5da;
  background: #f7f9f8;
  color: var(--ink);
}

.toggle-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid #cbd5da;
  border-radius: 8px;
  background: #eef3f0;
}

.toggle-group label {
  display: block;
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  text-transform: none;
}

.toggle-group input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle-group span {
  display: block;
  min-height: 32px;
  padding: 8px 6px;
  border-radius: 6px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.toggle-group input:checked + span {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(23, 32, 38, .12);
}

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

.stats div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stats span {
  display: block;
  overflow-wrap: anywhere;
  font-size: 22px;
  font-weight: 800;
}

.stats small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.coverage-note {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  border: 1px solid #cfd8d2;
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.coverage-note strong {
  font-size: 12px;
}

.coverage-note span {
  color: var(--muted);
  min-width: 0;
  overflow-wrap: anywhere;
}

.data-note {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid #cfd8d2;
  border-radius: 8px;
  background: #eef6f0;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.data-note strong {
  font-size: 12px;
}

.data-note span {
  color: #41604b;
  min-width: 0;
  overflow-wrap: anywhere;
}

.data-note.is-error {
  border-color: #e0b6b0;
  background: #fff5f3;
}

.data-note.is-error span {
  color: #9a3b31;
}

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

.legend-scale {
  height: 14px;
  border: 1px solid #b8c1c6;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--green), var(--gold), var(--orange), var(--red));
}

.legend-labels {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.legend-labels span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.legend-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.upgrade-note {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.upgrade-note strong {
  color: var(--ink);
  font-size: 12px;
}

.upgrade-note p {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.planned-variable-note {
  gap: 10px;
}

.planned-variable-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.planned-variable-list span {
  padding: 6px 8px;
  border: 1px solid #d9dfdb;
  border-radius: 999px;
  background: #f3f5f4;
  color: #8a928d;
  font-size: 11px;
  line-height: 1.2;
}

.locked-metric-box {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid #d9dfdb;
  border-radius: 8px;
  background: #f6f7f6;
}

.locked-metric-box strong {
  color: #6f7771;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.locked-metric-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.locked-metric-list span {
  padding: 6px 8px;
  border: 1px solid #d9dfdb;
  border-radius: 999px;
  background: #f0f2f1;
  color: #8a928d;
  font-size: 11px;
  line-height: 1.2;
}

.market-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding-left: 20px;
}

.market-list li {
  min-width: 0;
  padding: 10px 10px 10px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.market-list strong {
  display: block;
  margin-bottom: 3px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.market-list span {
  color: var(--muted);
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.map-wrap {
  position: relative;
  min-width: 0;
}

#map {
  width: 100%;
  height: 100vh;
  background: #f5f7f3;
}

.hover-card {
  position: absolute;
  z-index: 900;
  right: 18px;
  bottom: 18px;
  width: min(320px, calc(100% - 36px));
  max-width: calc(100% - 36px);
  max-height: calc(100vh - 36px);
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 16px 32px rgba(20, 32, 38, .18);
  font-size: 13px;
  overflow-wrap: anywhere;
  overflow-y: auto;
}

.hover-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.hover-card dl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 5px 14px;
  margin: 0;
}

.hover-section + .hover-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e2e9e3;
}

.hover-section h4 {
  margin: 0 0 6px;
  color: #2f4b3b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hover-card dt {
  color: var(--muted);
  min-width: 0;
  overflow-wrap: anywhere;
}

.hover-card dd {
  margin: 0;
  font-weight: 700;
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.screen-map-tooltip {
  width: 300px;
  max-width: 320px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 28px rgba(20, 32, 38, .18);
  color: var(--ink);
  font: inherit;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.screen-map-tooltip strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.screen-map-tooltip .hover-section + .hover-section,
.map-hover-tooltip .hover-section + .hover-section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e2e9e3;
}

.screen-map-tooltip h4,
.map-hover-tooltip h4 {
  margin: 0 0 6px;
  color: #2f4b3b;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.screen-map-tooltip dl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 5px 12px;
  margin: 0;
  font-size: 12px;
  white-space: normal;
}

.screen-map-tooltip dt {
  color: var(--muted);
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.screen-map-tooltip dd {
  margin: 0;
  font-weight: 700;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-align: right;
}

.map-hover-tooltip {
  width: 320px;
  max-width: 340px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 28px rgba(20, 32, 38, .18);
  color: var(--ink);
  font: inherit;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.map-hover-tooltip strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.map-hover-tooltip dl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 5px 12px;
  margin: 0;
  font-size: 12px;
  white-space: normal;
}

.map-hover-tooltip dt {
  color: var(--muted);
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.map-hover-tooltip dd {
  margin: 0;
  font-weight: 700;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-align: right;
}

.map-click-popup .leaflet-popup-content {
  margin: 13px 16px;
  color: var(--ink);
  font: 13px Arial, Helvetica, sans-serif;
  width: 300px;
  max-width: min(320px, calc(100vw - 96px));
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.map-click-popup strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.map-click-popup dl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 5px 12px;
  margin: 0;
  white-space: normal;
}

.map-click-popup dt {
  color: var(--muted);
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.map-click-popup dd {
  margin: 0;
  font-weight: 700;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-align: right;
}

.asc-name-details {
  margin-top: 6px;
  text-align: left;
}

.asc-name-details summary {
  cursor: pointer;
  color: #2f6a47;
  font-size: 11px;
  font-weight: 700;
  list-style: none;
}

.asc-name-details summary::-webkit-details-marker {
  display: none;
}

.asc-name-details ul {
  margin: 6px 0 0;
  padding-left: 16px;
}

.asc-name-details li {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.3;
}

.leaflet-tooltip.map-hover-tooltip,
.leaflet-tooltip.screen-map-tooltip {
  white-space: normal;
}

.leaflet-container {
  font: inherit;
}

#landingView {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: #edf2f4;
}

#landingView[hidden] {
  display: none;
}

.landing-shell {
  max-width: 1040px;
  text-align: center;
}

.landing-shell h1 {
  margin-top: 0;
  font-size: 44px;
}

.landing-shell .lede {
  margin: 14px auto 0;
  max-width: 560px;
  font-size: 15px;
}

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

.landing-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: normal;
  transition: box-shadow .15s ease, transform .15s ease;
}

.landing-card:hover {
  box-shadow: 0 10px 24px rgba(23, 32, 38, .12);
  transform: translateY(-2px);
}

.landing-card h2 {
  min-width: 0;
  font-size: 18px;
  color: #286e45;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.landing-card p {
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.landing-upgrade-window {
  display: grid;
  gap: 14px;
  min-width: 0;
  margin-top: 20px;
  padding: 18px;
  border: 1px solid #cfd8d2;
  border-radius: 8px;
  background: #fff;
  text-align: left;
  box-shadow: 0 12px 28px rgba(23, 32, 38, .08);
  overflow: hidden;
  overflow-wrap: anywhere;
}

.landing-upgrade-window h2 {
  min-width: 0;
  max-width: 760px;
  font-size: 18px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.landing-upgrade-window ol {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin: 0;
  padding-left: 20px;
}

.landing-upgrade-window li {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.landing-upgrade-window strong {
  color: var(--ink);
}

.landing-card-compact {
  justify-self: start;
  width: min(360px, 100%);
  padding: 14px 16px;
  border-radius: 8px;
  background: #f8faf9;
}

.landing-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.landing-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.text-link {
  width: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: #286e45;
  font-size: 12px;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

.terms-copy {
  margin: 0;
  max-width: 780px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.terms-copy a {
  color: #286e45;
}

.landing-card-compact h2 {
  font-size: 15px;
}

.landing-card-compact p {
  font-size: 12px;
  line-height: 1.35;
}

@media (max-width: 860px) {
  .landing-cards {
    grid-template-columns: 1fr;
  }
}

.back-link {
  width: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: #286e45;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.map-mode-bar {
  position: absolute;
  z-index: 800;
  top: 12px;
  right: 12px;
  display: grid;
  width: min(270px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  gap: 7px;
  padding: 8px;
  border: 1px solid #cfd8d2;
  border-radius: 8px;
  background: rgba(238, 246, 240, .96);
  box-shadow: 0 4px 14px rgba(20, 32, 38, .12);
  overflow: auto;
}

.map-mode-bar[hidden] {
  display: none;
}

.map-mode-btn {
  width: 100%;
  min-height: 34px;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid #cfd8d2;
  border-radius: 6px;
  background: rgba(255, 255, 255, .72);
  color: #286e45;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-align: left;
  overflow-wrap: anywhere;
}

.map-mode-btn.active {
  border-color: #8bb99a;
  background: #fff;
  color: #174f31;
  box-shadow: inset 3px 0 0 #4ac26b, 0 2px 8px rgba(20, 32, 38, .08);
}

.map-mode-btn:hover {
  border-color: #8bb99a;
  background: #fff;
  color: #174f31;
}

@media (max-width: 760px) {
  .map-mode-bar {
    top: auto;
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
    max-height: 34vh;
  }
}

.view-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

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

.limitations-panel {
  gap: 26px;
}

.limitation-section {
  display: grid;
  gap: 14px;
}

.limitation-section h2 {
  font-size: 18px;
  color: #286e45;
}

.limitation-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
}

.limitation-list article,
.purchase-grid article {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  line-height: 1.42;
}

.limitation-list strong,
.purchase-grid strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 14px;
}

.limitation-list p,
.purchase-grid p,
.purchase-grid span {
  margin: 0;
  color: var(--muted);
}

.purchase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}

.purchase-grid article {
  display: grid;
  gap: 8px;
}

.purchase-grid span {
  display: block;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.filter-group {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.filter-group h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #286e45;
}

.variable-filter {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.variable-filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.variable-filter-name {
  font-size: 13px;
  font-weight: 700;
}

.filter-mode-toggle {
  display: flex;
  gap: 4px;
}

.filter-mode-btn {
  width: auto;
  min-height: 26px;
  padding: 4px 8px;
  border: 1px solid #cbd5da;
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.filter-mode-btn.active {
  background: var(--panel);
  color: var(--ink);
  border-color: #286e45;
}

.filter-category-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-category-controls[hidden],
.filter-custom-controls[hidden],
.filter-outlier-controls[hidden] {
  display: none;
}

.variable-filter-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.variable-filter-stats span {
  min-width: 0;
  padding: 2px 6px;
  border: 1px solid #d6dfd9;
  border-radius: 999px;
  background: #f5faf6;
  overflow-wrap: anywhere;
}

.variable-footnote {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-style: italic;
  line-height: 1.35;
}

.filter-tier-btn {
  width: auto;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid #cbd5da;
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.filter-tier-btn.active {
  background: #4ac26b;
  color: #fff;
  border-color: #3a9c56;
}

.filter-custom-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.filter-custom-controls select {
  grid-column: 1 / -1;
}

.filter-outlier-controls {
  display: grid;
  gap: 6px;
}

.formula-card {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.formula-line {
  padding: 8px 10px;
  border: 1px solid #d8e2db;
  border-radius: 8px;
  background: #f6faf7;
  color: var(--ink);
}

.formula-card p {
  margin: 0;
}

.metric-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  padding: 2px 6px;
  border: 1px solid #d5ddd8;
  border-radius: 999px;
  background: #f4f7f5;
  color: #4a5b51;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
  vertical-align: middle;
}

.metric-badge.high {
  border-color: #8ed19d;
  background: #edf8f0;
  color: #25653f;
}

.metric-badge.mid {
  border-color: #cfe0b0;
  background: #f7f9ec;
  color: #5c6d1b;
}

.metric-badge.low {
  border-color: #e6c4bf;
  background: #fff4f1;
  color: #9a4336;
}

.metric-badge.neutral {
  border-color: #d5ddd8;
  background: #f4f7f5;
  color: #4a5b51;
}

.weight-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 8px;
}

.weight-row-name {
  font-size: 13px;
  font-weight: 700;
}

.weight-row-input {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.weight-row-input input {
  width: 68px;
  min-height: 30px;
  text-align: right;
}

.weight-unit {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

  .panel {
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  #map {
    height: 68vh;
  }
}
