/* Layout and components. Colours come only from tokens.css. */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, ul, dl, dd, figure { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.container { width: 100%; max-width: 1440px; margin-inline: auto; padding-inline: 24px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100; padding: 8px 14px; border-radius: 8px;
  background: var(--text-primary); color: var(--surface-1); font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---------- header ---------- */
.site-header { position: relative; background: var(--surface-1); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; padding-block: 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { flex: none; color: var(--text-primary); }
.brand h1 { font-size: 20px; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
.header-actions { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.status-wrap { position: relative; }
.status-btn {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; padding: 5px 8px; border: 1px solid transparent; border-radius: 10px;
  background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.status-btn:hover { background: var(--hover); }
.asof { font-size: 13px; color: var(--text-secondary); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 999px; border: 1px solid var(--border);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.pill--ok .icon { color: var(--good); }
.pill--warn .icon { color: var(--serious); }
.pill--error .icon { color: var(--critical); }
.pill--neutral .icon { color: var(--text-secondary); }

.popover {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; width: min(460px, calc(100vw - 32px)); max-height: min(70vh, 560px); overflow: auto;
  padding: 14px 16px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}
.pop-title { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.pop-empty { color: var(--text-secondary); }
.source-item { padding: 9px 0; border-top: 1px solid var(--grid); }
.source-item:first-child { border-top: 0; }
.source-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.source-name { font-weight: 600; font-size: 14px; }
.source-meta { margin-top: 2px; font-size: 12.5px; color: var(--text-secondary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 5px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn[aria-pressed="true"] { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }
.btn--ghost { border-color: transparent; background: none; color: var(--text-secondary); }
.btn--wide { width: 100%; margin-top: 12px; }
.theme-btn { min-width: 128px; }

.notices { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.notice {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-1); font-size: 14px;
}
.notice .icon { flex: none; margin-top: 2px; color: var(--text-secondary); }
.notice--warning .icon { color: var(--serious); }

/* ---------- sections and cards ---------- */
.section { margin-top: 36px; }
.section > h2 { font-size: 22px; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
.section-lede { margin: 4px 0 16px; color: var(--text-secondary); max-width: 80ch; }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.section > .card { margin-top: 16px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h3, .card-head h4 { font-size: 16px; font-weight: 700; line-height: 1.3; }
.card-head--plain { margin-top: 24px; }
.card-head--tight { margin-bottom: 8px; }
.card-sub { margin-top: 2px; font-size: 13px; color: var(--text-secondary); max-width: 90ch; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.unavailable {
  display: flex; align-items: flex-start; gap: 10px; padding: 16px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--hover); color: var(--text-secondary);
}
.unavailable .icon { flex: none; margin-top: 2px; color: var(--serious); }
.unavailable strong { color: var(--text-primary); }
.loading, .empty { padding: 20px 4px; color: var(--text-secondary); }
.na { color: var(--text-secondary); }

/* ---------- stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { min-width: 0; padding: 14px 16px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.tile-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.tile-value { margin: 4px 0 2px; font-size: 28px; line-height: 1.15; font-weight: 600; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.tile-sub { font-size: 13px; line-height: 1.4; color: var(--text-secondary); }

.delta { white-space: nowrap; font-weight: 600; }
.delta--up { color: var(--delta-up); }
.delta--down { color: var(--delta-down); }
.delta--flat { color: var(--text-secondary); }
.delta-glyph { font-size: 0.8em; }

/* ---------- MCCI card: headline figure beside a compact YoY chart ---------- */
.mcci-body { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 12px 32px; align-items: center; }
.mcci-stat { min-width: 0; }
.mcci-stat-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.mcci-stat-value { margin: 2px 0; font-size: 28px; line-height: 1.15; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.mcci-stat-yoy { font-size: 13px; color: var(--text-secondary); }
.mcci-stat-yoy .delta { font-size: 15px; }
.mcci-plot { min-width: 0; }

/* ---------- chips, badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 6px; border-radius: 999px; border: 1px solid var(--border);
  font-size: 12.5px; font-weight: 600; white-space: nowrap; color: var(--text-primary);
}
.chip--ok .icon, .chip--bull .icon { color: var(--good); }
.chip--warn .icon { color: var(--serious); }
.chip--error .icon, .chip--bear .icon { color: var(--critical); }
.chip--neutral .icon, .chip--off .icon, .chip--info .icon { color: var(--text-secondary); }

.badge {
  display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--border); font-size: 11px; font-weight: 600;
  letter-spacing: 0.03em; text-transform: uppercase; color: var(--text-secondary); vertical-align: 1px;
}
.badge--plain { text-transform: none; letter-spacing: 0; }

/* ---------- cycle card ---------- */
.tabs { position: relative; display: flex; gap: 4px; border-bottom: 1px solid var(--grid); overflow-x: auto; scrollbar-width: thin; }
.tab {
  flex: none; padding: 9px 14px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; color: var(--text-secondary);
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 6px 6px 0 0;
}
.tab:hover { color: var(--text-primary); background: var(--hover); }
.tab[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--text-primary); }

.controls { display: flex; flex-wrap: wrap; gap: 12px 32px; margin: 14px 0 10px; }
fieldset.ctl { margin: 0; padding: 0; border: 0; min-width: 0; }
fieldset.ctl legend { padding: 0; margin-bottom: 4px; font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; }
fieldset:disabled { opacity: 0.45; }
fieldset:disabled * { cursor: not-allowed; }
.check { display: inline-flex; align-items: center; gap: 7px; margin-right: 16px; min-height: 28px; cursor: pointer; font-size: 14px; }
.check input, .lag-row input { accent-color: var(--text-primary); }
.check input[type="checkbox"], .check input[type="radio"] { width: 16px; height: 16px; margin: 0; }
.swatch { display: inline-block; width: 16px; height: 3px; border-radius: 2px; background: var(--key); }
.lag-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lag-row input[type="range"] { width: 160px; }
.lag-out { min-width: 72px; font-size: 14px; font-weight: 600; }

.tabpanel:focus { outline: none; }
.chart-caption { margin: 4px 0 10px; font-size: 13px; color: var(--text-secondary); max-width: 110ch; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0 0 8px; font-size: 13px; color: var(--text-secondary); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-key { display: inline-block; flex: none; width: 16px; height: 3px; border-radius: 2px; background: var(--key); }
.legend-key--bar { width: 10px; height: 10px; border-radius: 3px; }
.legend-key--dash { background: repeating-linear-gradient(90deg, var(--key) 0 5px, transparent 5px 8px); }
.legend-key--ring { width: 10px; height: 10px; border-radius: 50%; background: var(--surface-1); border: 2px solid var(--key); }
.legend-chg { font-size: 12.5px; }

.chart { position: relative; width: 100%; min-width: 0; overflow: hidden; }
.cycle-chart { height: 480px; }
.exposure-chart { height: 360px; }
.detail-chart { height: 320px; }
.mini-chart { height: 160px; }
.mcci-chart { height: 200px; }
.eq-chart { height: 300px; }
.chart-fallback { padding: 24px; color: var(--text-secondary); }

.table-view { margin-top: 4px; }
.table-title { margin: 16px 0 6px; font-size: 14px; }
.panel-extra { margin-top: 16px; }
.compare h4 { font-size: 14px; }
.compare .card-sub { margin-bottom: 8px; }
.compare .data-table { min-width: 520px; }
.compare tr.is-primary th, .compare tr.is-primary td { background: var(--hover); }

.method { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--grid); }
.method summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.method-body { padding: 8px 0 0; display: grid; gap: 10px; max-width: 90ch; color: var(--text-secondary); font-size: 14px; }
.method-body strong { color: var(--text-primary); }
.quad-list { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; }
.quad-list dt { font-weight: 600; color: var(--text-primary); }

/* ---------- tables ---------- */
.table-scroll { position: relative; overflow-x: auto; max-width: 100%; } /* position: keeps .sr-only children inside the scroller */
.table-scroll--short { max-height: 380px; overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th, .data-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.data-table thead th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-1); font-size: 12px; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; border-bottom-color: var(--axis);
}
.data-table tbody th { font-weight: 500; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td.num, .data-table th.num { white-space: nowrap; }

.commodity-table { min-width: 1060px; }
.commodity-table tbody tr { cursor: pointer; }
.commodity-table tbody tr:hover { background: var(--hover); }
.commodity-table tbody tr.is-selected { background: var(--hover); box-shadow: inset 3px 0 0 var(--text-primary); }
.commodity-table tbody tr:focus-visible { outline-offset: -2px; }
.name-cell { white-space: nowrap; }
.cname { font-weight: 600; }
.last-val { font-weight: 600; }
.unit, .last-date { font-size: 12px; color: var(--text-secondary); }
.range-cell { min-width: 128px; }
.range-bar { display: block; position: relative; width: 104px; height: 4px; border-radius: 2px; background: var(--axis); }
.range-dot {
  position: absolute; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--text-primary);
  box-shadow: 0 0 0 2px var(--surface-1);
}
.range-nums { margin-top: 5px; font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.trend { display: inline-flex; align-items: center; gap: 5px; }
.spark-cell { width: 100px; }
.spark { display: block; color: var(--text-secondary); }

.detail { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--grid); }
.detail .card-head h4 { font-size: 16px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.btn--seg { border: 0; border-radius: 0; border-right: 1px solid var(--border); min-width: 44px; }
.btn--seg:last-child { border-right: 0; }
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 24px; margin-top: 16px; }
.metric dt { font-size: 12px; color: var(--text-secondary); }
.metric dd { font-weight: 600; font-size: 14px; }
.metric-note { font-weight: 400; color: var(--text-secondary); }

/* ---------- exposure ---------- */
.footnotes { display: grid; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--text-secondary); }
.footnotes strong { color: var(--text-primary); }

/* ---------- macro ---------- */
.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 16px; }
.mini { padding: 16px; }
.mini-head { display: grid; gap: 1px; }
.mini-head h4 { font-size: 14px; font-weight: 700; }
.mini-unit { font-size: 12px; color: var(--text-secondary); }
.mini-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; margin-top: 6px; }
.mini-val { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.chg { font-size: 13px; white-space: nowrap; }
.chg-label { color: var(--text-secondary); }
.mini-chip { margin: 8px 0 2px; }
.reading { margin: 4px 0 8px; font-size: 13px; color: var(--text-secondary); min-height: 2.8em; }
.eq-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* ---------- news ---------- */
.news-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.news-layout > * { min-width: 0; }
#newsletters { display: grid; gap: 16px; }
.news-filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-bottom: 8px; min-width: 0; }
.news-inputs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.input {
  min-height: 34px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
  font: inherit; font-size: 14px; min-width: 0;
}
input[type="search"].input { flex: 1 1 220px; }
select.input { flex: 1 1 160px; width: 100%; max-width: 100%; text-overflow: ellipsis; }
.news-inputs > * { min-width: 0; }
.chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip-label-row { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); margin-right: 4px; min-width: 76px; }
.fchip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); background: transparent;
  color: var(--text-primary); font: inherit; font-size: 13px; cursor: pointer;
}
.fchip:hover { background: var(--hover); }
.fchip[aria-pressed="true"] { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }
.fchip-n { font-size: 11.5px; opacity: 0.7; font-variant-numeric: tabular-nums; }
.news-status { margin: 6px 0 4px; font-size: 13px; color: var(--text-secondary); }
.news-item, .issue { padding: 12px 0; border-bottom: 1px solid var(--grid); }
.news-item:last-child, .issue:last-child { border-bottom: 0; }
.news-title, .issue-title { font-size: 15px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.news-meta { margin-top: 2px; font-size: 12.5px; color: var(--text-secondary); }
.news-summary { margin-top: 4px; font-size: 13.5px; color: var(--text-secondary); overflow-wrap: anywhere; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { padding: 1px 8px; border-radius: 999px; background: var(--hover); color: var(--text-secondary); font-size: 11.5px; }
.news-empty { padding: 20px 0; color: var(--text-secondary); }
.newsletter .card-sub a { color: var(--link); }

/* ---------- tooltips (ECharts renders our DOM inside the chart box) ---------- */
.tt { font: 12px/1.5 var(--font); min-width: 140px; }
.tt-title { margin-bottom: 4px; font-weight: 600; color: var(--text-secondary); }
.tt-row { display: flex; align-items: center; gap: 8px; }
.tt-key { flex: none; width: 10px; height: 3px; border-radius: 2px; }
.tt-key--none { background: transparent; }
.tt-val { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.tt-name { color: var(--text-secondary); }

/* ---------- footer ---------- */
.site-footer { margin-top: 48px; padding: 28px 0 40px; border-top: 1px solid var(--grid); font-size: 13px; color: var(--text-secondary); }
.footer-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 24px 48px; }
.footer-h { margin-bottom: 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-primary); }
.footer-list { display: grid; gap: 6px; }
.footer-grid p + p { margin-top: 8px; }
.footer-build { font-variant-numeric: tabular-nums; }

/* ---------- refresh: keep the previous render, dimmed ---------- */
#main { transition: opacity 0.2s ease; }
body.is-refreshing #main { opacity: 0.6; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  #exposure-card { display: block; }
}
@media (min-width: 1101px) {
  #exposure-card { display: grid; grid-template-columns: minmax(0, 1fr) 340px; column-gap: 32px; align-items: start; }
  #exposure-card > .card-head { grid-column: 1 / -1; }
  #exposure-card > .chart-wrap, #exposure-card > .table-view { grid-column: 1; grid-row: 2; }
  #exposure-card > .footnotes { grid-column: 2; grid-row: 2; margin-top: 0; }
}
@media (max-width: 960px) {
  .mcci-body { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .news-layout, .eq-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .container { padding-inline: 16px; }
  .section { margin-top: 28px; }
  .card { padding: 16px; }
  .mini { padding: 14px; }
  .site-footer .footer-grid { grid-template-columns: minmax(0, 1fr); }
  .cycle-chart { height: 420px; }
  .exposure-chart { height: 340px; }
  .eq-chart { height: 260px; }
  .tile-value { font-size: 24px; }
  .tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; border-bottom: 0; overflow: visible; }
  .tab { margin: 0; border: 1px solid var(--border); border-radius: 8px; text-align: center; }
  .tab[aria-selected="true"] { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }
  .tab[aria-selected="true"]:hover { background: var(--text-primary); color: var(--surface-1); }
  .header-inner { align-items: flex-start; }
  .header-actions { width: 100%; justify-content: space-between; }
  .status-wrap { position: static; }
  .popover { left: 16px; right: 16px; width: auto; top: 100%; }
  .brand h1 { font-size: 18px; }
  .chip-label-row { min-width: 0; width: 100%; }
}
@media (max-width: 340px) {
  .tiles { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .site-header .header-actions, .btn, .controls, .skip-link { display: none !important; }
}
