:root {
  --bg: #f7f7f5; --surface: #ffffff; --text: #1a1a1a;
  --text-muted: #5a5a5a; --border: #e2e2e0; --accent: #2b6cb0;
  --code-bg: #f0f0ee; --on-accent: #ffffff;
  --red-bg: #fde8e8;    --red-fg: #9b1c1c;    --red-border: #f5b5b5;
  --orange-bg: #fdf0e2; --orange-fg: #9a5b0c;  --orange-border: #f3cf9e;
  --yellow-bg: #fdf6d8; --yellow-fg: #7a6408;  --yellow-border: #eee0a0;
  --green-bg: #e6f4ea;  --green-fg: #1e6b34;   --green-border: #a9d9b8;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14151a; --surface: #1c1e24; --text: #eaeaec;
    --text-muted: #a2a4ac; --border: #2f3138; --accent: #6fa8dc;
    --code-bg: #21232a; --on-accent: #0f1115;
    --red-bg: #3a1c1c;    --red-fg: #f4a5a5;    --red-border: #6b2c2c;
    --orange-bg: #3a2c14; --orange-fg: #f2c07f;  --orange-border: #6b4c1e;
    --yellow-bg: #34301a; --yellow-fg: #e8d27a;  --yellow-border: #5c5325;
    --green-bg: #163823;  --green-fg: #8fd6a8;   --green-border: #285f3e;
  }
}
* { box-sizing: border-box; }
html {
  /* Fluid base size: ~16px on phones, scaling up to ~19px on wide
     desktop screens, so every rem-based size below grows with it. */
  font-size: clamp(16px, 15px + 0.4vw, 19px);
}
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}
.wrap {
  /* Mobile-first width; widens in the desktop media query below. */
  max-width: 900px; margin: 0 auto; padding: 0.5rem 1.25rem 4rem;
}
/* Title banner: a framed card with a cool-to-hot "temperature" strip
   down its left edge. The image is a full-colour opaque banner, shown
   unchanged in dark mode. */
.site-title {
  display: block; width: fit-content; max-width: 100%; margin: 0 auto 0.4rem;
  padding: 0 0.4rem 0 0.7rem; border: 1px solid var(--border); border-radius: 8px;
  background:
    linear-gradient(to bottom, #2b6cb0, #d69e2e, #c53030) left / 5px 100% no-repeat,
    var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.site-title img {
  display: block; height: 2.6rem; width: auto; max-width: 100%;
  object-fit: contain; object-position: left;
}
@media (prefers-color-scheme: dark) {
  .site-title { box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); }
}
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap;
}
.topbar h1 { font-size: 1.3rem; margin: 0; }
.topbar .topbar-links { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
/* Page links render as bordered tabs; the last link (Log out) stays plain text. */
.topbar a {
  color: var(--text); font-size: 0.85rem; text-decoration: none;
  padding: 0.35rem 0.8rem; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); transition: border-color 0.15s, background 0.15s;
}
.topbar a:hover { border-color: var(--accent); color: var(--accent); }
.topbar a.nav-active {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600;
}
.topbar a:last-child {
  border-color: transparent; background: none; color: var(--text-muted);
  padding-inline: 0.4rem; margin-left: 0.25rem;
}
.topbar a:last-child:hover { color: var(--text); text-decoration: underline; }

form.controls {
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 1rem; margin-bottom: 1.5rem;
}
form.controls .field { display: flex; flex-direction: column; gap: 0.25rem; }
form.controls label { font-size: 0.78rem; color: var(--text-muted); }
form.controls select, form.controls input {
  padding: 0.4rem 0.55rem; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text); font-size: 0.88rem;
}
form.controls button {
  padding: 0.45rem 1rem; border: none; border-radius: 6px;
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
  font-size: 0.88rem;
}
form.controls button:hover { opacity: 0.9; }

/* Historical-scenario shortcuts: a second row inside the controls
   box, under a divider. */
.scenarios {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem;
  flex-basis: 100%; margin-top: 0.15rem;
  padding-top: 0.75rem; border-top: 1px solid var(--border);
}
.scenarios-label { font-size: 0.78rem; color: var(--text-muted); margin-right: 0.2rem; }
.scenario-btn {
  display: inline-block; padding: 0.25rem 0.7rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); color: var(--accent);
  font-size: 0.8rem; font-weight: 600; text-decoration: none;
}
.scenario-btn:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.scenario-btn-reset {
  border-color: var(--border); color: var(--text-muted); margin-left: 0.25rem;
}
.scenario-btn-reset:hover { background: var(--text-muted); border-color: var(--text-muted); }

.status-card {
  border-radius: 12px; padding: 1.25rem 1.4rem; margin-bottom: 1.25rem;
  border: 1px solid var(--border);
}
.status-card.red    { background: var(--red-bg);    border-color: var(--red-border); }
.status-card.orange { background: var(--orange-bg); border-color: var(--orange-border); }
.status-card.yellow { background: var(--yellow-bg); border-color: var(--yellow-border); }
.status-card.green  { background: var(--green-bg);  border-color: var(--green-border); }
.status-card .label { font-size: 1.05rem; font-weight: 700; }

/* Cards link to their chart panel. */
a.status-card {
  display: block; color: inherit; text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
a.status-card:hover, a.status-card:focus-visible {
  transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}
.status-card.red .label    { color: var(--red-fg); }
.status-card.orange .label { color: var(--orange-fg); }
.status-card.yellow .label { color: var(--yellow-fg); }
.status-card.green .label  { color: var(--green-fg); }

/* Overview strip -- two headline answers at the top of every page. */
/* Three cards side by side on wide screens; stacked below that, since
   a third of a narrow page is too tight for their detail lines. */
.overview {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem; margin-bottom: 1.25rem;
}
@media (max-width: 900px) {
  .overview { grid-template-columns: 1fr; }
}
.overview-item {
  border: 1px solid var(--border); border-left-width: 5px; border-radius: 10px;
  padding: 0.75rem 1rem; background: var(--surface);
}
.overview-q { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.overview-a { font-size: 1.05rem; font-weight: 700; margin: 0.15rem 0 0.25rem; }
.overview-detail { font-size: 0.82rem; color: var(--text-muted); }
/* "?" badge in a card's top-right corner; its note shows on hover, or
   on focus (keyboard, or a tap on touch screens). */
.overview-item { position: relative; }
.overview-q { padding-right: 1.6rem; }
.info {
  position: absolute; top: 0.55rem; right: 0.6rem;
  width: 1.25rem; height: 1.25rem; border-radius: 50%;
  display: grid; place-items: center; cursor: help;
  font-size: 0.75rem; font-weight: 700; color: var(--text-muted);
  border: 1px solid var(--border); background: var(--bg);
}
.info:hover, .info:focus-visible { color: var(--accent); border-color: var(--accent); outline: none; }
.info-tip {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 10;
  width: max-content; max-width: min(280px, 75vw);
  background: rgba(15, 16, 20, 0.94); color: #fff;
  padding: 0.5rem 0.7rem; border-radius: 8px;
  font-size: 0.78rem; font-weight: 400; line-height: 1.4; text-align: left;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  opacity: 0; pointer-events: none; transition: opacity 0.15s ease;
}
.info:hover .info-tip, .info:focus .info-tip { opacity: 1; }
.overview-item.green  { border-left-color: var(--green-border); }
.overview-item.yellow { border-left-color: var(--yellow-border); }
.overview-item.orange { border-left-color: var(--orange-border); }
.overview-item.red    { border-left-color: var(--red-border); }
.overview-item.green .overview-a  { color: var(--green-fg); }
.overview-item.yellow .overview-a { color: var(--yellow-fg); }
.overview-item.orange .overview-a { color: var(--orange-fg); }
.overview-item.red .overview-a    { color: var(--red-fg); }
.overview-item.momentum-worse  { border-left-color: var(--red-border); }
.overview-item.momentum-better { border-left-color: var(--green-border); }
.overview-item.momentum-worse .overview-a  { color: var(--red-fg); }
.overview-item.momentum-better .overview-a { color: var(--green-fg); }

.status-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem; margin-bottom: 1.25rem;
}
.status-row .status-card { margin-bottom: 0; }
.status-card .sub-label { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.3rem; }

.table-wrap {
  overflow-x: auto; border: 1px solid var(--border); border-radius: 10px;
  margin-bottom: 1.5rem; background: var(--surface);
}
table { width: 100%; border-collapse: collapse; min-width: 420px; }
th, td { text-align: left; padding: 0.55rem 0.9rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { background: var(--code-bg); font-weight: 600; width: 45%; }
tr:last-child td, tr:last-child th { border-bottom: none; }

/* Measure | Value | Direction | Signal tables (Credit, Liquidity). */
.panel-header th { background: var(--surface); font-weight: 700; width: auto; }
.liquidity-table .column-header th, .credit-table .column-header th { width: auto; }
.liquidity-table .signal-cell, .credit-table .signal-cell { width: 8.5rem; white-space: nowrap; }
.liquidity-table .direction-cell, .credit-table .direction-cell { width: 6rem; font-size: 1.1rem; }
.liquidity-table .column-header .direction-cell,
.credit-table .column-header .direction-cell { font-size: inherit; }
.liquidity-table td.signal-cell[title], .credit-table td.signal-cell[title] { cursor: help; }

.section-title { font-size: 1.05rem; margin: 1.75rem 0 0.6rem; }
.section-meta { font-size: 0.8rem; font-weight: 400; color: var(--text-muted); }
.market-table th { width: auto; }
.market-table .market-group { scroll-margin-top: 0.75rem; }
.market-table .market-group:target th { animation: row-flash 1.8s ease-out; }
@keyframes row-flash {
  0%, 40% { background: var(--code-bg); color: var(--accent); }
}
.market-table .market-group th {
  background: var(--surface); font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-muted); padding-top: 0.9rem;
}
.market-table .num { text-align: right; white-space: nowrap; }
.market-table .detail { display: block; font-size: 0.75rem; color: var(--text-muted); }
.market-table .direction { font-size: 1.1rem; }

/* Momentum: arrows and 3-month signal changes, coloured by whether the
   move is toward stress (worse) or away from it (better). */
.direction.worse  { color: var(--red-fg); font-weight: 700; }
.direction.better { color: var(--green-fg); font-weight: 700; }
.direction.flat   { color: var(--text-muted); }
.signal-change { display: block; font-size: 0.75rem; margin-top: 0.15rem; white-space: nowrap; }
.signal-change.worse  { color: var(--red-fg); font-weight: 600; }
.signal-change.better { color: var(--green-fg); font-weight: 600; }
.signal-change.flat   { color: var(--text-muted); }
.market-table td[title] { cursor: help; }
.signal { white-space: nowrap; font-weight: 600; }
.signal::before {
  content: ""; display: inline-block; width: 0.8em; height: 0.8em;
  border-radius: 50%; margin-right: 0.45em; vertical-align: -0.05em;
  background: var(--text-muted);
}
.signal.red    { color: var(--red-fg); }    .signal.red::before    { background: #e03131; }
.signal.orange { color: var(--orange-fg); } .signal.orange::before { background: #f08c00; }
.signal.yellow { color: var(--yellow-fg); } .signal.yellow::before { background: #f2c200; }
.signal.green  { color: var(--green-fg); }  .signal.green::before  { background: #2f9e44; }
.signal.na     { color: var(--text-muted); font-weight: 400; }

.chart-wrap {
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  margin-bottom: 1.25rem; background: var(--surface); position: relative;
}
.chart-wrap img { display: block; width: 100%; height: auto; }
.chart-wrap img[hidden] { display: none; }

.chart-toolbar { display: flex; justify-content: flex-end; margin-bottom: 0.4rem; }
.chart-toggle {
  display: flex; align-items: center; gap: 0.4rem; cursor: pointer;
  font-size: 0.85rem; color: var(--text); user-select: none;
}
.chart-toggle input { width: 1rem; height: 1rem; margin: 0; cursor: pointer; }

/* Invisible hover bands over each chart panel's vertical slice of the
   image, revealing a plain-English explanation of that panel. The
   chart itself is one server-rendered PNG (no per-datapoint JS chart
   library), so these are approximate panel-height bands rather than
   pixel-exact hit areas -- good enough for "what does this graph
   mean," not meant to track exact data points. */
.chart-hotzone {
  position: absolute; left: 0; width: 100%; cursor: help;
}
.chart-hotzone::after {
  content: "ⓘ"; position: absolute; top: 0.5rem; right: 0.6rem;
  font-size: 0.9rem; color: rgba(120,120,120,0.55);
  transition: color 0.15s ease;
}
.chart-hotzone:hover::after { color: var(--accent); }

/* Landing on a panel from a status card: leave a little room above it
   and briefly outline it. */
.chart-hotzone { scroll-margin-top: 0.75rem; }
.chart-hotzone:target { animation: panel-flash 1.8s ease-out; }
@keyframes panel-flash {
  0%, 40% { box-shadow: inset 0 0 0 3px var(--accent); }
  100%    { box-shadow: inset 0 0 0 3px transparent; }
}
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .chart-hotzone:target { animation: none; }
}
.chart-hotzone .tooltip-box {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(340px, 88%); max-width: 88%;
  background: rgba(15, 16, 20, 0.94); color: #fff;
  padding: 0.8rem 1rem; border-radius: 10px;
  font-size: 0.83rem; line-height: 1.45; text-align: left;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  opacity: 0; pointer-events: none; transition: opacity 0.15s ease;
  z-index: 10;
}
.chart-hotzone:hover .tooltip-box { opacity: 1; }

.actions { display: flex; gap: 1rem; align-items: center; }
.actions a {
  font-size: 0.85rem; color: var(--accent); text-decoration: none;
}
.actions a:hover { text-decoration: underline; }

.meta { color: var(--text-muted); font-size: 0.8rem; margin-top: 1.5rem; }

.error-card {
  background: var(--red-bg); color: var(--red-fg); border: 1px solid var(--red-border);
  border-radius: 10px; padding: 1rem 1.25rem; font-size: 0.9rem;
}

/* Desktop: give the chart and tables room to actually be bigger,
   not just the same layout stretched wider. */
@media (min-width: 1000px) {
  .wrap { max-width: 1400px; padding-top: 0.75rem; }
  .topbar h1 { font-size: 1.6rem; }
  .status-card .label { font-size: 1.3rem; }
  th, td { padding: 0.75rem 1.1rem; }
}

/* Public pages: home, guides and methodology. Text is kept to a
   readable line length; the overview strip and cards use full width. */
.public-nav { margin-bottom: 1.25rem; }
.prose h1 { font-size: 1.45rem; line-height: 1.25; margin: 0.25rem 0 0.6rem; max-width: 48rem; }
.prose h2 { font-size: 1.1rem; margin: 1.9rem 0 0.6rem; }
.prose p, .prose ul, .prose dl { max-width: 48rem; }
.prose a:not(.guide-card):not(.button-link) { color: var(--accent); }
.prose .lede { font-size: 1.05rem; color: var(--text-muted); }
.prose .small, .prose .updated { font-size: 0.82rem; color: var(--text-muted); }
.prose .updated { margin-top: 0; }
.prose .breadcrumb { font-size: 0.82rem; color: var(--text-muted); margin: 0; }
.prose .rule {
  font-size: 0.88rem; background: var(--code-bg); border-radius: 6px;
  padding: 0.5rem 0.75rem;
}
.faq dt { font-weight: 700; margin-top: 0.9rem; }
.faq dd { margin: 0.2rem 0 0; }
.guide-cards {
  display: grid; gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}
.guide-card {
  display: flex; flex-direction: column; gap: 0.3rem; padding: 0.9rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); text-decoration: none; transition: border-color 0.15s;
}
.guide-card:hover, .guide-card:focus-visible { border-color: var(--accent); }
.guide-card-title { font-weight: 700; color: var(--accent); }
.guide-card-text { font-size: 0.85rem; color: var(--text-muted); }
.button-link {
  display: inline-block; padding: 0.55rem 1.1rem; border-radius: 6px;
  background: var(--accent); color: var(--on-accent); font-weight: 600;
  text-decoration: none;
}
.button-link:hover { opacity: 0.9; }
.members-cta {
  margin-top: 2rem; padding: 1rem 1.25rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
}
.members-cta p { margin: 0.4rem 0; }
.guide-table th { width: 30%; }
.guide-table td { font-size: 0.88rem; }
.site-footer {
  margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--border);
  font-size: 0.8rem; color: var(--text-muted); max-width: 48rem;
}
.site-footer a { color: var(--text-muted); }
