/* ==========================================================================
   Tradeloo - design system

   Bybit's trading-desk palette (near-black surfaces, signature gold, the
   green/red of an order book) laid out in Apple's language: hairline-bordered
   cards on a soft canvas, translucent chrome, segmented controls, switches,
   SF type and tabular figures.

   Every colour a chart needs is a custom property here, so light and dark
   both work - the tools re-read these on each render.
   ========================================================================== */

/* ---------- tokens: shared ---------- */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
          Inter, Roboto, system-ui, sans-serif;
  --font-num: "SF Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* Apple's standard interface easing - fast out, long settle. */
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --dur: 0.28s;

  --pad-x: clamp(16px, 4vw, 40px);
  --maxw: 1440px;
}

/* ---------- tokens: dark (Bybit) ---------- */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0b0e11;
  --bg-glass: rgba(17, 20, 25, 0.72);
  --surface: #16191f;
  --surface-2: #1e222a;
  --surface-3: #272c35;
  --border: #262b33;
  --border-strong: #333a45;

  --fg: #eaecef;
  --fg-dim: #98a1b0;
  --fg-faint: #6a7484;

  --accent: #f7a600;
  --accent-soft: rgba(247, 166, 0, 0.14);
  --accent-ink: #14171c;

  --pos: #20b26c;
  --neg: #ef454a;
  --info: #4a9eff;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.36);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.55);

  /* chart: cycle phases */
  --phase-bull: #1f6f4a;
  --phase-bear: #7a2434;
  --phase-accumulation: #1d4f6e;
  --phase-distribution: #7a5c1c;
  --phase-opacity: 0.3;

  /* chart: bear-market series */
  --series-2013: #8b8fa8;
  /* Kept clearly cooler than --series-now: on Tool 2 the two run side by side
     and a second orange would read as the same line. */
  --series-2017: #b06fd4;
  --series-2021: #5b9bd5;
  --series-now: #f7a600;

  /* chart: scenario bands */
  --scen-0: #2fa36b;
  --scen-1: #4a86c5;
  --scen-2: #cf4a56;
  --band-opacity: 0.18;

  --window: #2ecc71;
  --window-fg: #7fe0a8;
  --window-fg-dim: #5eb886;

  --grid: #21262e;
  --grid-minor: #191d24;
  --grid-zero: #3d4652;
  --ref: #e8b923;

  /* chart: market regimes (tool 3). Bright enough to read as filled bars,
     unlike the --phase-* tokens which are translucent backdrops. */
  --regime-all: #7f8a9c;
  --regime-bear: #ef454a;
  --regime-accumulation: #4a9eff;
  --regime-bull: #20b26c;
  --regime-distribution: #d38b3a;

  /* chart: analog price paths. Categorical, and deliberately clear of the
     gold used for the actual line and the cycle-low reference. */
  --path-0: #5b9bd5;
  --path-1: #b06fd4;
  --path-2: #4ec9a0;
  --path-3: #ef7f8a;
  --path-4: #9aa5b8;
  --path-5: #56c2d6;

  /* tool 4: red-news event types. Categorical and hot-leaning - these mark
     danger, so nothing here should read as a calm blue. */
  --evt-fomc: #ef454a;
  --evt-cpi: #ff8a3d;
  --evt-nfp: #d38b3a;
  --evt-gdp: #b06fd4;
  --evt-other: #7f8a9c;
}

/* ---------- tokens: light (Apple) ---------- */
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f5f5f7;
  --bg-glass: rgba(250, 250, 252, 0.76);
  --surface: #ffffff;
  --surface-2: #f2f2f5;
  --surface-3: #e6e7eb;
  --border: #e2e3e8;
  --border-strong: #d0d2d9;

  --fg: #1d1d1f;
  --fg-dim: #63656b;
  --fg-faint: #8a8d94;

  --accent: #d98c00;
  --accent-soft: rgba(217, 140, 0, 0.12);
  --accent-ink: #ffffff;

  --pos: #0f9d58;
  --neg: #dc3545;
  --info: #0071e3;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.12);

  --phase-bull: #7ecfa8;
  --phase-bear: #f0a3ad;
  --phase-accumulation: #9ec9e8;
  --phase-distribution: #f0d199;
  --phase-opacity: 0.45;

  --series-2013: #767a92;
  --series-2017: #8b46b8;
  --series-2021: #2f7ec2;
  --series-now: #d98c00;

  --scen-0: #0f9d58;
  --scen-1: #2f7ec2;
  --scen-2: #dc3545;
  --band-opacity: 0.13;

  --window: #0f9d58;
  --window-fg: #0b7c45;
  --window-fg-dim: #4a9e78;

  --grid: #e7e8ec;
  --grid-minor: #f0f1f4;
  --grid-zero: #bfc2c9;
  --ref: #c79100;

  --regime-all: #6d7787;
  --regime-bear: #dc3545;
  --regime-accumulation: #0071e3;
  --regime-bull: #0f9d58;
  --regime-distribution: #c07a1f;

  --path-0: #2f7ec2;
  --path-1: #8b46b8;
  --path-2: #128a6e;
  --path-3: #c2456a;
  --path-4: #6d7787;
  --path-5: #0f8ea3;

  --evt-fomc: #dc3545;
  --evt-cpi: #d2601a;
  --evt-nfp: #b3761f;
  --evt-gdp: #8b46b8;
  --evt-other: #6d7787;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

.num { font-variant-numeric: tabular-nums; }

::selection { background: var(--accent-soft); }

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

/* ==========================================================================
   Top bar - translucent, sticky, hairline base
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px var(--pad-x);
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.logo {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(150deg, #ffc247, var(--accent));
  color: #14171c;
  box-shadow: 0 2px 10px rgba(247, 166, 0, 0.32);
}
.logo svg { width: 22px; height: 22px; display: block; }

.brand > div { min-width: 0; }
.brand h1 {
  margin: 0;
  font-size: 17px; font-weight: 640;
  letter-spacing: -0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Two-tone wordmark. The tail carries the accent, so the name reads as one
   word but lands on the colour the rest of the app is built around. */
.brand-head { color: var(--fg); }
.brand-tail { color: var(--accent); }
.brand .sub {
  margin: 1px 0 0;
  font-size: 12.5px; color: var(--fg-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; flex: none; }

/* ---------- buttons ---------- */
.btn {
  font: inherit;
  font-size: 13.5px; font-weight: 550;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.14s var(--ease), background 0.18s, opacity 0.18s,
              border-color 0.18s, color 0.18s;
}
/* Buttons are used as both <button> and <a>; an anchor keeps the link
   underline unless it is turned off here. */
a.btn { display: inline-flex; align-items: center; text-decoration: none; }

.btn:active:not(:disabled) { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }

.btn-ghost {
  background: var(--surface-2);
  color: var(--fg);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); }

.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  display: grid; place-items: center;
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--fg-dim);
  border-radius: 50%;
}
.btn-icon:hover { color: var(--fg); background: var(--surface-3); }
.btn-icon svg { width: 17px; height: 17px; }
:root[data-theme="light"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon,
:root:not([data-theme="light"]) .icon-moon { display: none; }

/* ---------- status chip ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--fg-dim);
  white-space: nowrap;
}
.chip::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--fg-faint);
  flex: none;
}
.chip.ok { color: var(--pos); border-color: rgba(32, 178, 108, 0.3); }
.chip.ok::before { background: var(--pos); box-shadow: 0 0 0 3px rgba(32, 178, 108, 0.18); }
.chip.err { color: var(--neg); border-color: rgba(239, 69, 74, 0.3); }
.chip.err::before { background: var(--neg); }
.chip.busy::before { animation: pulse 1.1s var(--ease) infinite; }

@keyframes pulse { 50% { opacity: 0.25; } }

/* ==========================================================================
   Page shell
   ========================================================================== */
/* Full width, inset only by --pad-x, which is the same inset the topbar uses -
   so the content column now lines up with the header instead of sitting in a
   1440px block with the bar running past it on both sides. */
.shell {
  padding: 0 var(--pad-x) 8px;
}

/* ==========================================================================
   Ticker strip - the numbers you came for, above the fold
   ========================================================================== */
.ticker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 20px 0 4px;
}
@media (max-width: 900px) {
  .ticker { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 460px) {
  .ticker { grid-template-columns: 1fr; }
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 13px 16px;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 11.5px; font-weight: 560;
  letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--fg-faint);
}
.stat-value {
  margin-top: 3px;
  font-size: 22px; font-weight: 620;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.stat-meta {
  margin-top: 2px;
  font-size: 12px; color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}
.stat-meta .up { color: var(--pos); }
.stat-meta .down { color: var(--neg); }

/* ==========================================================================
   Segmented control (iOS) with a sliding thumb
   ========================================================================== */
.segmented {
  position: relative;
  display: flex;
  gap: 2px;
  margin: 20px 0 0;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow-x: auto;
  scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }

.segmented::before {
  content: "";
  position: absolute;
  top: 3px; bottom: 3px;
  left: 0;
  width: var(--seg-w, 0px);
  transform: translateX(var(--seg-x, 0px));
  background: var(--surface);
  border-radius: 11px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.34s var(--ease), width 0.34s var(--ease);
  pointer-events: none;
}
.segmented.no-anim::before { transition: none; }

.tab {
  position: relative;
  flex: 1 1 0;
  min-width: max-content;
  background: none;
  border: none;
  border-radius: 11px;
  font: inherit;
  font-size: 13.5px; font-weight: 550;
  color: var(--fg-dim);
  padding: 9px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s;
}
.tab:hover { color: var(--fg); }
.tab.active { color: var(--fg); }
.tab b {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px; margin-right: 7px;
  border-radius: var(--r-xs);
  background: var(--surface-3); color: var(--fg-faint);
  font-size: 10.5px; font-weight: 640;
  vertical-align: 1.5px;
  transition: background 0.2s, color 0.2s;
}
.tab.active b { background: var(--accent); color: var(--accent-ink); }

/* ==========================================================================
   Notice banner
   ========================================================================== */
.banner {
  position: relative;
  display: flex; gap: 12px;
  margin: 18px 0 0;
  padding: 13px 42px 13px 16px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  border: 1px solid rgba(247, 166, 0, 0.24);
  font-size: 13px; color: var(--fg-dim);
}
.banner[hidden] { display: none; }
.banner-icon {
  flex: none; width: 18px; height: 18px;
  color: var(--accent);
}
.banner b { color: var(--fg); font-weight: 600; }
.banner ul { margin: 6px 0 0; padding-left: 18px; }
.banner li { margin: 2px 0; }
.banner-close {
  position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border: none; border-radius: 50%;
  background: none; color: var(--fg-faint);
  font-size: 17px; line-height: 1; cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.banner-close:hover { background: var(--surface-3); color: var(--fg); }

/* ==========================================================================
   Panels
   ========================================================================== */
.panel[hidden] { display: none; }
.panel { animation: rise 0.4s var(--ease) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
}

.panel-head { margin: 26px 0 16px; }
.panel-head h2 {
  margin: 0 0 5px;
  font-size: clamp(21px, 2.4vw, 26px); font-weight: 650;
  letter-spacing: -0.032em;
}
.panel-head p {
  margin: 0;
  color: var(--fg-dim); font-size: 14.5px;
}

h3 {
  margin: 0 0 10px;
  font-size: 13px; font-weight: 600;
  letter-spacing: 0.02em; text-transform: uppercase;
  color: var(--fg-faint);
}

/* ---------- switches ---------- */
.controls {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.switch {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 13.5px; color: var(--fg-dim);
  padding: 6px 14px 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  cursor: pointer;
  user-select: none;
  transition: color 0.2s, border-color 0.2s;
}
.switch:hover { color: var(--fg); }
.switch:has(input:checked) { color: var(--fg); }

.switch input {
  appearance: none; -webkit-appearance: none;
  position: relative;
  flex: none;
  margin: 0;
  width: 38px; height: 22px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  cursor: pointer;
  transition: background 0.26s var(--ease);
}
.switch input::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.32);
  transition: transform 0.26s var(--ease);
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }

/* ---------- chart card ---------- */
.chart-host {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 10px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.chart-svg { display: block; width: 100%; height: auto; }

/* Below tablet width the axis labels shrink to nothing, so let the chart keep
   a legible size and pan sideways instead - the way a trading app does it.
   Scoped to .chart-host: the min-width only makes sense where there is a
   scroll container around it. The landing chart draws itself to the width it
   is given and must not be forced past its host. */
@media (max-width: 760px) {
  .chart-host {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .chart-host .chart-svg { min-width: 660px; }
  /* Twelve month columns, or a path with year labels hanging off the right
     edge, need more room than the default before they collapse. */
  .chart-wide .chart-svg { min-width: 860px; }
  .chart-host::after {
    content: "Swipe the chart to pan";
    position: sticky; left: 10px;
    display: block; width: max-content;
    margin-top: 2px;
    font-size: 10.5px; color: var(--fg-faint);
  }
}

/* ---------- legend ---------- */
.legend {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin: 12px 0 0;
  font-size: 12.5px; color: var(--fg-dim);
}
.key {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-variant-numeric: tabular-nums;
}
.key i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: none; }
.key i.key-line { width: 16px; height: 2px; border-radius: 2px; background: var(--accent); }

/* ==========================================================================
   Scenario cards
   ========================================================================== */
.cards {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 14px; margin-top: 20px;
}
@media (max-width: 900px) { .cards { grid-template-columns: 1fr; } }

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.28s var(--ease), box-shadow 0.28s var(--ease);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.card-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--fg-dim);
}
.card-head::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--card-color, var(--fg-faint));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--card-color, var(--fg-faint)) 22%, transparent);
}
.card-0 { --card-color: var(--scen-0); }
.card-1 { --card-color: var(--scen-1); }
.card-2 { --card-color: var(--scen-2); }

.card-range {
  margin: 8px 0 2px;
  font-size: 25px; font-weight: 640;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}
.card-dd {
  font-size: 12px; color: var(--fg-faint);
  margin-bottom: 10px;
  font-variant-numeric: tabular-nums;
}
.card p { margin: 0; font-size: 13px; color: var(--fg-dim); line-height: 1.55; }

/* ==========================================================================
   Table
   ========================================================================== */
.table-wrap {
  margin-top: 22px;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.5px;
  min-width: 640px;
  font-variant-numeric: tabular-nums;
}
th, td { text-align: right; padding: 12px 16px; }
th:first-child, td:first-child { text-align: left; }
thead th {
  color: var(--fg-faint); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  position: sticky; top: 0;
}
tbody tr { transition: background 0.16s; }
tbody tr + tr td { border-top: 1px solid var(--border); }
tbody tr:hover { background: var(--surface-2); }
tr.dim td { color: var(--fg-faint); }
td.neg { color: var(--neg); }
td.pos { color: var(--pos); }
.tag {
  font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: var(--r-pill);
  background: var(--surface-3); color: var(--fg-faint);
  text-transform: uppercase; letter-spacing: 0.04em;
  vertical-align: 1px;
}

/* ==========================================================================
   Tool 3 - historic returns
   ========================================================================== */

/* ---------- regime tokens shared by pills, chips and verdicts ---------- */
.regime-all          { --regime: var(--regime-all); }
.regime-bear         { --regime: var(--regime-bear); }
.regime-accumulation { --regime: var(--regime-accumulation); }
.regime-bull         { --regime: var(--regime-bull); }
.regime-distribution { --regime: var(--regime-distribution); }

.regime-pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  font-size: 10px; font-weight: 640;
  letter-spacing: 0.04em; text-transform: uppercase;
  background: color-mix(in srgb, var(--regime) 20%, transparent);
  color: var(--regime);
  border: 1px solid color-mix(in srgb, var(--regime) 34%, transparent);
  white-space: nowrap;
  vertical-align: 1px;
}

/* ---------- regime picker ---------- */
.chipset { display: flex; gap: 8px; flex-wrap: wrap; }

.rchip {
  font: inherit;
  font-size: 13.5px; font-weight: 550;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg-dim);
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}
.rchip::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--regime);
  flex: none;
}
.rchip:hover { color: var(--fg); border-color: var(--border-strong); }
.rchip.active {
  color: var(--fg);
  background: color-mix(in srgb, var(--regime) 13%, var(--surface));
  border-color: color-mix(in srgb, var(--regime) 46%, transparent);
}
.rchip.active::before {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--regime) 24%, transparent);
}
/* Quarter chips carry no regime colour, so they drop the leading dot. */
.rchip-plain::before { display: none; }

.rchip-n {
  font-size: 11px; font-weight: 620;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
}
.rchip.active .rchip-n {
  background: color-mix(in srgb, var(--regime) 26%, transparent);
  color: var(--regime);
}

/* ---------- "you are here" spotlight ---------- */
.spotlight {
  margin: 24px 0 20px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.spot-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spot-eyebrow {
  font-size: 11.5px; font-weight: 620;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--fg-faint);
}
.spot-when {
  font-size: 13px; color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}
.spot-lead {
  margin: 9px 0 0;
  font-size: 13.5px; color: var(--fg-dim); line-height: 1.55;
}
.spot-tiles {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; margin-top: 16px;
}
@media (max-width: 700px) { .spot-tiles { grid-template-columns: 1fr; } }

/* Tools 5 and 6 carry a fourth tile - the reading, the win rate, what the
   regime did anyway, and the difference between them. Three columns would
   strand the last one on a row of its own. */
.spot-tiles-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .spot-tiles-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px)  { .spot-tiles-4 { grid-template-columns: 1fr; } }

.spot-tile {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 13px 15px;
}
.spot-month {
  font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--fg-faint);
}
.spot-val {
  margin-top: 3px;
  font-size: 26px; font-weight: 650;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}
.spot-meta {
  font-size: 12px; color: var(--fg-dim); margin: 1px 0 9px;
  font-variant-numeric: tabular-nums;
}
.spot-note {
  margin: 15px 0 0;
  font-size: 12.5px; color: var(--fg-faint); line-height: 1.6;
}
.spot-note b { color: var(--fg-dim); }

/* ---------- verdict badges ---------- */
.verdict {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
  background: color-mix(in srgb, var(--v) 16%, transparent);
  color: var(--v);
  border: 1px solid color-mix(in srgb, var(--v) 30%, transparent);
}
.verdict-strong { --v: var(--pos); }
.verdict-good   { --v: color-mix(in srgb, var(--pos) 72%, var(--fg-dim)); }
.verdict-mixed  { --v: var(--fg-faint); }
.verdict-soft   { --v: color-mix(in srgb, var(--neg) 68%, var(--fg-dim)); }
.verdict-avoid  { --v: var(--neg); }
.verdict-thin   { --v: var(--fg-faint); }

/* The same scale reused as bare SVG text under each bar. */
text.verdict-strong { fill: var(--pos); }
text.verdict-good   { fill: var(--pos); opacity: 0.8; }
text.verdict-mixed,
text.verdict-thin   { fill: var(--fg-faint); }
text.verdict-soft   { fill: var(--neg); opacity: 0.8; }
text.verdict-avoid  { fill: var(--neg); }

/* ---------- returns heatmap ---------- */
.heat-wrap { margin-top: 0; }
.heat-wrap + h3 { margin-top: 30px; }
.heat-wrap-narrow { width: 100%; }

table.heat { font-size: 12.5px; }
table.heat-month { min-width: 1000px; }
/* Four data columns rather than twelve, so it keeps its own floor - but it
   fills the row like everything else instead of stopping two thirds in. */
table.heat-quarter { min-width: 620px; width: 100%; }
table.heat-quarter th[scope="col"]:first-child { width: 200px; }
table.heat th[scope="col"] { text-align: right; }
table.heat th[scope="col"]:first-child { text-align: left; }
table.heat th[scope="row"] {
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface);
  position: sticky; left: 0;
  border-right: 1px solid var(--border);
}
table.heat td, table.heat th { padding: 8px 12px; }
table.heat .yr { font-variant-numeric: tabular-nums; margin-right: 7px; }

.heat-cell { font-variant-numeric: tabular-nums; }
.heat-empty { background: repeating-linear-gradient(
  -45deg, transparent, transparent 5px,
  color-mix(in srgb, var(--fg-faint) 9%, transparent) 5px,
  color-mix(in srgb, var(--fg-faint) 9%, transparent) 10px); }
.heat-open { font-style: italic; }
.tag-open { margin-left: 5px; }

/* ---------- tool 6: reading x regime ----------
   Five wide cells rather than twelve narrow ones, and each carries a win rate
   and a sample size under the number - so the cell is centred and two lines
   tall instead of a right-aligned figure. */
table.heat-sentiment { min-width: 700px; width: 100%; }
table.heat-sentiment th[scope="col"] { text-align: center; }
table.heat-sentiment th[scope="col"]:first-child { text-align: left; width: 190px; }
table.heat-sentiment td { text-align: center; }
table.heat-sentiment .heat-cell,
table.heat-sentiment .heat-empty { border-radius: 7px; font-weight: 620; }
table.heat-sentiment td small {
  display: block;
  font-size: 10.5px; font-weight: 500;
  opacity: 0.75;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
/* A cell nobody should lean on. Dashed rather than faded: it still has to be
   readable, it just has to announce that it is thin. */
.heat-thin { outline: 1px dashed var(--border-strong); outline-offset: -2px; }

.heat-total {
  font-weight: 640;
  border-left: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
tr.heat-foot td, tr.heat-foot th {
  border-top: 1px solid var(--border-strong);
  font-weight: 600;
  background: var(--surface-2);
  font-variant-numeric: tabular-nums;
}
tr.dim-row { opacity: 0.26; }
tr.dim-row:hover { opacity: 0.7; }
table.heat tbody tr { transition: opacity 0.24s var(--ease), background 0.16s; }

/* ---------- quarter cards ---------- */
.cards-4 { grid-template-columns: repeat(4, 1fr); margin-top: 14px; }
@media (max-width: 1000px) { .cards-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px)  { .cards-4 { grid-template-columns: 1fr; } }
.card-q .card-range { font-size: 27px; }
.card-q p { margin-top: 4px; }
.card-sub { font-size: 17px; font-weight: 620; margin-left: 6px; }

/* Projection table: the two rows that are not analog years. */
tr.row-actual td { background: var(--accent-soft); }
tr.row-actual td:first-child { font-weight: 600; }
tr.row-mid td {
  border-top: 1px solid var(--border-strong);
  background: var(--surface-2);
}

.lede {
  margin: -4px 0 14px;
  font-size: 13.5px; color: var(--fg-dim); line-height: 1.55;
}
.muted { color: var(--fg-faint); font-weight: 400; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* ==========================================================================
   Notes + footer
   ========================================================================== */
.notes {
  margin-top: 22px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.notes p { margin: 0 0 10px; font-size: 13.5px; color: var(--fg-dim); line-height: 1.6; }
.notes p:last-child { margin-bottom: 0; }
.notes b { color: var(--fg); font-weight: 600; }

footer {
  margin-top: 34px;
  /* Edge to edge on every screen: no horizontal inset beyond the safe area, so
     the small print uses the whole window instead of the --maxw column the rest
     of the page sits in. env() keeps it off the rounded corners and the notch
     on phones, where a literal 0 would clip. */
  padding-block: 16px;
  padding-inline: env(safe-area-inset-left, 0px) env(safe-area-inset-right, 0px);
  border-top: 1px solid var(--border);
  color: var(--fg-faint); font-size: 12.5px;
  text-align: center;
}
/* Deliberately not the --maxw column the rest of the page lines up with: this
   is two lines of small print, and a 1440px centred measure left it wrapping in
   a narrow strip with most of a wide monitor empty beside it. */
footer > div { max-width: none; margin: 0; }
/* No measure cap either — a 92ch cap resolves to about 724px at this font
   size, which was the original half-width wrap. The last paragraph drops its
   margin so the block ends on the text rather than on empty space. */
footer p { margin: 0 0 6px; max-width: none; }
footer p:last-child { margin-bottom: 0; }
footer b { color: var(--fg-dim); }
.src { font-size: 11.5px; }

/* ==========================================================================
   SVG primitives
   ========================================================================== */
.grid { stroke: var(--grid); stroke-width: 1; }
.grid-minor { stroke: var(--grid-minor); }
.grid-zero { stroke: var(--grid-zero); stroke-width: 1.4; }
.axis-label { fill: var(--fg-faint); font-size: 11px; }
.axis-strong { fill: var(--fg-dim); font-size: 13px; font-weight: 600; }
.axis-note { fill: var(--fg-faint); font-size: 10px; }
.axis-title { fill: var(--fg-faint); font-size: 12px; }

.price-line {
  fill: none; stroke: var(--accent);
  stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round;
}
.marker { stroke: var(--surface); stroke-width: 2; }
.mk-top { fill: var(--neg); }
.mk-bottom { fill: var(--pos); }
.marker-minor { opacity: 0.75; }
.mk-label { fill: var(--fg); font-size: 11px; font-weight: 600; }
.mk-sub { fill: var(--fg-faint); font-size: 10px; }
.mk-lowsofar { fill: none; stroke: var(--ref); stroke-width: 2; }

.crosshair { stroke: var(--fg-faint); stroke-width: 1; stroke-dasharray: 3 3; }
.hover-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }

.dd-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; opacity: 0.85; }
.dd-line-current { stroke-width: 3.2; opacity: 1; }
.dd-end { stroke: var(--surface); stroke-width: 1.5; }
.dd-note { font-size: 11px; font-weight: 600; }

.window-label { fill: var(--window-fg); font-size: 12px; font-weight: 600; }
.window-sub { fill: var(--window-fg-dim); font-size: 10.5px; }
.scen-name { fill: var(--fg-dim); font-size: 11.5px; font-weight: 600; }
.scen-price { fill: var(--fg-faint); font-size: 11px; }

.bar { transition: opacity 0.14s; }
.bar:hover { opacity: 1 !important; }
.bar-value { fill: var(--fg-dim); font-size: 11px; font-weight: 600; }

.proj-line {
  fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round;
  opacity: 0.9;
}
/* The middle path has to win the eye against up to six analog lines. */
.proj-mid {
  fill: none; stroke: var(--fg); stroke-width: 3.4;
  stroke-linejoin: round; stroke-linecap: round;
  stroke-dasharray: 9 5;
}
.proj-actual { fill: none; stroke: var(--accent); stroke-width: 3.4; stroke-linecap: round; }
.proj-label { font-size: 11.5px; font-weight: 600; }
.q-divider { stroke: var(--fg-faint); stroke-width: 1; stroke-dasharray: 2 4; opacity: 0.7; }
.ref-line { stroke: var(--ref); stroke-width: 1.2; stroke-dasharray: 4 4; opacity: 0.75; }
/* Sits on top of the paths, so it gets a card-coloured outline to stay legible
   wherever the reference level happens to fall. */
.ref-label {
  fill: var(--ref); font-size: 10.5px;
  paint-order: stroke;
  stroke: var(--surface); stroke-width: 3.5px; stroke-linejoin: round;
}

/* Tool 4: the all-years reference level drawn across each regime bar. */
.cmp-tick { stroke: var(--fg-dim); stroke-width: 2; stroke-dasharray: 3 2.5; opacity: 0.85; }
.key i.key-cmp {
  background: none; height: 0;
  border-top: 2px dashed var(--fg-dim);
  width: 16px;
}
.key i.key-mid {
  background: none; height: 0;
  border-top: 3px dashed var(--fg);
  width: 16px;
}
.key i.key-ref {
  background: none; height: 0;
  border-top: 2px dashed var(--ref);
  width: 16px;
}

/* ==========================================================================
   Tooltip - frosted, floating
   ========================================================================== */
.tooltip {
  position: absolute; pointer-events: none; z-index: 10;
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 10px 13px;
  font-size: 12.5px; line-height: 1.45; max-width: 290px;
  box-shadow: var(--shadow-lg);
  font-variant-numeric: tabular-nums;
}
.tooltip[hidden] { display: none; }
.tt-price { font-size: 18px; font-weight: 640; margin-top: 3px; letter-spacing: -0.03em; }
.tt-phase { font-size: 11.5px; margin-top: 4px; font-weight: 550; }
.tt-note { font-size: 11.5px; color: var(--fg-faint); margin-top: 6px; }
.tt-row { display: flex; align-items: center; gap: 8px; margin-top: 5px; font-size: 12px; }
.tt-row i { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.tt-row span { flex: 1; color: var(--fg-dim); }

/* ==========================================================================
   Tool 4 - red USD news days
   ========================================================================== */

/* Status chip + refresh sit on one line, pushed apart. */
.controls-split { align-items: center; justify-content: space-between; }

.empty-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.empty-state p {
  margin: 0 auto 16px;
  color: var(--fg-dim); font-size: 14px; line-height: 1.6;
}

/* ---------- source provenance badges ---------- */
.src-badge {
  display: inline-block;
  margin-left: 7px;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  font-size: 10px; font-weight: 640;
  letter-spacing: 0.04em; text-transform: uppercase;
  white-space: nowrap; vertical-align: 1px;
  background: color-mix(in srgb, var(--badge) 18%, transparent);
  color: var(--badge);
  border: 1px solid color-mix(in srgb, var(--badge) 34%, transparent);
}
.src-fed  { --badge: var(--info); }
.src-feed { --badge: var(--pos); }
/* Estimated dates are the ones that can be wrong, so they get the warning
   colour rather than a neutral grey. */
.src-rule { --badge: var(--accent); }

/* ---------- the headline warning ---------- */
.danger-card {
  display: flex; gap: 18px;
  margin: 4px 0 26px;
  padding: 20px 22px;
  border-radius: var(--r-lg);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--neg) 11%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--neg) 38%, transparent);
  box-shadow: var(--shadow-md);
}
.danger-imminent {
  border-color: color-mix(in srgb, var(--neg) 62%, transparent);
  box-shadow: var(--shadow-md), 0 0 0 4px color-mix(in srgb, var(--neg) 12%, transparent);
}
.danger-mark { color: var(--neg); flex: none; }
.danger-mark svg { width: 34px; height: 34px; display: block; }
.danger-body { min-width: 0; }

.danger-kicker {
  font-size: 11.5px; font-weight: 640;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--neg);
}
.danger-date {
  margin: 4px 0 2px;
  font-size: 26px; font-weight: 660; letter-spacing: -0.035em;
}
.danger-weekday {
  margin-left: 9px;
  font-size: 14px; font-weight: 500; letter-spacing: -0.01em;
  color: var(--fg-faint);
}
.danger-events { font-size: 13.5px; color: var(--fg-dim); }
.danger-time {
  margin-left: 7px;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: var(--surface-3); color: var(--fg-faint);
  font-size: 11px; font-variant-numeric: tabular-nums;
}
.danger-warn {
  margin: 12px 0 0;
  font-size: 13.5px; line-height: 1.55; color: var(--fg-dim);
}
.danger-warn b { color: var(--fg); }
.danger-hist {
  margin: 8px 0 0;
  font-size: 13px; line-height: 1.6; color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}

/* ---------- the month ahead ---------- */
.up-list-host { display: flex; flex-direction: column; gap: 10px; }

.up-row {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 18px; align-items: center;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--evt, var(--fg-faint));
  border-radius: var(--r-lg);
  transition: border-color 0.2s, background 0.2s;
}
.up-row:hover { background: var(--surface-2); border-color: var(--border-strong); }
.up-fomc  { --evt: var(--evt-fomc); }
.up-cpi   { --evt: var(--evt-cpi); }
.up-nfp   { --evt: var(--evt-nfp); }
.up-gdp   { --evt: var(--evt-gdp); }
.up-other { --evt: var(--evt-other); }

.up-when { text-align: center; font-variant-numeric: tabular-nums; }
.up-date { font-size: 17px; font-weight: 640; letter-spacing: -0.03em; }
.up-day {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--fg-faint);
}
.up-away { margin-top: 3px; font-size: 11.5px; color: var(--evt); }

.up-what { min-width: 0; }
.up-title {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 14px; font-weight: 600;
}
.up-title i { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.up-list { margin-top: 3px; font-size: 12.5px; color: var(--fg-dim); }
.up-warn { margin-top: 5px; font-size: 12px; color: var(--neg); }
.up-warn em { color: var(--accent); font-style: normal; }

.up-expect {
  text-align: right; font-variant-numeric: tabular-nums;
  font-size: 12px; color: var(--fg-dim);
}
.up-mult { font-size: 19px; font-weight: 640; color: var(--fg); letter-spacing: -0.03em; }
.up-sub { display: block; margin-top: 2px; font-size: 11.5px; color: var(--fg-faint); }

@media (max-width: 760px) {
  .up-row { grid-template-columns: 72px 1fr; }
  .up-expect { grid-column: 2; text-align: left; }
}

/* ---------- type cards ---------- */
.card-head i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
/* These cards carry their dot in the markup, so suppress the generic one. */
#t4-types .card-head::before { display: none; }
.card-unit {
  font-size: 12px; font-weight: 500; letter-spacing: 0;
  color: var(--fg-faint);
}
.card-worst { margin-top: 8px !important; font-size: 12.5px !important; }
.card-worst b { color: var(--fg); }

/* ---------- chart + table ---------- */
.red-bar { transition: opacity 0.2s; }
.baseline-line {
  stroke: var(--fg-faint);
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
}
.key i.key-dash {
  background: none;
  border-top: 2px dashed var(--fg-faint);
  width: 16px; height: 0; border-radius: 0;
}
.key-note { color: var(--fg-faint); }

th.txt, td.txt { text-align: left; }
td .dot {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  margin-right: 8px; vertical-align: 0;
}
td.up { color: var(--pos); }
td.down { color: var(--neg); }

.mult {
  display: inline-block;
  min-width: 46px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-3); color: var(--fg-dim);
  font-size: 12px; font-weight: 600;
}
.mult-hot {
  background: color-mix(in srgb, var(--neg) 20%, transparent);
  color: var(--neg);
}

/* ---------- sortable headers ---------- */
.th-sort {
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  color: inherit; background: none; border: 0; padding: 0;
  display: inline-flex; align-items: center; gap: 5px;
  cursor: pointer;
  transition: color 0.16s;
}
.th-sort:hover { color: var(--fg); }
.th-sort.active { color: var(--fg); }
/* The arrow holds its space at all times so a sort never nudges the columns. */
.th-arrow { font-size: 8px; opacity: 0; transition: opacity 0.16s; }
.th-sort:hover .th-arrow { opacity: 0.45; }
.th-sort.active .th-arrow { opacity: 1; color: var(--accent); }

/* ---------- pagination ---------- */
.pager {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 12px;
}
.pg-info {
  margin-right: auto;
  font-size: 12.5px; color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
}
.pg-btn {
  font: inherit;
  min-width: 32px; height: 32px;
  padding: 0 9px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg-dim);
  font-size: 13px; font-weight: 550;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: color 0.16s, border-color 0.16s, background 0.16s;
}
.pg-btn:hover:not(:disabled) { color: var(--fg); border-color: var(--border-strong); }
.pg-btn:disabled { opacity: 0.4; cursor: default; }
.pg-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.pg-gap { color: var(--fg-faint); padding: 0 2px; font-size: 12.5px; }

/* ==========================================================================
   Small screens + motion preferences
   ========================================================================== */
@media (max-width: 620px) {
  /* The topbar chip is hidden below, but tool 4's status line is the only
     signal that its numbers are live - keep that one. */
  .controls .chip { display: inline-flex; }
  .danger-card { flex-direction: column; gap: 12px; padding: 16px 18px; }
  .danger-date { font-size: 21px; }
}

@media (max-width: 620px) {
  .brand .sub { display: none; }
  .brand h1 { font-size: 15.5px; }
  .topbar { padding: 10px var(--pad-x); gap: 10px; }
  .chip { display: none; }
  .tab b { display: none; }
  .btn-primary { padding: 8px 13px; font-size: 13px; }
  .stat { padding: 11px 14px; }
  .stat-value { font-size: 20px; }
  .notes, .panel-head p { font-size: 13.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
