/* Energy Flow Observatory — an atlas of trade and disruption. */
:root {
  color-scheme: light;
  --bg: #f4f0e6;
  --panel: #eae7dc;
  --panel2: #fbf8f1;
  --line: #c9c8bb;
  --line-soft: #deddd2;
  --text: #242b29;
  --muted: #5d685f;
  --faint: #626c65;
  --teal: #2c625a;
  --coral: #a64b36;
  --amber: #9a7439;
  --blue: #45677d;
  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; border: 0; background: none; }
button:disabled { cursor: default; opacity: .55; }
button, select { color: inherit; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, canvas:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }
button, select, input { transition: border-color .15s, background .15s, color .15s, opacity .15s; }
button:hover { color: var(--teal); }
input, select { min-width: 0; }
select { appearance: none; background: var(--panel2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='m3 4 3 3 3-3' fill='none' stroke='%234f5d53' stroke-width='1.3'/%3E%3C/svg%3E") no-repeat right 11px center; border: 1px solid #aeb5aa; border-radius: 0; padding: 10px 30px 10px 10px; font-size: 12px; height: 40px; width: 100%; }
select:hover { border-color: var(--text); }
input[type=range] { appearance: none; display: block; width: 100%; height: 3px; border-radius: 0; background: linear-gradient(to right, var(--teal) 0 var(--fill,50%), #c2c8bc var(--fill,50%) 100%); margin: 16px 0 10px; cursor: pointer; accent-color: var(--teal); }
input[type=range]::-webkit-slider-thumb { appearance: none; background: var(--panel2); width: 13px; height: 17px; border: 2px solid var(--teal); border-radius: 1px; }
input[type=range]::-moz-range-thumb { background: var(--panel2); width: 9px; height: 13px; border: 2px solid var(--teal); border-radius: 1px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; letter-spacing: -.035em; }
h1 { font-size: 31px; line-height: 1.12; margin-top: 11px; }
h2 { font-size: 36px; line-height: 1.16; }
h3 { font-size: 23px; line-height: 1.3; }
.eyebrow { font: 10px/1.5 var(--mono); letter-spacing: .1em; color: var(--teal); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip { position: fixed; z-index: 100; top: -60px; left: 20px; background: var(--text); color: var(--panel2); padding: 10px; }
.skip:focus { top: 10px; }

/* A masthead, section index and working ledger. */
.topbar { min-height: 100px; border-top: 5px solid var(--text); border-bottom: 1px solid var(--text); background: var(--bg); display: flex; align-items: center; gap: 43px; padding: 0 29px; position: sticky; top: 0; z-index: 30; }
.brand { display: flex; align-items: center; gap: 13px; min-width: 243px; font: 27px/1.03 var(--serif); letter-spacing: -.055em; }
.brand svg { width: 37px; height: 42px; stroke: var(--text); fill: var(--bg); stroke-width: 1.3; }
.brand-sub { display: block; font: 9px/1.5 var(--mono); color: var(--muted); letter-spacing: .24em; margin-top: 7px; }
.topnav { display: flex; align-self: stretch; gap: 29px; }
.nav-btn { position: relative; font-size: 12px; color: var(--muted); padding: 16px 0 13px; font-weight: 500; }
.nav-btn::before { display: block; font: 9px/1.5 var(--mono); color: var(--faint); margin-bottom: 4px; letter-spacing: .07em; }
.nav-btn[data-page=network]::before { content: "01"; }
.nav-btn[data-page=pairs]::before { content: "02"; }
.nav-btn[data-page=sensitivity]::before { content: "03"; }
.nav-btn[data-page=method]::before { content: "04"; }
.nav-btn.active { color: var(--text); }
.nav-btn.active::after { position: absolute; content: ""; bottom: -1px; height: 3px; left: 0; right: 0; background: var(--text); }
.nav-btn:hover { color: var(--text); }
.header-actions { display: flex; align-items: center; gap: 22px; margin-left: auto; }
.snapshot-badge { color: var(--muted); font: 9px/1.6 var(--mono); letter-spacing: .01em; white-space: nowrap; }
.snapshot-badge i { display: none; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--text); padding: 9px 14px; border-radius: 0; font-size: 11px; background: transparent; }
.button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.button:hover { background: var(--text); color: var(--panel2); border-color: var(--text); }
.app-shell { display: grid; grid-template-columns: 282px minmax(0,1fr); min-height: calc(100vh - 100px); }
.scenario-panel { background: var(--panel); border-right: 1px solid var(--line); padding: 31px 23px 26px; position: sticky; top: 100px; height: calc(100vh - 100px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: #aeb5aa transparent; }
.panel-heading { display: flex; justify-content: space-between; }
.panel-heading .eyebrow { color: var(--muted); }
.intro { font-size: 12px; line-height: 1.7; color: var(--muted); margin: 14px 0 29px; }
.field { margin-bottom: 19px; }
.field > label, .range-label label, .label-row label { display: block; font-size: 11px; color: #424f46; margin-bottom: 7px; font-weight: 500; }
.segmented { display: inline-flex; border: 1px solid #b5bcae; border-radius: 0; padding: 2px; background: transparent; gap: 1px; }
.segmented button { border-radius: 0; flex: 1; color: #5c675e; padding: 7px 13px; font-size: 11px; white-space: nowrap; }
.segmented button:hover { background: #e1e4d9; color: var(--text); }
.segmented button.active { background: var(--text); color: var(--panel2); }
.field .segmented { width: 100%; }
.product-segment { height: 41px; }
.product-segment button { font-size: 12px; }
.control-rule { border-top: 1px solid #bbc1b5; margin: 24px 0 23px; }
.range-field { margin-bottom: 22px; }
.range-label { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.range-label label { margin: 0; }
.range-label output { font: 19px var(--mono); letter-spacing: -.055em; color: var(--text); }
.range-label output span { font-size: 11px; color: var(--muted); margin-left: 2px; }
.range-ends { display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; margin-top: 12px; }
.help { font-size: 10px; color: var(--muted); line-height: 1.6; margin-top: 9px; }
.text-button { font-size: 11px; padding: 0; color: var(--teal); text-align: left; }
.text-button:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.add-shock { color: var(--teal); display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.add-shock span { font-size: 17px; }
.second-shock { border-left: 2px solid var(--teal); padding-left: 13px; margin-top: 16px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.run-button { margin-top: 5px; background: var(--text); color: var(--panel2); border: 1px solid var(--text); border-radius: 0; padding: 13px 14px; display: flex; justify-content: space-between; align-items: center; width: 100%; font-size: 12px; font-weight: 500; }
.run-button:hover { background: var(--teal); border-color: var(--teal); color: white; }
.run-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.scenario-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 15px; }
.scope-note { display: flex; align-items: flex-start; gap: 9px; margin-top: 29px; padding-top: 19px; border-top: 1px solid #bbc1b5; font-size: 10px; color: var(--muted); line-height: 1.75; }
.tiny-dot { display: inline-block; width: 5px; height: 5px; background: var(--amber); margin-top: 7px; flex-shrink: 0; }
main { min-width: 0; padding: 32px 30px 0; max-width: 1900px; width: 100%; margin: auto; align-self: start; }
.workspace-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 24px; }
.workspace-heading h2 { margin: 7px 0 9px; }
.workspace-heading p { color: var(--muted); font-size: 12px; line-height: 1.6; }
.workspace-heading .eyebrow { color: var(--muted); }
.status-pill { display: flex; align-items: center; font: 9px/1.5 var(--mono); color: var(--teal); padding: 5px 0; white-space: nowrap; }
.status-pill i { display: inline-block; width: 5px; height: 5px; background: var(--teal); margin-right: 7px; }
.status-pill.busy i { animation: pulse 1s infinite; }
.status-pill.error { color: var(--coral); }
.status-pill.error i { background: var(--coral); }
.metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); border-top: 1px solid var(--text); border-bottom: 1px solid var(--line); background: transparent; margin-bottom: 25px; }
.metric { padding: 18px 19px 22px; border-right: 1px solid var(--line); position: relative; min-height: 135px; }
.metric:first-child { padding-left: 0; }
.metric:last-child { border-right: 0; padding-right: 0; }
.metric > span { font-size: 11px; color: var(--muted); display: block; }
.metric strong { display: block; font: 40px/1.12 var(--serif); letter-spacing: -.055em; font-weight: 400; margin-top: 10px; font-variant-numeric: lining-nums tabular-nums; }
.metric:first-child strong { color: var(--teal); }
.metric strong .metric-unit { font: 15px var(--mono); color: var(--muted); margin-left: 5px; letter-spacing: -.02em; }
.metric small { font-size: 9px; color: var(--muted); display: block; margin-top: 7px; line-height: 1.5; }
.metric-meter { position: absolute; left: 0; right: 19px; bottom: -1px; height: 2px; background: var(--line); }
.metric-meter i { display: block; height: 100%; background: var(--teal); transition: width .35s; }

/* Cartographic plate and its reading tools. */
.view-toolbar { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; min-height: 37px; }
.toolbar-spacer { flex: 1; }
.search-wrap { display: flex; align-items: center; position: relative; max-width: 220px; width: 100%; }
.search-wrap > svg { position: absolute; left: 9px; width: 14px; height: 14px; fill: none; stroke: var(--muted); stroke-width: 1.5; }
.search-wrap input { background: transparent; border: 0; border-bottom: 1px solid #aeb5aa; border-radius: 0; width: 100%; color: var(--text); font-size: 11px; padding: 10px 26px 9px 31px; }
.search-wrap input::placeholder { color: var(--muted); }
.search-wrap button { position: absolute; right: 5px; color: var(--muted); font-size: 18px; }
.history-controls { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.history-controls select { width: 76px; height: 34px; font: 11px var(--mono); padding: 6px 25px 6px 9px; }
.network-card { background: var(--panel2); border-top: 2px solid var(--text); border-bottom: 1px solid var(--text); }
.network-heading { display: flex; justify-content: space-between; align-items: center; padding: 22px 21px 10px; gap: 15px; }
.network-heading h3 { font-size: 26px; }
.network-heading p { font-size: 11px; color: var(--muted); margin-top: 5px; }
.map-surface { height: clamp(400px,42vw,630px); position: relative; overflow: hidden; background: var(--panel2); touch-action: pan-y; }
#network-svg { width: 100%; height: 100%; display: block; user-select: none; cursor: grab; }
#network-svg:active { cursor: grabbing; }
#network-svg .land { fill: #e2e4d9; stroke: #a8b2a5; stroke-width: .45; vector-effect: non-scaling-stroke; }
#network-svg .graticule { fill: none; stroke: #bac4b5; stroke-width: .45; stroke-dasharray: 2 5; opacity: .65; }
#network-svg .flow { fill: none; pointer-events: stroke; cursor: pointer; transition: opacity .2s; }
#network-svg .flow:hover { opacity: 1 !important; stroke-width: 2.5 !important; }
#network-svg .country-node { cursor: pointer; stroke: var(--panel2); stroke-width: 1; transition: r .2s; }
#network-svg .country-node:hover { stroke: var(--text); stroke-width: 1.5; }
#network-svg .country-label { font: 8px var(--sans); fill: #49594d; pointer-events: none; paint-order: stroke; stroke: var(--panel2); stroke-width: 3px; stroke-linejoin: round; letter-spacing: .01em; }
#network-svg .shock-label { fill: var(--coral); font-weight: 600; }
#network-svg .focus-label { fill: var(--teal); font-weight: 600; }
.map-watermark { position: absolute; bottom: 15px; left: 21px; font: 8px var(--mono); letter-spacing: .12em; color: #617163; pointer-events: none; border-left: 1px solid #8d9a8e; padding-left: 9px; }
.map-watermark span { display: block; font-size: 6px; letter-spacing: .16em; margin-top: 4px; }
.map-controls { position: absolute; right: 18px; bottom: 15px; display: flex; border: 1px solid #afb8a9; background: var(--panel2); overflow: hidden; }
.map-controls button { font-size: 17px; color: var(--muted); padding: 5px 11px; border-right: 1px solid var(--line); }
.map-controls button:last-child { border-right: 0; }
.map-controls button:hover { background: var(--text); color: var(--panel2); }
.network-footer { display: flex; justify-content: space-between; align-items: center; padding: 13px 21px; border-top: 1px solid var(--line); gap: 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 18px; font-size: 9px; color: var(--muted); }
.legend span, .chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend-line { width: 19px; height: 0; border-top: 2px solid var(--teal); display: inline-block; }
.legend-line.gain { border-color: var(--teal); }
.legend-line.loss { border-color: var(--coral); border-top-style: dashed; }
.legend-dot { width: 5px; height: 5px; border-radius: 50%; background: #778b7a; display: inline-block; }
.display-controls { display: flex; align-items: center; gap: 9px; font-size: 10px; color: var(--muted); }
.display-controls select { height: 31px; width: 148px; font-size: 10px; padding: 5px 25px 5px 8px; background-color: transparent; }
.network-note { display: flex; justify-content: space-between; gap: 15px; color: var(--muted); font-size: 9px; border-top: 1px solid var(--line-soft); padding: 10px 21px; }
.network-tooltip { position: absolute; pointer-events: none; background: #fbf8f1fa; border: 1px solid var(--text); padding: 12px 15px; z-index: 9; box-shadow: 4px 5px 0 #242b2910; font-size: 11px; max-width: 280px; }
.network-tooltip strong { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 500; }
.tip-row { display: flex; justify-content: space-between; gap: 28px; color: var(--muted); font-size: 10px; line-height: 1.9; }
.tip-row b { font-family: var(--mono); font-weight: 500; color: var(--text); }
.tip-note { font-size: 9px; color: var(--muted); margin-top: 6px; }
.country-inspector { position: absolute; top: 16px; right: 18px; width: 245px; background: #fbf8f1f5; border-top: 3px solid var(--text); border-bottom: 1px solid var(--text); box-shadow: 4px 5px 0 #242b2910; padding: 17px; z-index: 8; }
.inspector-title { display: flex; justify-content: space-between; align-items: flex-start; }
.inspector-title h4 { margin: 3px 0 17px; font: 23px/1.1 var(--serif); font-weight: 400; letter-spacing: -.03em; }
.inspector-title button { font-size: 20px; color: var(--muted); line-height: 1; }
.inspector-values { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.inspector-values small { display: block; font-size: 9px; color: var(--muted); }
.inspector-values b { font: 18px var(--mono); display: block; margin-top: 5px; letter-spacing: -.05em; }
.inspector-links { border-top: 1px solid var(--line); margin-top: 17px; padding-top: 12px; }
.inspector-links > p { font-size: 9px; color: var(--muted); margin-bottom: 8px; }
.inspector-links button { display: flex; justify-content: space-between; gap: 10px; width: 100%; padding: 6px 0; font-size: 10px; text-align: left; }
.inspector-links button span:last-child { font-family: var(--mono); }
.map-loading { position: absolute; inset: 0; background: #fbf8f1ef; display: flex; align-items: center; justify-content: center; gap: 15px; color: var(--muted); font-size: 12px; z-index: 12; }
.loading-orbit { border: 1px solid #b3bfb0; border-top: 1px solid var(--teal); border-radius: 50%; width: 22px; height: 22px; animation: spin .9s linear infinite; }
#matrix-canvas { display: block; width: 100%; height: 100%; cursor: crosshair; object-fit: contain; }

/* Detailed ledgers, model plates and sensitivity. */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 32px; }
.surface { background: transparent; border-top: 1px solid var(--text); padding: 22px 0 0; min-width: 0; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 15px; }
.section-heading .eyebrow { color: var(--muted); font-size: 9px; }
.section-heading h3 { margin-top: 5px; }
.section-description { font-size: 10px; color: var(--muted); line-height: 1.7; margin-top: 10px; }
.table-scroll { overflow: auto; scrollbar-width: thin; scrollbar-color: #aeb5aa transparent; }
table { width: 100%; border-collapse: collapse; font-size: 11px; white-space: nowrap; }
th { text-align: left; font-weight: 400; color: var(--muted); font-size: 9px; border-bottom: 1px solid #a3ad9e; padding: 19px 0 11px; }
td { padding: 12px 0; border-bottom: 1px solid var(--line-soft); color: #455048; }
th:not(:first-child), td:not(:first-child) { text-align: right; padding-left: 12px; }
td:not(:first-child) { font-family: var(--mono); font-size: 10px; }
td:first-child button { padding: 0; text-align: left; color: var(--text); font-size: 11px; }
td:first-child button:hover { color: var(--teal); text-decoration: underline; text-underline-offset: 3px; }
tbody tr:hover { background: #e8eadd66; }
.country-code { font: 8px var(--mono); color: var(--muted); margin-left: 6px; }
.gain { color: var(--teal); }
.loss { color: var(--coral); }
.route-arrow { color: #899786; padding: 0 5px; }
.table-more { display: block; width: 100%; color: var(--teal); font-size: 10px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.table-more:hover { color: var(--text); background: #e8eadd66; }
.history-summary { margin-top: 22px; display: grid; grid-template-columns: repeat(3,1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.history-summary > div { padding: 16px 18px; border-right: 1px solid var(--line); }
.history-summary > div:first-child { padding-left: 0; }
.history-summary > div:last-child { border-right: 0; }
.history-summary strong { display: block; font: 28px var(--serif); color: var(--blue); margin-top: 6px; letter-spacing: -.03em; }
.history-summary small { color: var(--muted); font-size: 10px; }
.history-summary span { font-size: 11px; color: var(--muted); }
.workspace-footer { border-top: 1px solid var(--text); display: flex; justify-content: space-between; gap: 20px; padding: 21px 0; margin-top: 40px; color: var(--muted); font-size: 9px; }
.workspace-footer > span:first-child { font: 14px var(--serif); color: var(--text); }
.section-intro { margin: 34px 0 29px; max-width: 850px; }
.section-intro h2 { font-size: 35px; margin: 10px 0 13px; }
.section-intro p { font-size: 13px; color: var(--muted); max-width: 730px; line-height: 1.85; }
.sensitivity-stats { display: grid; grid-template-columns: repeat(3,1fr); margin-bottom: 29px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.sensitivity-stats > div { padding: 20px 22px; border-right: 1px solid var(--line); }
.sensitivity-stats > div:first-child { padding-left: 0; }
.sensitivity-stats > div:last-child { border-right: 0; }
.sensitivity-stats span { font-size: 11px; color: var(--muted); }
.sensitivity-stats strong { display: block; font: 36px var(--serif); letter-spacing: -.04em; color: var(--teal); margin: 9px 0 8px; }
.sensitivity-stats small { font-size: 10px; color: var(--muted); line-height: 1.65; display: block; }
.small-badge { font: 9px var(--mono); color: var(--muted); border-bottom: 1px solid var(--line); padding: 5px 0; }
.chart-container { width: 100%; min-height: 270px; }
.chart-container svg { display: block; width: 100%; height: auto; max-height: 350px; }
.chart-legend { display: flex; justify-content: center; gap: 26px; font-size: 10px; color: var(--muted); margin: 10px 0; }
.sensitivity-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 30px; margin-top: 32px; }
.heatmap-container { min-height: 235px; margin: 17px 0; }
.heatmap-container table { border-collapse: separate; border-spacing: 4px; }
.heatmap-container th { border: 0; font-size: 9px; padding: 4px; white-space: normal; text-align: center !important; }
.heatmap-container td { border: 1px solid transparent; text-align: center; padding: 17px 6px; font-size: 11px; }
.heatmap-container td:first-child { background: none !important; color: var(--muted); font: 10px var(--mono); padding-left: 0; text-align: left; }
.heatmap-container td.active-cell { outline: 1px solid var(--text); outline-offset: 1px; }
.chart-note { font-size: 10px; color: var(--muted); line-height: 1.8; }
.ranking-container { min-height: 235px; margin: 22px 0; }
.ranking-row { display: grid; grid-template-columns: 100px 1fr 44px; gap: 12px; align-items: center; margin: 17px 0; font-size: 10px; }
.ranking-row > span:first-child { color: #4c594f; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ranking-row .bar-track { height: 5px; background: #dce2d5; overflow: hidden; }
.ranking-row .bar-fill { height: 100%; background: #6a8076; }
.ranking-row.selected .bar-fill { background: var(--coral); }
.ranking-row > span:last-child { font: 10px var(--mono); text-align: right; color: #4c594f; }
.insight-strip { margin-top: 28px; border-top: 1px solid var(--teal); border-bottom: 1px solid var(--teal); padding: 19px 0; font: 17px/1.7 var(--serif); color: var(--teal); }
.method-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.method-grid h3 { font-size: 26px; margin: 12px 0 17px; }
.method-grid p { font-size: 12px; line-height: 1.95; color: #566158; margin-top: 14px; }
.formula { font-family: var(--serif); font-size: 23px; line-height: 1.75; text-align: center; padding: 20px; margin-top: 20px; background: #e9eadd; color: var(--text); border-top: 1px solid #bcc6b5; border-bottom: 1px solid #bcc6b5; }
.formula small { font-size: 16px; color: #54634f; }
.metric-definitions { margin: 32px 0; }
.metric-definitions table { white-space: normal; min-width: 660px; }
.metric-definitions td, .metric-definitions th { text-align: left !important; padding: 15px 20px 15px 0 !important; vertical-align: top; }
.metric-definitions td { font: 12px/1.8 var(--sans) !important; }
.metric-definitions td:nth-child(1) { width: 20%; color: var(--text); }
.metric-definitions td:nth-child(2) { width: 32%; font-family: var(--serif) !important; color: var(--teal); font-size: 14px !important; }
.metric-definitions td:nth-child(3) { color: var(--muted); }
#data-details { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 17px; }
#data-details p { font-size: 12px; line-height: 1.95; color: var(--muted); margin-top: 13px; }
#data-details strong { color: var(--text); font-weight: 500; }
.page { animation: fade-in .2s ease; }

/* The country-pair index is a directory, not a wall of cards. */
.pair-filters, .pairs-filters, .pair-controls { display: grid; grid-template-columns: 1.35fr 1fr 1fr 1fr; gap: 16px; margin: 22px 0; }
.pair-filters label, .pairs-filters label, .pair-controls label { display: block; color: var(--muted); font-size: 11px; margin-bottom: 7px; }
.pair-filters input, .pairs-filters input, .pair-controls input { width: 100%; min-width: 0; padding: 10px; height: 40px; border: 1px solid #aeb5aa; border-radius: 0; background: var(--panel2); color: var(--text); font-size: 12px; }
.pairs-summary, .pair-coverage { padding: 15px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.8; }
.pair-pagination, .pagination { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 0; font-size: 11px; color: var(--muted); }
.pair-pagination button, .pagination button, .pair-run { padding: 8px 12px; border: 1px solid #aeb5aa; font-size: 11px; }
.pair-pagination button:hover, .pagination button:hover, .pair-run:hover { border-color: var(--text); background: var(--text); color: var(--panel2); }
.pair-summary { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 25px 0; }
.pair-summary > div { padding: 18px 22px; border-right: 1px solid var(--line); }
.pair-summary > div:first-child { padding-left: 0; }
.pair-summary > div:last-child { border-right: 0; padding-right: 0; }
.pair-summary span { color: var(--muted); font-size: 11px; }
.pair-summary strong { display: block; font: 33px/1.25 var(--serif); letter-spacing: -.04em; color: var(--text); margin: 7px 0; }
.pair-summary small { color: var(--muted); font-size: 10px; }
.pair-table td { white-space: normal; }
.pair-table th:nth-child(2), .pair-table td:nth-child(2), .pair-table th:nth-child(4), .pair-table td:nth-child(4), .pair-table th:nth-child(5), .pair-table td:nth-child(5) { text-align: left; }
.pair-table td:nth-child(2) { font-family: var(--sans); font-size: 11px; }
.pair-table th:nth-child(4) { min-width: 130px; }
.pair-table td:nth-child(5) { min-width: 90px; }
.pair-table td button { padding: 7px 9px; border: 1px solid #aeb5aa; font-size: 10px; font-family: var(--sans); }
.pair-table td button:hover { background: var(--text); color: var(--panel2); border-color: var(--text); }
.pair-state { font: 10px/1.5 var(--sans); color: var(--muted); }
.pair-state.positive { color: var(--teal); }
.pair-state.zero { color: var(--blue); }
.pair-state.unknown { color: #866533; }
.pair-state.outside, .pair-state.self { color: var(--muted); }
.pair-coverage-note, .pair-route-note { font-size: 10px; line-height: 1.8; color: var(--muted); }
.pair-route-note { border-left: 2px solid #aeb5aa; padding-left: 10px; margin: 12px 0 18px; }
.pair-coverage-note { margin: 15px 0 22px; }
.pair-table .status, .pair-status, .pair-badge { font: 10px/1.5 var(--sans); color: var(--muted); }
.pair-status.positive, .pair-status.available { color: var(--teal); }
.pair-status.unavailable { color: var(--muted); }
.pair-note { color: var(--muted); font-size: 11px; line-height: 1.8; margin: 12px 0 20px; }

/* Dialogs and the narrow-screen control drawer. */
.mobile-only, .mobile-controls { display: none; }
.drawer-backdrop { position: fixed; inset: 0; background: #242b295e; z-index: 39; }
.icon-button { font-size: 24px; color: var(--muted); padding: 2px 6px; }
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); max-width: 90vw; background: var(--text); border: 1px solid var(--text); color: var(--panel2); padding: 13px 20px; box-shadow: 3px 4px 0 #242b2920; font-size: 12px; z-index: 100; }
dialog { border: 1px solid var(--text); border-top: 4px solid var(--text); border-radius: 0; background: var(--panel2); color: var(--text); padding: 29px; width: 460px; max-width: calc(100vw - 35px); box-shadow: 7px 8px 0 #242b2920; }
dialog::backdrop { background: #242b296e; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; }
.dialog-heading h3 { font-size: 29px; margin: 8px 0 18px; }
dialog > p { font-size: 12px; color: var(--muted); line-height: 1.85; margin-bottom: 24px; }
.export-option { display: block; position: relative; text-align: left; border-top: 1px solid var(--line); padding: 17px 25px 17px 0; width: 100%; }
.export-option:last-child { border-bottom: 1px solid var(--line); }
.export-option span { font-size: 13px; display: block; }
.export-option small { display: block; color: var(--muted); font-size: 10px; margin-top: 5px; }
.export-option b { position: absolute; right: 4px; top: 23px; color: var(--teal); }
.export-option:hover { background: #e9eadd; padding-left: 10px; }
.loading-label { padding: 70px 20px; text-align: center; color: var(--muted); font-size: 12px; }
.empty-row { text-align: center !important; color: var(--muted); padding: 26px 0 !important; }
.error-banner { background: #f4e5da; border-left: 3px solid var(--coral); padding: 16px 20px; color: #813b2d; font-size: 12px; margin: 16px 0; }
.dimmed { opacity: .55; pointer-events: none; }
@keyframes pulse { 50% { opacity: .3; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: .4; transform: translateY(2px); } to { opacity: 1; transform: translateY(0); } }

@media (min-width: 1600px) {
  main { padding: 38px 44px 0; }
  .app-shell { grid-template-columns: 306px minmax(0,1fr); }
  .scenario-panel { padding-left: 30px; padding-right: 30px; }
  .topbar { gap: 66px; padding: 0 32px; }
  .map-surface { height: 620px; }
  .metric { padding: 22px 28px 26px; }
  .metric strong { font-size: 46px; }
  .network-heading { padding: 25px 27px 12px; }
  .detail-grid, .sensitivity-grid, .method-grid { gap: 38px; }
}
@media (max-width: 1250px) {
  .topbar { gap: 25px; padding: 0 23px; }
  .brand { min-width: 219px; font-size: 25px; }
  .snapshot-badge { display: none; }
  .app-shell { grid-template-columns: 266px minmax(0,1fr); }
  .scenario-panel { padding: 29px 19px; }
  .topnav { gap: 25px; }
  main { padding: 29px 24px 0; }
  .metric { padding: 17px 15px 22px; }
  .metric strong { font-size: 34px; }
  .metric small { font-size: 8px; }
  .network-heading { padding: 20px 17px 8px; }
  .legend { gap: 12px; font-size: 8px; }
  .network-footer { padding: 12px 17px; }
  .detail-grid { grid-template-columns: 1fr; }
  .table-scroll { max-height: 500px; }
  .sensitivity-grid { grid-template-columns: 1fr; }
  .network-note { padding: 10px 17px; font-size: 8px; }
  .view-toolbar { gap: 9px; }
  .mode-segment button { padding: 7px 10px; font-size: 10px; }
  .search-wrap { max-width: 180px; }
  .history-controls { gap: 5px; }
  .history-controls label { display: none; }
  .history-controls select { width: 65px; font-size: 10px; }
  .workspace-heading h2 { font-size: 31px; }
  .method-grid { gap: 23px; }
}
@media (max-width: 950px) {
  .topbar { min-height: 85px; padding: 0 22px; gap: 26px; }
  .brand { min-width: 0; font-size: 24px; margin-right: auto; }
  .brand svg { width: 31px; height: 37px; }
  .brand-sub { font-size: 8px; }
  .header-actions { margin-left: 0; }
  .topnav { gap: 25px; }
  .nav-btn { font-size: 11px; }
  .app-shell { display: block; }
  .scenario-panel { position: fixed; left: 0; top: 0; bottom: 0; height: 100dvh; width: 310px; z-index: 40; transform: translateX(-100%); transition: transform .23s ease; border-right: 1px solid #8d9a86; padding: 29px 25px; }
  .scenario-panel.open { transform: translateX(0); }
  .mobile-only { display: block; }
  .mobile-controls { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 32; background: var(--text); color: var(--panel2); padding: 13px 23px; border: 1px solid var(--panel2); display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 500; box-shadow: 3px 4px 0 #242b2920; white-space: nowrap; }
  .mobile-controls:hover { background: var(--teal); color: white; }
  .mobile-controls svg { width: 16px; height: 16px; stroke: currentColor; fill: var(--text); stroke-width: 1.5; }
  .workspace-footer { margin-bottom: 69px; }
  .map-surface { height: 480px; }
  .metric small { font-size: 9px; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .sensitivity-grid { grid-template-columns: 1fr 1fr; }
  .network-note { font-size: 9px; }
  .legend { font-size: 9px; }
  .workspace-heading { margin-top: 3px; }
  main { padding: 29px 24px 0; }
  .history-controls label { display: inline; }
  .history-controls select { width: 76px; font-size: 11px; }
  .country-inspector { width: 225px; padding: 15px; }
}
@media (max-width: 700px) {
  .topbar { padding: 0 16px; min-height: 112px; gap: 0; flex-wrap: wrap; align-content: center; }
  .brand { font-size: 24px; gap: 11px; height: 63px; order: 0; }
  .brand-sub { font-size: 7px; letter-spacing: .24em; margin-top: 5px; }
  .brand svg { width: 28px; height: 33px; }
  .topnav { gap: 0; width: 100%; height: 43px; order: 2; justify-content: space-between; border-top: 1px solid var(--line); }
  .nav-btn { font-size: 10px; padding: 9px 0 10px; display: flex; align-items: center; gap: 6px; }
  .nav-btn::before { font-size: 8px; margin: 0; }
  .header-actions { order: 1; }
  .header-actions .button { padding: 8px 10px; font-size: 10px; gap: 6px; }
  .header-actions .button svg { width: 12px; height: 12px; }
  main { padding: 24px 16px 0; }
  .workspace-heading { gap: 10px; align-items: flex-start; margin-bottom: 22px; }
  .workspace-heading h2 { font-size: 30px; }
  .workspace-heading p { font-size: 10px; line-height: 1.75; max-width: 260px; }
  .workspace-heading .eyebrow { font-size: 9px; }
  .status-pill { font-size: 8px; padding: 5px 0; margin-top: 3px; }
  .status-pill i { width: 4px; height: 4px; margin-right: 5px; }
  .metrics { grid-template-columns: repeat(2,1fr); margin-bottom: 22px; }
  .metric { min-height: 116px; padding: 16px; }
  .metric:nth-child(2) { border-right: 0; padding-right: 0; }
  .metric:nth-child(3) { padding-left: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .metric > span { font-size: 10px; }
  .metric strong { font-size: 36px; margin-top: 7px; }
  .metric small { font-size: 8px; }
  .view-toolbar { flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
  .toolbar-spacer { display: none; }
  .mode-segment { margin-right: auto; }
  .mode-segment button { font-size: 10px; padding: 7px 10px; }
  .search-wrap { max-width: 155px; width: 40%; }
  .search-wrap input { font-size: 10px; padding-left: 26px; }
  .search-wrap > svg { left: 6px; }
  .history-controls { order: 3; width: 100%; }
  .network-heading { padding: 17px 13px 10px; align-items: flex-start; gap: 9px; }
  .network-heading h3 { font-size: 23px; }
  .network-heading p { font-size: 9px; line-height: 1.65; max-width: 200px; }
  .view-segment button { padding: 6px 7px; font-size: 9px; }
  .map-surface { height: 385px; }
  .network-footer { padding: 12px 13px; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
  .legend { font-size: 8px; gap: 12px; }
  .display-controls { width: 100%; justify-content: flex-end; font-size: 9px; }
  .display-controls select { height: 29px; font-size: 9px; width: 140px; }
  .network-note { font-size: 8px; line-height: 1.65; flex-direction: column; gap: 5px; padding: 10px 13px; }
  .map-watermark { font-size: 6px; left: 13px; bottom: 13px; }
  .map-watermark span { font-size: 5px; }
  .map-controls { right: 11px; bottom: 11px; }
  .map-controls button { padding: 4px 9px; font-size: 15px; }
  .country-inspector { top: 12px; right: 13px; width: 210px; max-height: calc(100% - 60px); overflow: auto; padding: 13px; }
  .inspector-title h4 { font-size: 21px; margin-bottom: 12px; }
  .inspector-values b { font-size: 16px; }
  .detail-grid, .sensitivity-grid, .method-grid { grid-template-columns: 1fr; gap: 27px; margin-top: 28px; }
  .surface { padding: 20px 0 0; }
  .section-heading h3 { font-size: 23px; }
  .section-description { font-size: 10px; }
  .table-scroll { max-height: 460px; }
  td { padding: 11px 0; }
  td:first-child button { font-size: 10px; }
  .country-code { font-size: 7px; }
  .history-summary > div { padding: 14px 12px; }
  .history-summary strong { font-size: 24px; }
  .history-summary span { font-size: 9px; }
  .history-summary small { font-size: 8px; }
  .section-intro { margin: 28px 0 24px; }
  .section-intro h2 { font-size: 31px; line-height: 1.2; }
  .section-intro p { font-size: 12px; }
  .sensitivity-stats { grid-template-columns: 1fr; }
  .sensitivity-stats > div { display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 16px 0; border-right: 0; border-bottom: 1px solid var(--line); gap: 4px; }
  .sensitivity-stats > div:last-child { border-bottom: 0; }
  .sensitivity-stats strong { grid-column: 2; grid-row: 1/3; font-size: 34px; margin: 0 0 0 20px; }
  .sensitivity-stats small { max-width: 260px; font-size: 9px; }
  .sensitivity-stats span { font-size: 10px; }
  .chart-container { min-height: 210px; }
  .chart-container svg { min-height: 220px; }
  .chart-legend { gap: 13px; font-size: 8px; flex-wrap: wrap; }
  .small-badge { font-size: 7px; padding: 5px 0; }
  .insight-strip { font-size: 16px; padding: 17px 0; }
  .method-grid h3 { font-size: 25px; }
  .method-grid p { font-size: 12px; }
  .formula { font-size: 22px; }
  .formula small { font-size: 15px; }
  #data-details { grid-template-columns: 1fr; gap: 12px; }
  #data-details p { font-size: 12px; }
  .workspace-footer { font-size: 8px; line-height: 1.6; }
  .workspace-footer > span:first-child { font-size: 12px; }
  .workspace-footer > span:last-child { max-width: 170px; text-align: right; }
  .network-tooltip { max-width: 235px; padding: 10px 13px; font-size: 10px; }
  .network-tooltip strong { font-size: 11px; }
  .tip-row { font-size: 9px; }
  .pair-filters, .pairs-filters, .pair-controls { grid-template-columns: 1fr 1fr; gap: 12px; }
  .pair-filters > :first-child { grid-column: 1/-1; }
  .pair-summary { grid-template-columns: 1fr 1fr; }
  .pair-summary > div { padding: 15px; }
  .pair-summary > div:nth-child(2) { border-right: 0; }
  .pair-summary > div:nth-child(3) { padding-left: 0; }
  .pair-summary > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .pair-summary strong { font-size: 30px; }
  .pair-summary span, .pair-summary small { font-size: 9px; }
  .pair-pagination, .pagination { gap: 8px; font-size: 10px; }
  .pair-pagination button, .pagination button { padding: 7px 9px; }
}
@media (max-width: 380px) {
  .topbar { padding-left: 12px; padding-right: 12px; }
  .brand { font-size: 22px; }
  .nav-btn { font-size: 9px; gap: 4px; }
  .workspace-heading h2 { font-size: 27px; }
  .status-pill { max-width: 63px; white-space: normal; line-height: 1.6; }
  .view-toolbar .search-wrap { max-width: none; width: 100%; }
  .network-heading { flex-wrap: wrap; gap: 12px; }
  .network-heading .view-segment { margin-left: auto; }
  .metric strong { font-size: 33px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
@media print {
  .topbar, .scenario-panel, .mobile-controls, .view-toolbar, .map-controls, .header-actions, .workspace-footer, .text-button, .table-more { display: none !important; }
  .app-shell { display: block; }
  body { background: white; color: black; }
  main { padding: 0; width: 100%; max-width: none; }
  .surface, .network-card, .metrics { break-inside: avoid; }
}

/* Reading position remains below the fixed masthead when changing sections. */
main { scroll-margin-top: 117px; }
.pair-intro { max-width: 760px; color: var(--muted); margin: 0 0 23px; font-size: 13px; line-height: 1.8; }
@media (max-width: 950px) { main { scroll-margin-top: 126px; } }

.guide-download { display:flex; align-items:center; justify-content:space-between; gap:24px; }
.guide-download p { margin-top:8px; color:var(--muted); font-size:12px; }
.guide-download .button { flex-shrink:0; }
@media(max-width:650px) { .guide-download { display:block; } .guide-download .button { margin-top:17px; } }
