:root {
  color-scheme: light;
  --ink: #1c1915;
  --muted: #5c564c;
  --paper: #f4f0e6;
  --panel: #fbf8f2;
  --line: #d8d0c2;
  --ocean: #d5e2da;
  --green: #1d5c45;
  --focus: #1d5c45;
  --shadow: 0 12px 40px rgba(28, 25, 21, 0.08);
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
}

html:has(body.about),
html:has(body.page) {
  height: auto;
}

body {
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: end;
  padding: 0.85rem 1.25rem 0.7rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.topnav {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  justify-content: flex-end;
}

.topnav a {
  color: var(--green);
  font-weight: 700;
  text-decoration: none;
}

.topnav a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

.site-line {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.35;
}

.map-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.map-switch button {
  flex: 1 1 7.2rem;
  padding-left: 0.45rem;
  padding-right: 0.45rem;
}

.map-switch button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

h1, h2, h3, .summary-figure, .detail-figure {
  font-family: Fraunces, Georgia, serif;
  font-weight: 560;
}

h1 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.status {
  margin: 0;
  max-width: 36rem;
  text-align: right;
  color: var(--muted);
  font-size: 0.92rem;
}

.workspace {
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr) 360px;
}

.panel {
  min-height: 0;
  overflow: auto;
  padding: 1rem 1.1rem 1.4rem;
  background: var(--panel);
}

.panel-left { border-right: 1px solid var(--line); }
.panel-right { border-left: 1px solid var(--line); }
.panel-right[hidden] { display: none !important; }

.workspace:has(.panel-right[hidden]),
.workspace:has(.panel-right.is-collapsed) {
  grid-template-columns: 360px minmax(0, 1fr);
}

.panel-right.is-collapsed {
  display: none !important;
}

.field-label {
  display: block;
  margin: 0.85rem 0 0.3rem;
}
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

select, input[type="search"] {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  font: inherit;
}

.summary h2 {
  margin: 0.15rem 0 0.2rem;
  font-size: 1.15rem;
  line-height: 1.2;
}

.summary-figure {
  margin: 0 0 0.2rem;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.equation {
  list-style: none;
  margin: 0.45rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.15rem;
}

.equation li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
}

.equation li strong {
  font-variant-numeric: tabular-nums;
}

.equation li.result {
  border-top: 2px solid var(--green);
  font-family: Fraunces, Georgia, serif;
  font-size: 1.05rem;
}

.explore {
  margin: 0.85rem 0 0;
  padding: 0.65rem 0.75rem;
  background: var(--ocean);
  border-radius: 8px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.leaflet-tooltip.map-tip {
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  font-size: 0.92rem;
  line-height: 1.2;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  white-space: nowrap;
  width: max-content;
  max-width: none;
  padding: 0.4rem 0.55rem;
}

.leaflet-tooltip.map-tip .tip-name {
  display: block;
  margin: 0 0 0.15rem;
}

.leaflet-tooltip.map-tip .tip-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.12rem;
  white-space: nowrap;
}

.leaflet-tooltip.map-tip .tip-icon {
  width: 0.9rem;
  height: 0.9rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.leaflet-tooltip.map-tip .tip-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex: none;
  white-space: nowrap;
}

.leaflet-tooltip.map-tip .tip-value {
  margin-left: auto;
  font-weight: 700;
  flex: none;
  white-space: nowrap;
}

.caveat {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.7rem;
  margin: 0.55rem 0 0.2rem;
}

.legend .caveat {
  flex-basis: 100%;
}

.legend-row {
  display: grid;
  grid-template-columns: 1.4rem 1fr;
  gap: 0.55rem;
  align-items: center;
  font-size: 0.9rem;
}

.swatch {
  height: 0.85rem;
  border: 1px solid rgba(28, 25, 21, 0.25);
  border-radius: 2px;
}

.swatch.hatch {
  background-color: #6eae8e;
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 2px,
    #1c1915 2px,
    #1c1915 3.4px
  );
}

.hatch-overlay {
  pointer-events: none;
}

.flags {
  list-style: none;
  margin: 0.4rem 0 1.4rem;
  padding: 0;
}

.flags li {
  display: grid;
  grid-template-columns: 1.15rem 1fr;
  gap: 0.55rem;
  align-items: start;
  margin: 0 0 0.85rem;
}

.flags p {
  margin: 0;
}

.flag {
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 0.15rem;
}

.flag-red {
  color: #9d2c2c;
}

.flag-green {
  color: #1f6b45;
}

.flag-label {
  font-weight: 700;
}

.national h2, .panel-right h2, .panel-right h3 {
  margin: 1.1rem 0 0.4rem;
  font-size: 1.15rem;
}

.stat-list {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.8rem;
  margin: 0;
}

.stat-list dt { color: var(--muted); }
.stat-list dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }

.map-wrap {
  position: relative;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ocean);
}

#map { height: 100%; width: 100%; background: var(--ocean); }

.map-reset {
  position: absolute;
  z-index: 500;
  top: 0.8rem;
  left: 0.8rem;
}

.panel-toggle {
  position: absolute;
  z-index: 500;
  top: 50%;
  right: 0.7rem;
  width: 1.7rem;
  height: 1.7rem;
  margin-top: -0.85rem;
  padding: 0.25rem;
  display: grid;
  place-items: center;
  background: var(--panel);
  color: var(--ink);
}

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

.panel-arrow {
  width: 0.95rem;
  height: 0.95rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.panel-toggle[aria-expanded="true"] .panel-arrow {
  transform: rotate(180deg);
}

button, .text-button {
  font: inherit;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 0.4rem 0.8rem;
  cursor: pointer;
}

button:hover, select:hover, input:hover { border-color: #b7ae9f; }

button:disabled {
  opacity: 0.55;
  cursor: default;
}

button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.detail-figure {
  font-size: 2rem;
  margin: 0.2rem 0 0.6rem;
  letter-spacing: -0.03em;
}

.org-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.org-card {
  border-top: 1px solid var(--line);
  padding-top: 0.7rem;
}

.org-card h4 { margin: 0 0 0.15rem; font-size: 1rem; }
.org-card p { margin: 0.15rem 0; color: var(--muted); font-size: 0.92rem; }
.org-card a { color: var(--green); }

.drawer {
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.drawer-bar {
  display: flex;
  align-items: center;
}

.drawer-toggle {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.4rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
  font-weight: 700;
  padding: 0.75rem 1.1rem;
}

.drawer-arrow {
  width: 0.95rem;
  height: 0.95rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drawer-toggle[aria-expanded="true"] .drawer-arrow {
  transform: rotate(180deg);
}

.refresh-data {
  flex: 0 0 auto;
  width: 1.7rem;
  height: 1.7rem;
  margin-right: 0.7rem;
  padding: 0.25rem;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
}

.refresh-data svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.refresh-data:hover { color: var(--ink); }

.refresh-data.is-refreshing svg { animation: refresh-spin 0.8s linear infinite; }

@keyframes refresh-spin { to { transform: rotate(360deg); } }

.drawer-body { padding: 0 1.1rem 1rem; }

.table-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

.tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; flex: 0 1 auto; }

.table-filter {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.table-filter input[type="search"] {
  width: 14rem;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  font-size: 0.95rem;
  padding: 0.4rem 0.65rem;
}

.tab[aria-selected="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.table-wrap { overflow: auto; max-height: 36vh; margin-top: 0.8rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { position: sticky; top: 0; background: #f7f3eb; font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
a.external-link {
  display: inline-flex;
  color: var(--green);
  line-height: 0;
}
a.external-link svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
a.external-link:hover { color: var(--ink); }
.pager { display: flex; align-items: center; gap: 0.8rem; margin-top: 0.6rem; }

body.about,
body.page {
  height: auto;
  min-height: 100%;
  overflow: auto;
  display: block;
}

.about-wrap,
.page-wrap {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.4rem 1.25rem 3rem;
}

.about-wrap h2,
.page-wrap h2 {
  margin: 2rem 0 0.45rem;
  font-size: 1.45rem;
}

.about-wrap p,
.about-wrap li,
.page-wrap p,
.page-wrap li {
  line-height: 1.5;
}

.about-wrap ul,
.about-wrap ol,
.page-wrap ul,
.page-wrap ol {
  padding-left: 1.2rem;
}

.formula {
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  font-family: Fraunces, Georgia, serif;
  font-size: 1.15rem;
}

.disclaimer {
  margin: 1.25rem 0 0;
  padding: 0.95rem 1rem 1rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--ink);
  border-radius: 12px;
  background: var(--panel);
}

.about-wrap .disclaimer h2 {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
}

.disclaimer p:last-child { margin-bottom: 0; }

.terms { margin: 0; }
.terms dt {
  margin-top: 0.9rem;
  font-weight: 700;
}
.terms dd { margin: 0.15rem 0 0; }

.method {
  width: 100%;
  margin: 0.6rem 0 0;
}
.method th,
.method td {
  font-size: 0.95rem;
}

.leaflet-container { font-family: inherit; background: var(--ocean); }
.leaflet-overlay-pane .context-country { pointer-events: none; }
.leaflet-control-attribution { font-size: 0.7rem; }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 280px 1fr; }
  .panel-right {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: 40vh;
  }
}

@media (max-width: 760px) {
  .topbar, .status { text-align: left; }
  .topbar { flex-direction: column; align-items: start; }
  .topnav { margin-left: 0; }
  .workspace { grid-template-columns: 1fr; }
  .map-wrap { height: 68vh; }
  .panel-left { border-right: 0; border-bottom: 1px solid var(--line); }
}

.page-foot {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem;
}

.tiers {
  display: grid;
  gap: 0.8rem;
}

.tier,
.notice,
.sponsor-list li,
.search-results li {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.tier { padding: 1rem 1rem 1.1rem; }
.tier h2 { margin: 0; font-size: 1.35rem; }
.tier .price {
  margin: 0.2rem 0 0.5rem;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.7rem;
}
.tier ul { margin: 0 0 0.8rem; }

.stack { display: grid; gap: 0.75rem; margin-top: 1.2rem; }
.stack label { display: grid; gap: 0.25rem; font-weight: 700; }
.stack input,
.stack select,
.stack textarea {
  font: inherit;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: inherit;
}
.stack textarea { min-height: 7rem; resize: vertical; }
.stack label[hidden],
.stack form[hidden],
form.stack[hidden],
.notice[hidden],
#search-actions[hidden] { display: none; }

.notice {
  margin: 0.8rem 0 0;
  padding: 0.75rem 0.9rem;
}
.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.search-results,
.sponsor-list { list-style: none; padding: 0; display: grid; gap: 0.55rem; }
.search-results li,
.sponsor-list li { padding: 0.75rem 0.9rem; }
.search-results p,
.sponsor-list .muted { margin: 0.25rem 0 0; color: var(--muted); }
.sponsor-list li { display: flex; gap: 0.75rem; align-items: center; }
.sponsor-list img { height: 32px; width: auto; }
#sponsor-checkout { margin-top: 1rem; }

.sponsor-footer:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.2rem;
  align-items: center;
  padding: 0.45rem 1.25rem;
  border-top: 1px solid var(--line);
  background: var(--panel);
  font-size: 0.92rem;
}
.sponsor-footer img { height: 26px; width: auto; }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
