/* EMEA Crude Oil Market Monitor — institutional research-terminal styling.
   Two themes (Institutional Light / Terminal Dark) share ONE set of semantic tokens; every
   component below is written against those tokens (never a raw hex), so switching
   html[data-theme] re-themes the entire app with no per-component changes needed. The existing
   --ink/--navy/--paper/etc. names are kept as aliases onto the new semantic tokens so none of
   the ~600 lines of already-approved component CSS below this block had to change — only the
   token DEFINITIONS did. Status colors (Actual/Forecast/Derived/Scenario/Estimated/Gap) are
   unchanged in MEANING between themes — only brightened/darkened per theme for contrast; the
   taxonomy itself is not altered here (out of scope — see the visual-redesign brief). */

:root {
  /* ---- semantic tokens (Institutional Light — default) ---- */
  --bg-app: #f4f5f7;
  --bg-panel: #ffffff;
  --bg-alt: #eef0f3;
  --bg-elevated: #ffffff;
  --text-primary: #1a1f2b;
  --text-secondary: #4a5568;
  --text-muted: #6b7280;
  --border-subtle: #e2e5ea;
  --border-strong: #c7ccd6;
  --accent-primary: #1f3864;
  --accent-primary-soft: #eef1f7;
  --accent-secondary: #a8791f;
  --positive: #2e7d32;
  --positive-soft: #eaf3ea;
  --caution: #8d6e00;
  --caution-soft: #f8f2df;
  --negative: #b3261e;
  --negative-soft: #fbeceb;
  --focus-ring: #1f3864;
  --scenario: #6a1b9a;
  --scenario-soft: #f3ebf8;
  --chart-grid: #e2e5ea;
  --chart-axis: #4a5568;
  --chart-tooltip-bg: #1a1f2b;
  --chart-tooltip-text: #f2f4f7;
  --shadow: 0 1px 2px rgba(20, 24, 33, 0.06), 0 1px 1px rgba(20, 24, 33, 0.04);
  --overlay: rgba(20, 24, 33, 0.45);

  /* ---- legacy names kept as aliases so existing component CSS is untouched ---- */
  --ink: var(--text-primary);
  --ink-soft: var(--text-secondary);
  --paper: var(--bg-panel);
  --paper-alt: var(--bg-alt);
  --line: var(--border-subtle);
  --navy: var(--accent-primary);
  --navy-soft: var(--accent-primary-soft);
  --orange: #c55a11;
  --orange-soft: #fbeee4;
  --green: var(--positive);
  --green-soft: var(--positive-soft);
  --plum: var(--scenario);
  --plum-soft: var(--scenario-soft);
  --ochre: var(--caution);
  --ochre-soft: var(--caution-soft);
  --grey: var(--text-muted);
  --grey-soft: #f0f1f3;
  --danger: var(--negative);
  --danger-soft: var(--negative-soft);
  --radius: 8px;
  --max-width: 1180px;
  font-size: 16px;
}

/* Terminal Dark — deep charcoal-navy, never pure black; every accent brightened for contrast
   against a dark panel, never the same hex as its light-theme counterpart. The dark token block
   is defined ONCE (in the shared %dark-tokens comment below, duplicated into the two selectors
   that need it — plain CSS has no mixins) and applies in two cases: (1) the user has no saved
   preference or chose "system" AND the OS prefers dark — the :not([data-theme="light"]):not(
   [data-theme="dark"]) guard stops this from fighting an explicit choice in either direction;
   (2) the user explicitly chose "dark" — html[data-theme="dark"], which applies regardless of
   OS preference. See theme.js for how/when data-theme is set (before first paint). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg-app: #1c2128;
    --bg-panel: #242a33;
    --bg-alt: #2b323c;
    --bg-elevated: #2b323c;
    --text-primary: #e8eaed;
    --text-secondary: #b0b7c3;
    --text-muted: #838c99;
    --border-subtle: #363d47;
    --border-strong: #4a525e;
    --accent-primary: #5b8dc9;
    --accent-primary-soft: #1e2c3f;
    --accent-secondary: #d1a659;
    --positive: #4caf60;
    --positive-soft: #1c3324;
    --caution: #d1a659;
    --caution-soft: #3a2f18;
    --negative: #e0655f;
    --negative-soft: #3d1f1d;
    --focus-ring: #5b8dc9;
    --scenario: #b287d1;
    --scenario-soft: #332140;
    --chart-grid: #363d47;
    --chart-axis: #b0b7c3;
    --chart-tooltip-bg: #2b323c;
    --chart-tooltip-text: #e8eaed;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 2px 12px rgba(0, 0, 0, 0.28);
    --overlay: rgba(0, 0, 0, 0.55);
    --orange: #e08a4e;
    --orange-soft: #3d2a1a;
    --grey-soft: #2d333c;
    color-scheme: dark;
  }
}
html[data-theme="dark"] {
  --bg-app: #1c2128;
  --bg-panel: #242a33;
  --bg-alt: #2b323c;
  --bg-elevated: #2b323c;
  --text-primary: #e8eaed;
  --text-secondary: #b0b7c3;
  --text-muted: #838c99;
  --border-subtle: #363d47;
  --border-strong: #4a525e;
  --accent-primary: #5b8dc9;
  --accent-primary-soft: #1e2c3f;
  --accent-secondary: #d1a659;
  --positive: #4caf60;
  --positive-soft: #1c3324;
  --caution: #d1a659;
  --caution-soft: #3a2f18;
  --negative: #e0655f;
  --negative-soft: #3d1f1d;
  --focus-ring: #5b8dc9;
  --scenario: #b287d1;
  --scenario-soft: #332140;
  --chart-grid: #363d47;
  --chart-axis: #b0b7c3;
  --chart-tooltip-bg: #2b323c;
  --chart-tooltip-text: #e8eaed;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 2px 12px rgba(0, 0, 0, 0.28);
  --overlay: rgba(0, 0, 0, 0.55);
  --orange: #e08a4e;
  --orange-soft: #3d2a1a;
  --grey-soft: #2d333c;
  color-scheme: dark;
}
html[data-theme="light"] {
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  transition: background-color 0.15s ease, color 0.15s ease;
}

h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; margin: 0 0 0.3em; }
p { margin: 0 0 0.6em; color: var(--ink-soft); }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--navy);
  color: #fff;
  padding: 0.6em 1em;
  z-index: 1000;
}
.skip-link:focus { left: 0; }

/* ---------------- Masthead ---------------- */
/* A calm, neutral panel — not a bold colored band — matching an institutional research terminal
   rather than a corporate marketing banner. The brand mark + a sliver of --accent-secondary
   carries the "oil/energy" identity instead of a full-bleed color fill. */

.masthead {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  padding: 1rem 1.5rem 0;
}
.mast-top {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  flex-wrap: wrap;
}
.mast-mark { width: 30px; height: 30px; flex: none; margin-top: 0.15rem; }
.mast-titles { min-width: 0; }
.mast-title { font-size: 1.35rem; color: var(--text-primary); }
.mast-title-sub { font-weight: 500; color: var(--text-muted); font-size: 0.85em; }
.mast-subtitle { font-size: 0.88rem; color: var(--text-secondary); max-width: 62ch; margin: 0.25rem 0 0; }

.mast-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.release-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.1rem;
  padding: 0.5rem 0.8rem;
  background: var(--bg-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}
.banner-fact { display: flex; flex-direction: column; font-size: 0.78rem; }
.banner-fact-label { color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.65rem; }
.banner-fact-value { font-weight: 600; color: var(--text-primary); }
.banner-fact.tone-ok .banner-fact-value { color: var(--positive); }
.banner-fact.tone-warn .banner-fact-value { color: var(--caution); }

.mast-bottom {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.6rem 0 0.7rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
}
.vintage-note { font-size: 0.78rem; color: var(--text-muted); margin: 0; flex: 1 1 320px; }
.vintage-note strong { color: var(--text-secondary); }
.methodology-link {
  margin-left: auto;
  background: var(--bg-panel);
  color: var(--accent-primary);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.methodology-link:hover { background: var(--accent-primary-soft); }

/* ---------------- Theme toggle ---------------- */

.theme-toggle {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  overflow: hidden;
  flex: none;
}
.theme-toggle-btn {
  background: var(--bg-panel);
  color: var(--text-secondary);
  border: none;
  border-right: 1px solid var(--border-strong);
  padding: 0.4rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
}
.theme-toggle-btn:last-child { border-right: none; }
.theme-toggle-btn:hover { color: var(--text-primary); background: var(--bg-alt); }
/* The active option is never indicated by color alone: filled background AND bold weight. */
.theme-toggle-btn[aria-pressed="true"] {
  background: var(--accent-primary);
  color: #fff;
  font-weight: 700;
}

/* ---------------- Nav ---------------- */

.section-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  gap: 0.2rem;
  overflow-x: auto;
  padding: 0 1rem;
}
.section-nav a {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.8rem 0.9rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.nav-num { font-family: "SF Mono", ui-monospace, "Roboto Mono", Menlo, Consolas, monospace; font-size: 0.72rem; color: var(--text-muted); }
.section-nav a:hover { color: var(--text-primary); }
.section-nav a.active { color: var(--accent-primary); border-bottom-color: var(--accent-primary); font-weight: 600; }
.section-nav a.active .nav-num { color: var(--accent-primary); }

main { max-width: var(--max-width); margin: 0 auto; padding: 0 1rem; }

/* ---------------- Sections ---------------- */

.dashboard-section {
  padding: 2.2rem 0 1.2rem;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 3.2rem;
}
.dashboard-section:last-of-type { border-bottom: none; }
.section-head h2 { font-size: 1.3rem; }
.section-subtitle { color: var(--ink-soft); font-size: 0.92rem; }
.section-note { font-size: 0.85rem; color: var(--grey); background: var(--grey-soft); border-radius: 6px; padding: 0.6rem 0.8rem; }
.scenario-caveat { border-left: 3px solid var(--plum); }

/* ---------------- KPI cards ---------------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.metric-stack {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin: 0.8rem 0 1.6rem;
}

.kpi-card, .chart-block {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
}
.kpi-card-head, .chart-block-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.kpi-label { font-size: 0.85rem; color: var(--ink-soft); font-weight: 600; margin: 0; }
.kpi-value { display: flex; align-items: baseline; gap: 0.2rem; }
.kpi-number { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-unit { color: var(--ink-soft); font-size: 0.9rem; }
.kpi-as-of { font-size: 0.75rem; color: var(--grey); margin-top: 0.2rem; }
.kpi-footnote { font-size: 0.75rem; color: var(--grey); margin-top: 0.6rem; display: flex; align-items: center; gap: 0.3rem; }
.kpi-missing-text { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; color: var(--grey); padding: 0.4rem 0; }
.kpi-missing-headline { color: var(--ink-soft); font-weight: 600; }
.kpi-missing-reason { line-height: 1.45; }
.kpi-missing { background: var(--grey-soft); }

/* ---------------- Status badges (Actual/Forecast/Derived/Scenario/Estimated/Gap) ----------------
   Distinct color AND border style per status — never relies on color alone. */

.status-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}
.status-actual .status-badge, .status-badge.status-actual { background: var(--navy-soft); color: var(--navy); border: 1px solid var(--navy); }
.status-forecast .status-badge, .status-badge.status-forecast { background: var(--orange-soft); color: var(--orange); border: 1px dashed var(--orange); }
.status-derived .status-badge, .status-badge.status-derived { background: var(--green-soft); color: var(--green); border: 1px dotted var(--green); }
.status-scenario .status-badge, .status-badge.status-scenario { background: var(--plum-soft); color: var(--plum); border: 1px solid var(--plum); }
.status-estimated .status-badge, .status-badge.status-estimated { background: var(--ochre-soft); color: var(--ochre); border: 1px dotted var(--ochre); }
.status-gap .status-badge, .status-badge.status-gap { background: var(--grey-soft); color: var(--grey); border: 1px solid var(--grey); }

.kpi-card.status-forecast, .chart-block.status-forecast { border-left: 4px solid var(--orange); }
.kpi-card.status-actual, .chart-block.status-actual { border-left: 4px solid var(--navy); }
.kpi-card.status-derived, .chart-block.status-derived { border-left: 4px solid var(--green); }
.kpi-card.status-scenario, .chart-block.status-scenario { border-left: 4px solid var(--plum); }
.kpi-card.status-estimated, .chart-block.status-estimated { border-left: 4px solid var(--ochre); }
.kpi-card.status-gap, .chart-block.status-gap { border-left: 4px solid var(--grey); }

/* ---------------- Info control (accessible tooltip) ---------------- */

.info-wrap { position: relative; display: inline-block; }
.info-btn {
  width: 1.1rem; height: 1.1rem;
  border-radius: 50%;
  border: 1px solid var(--grey);
  background: var(--paper);
  color: var(--grey);
  font-size: 0.65rem;
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.info-btn:hover, .info-btn[aria-expanded="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.info-popover {
  position: absolute;
  z-index: 20;
  bottom: 130%;
  left: 0;
  width: 280px;
  /* A deliberately fixed dark chip in both themes (not var(--ink), which flips to a LIGHT color
     in dark mode and would put light text on a light background) — same reasoning as Chart.js's
     tooltip, so it reuses the same always-dark tokens. */
  background: var(--chart-tooltip-bg);
  color: var(--chart-tooltip-text);
  border: 1px solid var(--border-strong);
  font-size: 0.78rem;
  padding: 0.6rem 0.7rem;
  border-radius: 6px;
  white-space: pre-line;
  box-shadow: var(--shadow);
}

/* ---------------- Charts ---------------- */

.chart-block { margin-bottom: 1rem; }

/* Chart.js with responsive:true + maintainAspectRatio:false needs its canvas's PARENT to have
   an explicit, non-zero height — otherwise the canvas can collapse to 0px or grow without bound
   on some browsers. This wrapper is that explicit-height parent; the canvas fills it exactly. */
.chart-canvas-wrapper {
  position: relative;
  width: 100%;
  height: 220px;
}
.chart-canvas-wrapper-large { height: 320px; }
.chart-canvas-wrapper canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
}
@media (max-width: 640px) {
  .chart-canvas-wrapper { height: 200px; }
  .chart-canvas-wrapper-large { height: 260px; }
}

.chart-controls { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.5rem; font-size: 0.82rem; color: var(--ink-soft); }
.range-btn {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
}
.range-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.chart-legend { display: flex; gap: 1rem; font-size: 0.8rem; margin-bottom: 0.4rem; }
.legend-item.status-actual { color: var(--navy); }
.legend-item.status-forecast { color: var(--orange); }
.chart-footnote { font-size: 0.75rem; color: var(--grey); margin-top: 0.4rem; }
.chart-fallback-notice {
  font-size: 0.82rem;
  color: var(--ochre);
  background: var(--ochre-soft);
  border: 1px solid var(--ochre);
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  margin: 0.4rem 0;
}
.revision-note { font-size: 0.8rem; color: var(--ink-soft); display: flex; align-items: center; gap: 0.3rem; }
canvas { max-width: 100%; }

/* ---------------- Tables ---------------- */

.table-scroll { overflow-x: auto; margin-top: 0.6rem; }
.table-caption { font-size: 0.78rem; color: var(--grey); margin-bottom: 0.3rem; }
.data-table { border-collapse: collapse; width: 100%; font-size: 0.85rem; table-layout: fixed; }
.data-table th, .data-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.4rem 0.6rem;
  text-align: left;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}
.data-table th { color: var(--ink-soft); font-weight: 600; background: var(--paper-alt); position: sticky; top: 0; }
/* A long text label (e.g. "Saudi Arabia, 2Q25", or a scenario assumption description) must never
   crowd a numeric column — .col-right marks specific columns (the last one for the common
   ["Period", value] shape, or every scenario column in a multi-scenario comparison table) so
   numbers stay right-aligned and easy to scan down the column regardless of label length. */
.data-table-has-right-cols .col-right {
  text-align: right;
  white-space: nowrap;
}
/* Single-value-column tables (the ["Period", value] shape most metric cards use) additionally
   cap the numeric column's width so the label column keeps most of the room. Multi-column
   scenario-comparison tables intentionally skip this — table-layout:fixed distributes several
   right-aligned scenario columns evenly instead. */
.data-table-single-value-col .col-right { width: 9rem; }

/* ---------------- Methodology ---------------- */

/* ---------------- States: loading / empty / error ---------------- */

.loading-panel, .empty-panel {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 2.4rem 1rem;
  color: var(--ink-soft);
  justify-content: center;
  max-width: var(--max-width);
  margin: 0 auto;
}
.spinner {
  width: 1.1rem; height: 1.1rem;
  border: 2px solid var(--line);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-panel {
  max-width: 640px;
  margin: 3rem auto;
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 1.4rem 1.6rem;
}
.error-panel h2 { color: var(--danger); }
.error-detail {
  white-space: pre-wrap;
  font-size: 0.78rem;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.6rem;
  border-radius: 6px;
  overflow-x: auto;
}

/* ---------------- Focus visibility (P0 #14 — keyboard focus must always be visible) ---------------- */

a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------------- Overview: legacy anchor, grids ---------------- */

.legacy-anchor { display: block; height: 0; }

.overview-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1rem 0;
}

/* ---------------- Overview: Brent decomposition hero ---------------- */

.hero-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 4px solid var(--navy);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.6rem;
  margin-top: 1rem;
}
.hero-card.hero-unavailable { border-top-color: var(--grey); }
.hero-head h2 { font-size: 1.35rem; }
.hero-subtitle { font-size: 0.9rem; color: var(--ink-soft); }
.hero-figures {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin: 1rem 0;
}
.hero-figure {
  flex: 1 1 220px;
  background: var(--paper-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.hero-figure-label { font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 0.3rem; }
.hero-figure-value { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: 0.3rem 0; }
.hero-figure-unit { font-size: 0.85rem; color: var(--ink-soft); font-weight: 400; }
.hero-op { align-self: center; font-size: 1.6rem; font-weight: 700; color: var(--grey); padding: 0 0.2rem; }
.hero-asof { font-size: 0.78rem; color: var(--grey); }

/* Stale-data banner — never color alone: a leading "⚠ Stale:" text glyph+word, a border, AND a
   tinted background, so the signal survives grayscale/colorblind viewing. Restrained (caution
   tone, not danger/red) since a stale-but-real last-approved observation is not itself an
   error — the banner exists so nobody mistakes it for a live/current figure. */
.stale-banner {
  font-size: 0.85rem;
  color: var(--caution);
  background: var(--caution-soft);
  border: 1px solid var(--caution);
  border-radius: 6px;
  padding: 0.55rem 0.8rem;
  margin: 0.6rem 0;
}
.stale-banner strong { color: var(--caution); }
.hero-limitation {
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: var(--grey-soft);
  border-radius: 6px;
  padding: 0.7rem 0.9rem;
  margin-top: 0.6rem;
}

/* ---------------- Overview: Market Thesis / Analyst Takeaway ---------------- */

.thesis-card, .whatchanged-card, .balance-card, .scenario-card, .risk-card,
.scenario-outlook-card, .scenario-takeaway-card, .scenario-assumptions-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.3rem;
}
.thesis-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem; }
.thesis-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--navy);
  background: var(--navy-soft);
  border: 1px solid var(--navy);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  white-space: normal;
}
.thesis-fields { margin: 0.8rem 0; }
.thesis-fields dt { font-size: 0.78rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.02em; margin-top: 0.7rem; }
.thesis-fields dt:first-child { margin-top: 0; }
.thesis-fields dd { margin: 0.2rem 0 0; font-size: 0.95rem; }
.thesis-unavailable, .hero-unavailable { color: var(--grey); }

/* ---------------- Overview: What Changed ---------------- */

.whatchanged-card .data-table { font-size: 0.82rem; }
.change-indicator { font-size: 0.78rem; font-weight: 600; margin-left: 0.5rem; }
.change-up { color: var(--green); }
.change-down { color: var(--danger); }
.change-flat { color: var(--grey); }

/* ---------------- Overview: Market Balance ---------------- */

.balance-row { display: flex; flex-wrap: wrap; gap: 1rem; margin: 0.8rem 0; }
.balance-stat { flex: 1 1 140px; }
.balance-stat-label { font-size: 0.78rem; color: var(--ink-soft); font-weight: 600; }
.balance-stat-value { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.balance-direction { font-size: 0.85rem; }

/* ---------------- Scenarios section ---------------- */

.scenario-outlook-stats { display: flex; flex-wrap: wrap; gap: 1rem; margin: 0.8rem 0 0.2rem; }
.scenario-outlook-stat { flex: 1 1 170px; background: var(--paper-alt); border: 1px solid var(--line); border-radius: 6px; padding: 0.6rem 0.8rem; }
.scenario-outlook-stat-label { display: block; font-size: 0.75rem; color: var(--ink-soft); font-weight: 600; margin-bottom: 0.2rem; }
.scenario-outlook-stat-value { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Scenario-comparison table: Base column gets a subtle, non-color-only highlight (also bolded)
   so it's identifiable in print/grayscale, not just by a background tint. */
.scenario-assumptions-table th.col-base, .scenario-assumptions-table td.col-base {
  background: var(--navy-soft);
  font-weight: 700;
}
.scenario-assumptions-table th.col-base { color: var(--navy); }

/* The optional same-unit assumptions chart gets full section width and a taller canvas — never
   squeezed into a narrow metric-stack column (P0 responsiveness requirement for multi-series/
   grouped scenario visuals). */
.scenario-chart-block { max-width: none; }
.scenario-chart-wrapper { height: 260px; }
@media (max-width: 640px) { .scenario-chart-wrapper { height: 220px; } }

.scenario-toggle-row { flex-wrap: wrap; }
.scenario-toggle {
  border-color: var(--scenario-color, var(--line));
  color: var(--scenario-color, var(--ink-soft));
  background: var(--paper);
}
.scenario-toggle.active { background: var(--scenario-color, var(--navy)); color: #fff; }
.scenario-toggle:not(.active) { opacity: 0.6; text-decoration: line-through; }

.scenario-milestone-row { display: flex; flex-wrap: wrap; gap: 0.8rem; margin: 0.8rem 0; }
.scenario-milestone-chip {
  flex: 1 1 150px;
  background: var(--plum-soft);
  border: 1px solid var(--plum);
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
}
.scenario-milestone-label { display: block; font-size: 0.75rem; color: var(--plum); font-weight: 600; margin-bottom: 0.15rem; }
.scenario-milestone-value { font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }

/* ---------------- Overview: Scenario ---------------- */

.scenario-active { margin: 0.6rem 0; }
.scenario-link { font-size: 0.85rem; font-weight: 600; color: var(--navy); text-decoration: none; }
.scenario-link:hover { text-decoration: underline; }

/* ---------------- Overview: Risk panel ---------------- */

.risk-list { margin: 0.6rem 0 0; padding-left: 1.2rem; }
.risk-list li { font-size: 0.9rem; margin-bottom: 0.4rem; }
.risk-list a { color: var(--navy); }

/* ---------------- Overview: secondary headline grid ---------------- */

.headline-grid-block { margin-top: 1.6rem; padding-top: 1rem; border-top: 1px dashed var(--line); }
.headline-grid-block h2 { font-size: 1.05rem; color: var(--ink-soft); }

/* ---------------- Chart latest-value context ---------------- */

.chart-latest-value { font-size: 0.85rem; color: var(--ink-soft); margin: 0.2rem 0 0.6rem; }

/* ---------------- Supply & Demand layout ---------------- */

.supply-pair-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 0.8rem 0; }
.producer-history-block { margin: 0.8rem 0 1.6rem; }
.producer-history-content { margin-top: 0.6rem; }

/* ---------------- Collapsible (P0 #10) ---------------- */

.collapsible { margin-top: 0.6rem; }
.collapsible-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--paper-alt);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
}
.collapsible-toggle:hover { background: var(--navy-soft); }
.collapsible-caret { transition: transform 0.15s ease; }
.collapsible-toggle[aria-expanded="true"] .collapsible-caret { transform: rotate(180deg); }
.collapsible-content { margin-top: 0.6rem; }

/* ---------------- Evidence drawer (P0 #12) ---------------- */

.evidence-btn {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--navy);
  background: var(--navy-soft);
  border: 1px solid var(--navy);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  cursor: pointer;
}
.evidence-btn:hover { background: var(--navy); color: #fff; }

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  justify-content: flex-end;
  z-index: 200;
}
.evidence-drawer {
  background: var(--bg-elevated);
  width: min(480px, 100%);
  height: 100%;
  overflow-y: auto;
  padding: 1.4rem;
  box-shadow: var(--shadow);
  border-left: 1px solid var(--border-subtle);
}
.drawer-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.drawer-header h2 { font-size: 1.15rem; margin: 0; }
.drawer-close {
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  width: 2rem;
  height: 2rem;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--ink-soft);
}
.drawer-close:hover { background: var(--grey-soft); }
.evidence-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.evidence-table th { text-align: left; vertical-align: top; padding: 0.5rem 0.6rem 0.5rem 0; color: var(--ink-soft); font-weight: 600; width: 40%; }
.evidence-table td { padding: 0.5rem 0; border-top: 1px solid var(--line); }
.evidence-table tr:first-child td { border-top: none; }
.rules-list { margin: 0; padding-left: 1.2rem; font-size: 0.88rem; }
.rules-list li { margin-bottom: 0.6rem; }

/* ---------------- Footer ---------------- */

.site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.4rem 1rem 3rem;
  font-size: 0.78rem;
  color: var(--grey);
}

/* ---------------- Responsive ---------------- */

@media (max-width: 900px) {
  .overview-grid-2, .supply-pair-row { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  :root { font-size: 15px; }
  .release-banner { gap: 0.8rem; }
  .methodology-link { margin-left: 0; }
  .kpi-grid, .metric-stack { grid-template-columns: 1fr; }
  .hero-figures { flex-direction: column; }
  .hero-op { align-self: center; padding: 0.2rem 0; }
  .evidence-drawer { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}

/* ---------------- Markets & Refining (separate market feed) ----------------
   Written against the same semantic tokens as everything above, so both themes work with no
   extra rules. Status is never color alone: each tile carries a text label (Actual, Derived,
   Projection) as well as a left border. */

.market-feed-note { margin: 0.6rem 0 1rem; }
.market-group-h { margin: 1.8rem 0 0.4rem; font-size: 1.05rem; }
.market-group-h:first-of-type { margin-top: 1rem; }
.market-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 0.8rem;
  margin: 0.8rem 0;
}
.market-tile {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--navy);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.7rem 0.85rem;
  min-width: 0;
}
.market-tile.tile-derived { border-left-color: var(--green); }
.market-tile.tile-projection { border-left-color: var(--orange); }
.market-tile-label { font-size: 0.78rem; color: var(--ink-soft); font-weight: 600; margin: 0 0 0.25rem; }
.market-tile-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.market-tile-unit { font-size: 0.78rem; font-weight: 400; color: var(--ink-soft); }
.market-tile-sub { font-size: 0.74rem; color: var(--grey); margin-top: 0.2rem; }
.market-tile-tag {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--grey);
  margin-top: 0.3rem;
}
.market-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.market-grid-2 > .chart-block { margin-bottom: 0; min-width: 0; }
.market-card-note { font-size: 0.82rem; color: var(--ink-soft); margin: 0 0 0.5rem; line-height: 1.45; }
.market-signal-up { color: var(--green); }
.market-signal-down { color: var(--danger); }
.market-emea-summary { margin: 0.8rem 0 1.4rem; }
.market-emea-summary h3 { margin-bottom: 0.3rem; }

@media (max-width: 640px) {
  .market-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .market-grid-2 { grid-template-columns: 1fr; }
  .market-tile-value { font-size: 1.25rem; }
}
