/* SWIFT vs Stablecoin dashboard — institutional research aesthetic (Phase 4 palette) */

:root {
  /* Phase 4 palette ------------------------------------------------- */
  --bg-base:        #FAF8F5;  /* warm off-white, paper not screen */
  --bg-surface:     #F2EFEA;  /* card / table-header surface */
  --text-primary:   #1A1A1A;  /* warm-leaning near-black */
  --text-secondary: #5C5651;  /* warm grey */
  --border-soft:    #D8D2C8;  /* dividers */
  --accent-primary: #1F3A5F;  /* institutional navy — single chrome accent */
  --series-usdc:    #1F3A5F;
  --series-usdt:    #B8860B;
  --series-legacy:  #3D3935;
  --semantic-pos:   #5A7A5A;  /* sage — savings only */
  --semantic-neg:   #8B3A3A;  /* brick — cost only */
  --highlight-band: #E8DFC8;  /* CI / range fill */

  /* Backward-compat aliases — JSX inline styles reference these names.
     Renaming the underlying values is the palette swap; the names stay live so that
     `style={{color:'var(--accent)'}}` etc. continues to resolve without JSX edits. */
  --paper:   var(--bg-base);
  --paper-2: var(--bg-surface);
  --ink:     var(--text-primary);
  --muted:   var(--text-secondary);
  --line:    var(--border-soft);
  --line-2:  rgba(216, 210, 200, 0.5); /* border-soft at 50% — faintest grid */
  --accent:  var(--accent-primary);

  /* Typography stacks. Source Serif 4 + Inter loaded via <link> in
     Stablecoin_Dashboard.html (weights 400/600 only). */
  --serif: "Source Serif 4", "Source Serif Pro", Charter, Georgia, serif;
  --sans:  "Inter", "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono:  var(--sans); /* spec retires mono; alias to sans for JSX backward-compat */

  --num-feat: "tnum" 1, "lnum" 1;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body { min-height: 100vh; }

a { color: var(--accent-primary); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--text-primary); }
button { font-family: var(--sans); cursor: pointer; }

/* ---------- Shell ---------- */
.shell { max-width: 1480px; margin: 0 auto; padding: 28px 40px 80px; }

.masthead {
  border-top: 1px solid var(--text-primary);
  border-bottom: 1px solid var(--text-primary);
  padding: 18px 0 14px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}
.masthead .left  { font-family: var(--sans); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-secondary); font-feature-settings: var(--num-feat); }
.masthead .mid   { font-family: var(--serif); font-size: clamp(2.5rem, 4.5vw, 3.5rem); font-weight: 600; letter-spacing: -0.015em; text-align: center; line-height: 1.1; margin-bottom: 0.5rem; }
.masthead .mid em { font-style: italic; color: var(--accent-primary); }
.masthead .right { font-family: var(--sans); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; text-align: right; color: var(--text-secondary); font-feature-settings: var(--num-feat); }

/* sub-bar */
.subbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 0; border-bottom: 1px solid var(--border-soft);
  font-family: var(--sans); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-secondary);
}
.subbar .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-primary); display: inline-block; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--text-primary); margin-top: 20px; }
.tab {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  padding: 14px 22px 12px; font-family: var(--sans); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-secondary); margin-bottom: -1px; position: relative;
  transition: color .15s;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent-primary); border-bottom-color: var(--accent-primary); }
.tab .num { font-family: var(--serif); font-size: 18px; font-weight: normal; margin-right: 8px; letter-spacing: 0; color: var(--accent-primary); font-feature-settings: var(--num-feat); }
.tab.active .num { color: var(--accent-primary); }

/* Hypothesis header */
.hero {
  display: grid; grid-template-columns: 110px 1fr 260px;
  gap: 36px; padding: 28px 0 24px; border-bottom: 1px solid var(--border-soft);
  align-items: start;
}
.hero .hnum { font-family: var(--serif); font-size: 88px; line-height: .85; color: var(--accent-primary); letter-spacing: -0.03em; font-feature-settings: var(--num-feat); }
.hero h1 { font-family: var(--serif); font-weight: 600; font-size: 38px; line-height: 1.1; letter-spacing: -0.015em; margin-bottom: 8px; color: var(--text-primary); }
.hero .sub { font-family: var(--serif); font-style: italic; font-size: 19px; color: var(--text-secondary); line-height: 1.35; max-width: 60ch; }
.hero .verdict {
  border: 1px solid var(--border-soft); padding: 10px 12px; background: var(--bg-surface);
}
.hero .verdict .label { font-family: var(--sans); font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 6px; }
.hero .verdict .val   { font-family: var(--serif); font-size: 22px; line-height: 1.15; color: var(--text-primary); font-feature-settings: var(--num-feat); }
/* Statistical findings stay neutral or navy — verdict.red/green/ochre are class hooks
   from JSX; we collapse them to a single navy treatment per the design discipline. */
.hero .verdict .val.red,
.hero .verdict .val.green,
.hero .verdict .val.ochre { color: var(--accent-primary); }
.hero .verdict .tag { display: inline-block; margin-top: 10px; font-family: var(--sans); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; padding: 3px 8px; border: 1px solid var(--border-soft); color: var(--text-primary); }

/* Grid layout */
.grid { display: grid; gap: 20px; margin-top: 20px; }
.grid.c3  { grid-template-columns: repeat(3, 1fr); }
.grid.c4  { grid-template-columns: repeat(4, 1fr); }
.grid.c12 { grid-template-columns: 8fr 4fr; }
.grid.c21 { grid-template-columns: 2fr 1fr; }

/* Cards — flat, surface-distinguished (no shadows) */
.card {
  background: var(--bg-base); border: 1px solid var(--border-soft);
  padding: 18px 20px;
  position: relative;
}
.card.dark { background: var(--text-primary); color: var(--bg-base); border-color: var(--text-primary); }
.card.dark .ctitle, .card.dark .clabel, .card.dark .csub { color: rgba(250, 248, 245, 0.72); }
.card .ctitle  { font-family: var(--sans); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
.card .csub    { font-family: var(--serif); font-style: italic; color: var(--text-secondary); font-size: 14px; margin-bottom: 12px; }
.card .big     { font-family: var(--serif); font-size: 48px; line-height: 1; letter-spacing: -0.02em; font-feature-settings: var(--num-feat); }
.card .big .unit { font-size: 18px; color: var(--text-secondary); margin-left: 4px; font-style: italic; }
.card .mid     { font-family: var(--serif); font-size: 28px; line-height: 1.1; font-feature-settings: var(--num-feat); }
.card .caption { font-family: var(--sans); font-size: 10.5px; letter-spacing: 0.06em; color: var(--text-secondary); margin-top: 10px; text-transform: uppercase; }

/* KPI tiles */
.kpi { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--border-soft); background: var(--bg-surface); }
.kpi > div { padding: 18px 20px; border-right: 1px solid var(--border-soft); }
.kpi > div:last-child { border-right: none; }
.kpi .k    { font-family: var(--sans); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 8px; }
.kpi .v    { font-family: var(--serif); font-size: 34px; line-height: 1; color: var(--text-primary); font-feature-settings: var(--num-feat); }
.kpi .v .sub { font-size: 13px; color: var(--text-secondary); font-style: italic; margin-left: 4px; }
.kpi .hint { font-family: var(--sans); font-size: 9.5px; color: var(--text-secondary); margin-top: 6px; text-transform: uppercase; letter-spacing: 0.06em; }

/* Chart holders */
.chart { width: 100%; display: block; overflow: visible; }
.axis text { font-family: var(--sans); font-size: 10px; fill: var(--text-secondary); font-feature-settings: var(--num-feat); }
.axis line, .axis path { stroke: var(--border-soft); fill: none; shape-rendering: crispEdges; }
.ref-line  { stroke: var(--accent-primary); stroke-width: 1; stroke-dasharray: 3 3; }
.grid-line { stroke: var(--line-2); stroke-width: 1; }

/* Controls */
.controls { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.seg { display: inline-flex; border: 1px solid var(--border-soft); background: var(--bg-base); }
.seg button { background: transparent; border: none; padding: 8px 14px; font-family: var(--sans); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-primary); border-right: 1px solid var(--border-soft); }
.seg button:last-child { border-right: none; }
.seg button.active { background: var(--accent-primary); color: var(--bg-base); }

.slider-wrap { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 260px; }
.slider-wrap label { font-family: var(--sans); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-secondary); white-space: nowrap; }
.slider-wrap .val   { font-family: var(--serif); font-size: 22px; min-width: 90px; text-align: right; font-feature-settings: var(--num-feat); }
input[type="range"] { flex: 1; -webkit-appearance: none; appearance: none; height: 2px; background: var(--border-soft); outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; background: var(--accent-primary); border: 2px solid var(--bg-base); border-radius: 50%; cursor: pointer; }
input[type="range"]::-moz-range-thumb     { width: 16px; height: 16px; background: var(--accent-primary); border: 2px solid var(--bg-base); border-radius: 50%; cursor: pointer; }

/* Narrative blocks */
.essay { font-family: var(--serif); font-size: 17px; line-height: 1.6; color: var(--text-primary); max-width: 68ch; }
.essay p + p { margin-top: 12px; }
.essay em { color: var(--accent-primary); font-style: italic; }
.pullquote { font-family: var(--serif); font-size: 28px; line-height: 1.25; font-style: italic; border-left: 2px solid var(--accent-primary); padding: 4px 0 4px 20px; color: var(--text-primary); }

/* Mono stat lines (now rendered in sans + tabular numerals) */
.stat-line { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dotted var(--border-soft); font-family: var(--sans); font-size: 12px; font-feature-settings: var(--num-feat); }
.stat-line:last-child { border-bottom: none; }
.stat-line .k { color: var(--text-secondary); letter-spacing: 0.04em; text-transform: uppercase; font-size: 10px; }
.stat-line .v { font-weight: 600; color: var(--text-primary); }
/* Stat-line semantic classes — collapsed to neutral/navy (statistical findings are
   results, not value judgments). */
.stat-line .v.sig { color: var(--accent-primary); }
.stat-line .v.nul { color: var(--text-secondary); }
.stat-line .v.pos { color: var(--accent-primary); }

/* Legend */
.legend { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 8px; font-family: var(--sans); font-size: 10.5px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 14px; height: 3px; display: inline-block; }

/* Hover tooltip */
.tooltip { position: absolute; pointer-events: none; background: var(--text-primary); color: var(--bg-base); padding: 8px 10px; font-family: var(--sans); font-size: 10.5px; white-space: nowrap; transform: translate(-50%, -110%); z-index: 50; font-feature-settings: var(--num-feat); }
.tooltip::after { content: ''; position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); border: 3px solid transparent; border-top-color: var(--text-primary); }

/* Footnotes */
.footnote { font-family: var(--sans); font-size: 10px; color: var(--text-secondary); margin-top: 10px; letter-spacing: 0.02em; }

/* Synthesis scorecard */
.scorecard { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border: 1px solid var(--border-soft); }
.scorecard .cell { padding: 22px 20px; border-right: 1px solid var(--border-soft); background: var(--bg-base); position: relative; }
.scorecard .cell:last-child { border-right: none; }
.scorecard .cell .hnum   { font-family: var(--serif); font-size: 42px; color: var(--accent-primary); line-height: 1; font-feature-settings: var(--num-feat); }
.scorecard .cell h3      { font-family: var(--serif); font-weight: 600; font-size: 22px; line-height: 1.15; margin: 8px 0 10px; color: var(--text-primary); }
.scorecard .cell .verdict { font-family: var(--sans); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; padding: 3px 8px; border: 1px solid var(--border-soft); display: inline-block; color: var(--text-primary); }
/* Verdict pill class hooks (.red/.green/.ochre) collapsed to single navy treatment. */
.scorecard .cell .verdict.red,
.scorecard .cell .verdict.green,
.scorecard .cell .verdict.ochre { background: var(--accent-primary); color: var(--bg-base); border-color: var(--accent-primary); }
.scorecard .cell p { font-family: var(--serif); font-size: 14.5px; line-height: 1.45; color: var(--text-primary); margin-top: 10px; }

/* Footer */
.footer {
  margin-top: 60px; border-top: 1px solid var(--text-primary); padding-top: 18px;
  display: flex; justify-content: space-between;
  font-family: var(--sans); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-secondary);
}

/* Appendix regression table */
.regtbl       { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 12px; font-feature-settings: var(--num-feat); }
.regtbl th, .regtbl td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border-soft); }
.regtbl thead { background: var(--bg-surface); }
.regtbl th    { font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-secondary); font-weight: 600; }
.regtbl td.num { text-align: right; font-feature-settings: var(--num-feat); }
.regtbl tr:hover { background: var(--bg-surface); }
.sig-pill         { padding: 1px 6px; font-size: 9.5px; letter-spacing: 0.08em; }
.sig-pill.sig { background: var(--accent-primary); color: var(--bg-base); }
.sig-pill.nul { background: var(--border-soft); color: var(--text-secondary); }
.sig-pill.mar { background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border-soft); }

/* Sliced illustrations */
.illus { position: absolute; right: 18px; top: 18px; opacity: 0.08; pointer-events: none; }

/* Event markers */
.event-label { font-family: var(--sans); font-size: 9.5px; fill: var(--text-primary); letter-spacing: 0.04em; }
.event-line  { stroke: var(--text-primary); stroke-width: 0.5; stroke-dasharray: 2 3; }

/* Appropriability bars */
.bar-row { display: grid; grid-template-columns: 110px 1fr 80px; align-items: center; gap: 12px; padding: 8px 0; }
.bar-row .lab { font-family: var(--sans); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-secondary); }
.bar-row .bar { height: 14px; background: var(--line-2); position: relative; }
.bar-row .bar .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-primary); }
.bar-row .val { font-family: var(--serif); font-size: 20px; text-align: right; font-feature-settings: var(--num-feat); }

/* Answer hero */
.answer-hero {
  border: 1px solid var(--text-primary); padding: 44px 40px; margin-top: 18px; background: var(--bg-surface); position: relative;
}
.answer-hero .kicker { font-family: var(--sans); font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent-primary); margin-bottom: 12px; }
.answer-hero h2 { font-family: var(--serif); font-weight: 600; font-size: 50px; line-height: 1.1; letter-spacing: -0.02em; max-width: 22ch; margin-bottom: 18px; color: var(--text-primary); }
.answer-hero h2 em { color: var(--accent-primary); font-style: italic; }
.answer-hero p  { font-family: var(--serif); font-size: 18px; line-height: 1.55; max-width: 70ch; color: var(--text-primary); }
.answer-hero .drop::first-letter { font-family: var(--serif); font-size: 64px; float: left; line-height: .85; padding: 6px 10px 0 0; color: var(--accent-primary); }

/* Specification selector pills */
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.pill { padding: 6px 10px; border: 1px solid var(--border-soft); font-family: var(--sans); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; background: var(--bg-base); color: var(--text-primary); cursor: pointer; }
.pill.active { background: var(--accent-primary); color: var(--bg-base); border-color: var(--accent-primary); }
.pill:hover { border-color: var(--accent-primary); }

/* Explainer cards */
.explainer {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin-top: 20px;
}
.explainer .ex {
  background: var(--bg-surface); border: 1px solid var(--border-soft);
  padding: 22px 24px; position: relative;
}
.explainer .ex .ribbon {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--sans); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--bg-base); background: var(--accent-primary); padding: 4px 10px; margin-bottom: 14px;
}
.explainer .ex .ribbon .glyph { font-family: var(--serif); font-size: 14px; font-style: italic; }
.explainer .ex h4 {
  font-family: var(--serif); font-weight: 600; font-size: 24px; line-height: 1.2;
  letter-spacing: -0.01em; margin-bottom: 10px; color: var(--text-primary);
}
.explainer .ex h4 em { color: var(--accent-primary); font-style: italic; }
.explainer .ex .plain {
  font-family: var(--serif); font-size: 15px; line-height: 1.5; color: var(--text-primary);
  border-left: 2px solid var(--accent-primary); padding-left: 14px; margin-bottom: 14px;
}
.explainer .ex .plain .lab {
  display: block; font-family: var(--sans); font-size: 9.5px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-secondary); margin-bottom: 4px;
}
.explainer .ex .tech {
  font-family: var(--sans); font-size: 13px; line-height: 1.55; color: var(--text-primary);
}
.explainer .ex .tech .lab {
  display: block; font-family: var(--sans); font-size: 9.5px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-secondary); margin-bottom: 6px;
}
.explainer .ex .formula {
  font-family: var(--sans); font-size: 12.5px; background: var(--bg-base); border: 1px solid var(--border-soft);
  padding: 10px 12px; margin: 10px 0; display: inline-block; font-feature-settings: var(--num-feat);
}
.explainer .ex .verdict-mini {
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  border-top: 1px dotted var(--border-soft); padding-top: 12px; margin-top: 14px;
}
.explainer .ex .verdict-mini .tag-txt {
  font-family: var(--sans); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-secondary);
}
.explainer .ex .verdict-mini .res {
  font-family: var(--serif); font-size: 18px; color: var(--text-primary); font-feature-settings: var(--num-feat);
}
.explainer .ex .verdict-mini .res.sig,
.explainer .ex .verdict-mini .res.rej { color: var(--accent-primary); }

/* Asset toggle labeled chip */
.chip { display: inline-block; padding: 2px 8px; font-family: var(--sans); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; border: 1px solid var(--border-soft); color: var(--text-primary); background: var(--bg-surface); }
.chip.usdc { color: var(--series-usdc); border-color: var(--series-usdc); }
.chip.usdt { color: var(--series-usdt); border-color: var(--series-usdt); }

/* ==========================================================================
   MOBILE OVERRIDES (Appended for QR Code / Mobile Presentation)
   These rules only apply to screens 768px wide or smaller.
   ========================================================================== */
@media (max-width: 768px) {
  /* 1. Adjust main container padding for smaller screens */
  .shell { 
    padding: 16px 16px 40px; 
  }

  /* 2. Stack the Masthead (Title bar) vertically */
  .masthead { 
    display: flex; 
    flex-direction: column; 
    gap: 12px; 
    text-align: center; 
  }
  .masthead .left, .masthead .right { 
    text-align: center; 
  }
  .masthead .mid {
    font-size: 2.2rem; /* Scale down title */
  }

  /* 3. Sub-bar metadata layout */
  .subbar { 
    flex-direction: column; 
    align-items: flex-start; 
    gap: 8px; 
    line-height: 1.4;
  }

  /* 4. Make Navigation Tabs scrollable horizontally */
  .tabs { 
    overflow-x: auto; 
    white-space: nowrap; 
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    padding-bottom: 5px;
  }
  .tab { 
    padding: 10px 16px; 
  }

  /* 5. Stack the Hero section (H1, H2, etc.) */
  .hero { 
    grid-template-columns: 1fr; 
    gap: 16px; 
    padding: 20px 0; 
  }
  .hero .hnum { 
    font-size: 64px; 
    line-height: 1;
  }

  /* 6. Collapse all multi-column grids into a single column */
  .grid.c3, 
  .grid.c4, 
  .grid.c12, 
  .grid.c21, 
  .kpi, 
  .scorecard,
  .explainer { 
    grid-template-columns: 1fr; 
  }

  /* 7. Fix borders on stacked tiles (KPIs and Scorecards) */
  .kpi > div, 
  .scorecard .cell { 
    border-right: none; 
    border-bottom: 1px solid var(--border-soft); 
  }
  .kpi > div:last-child, 
  .scorecard .cell:last-child { 
    border-bottom: none; 
  }

  /* 8. Make large Data Tables scrollable horizontally so they don't break the screen */
  .card { 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch; 
  }
  .regtbl {
    min-width: 600px; /* Forces table to maintain shape and scroll */
  }

  /* 9. Adjust the Answer Hero (Synthesis Tab) */
  .answer-hero { 
    padding: 24px 20px; 
  }
  .answer-hero h2 { 
    font-size: 32px; 
  }
  .answer-hero .drop::first-letter {
    font-size: 48px;
  }

  /* 10. Stack chart controls and sliders */
  .controls {
    flex-direction: column;
    align-items: flex-start;
  }
  .slider-wrap {
    width: 100%;
  }

  /* 11. Adjust Footers */
  .footer {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
}
