:root {
  --ink: #142d3c;
  --muted: #5d6f7b;
  --teal: #187f83;
  --line: #dce3e7;
  --navy: #071d2d;
  --paper: #f2f6f7;
  --surface: #ffffff;
  --none: #e6ebee;
  --s1: #d3ebe9; --s2: #a4d4d1; --s3: #6cb8b6; --s4: #3a9799; --s5: #1c7479; --s6: #0b4d57;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: 'Inter', system-ui, sans-serif; font-size: 16px; line-height: 1.6; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
.wrap { width: min(1240px, calc(100% - 32px)); margin-inline: auto; }
.eyebrow { margin: 0 0 12px; font-size: 12px; font-weight: 600; letter-spacing: .14em; color: var(--teal); }

/* Header */
.m-header { position: sticky; top: 0; z-index: 20; height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 max(16px, calc((100% - 1240px) / 2)); background: #fff; border-bottom: 1px solid var(--line); }
.m-brand { display: flex; align-items: center; gap: 16px; text-decoration: none; }
.m-brand img { height: 40px; width: auto; display: block; }
.m-brand-divider { width: 1px; height: 34px; background: #b9c6cd; }
.m-brand-long { font-family: 'Montserrat', 'Inter', sans-serif; font-weight: 600; font-size: 13px; letter-spacing: .07em; line-height: 1.3; text-transform: uppercase; }
.m-back { font-size: 15px; font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--ink); padding: 6px 0; }
.m-back:hover { color: var(--teal); border-color: var(--teal); }

/* Intro */
.m-intro { padding: 56px 0 28px; }
.m-intro h1 { font-size: clamp(34px, 5vw, 56px); line-height: 1.1; }
.m-lead { max-width: 720px; margin: 18px 0 0; font-size: 18px; color: var(--muted); }

/* Controls */
.m-controls { display: flex; flex-wrap: wrap; gap: 20px 36px; align-items: flex-end; padding: 20px 0 8px; border-top: 1px solid var(--line); }
.m-control { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.m-label { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.m-year-row { display: flex; align-items: center; gap: 8px; }
.m-year-row output { min-width: 3.2em; text-align: center; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.m-step { width: 36px; height: 36px; border: 1px solid #b9c6cd; background: #fff; border-radius: 4px; font-size: 20px; line-height: 1; }
.m-step:hover:not(:disabled) { border-color: var(--ink); }
.m-step:disabled { opacity: .35; cursor: default; }
#year-range { width: 220px; margin-left: 8px; accent-color: var(--teal); }
.m-segment { display: inline-flex; border: 1px solid #b9c6cd; border-radius: 4px; overflow: hidden; background: #fff; }
.m-segment button { border: 0; background: transparent; padding: 8px 14px; font-size: 14px; font-weight: 500; min-height: 38px; }
.m-segment button + button { border-left: 1px solid #b9c6cd; }
.m-segment button[aria-checked="true"] { background: var(--ink); color: #fff; }
.m-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.m-chips button { border: 1px solid #b9c6cd; background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 500; min-height: 34px; }
.m-chips button:hover { border-color: var(--ink); }
.m-chips button[aria-checked="true"] { background: var(--teal); border-color: var(--teal); color: #fff; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* Stats */
.m-provisional { margin: 16px 0 0; display: inline-block; font-size: 13px; font-weight: 600; color: #7a4b00; background: #fff4dc; border: 1px solid #f0d49a; border-radius: 4px; padding: 4px 10px; }
.m-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.m-stat { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 16px 18px; }
.m-stat strong { display: block; font-size: clamp(22px, 2.6vw, 30px); line-height: 1.2; font-variant-numeric: tabular-nums; }
.m-stat span { font-size: 13px; color: var(--muted); }

/* Map */
.m-map-card { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 12px 12px 16px; }
.m-map svg { display: block; width: 100%; height: auto; }
.m-map .country { stroke: #fff; stroke-width: .5; vector-effect: non-scaling-stroke; cursor: pointer; }
.m-map .country:hover, .m-map .country.active, .m-map .dot:hover, .m-map .dot.active { stroke: var(--ink); stroke-width: 1.4; }
.m-map .dot { stroke: #fff; stroke-width: 1; cursor: pointer; }
.m-map .sphere { fill: #f7fafb; stroke: var(--line); }
.m-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 10px 6px 0; font-size: 13px; color: var(--muted); }
.m-legend .key { display: inline-flex; align-items: center; gap: 6px; }
.m-legend i { width: 18px; height: 12px; border-radius: 2px; display: inline-block; }
.m-legend .title { font-weight: 600; color: var(--ink); }
.m-tooltip { position: absolute; z-index: 5; width: 290px; pointer-events: none; background: #fff; border: 1px solid #c9d4da; border-radius: 6px; box-shadow: 0 8px 24px rgba(7, 29, 45, .14); padding: 12px 14px; font-size: 13px; line-height: 1.45; }
.m-tooltip h3 { font-size: 15px; margin-bottom: 2px; }
.m-tooltip .lead { font-size: 22px; font-weight: 700; color: var(--ink); }
.m-tooltip .lead small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.m-tooltip dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 8px 0 0; }
.m-tooltip dt { color: var(--muted); }
.m-tooltip dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.m-tooltip .event { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.m-tooltip .event b { display: block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--teal); margin-bottom: 2px; }
.m-tooltip .close { display: none; }

/* Lower panels */
.m-lower { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.m-panel { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 20px; min-width: 0; }
.m-panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 12px; }
.m-panel h2 { font-size: 20px; }
.m-hint { margin: 0; font-size: 13px; color: var(--muted); }
.m-table-wrap { overflow-x: auto; }
.m-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.m-table th { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--line); padding: 6px 8px; white-space: nowrap; }
.m-table td { border-bottom: 1px solid #edf1f3; padding: 8px; vertical-align: top; }
.m-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.m-table th.sorted { color: var(--ink); }
.m-table td.event { color: var(--muted); min-width: 160px; }
.m-more { margin-top: 12px; border: 1px solid #b9c6cd; background: #fff; border-radius: 4px; padding: 8px 14px; font-size: 14px; font-weight: 600; }
.m-more:hover { border-color: var(--ink); }
.m-trend svg { display: block; width: 100%; height: auto; overflow: visible; }
.m-trend .bar { cursor: pointer; }
.m-trend .axis text { font-size: 11px; fill: var(--muted); }
.m-trend .axis line, .m-trend .grid line { stroke: #e6ebee; }
.m-trend .axis path { display: none; }
.m-trend .label { font-size: 11px; fill: var(--ink); font-weight: 600; }

/* Notes */
.m-notes { padding: 40px 0 56px; }
.m-notes > h2 { font-size: 24px; margin-bottom: 16px; }
.m-notes-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.m-notes h3 { font-size: 16px; margin-bottom: 6px; }
.m-notes p { margin: 0 0 10px; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }

.m-footer { background: var(--navy); color: #a9bcc8; font-size: 13px; }
.m-footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding: 22px 0; }
.m-footer a { color: #d4e1e8; }

@media (max-width: 900px) {
  .m-lower { grid-template-columns: minmax(0, 1fr); }
  .m-notes-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .m-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .m-header { height: 64px; }
  .m-brand img { height: 30px; }
  .m-brand-long, .m-brand-divider { display: none; }
  .m-intro { padding: 36px 0 20px; }
  .m-lead { font-size: 16px; }
  .m-controls { gap: 16px; }
  .m-year-row { flex-wrap: wrap; }
  #year-range { width: 100%; margin: 4px 0 0; }
  .m-segment button { padding: 8px 10px; font-size: 13px; }
  .m-map-card { padding: 6px 6px 12px; }
  /* On small screens the tooltip becomes a bottom sheet opened by tapping a country */
  .m-tooltip { position: fixed; left: 8px !important; right: 8px; top: auto !important; bottom: 8px; width: auto; pointer-events: auto; padding-right: 44px; }
  .m-tooltip .close { display: block; position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; border: 0; background: transparent; font-size: 22px; line-height: 1; }
  .m-table td.event { display: none; }
  .m-table th:last-child { display: none; }
}
.m-provisional[hidden], .m-tooltip[hidden], .m-more[hidden] { display: none; }
.m-lower { align-items: start; }
@media (max-width: 640px) {
  .m-panel { padding: 16px 12px; }
  .m-table { font-size: 13px; }
  .m-table th { white-space: normal; padding: 6px 4px; vertical-align: bottom; }
  .m-table td { padding: 7px 4px; }
}
.m-source { margin: 8px 6px 0; font-size: 13px; color: var(--muted); } .m-source a { color: var(--ink); }
