/* Flex Model: clean and plain. One system sans throughout, thin rules, one blue accent. White background only (F11).
   The intro and the further info sit in collapsible "windows" so the model is visible without scrolling. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #fafafa;
  --ink: #111111;
  --ink-2: #474744;
  --muted: #6b6b66;
  --rule: #e3e3de;
  --rule-strong: #c6c6bf;
  --accent: #1c5cab;
  --judge: #8a5a00;
  --judge-bg: #fdf3dc;
  /* charts */
  --surface: #ffffff;
  --series-1: #2a78d6;
  --strat-cons: #2a78d6; --strat-mod: #eb6834; --strat-agg: #1baf7a; --strat-taper: #eda100;
  --series-context: #9ec5f4;
  --series-ref: #898781;
  --grid: #ebeae5;
  --axis: #c3c2b7;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.55 var(--sans); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
p { margin: 0 0 1em; }
.wide { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* top bar */
.topbar { border-bottom: 1px solid var(--rule); }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 10px 24px; display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.brand { display: flex; align-items: center; gap: 10px; }
.wordmark { font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.badge { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--judge); background: var(--judge-bg); border-radius: 3px; padding: 2px 6px; }
.badge.market { color: var(--ink-2); background: none; border: 1px solid var(--rule-strong); padding: 1px 6px; text-transform: none; letter-spacing: 0; white-space: nowrap; }
.topbar a.byline { color: var(--ink-2); text-decoration: none; }
.topbar a.byline:hover { color: var(--ink); text-decoration: underline; }

/* collapsible windows */
.win { border: 1px solid var(--rule-strong); border-radius: 6px; margin: 16px 0; background: var(--bg); }
.win-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 8px 7px 14px; background: var(--panel); border-radius: 6px; cursor: pointer; list-style: none; user-select: none; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.win[open] > .win-bar { border-bottom: 1px solid var(--rule); border-radius: 6px 6px 0 0; }
.win-bar::-webkit-details-marker { display: none; }
.win-bar:hover { color: var(--ink); }
.win-btn { flex: none; width: 24px; height: 20px; border: 1px solid var(--rule-strong); border-radius: 4px; background: var(--bg); position: relative; }
.win-btn::before { content: ""; position: absolute; left: 7px; right: 7px; top: 9px; border-top: 1.5px solid var(--ink-2); } /* minimise */
.win:not([open]) .win-btn::after { content: ""; position: absolute; top: 5px; bottom: 5px; left: 11px; border-left: 1.5px solid var(--ink-2); } /* restore (+) */
.win-body { padding: 16px 18px 18px; }

h1 { font-size: 22px; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 4px; }
.dek { color: var(--ink-2); margin: 0 0 14px; }
.facts { list-style: none; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--rule); }
.facts li { padding: 10px 16px 0 0; }
.facts li + li { padding-left: 16px; border-left: 1px solid var(--rule); }
.facts b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.facts span { display: block; font-size: 13px; color: var(--ink-2); line-height: 1.4; }
.notes-line { font-size: 13px; color: var(--muted); margin: 0; }
.notes-line b { color: var(--ink-2); }

#further .win-body { max-width: 900px; }
#further h2 { font-size: 19px; margin: 4px 0 8px; }
#further h3 { font-size: 16px; margin: 22px 0 6px; }
#further ul { padding-left: 1.2em; }
#further li { margin-bottom: 4px; }

/* the tool */
.tool { padding: 8px 0 24px; }
.tool-grid { display: grid; grid-template-columns: 336px minmax(0, 1fr); gap: 32px; align-items: start; }
.controls { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; padding-right: 4px; scrollbar-width: thin; }
.results { min-width: 0; }

.field { margin: 0 0 8px; }
.field-label { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 13px; line-height: 1.4; font-weight: 600; color: var(--ink); margin-bottom: 2px; }
.field-name { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.help { flex: none; width: 15px; height: 15px; padding: 0; border: 1px solid var(--rule-strong); border-radius: 50%; background: var(--bg); color: var(--muted); font: 600 10px/1 var(--sans); cursor: help; position: relative; }
.help::after { content: ""; position: absolute; inset: -5px; }
.help:hover, .help:focus-visible { border-color: var(--ink); color: var(--ink); }
.help-tip { position: fixed; z-index: 20; width: max-content; max-width: min(320px, calc(100vw - 16px)); background: var(--bg); border: 1px solid var(--rule-strong); border-radius: 6px; padding: 9px 11px; font-size: 13px; line-height: 1.45; color: var(--ink-2); pointer-events: none; }
.help-tip p { margin: 0; }
.help-tip p + p { margin-top: 6px; }
.help-tip b { color: var(--ink); }
.topbar-right { display: flex; align-items: center; gap: 18px; }
#currency .seg button { padding: 4px 9px; font-size: 12.5px; }
.field-label output { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.field-note { font-size: 12px; line-height: 1.4; color: var(--muted); margin: 3px 0 0; }

.seg { display: flex; border: 1px solid var(--rule-strong); border-radius: 5px; overflow: hidden; background: var(--bg); }
.seg button { flex: 1 1 auto; min-width: 0; font: 500 13px/1.2 var(--sans); color: var(--ink-2); background: transparent; border: 0; border-left: 1px solid var(--rule-strong); padding: 6px 4px; cursor: pointer; }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg button:hover:not([aria-pressed="true"]) { background: var(--panel); color: var(--ink); }

select { width: 100%; font: 13.5px/1.3 var(--sans); color: var(--ink); background: var(--bg); border: 1px solid var(--rule-strong); border-radius: 5px; padding: 5px 8px; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 16px; background: transparent; margin: 0; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; background: var(--rule-strong); border-radius: 2px; }
input[type="range"]::-moz-range-track { height: 3px; background: var(--rule-strong); border-radius: 2px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6.5px; border-radius: 50%; background: var(--ink); border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--ink); }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--ink); border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--ink); }

.divider { border: 0; border-top: 1px solid var(--rule); margin: 10px 0; }
details.advanced > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink); padding: 2px 0; }
details.advanced .group { margin: 10px 0 0; }
details.advanced .group > summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding: 5px 0; border-top: 1px solid var(--rule); }
details.advanced .group .field { margin: 10px 0 14px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; }
.btn { font: 600 13px/1 var(--sans); padding: 9px 12px; border-radius: 5px; border: 1px solid var(--ink); background: var(--ink); color: var(--bg); cursor: pointer; text-decoration: none; }
.btn.secondary { background: transparent; color: var(--ink); border-color: var(--rule-strong); }
.btn:hover { opacity: 0.88; }
.btn[disabled] { opacity: 0.5; cursor: progress; }
.linkish { font: 12.5px var(--sans); color: var(--muted); background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }

/* results */
.headline-label { font-size: 13px; color: var(--ink-2); margin: 0 0 2px; }
.headline { font-size: clamp(40px, 5vw, 52px); line-height: 1; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 10px; font-variant-numeric: tabular-nums; }
.limit-note { font-size: 13px; color: var(--ink-2); border-left: 3px solid var(--accent); padding: 2px 0 2px 10px; margin: 0 0 16px; max-width: 680px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); margin: 0 0 32px; }
.tile { padding: 12px 14px 14px 0; }
.tile + .tile { padding-left: 14px; border-left: 1px solid var(--rule); }
.tile-label { font-size: 12.5px; color: var(--ink-2); margin: 0 0 4px; }
.tile-value { font-size: 22px; font-weight: 600; margin: 0; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12px; color: var(--muted); margin: 3px 0 0; }

.chart-block { margin: 0 0 36px; }
.chart-title { font-size: 15px; line-height: 1.3; font-weight: 600; margin: 0 0 3px; }
.chart-sub { font-size: 13px; color: var(--ink-2); margin: 0 0 10px; max-width: 760px; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart svg text { font-family: var(--sans); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12.5px; color: var(--ink-2); margin: 0 0 8px; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend .key { width: 16px; height: 0; border-top: 2px solid; border-radius: 1px; }
.tooltip { position: absolute; pointer-events: none; z-index: 5; background: var(--bg); border: 1px solid var(--rule-strong); border-radius: 6px; padding: 8px 10px; font: 13px/1.35 var(--sans); color: var(--ink-2); white-space: nowrap; opacity: 0; transition: opacity 0.08s; }
.tooltip.on { opacity: 1; }
.tooltip .tt-head { color: var(--muted); margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; }
.tooltip .tt-row b { color: var(--ink); font-variant-numeric: tabular-nums; }
.tooltip .key { width: 12px; border-top: 2px solid; }

table.results-table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.results-table th { text-align: right; font-weight: 600; font-size: 12px; color: var(--ink-2); padding: 7px 10px; border-bottom: 1px solid var(--rule-strong); vertical-align: bottom; }
.results-table td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.results-table th:first-child, .results-table td:first-child { text-align: left; padding-left: 0; }
.results-table tr.selected td { font-weight: 600; background: var(--panel); }
.results-table tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); padding-left: 10px; }

/* further info */
.steps { list-style: none; padding: 0 !important; margin: 14px 0 8px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.steps li { padding: 10px 12px 12px; border-top: 3px solid var(--ink); margin: 0 !important; }
.steps li + li { border-left: 1px solid var(--rule); }
.steps b { display: block; font-size: 14px; margin-bottom: 3px; }
.steps span { font-size: 12.5px; line-height: 1.45; color: var(--ink-2); display: block; }
.sources { padding-left: 1.4em; font-size: 14px; line-height: 1.5; }
.sources li { margin: 0 0 10px !important; }
.sources .src-title { font-weight: 600; }
.sources .src-finding { color: var(--ink-2); }

footer { border-top: 1px solid var(--rule); margin-top: 8px; padding: 18px 0 32px; font-size: 13px; color: var(--muted); }
footer a { color: var(--ink-2); }

@media (max-width: 960px) {
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts li:nth-child(3) { padding-left: 0; border-left: 0; }
  .tool-grid { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .controls { position: static; max-height: none; overflow: visible; padding-right: 0; }
  .steps { grid-template-columns: minmax(0, 1fr); }
  .steps li + li { border-left: 0; }
  .steps li { border-top-width: 1px; padding-left: 0; }
  .steps li:first-child { border-top-width: 3px; }
}
@media (max-width: 640px) {
  .topbar-inner { flex-wrap: wrap; gap: 8px; }
  .wide, .topbar-inner { padding-left: 16px; padding-right: 16px; }
  .win-body { padding: 14px; }
  h1 { font-size: 19px; }
  .facts { grid-template-columns: minmax(0, 1fr); }
  .facts li + li { padding-left: 0; border-left: 0; }
  .facts li { padding-top: 8px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile:nth-child(3) { padding-left: 0; border-left: 0; }
  .tile:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .topbar a.byline .long { display: none; }
}
.side { border: 1px solid var(--rule); border-radius: 6px; margin: 0 0 10px; background: var(--bg); }
.side > summary { cursor: pointer; padding: 6px 12px; background: var(--panel); border-radius: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.side[open] > summary { border-bottom: 1px solid var(--rule); border-radius: 6px 6px 0 0; }
.side-body { padding: 10px 10px 4px; }
.controls > .advanced { margin: 0 0 10px; padding: 0 12px; }
