:root {
    --bg: #f4f6fa;
    --card: #ffffff;
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --line-2: #f1f5f9;
    --accent: #2563eb;
    --good: #16a34a;
    --warn: #d97706;
    --bad: #dc2626;
    --import: #16a34a;
    --export: #ea580c;
    --radius: 14px;
    --sign: #f5c400;
    --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .05);
    color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
code { background: var(--line-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.wrap { max-width: 1480px; margin: 0 auto; padding: 0 20px; }
[hidden] { display: none !important; }

/* Masthead and introduction */
@font-face {
    font-family: "Source Serif 4";
    src: url("fonts/source-serif-4-latin-wght.woff2") format("woff2");
    font-weight: 200 900;
    font-style: normal;
    font-display: swap;
}
.masthead { background: var(--card); border-bottom: 1px solid var(--line); }
.masthead-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 16px; padding-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 20px; height: 26px; fill: none; stroke: var(--ink); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.brand-name { font-family: var(--serif); font-size: 19px; font-weight: 650; letter-spacing: -.01em; }
.status { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #94a3b8; flex: none; }
.live-dot.ok { background: var(--good); box-shadow: 0 0 0 0 rgba(22, 163, 74, .5); animation: pulse 2s infinite; }
.live-dot.stale { background: var(--warn); }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); } 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); } }

.intro { display: grid; grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); gap: 64px; padding-top: 40px; padding-bottom: 46px; }
.intro-lead { font-family: var(--serif); }
#headline { font-size: clamp(30px, 3.4vw, 46px); line-height: 1.12; font-weight: 620; letter-spacing: -.018em; max-width: 24ch; text-wrap: balance; }
.headline-sub { margin: 16px 0 0; font-size: 20px; line-height: 1.5; color: var(--ink-2); max-width: 52ch; }
.headline-sub:empty { display: none; }
.intro-text { margin: 14px 0 0; font-size: 17px; line-height: 1.68; color: var(--ink-2); max-width: 66ch; }
.headline-sub + .intro-text, #headline + .headline-sub:empty + .intro-text { margin-top: 30px; }
.intro-facts { margin: 6px 0 0; padding-left: 26px; border-left: 3px solid var(--sign); display: grid; gap: 18px; align-content: start; }
.intro-facts dt { font-size: 13px; color: var(--muted); }
.intro-facts dd { margin: 2px 0 0; font-size: 15px; color: var(--ink); }

main { padding-top: 20px; padding-bottom: 12px; display: grid; gap: 18px; }
.notice { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 12px 16px; border-radius: var(--radius); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.foot { margin: 12px 0 0; }

/* Dials */
.dials { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 14px; }
.dial { padding: 14px 14px 10px; text-align: center; }
.dial h2 { font-size: 13px; color: var(--ink-2); font-weight: 600; text-align: left; }
.gauge svg { width: 100%; height: auto; display: block; }
.gauge .g-track { stroke: var(--line-2); }
.gauge .g-val-text { font-size: 30px; font-weight: 700; fill: var(--ink); }
.gauge .g-unit { font-size: 12px; fill: var(--muted); }
.gauge .g-lim { font-size: 10px; fill: #94a3b8; }
.gauge .g-arc { transition: d .6s ease; }
.dial .sub { margin: 2px 0 6px; font-size: 12.5px; color: var(--muted); min-height: 1.45em; }
.spark svg { width: 100%; height: 34px; display: block; }
.spark .s-line { fill: none; stroke-width: 1.5; }
.spark .s-area { opacity: .12; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; box-shadow: var(--shadow); }
.stat .k { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 21px; font-weight: 700; margin-top: 2px; }
.stat .v small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.stat .d { font-size: 11.5px; color: var(--muted); }
.swatch { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: none; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 18px; }

/* Mix bars */
.mix-split { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--line-2); margin-bottom: 14px; }
.mix-split span { display: block; height: 100%; transition: width .6s ease; }
.mix { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.mix li { display: grid; grid-template-columns: 170px minmax(0, 1fr) 82px 52px; align-items: center; gap: 10px; font-size: 13.5px; }
.mix .name { display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 10px; background: var(--line-2); border-radius: 5px; overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 5px; transition: width .6s ease; }
.num { text-align: right; font-weight: 600; }
.pct { text-align: right; color: var(--muted); }

/* Interconnectors */
.ic-scale { display: flex; justify-content: space-between; margin: -4px 0 8px; padding-left: 150px; }
.ic { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ic li { display: grid; grid-template-columns: 140px minmax(0, 1fr) 80px; gap: 10px; align-items: center; font-size: 13.5px; }
.ic .who b { display: block; font-weight: 600; }
.ic .who span { font-size: 12px; color: var(--muted); }
.flow { position: relative; height: 12px; background: var(--line-2); border-radius: 6px; }
.flow::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: #cbd5e1; }
.flow span { position: absolute; top: 0; bottom: 0; border-radius: 6px; transition: all .6s ease; }
.flow .imp { left: 50%; background: var(--import); }
.flow .exp { right: 50%; background: var(--export); }
.ic .num.imp { color: var(--import); }
.ic .num.exp { color: var(--export); }
.ic .num small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }

/* Map */
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; }
#map { height: 640px; border-radius: 10px; border: 1px solid var(--line); z-index: 0; }
.map-side h3 { margin: 14px 0 6px; font-size: 13px; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin-bottom: 10px; cursor: pointer; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.legend label { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; padding: 2px 0; }
.legend .cnt { margin-left: auto; color: var(--muted); font-size: 12px; }
.top-list { margin: 0; padding-left: 20px; font-size: 13px; display: grid; gap: 3px; }
.top-list li span { color: var(--muted); float: right; }
.top-list button { all: unset; cursor: pointer; color: var(--ink); }
.top-list button:hover { text-decoration: underline; }
.leaflet-container { font: inherit; }
.st-pop { min-width: 210px; font-size: 13px; }
.st-pop h4 { margin: 0 0 2px; font-size: 14px; }
.st-pop dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 8px 0 6px; }
.st-pop dt { color: var(--muted); }
.st-pop dd { margin: 0; text-align: right; font-weight: 600; }
.st-pop .spark svg { height: 40px; }
.ic-line { stroke-dasharray: 8 8; }
.ic-line.import { animation: flow-in 1.2s linear infinite; }
.ic-line.export { animation: flow-out 1.2s linear infinite; }
@keyframes flow-in { from { stroke-dashoffset: 0; } to { stroke-dashoffset: 16; } }
@keyframes flow-out { from { stroke-dashoffset: 16; } to { stroke-dashoffset: 0; } }

/* Charts */
.charts { display: grid; gap: 14px; }
.charts-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.charts-bar h2 { font-size: 17px; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; box-shadow: var(--shadow); }
.seg button { border: 0; background: none; font: inherit; font-size: 13.5px; padding: 6px 14px; border-radius: 7px; cursor: pointer; color: var(--ink-2); }
.seg button:hover { background: var(--line-2); }
.seg button.active { background: var(--ink); color: #fff; }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.chart.wide { grid-column: 1 / -1; }
.canvas-box { position: relative; height: 280px; }
.canvas-box.tall { height: 380px; }
.chart .empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; }

.footer { padding-top: 8px; padding-bottom: 32px; }
.footer p { margin: 6px 0; }
#sources { display: flex; flex-wrap: wrap; gap: 6px 14px; }
#sources .src::before { content: "●"; margin-right: 5px; color: var(--good); }
#sources .src.fail::before { color: var(--bad); }

@media (max-width: 1280px) {
    .dials { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
    .intro { grid-template-columns: minmax(0, 1fr); gap: 30px; }
    .intro-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 28px; }
    .grid-2, .chart-grid, .map-layout { grid-template-columns: minmax(0, 1fr); }
    #map { height: 480px; }
}
@media (max-width: 640px) {
    .wrap { padding: 0 16px; }
    .dials { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    /* Seven dials: the odd one out gets the full row, with its gauge kept dial-sized. */
    .dials > .dial:last-child { grid-column: 1 / -1; }
    .dials > .dial:last-child .gauge { max-width: 200px; margin: 0 auto; }
    .gauge .g-val-text { font-size: 34px; }
    .mix li { grid-template-columns: 120px minmax(0, 1fr) 64px; }
    .mix .pct { display: none; }
    .ic li { grid-template-columns: 100px minmax(0, 1fr) 66px; }
    .ic-scale { padding-left: 110px; }
    .intro { padding-top: 26px; padding-bottom: 32px; }
    .headline-sub { font-size: 18px; }
    .intro-text { font-size: 16px; }
    .intro-facts { grid-template-columns: minmax(0, 1fr); padding-left: 18px; }
    .brand-name { font-size: 17px; white-space: nowrap; }
    .status { font-size: 12.5px; text-align: right; }
    .seg button { padding: 6px 9px; }
    .canvas-box, .canvas-box.tall { height: 260px; }
}
