/* --- Type scale: six sizes, one job each -------------------------------------------------------------------
   11 badges, chip counts, tiny captions - 12 secondary text: hints, labels, table meta, tooltips -
   13 the default: body, form fields, tables, buttons - 15 card / section titles, key figures -
   18 page titles - 22 headline numbers */
:root {
  --fs-xs: 11px; --fs-sm: 12px; --fs-md: 13px; --fs-lg: 15px; --fs-xl: 18px; --fs-xxl: 22px;
  /* Soft pastel workflow tints - originally the sidebar's own icon-tile colors (Data/Research/
     Portfolio/Runs), promoted here so any page can reuse the same palette for its own icons/badges
     rather than inventing new colors - one consistent "soft pastel" language across the whole app. */
  --nav-data: #2c6e14; --nav-data-soft: #eaf3e4; --nav-research: #4a3aa7; --nav-research-soft: #efebfb;
  --nav-portfolio: #185fa5; --nav-portfolio-soft: #e6f1fb; --nav-runs: #8a5a00; --nav-runs-soft: #fbf1df;
  --nav-gov: #7a2e3a; --nav-gov-soft: #f8e9ec; --nav-live: #0f6b66; --nav-live-soft: #e2f3f1;
}
body { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; font-size: var(--fs-md); margin: 0; background: #f5f5f5; color: #222; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }

/* --- Home page (4-tile landing, replaces the old sidebar) --- */
.home-wrap { max-width: 700px; margin: 60px auto; padding: 0 20px; }
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.home-tile {
  background: #fff; border: 1px solid #ddd; border-radius: 12px;
  padding: 36px 24px; text-align: center; cursor: pointer;
  text-decoration: none; color: #222; transition: box-shadow 0.15s, transform 0.15s;
  display: block;
}
.home-tile:hover { box-shadow: 0 6px 24px rgba(0,0,0,0.12); transform: translateY(-2px); }
.home-tile .icon { font-size: 34px; margin-bottom: 10px; }
.home-tile h2 { margin: 0 0 6px; font-size: 15px; }
.home-tile p { margin: 0; font-size: 12px; color: #777; }

/* --- Simple top header (replaces the persistent sidebar on section pages) --- */
.top-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; border-bottom: 1px solid #ddd; background: #fff;
}
.top-header a { text-decoration: none; color: #185fa5; font-weight: 500; font-size: 13px; }
.top-header .page-title { font-size: 13px; color: #999; margin-left: 4px; }

/* --- Shared page content styles --- */
.main { padding: 24px; max-width: 900px; }
.card { background: #fff; border: 1px solid #ddd; border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.card h2 { margin-top: 0; font-size: var(--fs-lg); }
label { display: block; font-size: var(--fs-sm); color: #666; margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 8px; margin-bottom: 14px; border: 1px solid #ccc; border-radius: 6px; box-sizing: border-box; font-family: inherit; font-size: var(--fs-md); }
textarea { font-family: monospace; font-size: 12px; min-height: 90px; }
.row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.row2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
/* --- Buttons: two sizes, five meanings -------------------------------------------------------------------
   Normal (13px, 32px tall) or .btn-sm (12px, 26px tall, for in-row / in-table actions).
   Primary - the plain button - blue: the main action (Run, Build, Submit, Apply).
   .btn-save green: Save, Save All, Set as default.  .btn-secondary white: Cancel, Open, Edit and other neutral actions.
   .btn-danger red outline: Close All, Delete, Remove (.btn-danger-solid to confirm).  .btn-accent purple: Risk Management. */
/* :where() keeps the base at zero specificity, so any button that styles itself (icons, chips, links) keeps its own look */
:where(button) { display: inline-flex; align-items: center; justify-content: center; gap: 6px; box-sizing: border-box;
  padding: 6px 14px; font-family: inherit; font-size: var(--fs-md); font-weight: 500; line-height: 1.25;
  background: #185fa5; color: #fff; border: 1px solid transparent; border-radius: 6px; cursor: pointer;
  transition: background .12s, border-color .12s, box-shadow .12s; white-space: nowrap; }
/* the standard height - not for icon / link buttons (no background) */
:where(button:not([style*="background:none"]):not([style*="background: none"]):not([style*="background:transparent"])) { min-height: 32px; }
:where(button):hover { background: #154f8a; }
/* chips, icon and link buttons keep their own compact size */
:where(.mp-btn, .mp-link, .sc-chipbtn, .sc-link, .sc-results-link, .sc-x, .pb-tok-clear, .pb-more, .pb-eye, .pb-token button,
       .oq-delete-btn, .remove-btn, .nav-row) { min-height: 0; }
/* a link that looks like a secondary button (e.g. the Request Queue link in page headers) */
a.btn-link { display: inline-flex; align-items: center; gap: 6px; box-sizing: border-box; min-height: 32px; padding: 6px 14px;
  font-size: var(--fs-md); font-weight: 500; color: #333; background: #fff; border: 1px solid #c9d0d8; border-radius: 6px; text-decoration: none; }
a.btn-link:hover { background: #f3f6f9; border-color: #aeb8c4; }
:where(button):focus-visible { outline: 2px solid #7fb0e6; outline-offset: 1px; }
/* pressed: every button visibly dips when clicked (user request 2026-11-24) */
:where(button):not(:disabled):active { transform: translateY(1px); box-shadow: inset 0 2px 4px rgba(0,0,0,.28); filter: brightness(.92); }
:where(button):disabled { background: #aab4bf; border-color: transparent; color: #fff; cursor: not-allowed; }
button.btn-sm { min-height: 26px; padding: 3px 10px; font-size: var(--fs-sm); }
button.btn-save { background: #3b6d11; }
button.btn-save:hover { background: #315b0e; }
button.btn-secondary { background: #fff; color: #333; border-color: #c9d0d8; }
button.btn-secondary:hover { background: #f3f6f9; border-color: #aeb8c4; }
button.btn-danger { background: #fff; color: #a32d2d; border-color: #e3b9b9; }
button.btn-danger:hover { background: #fcebeb; border-color: #d99a9a; }
button.btn-danger-solid { background: #a32d2d; color: #fff; }
button.btn-danger-solid:hover { background: #8c2525; }
button.btn-accent { background: #4a3aa7; }
button.btn-accent:hover { background: #3f3190; }
button.btn-secondary:disabled, button.btn-danger:disabled { background: #f3f4f6; color: #aab4bf; border-color: #e1e5ea; }
/* --- Action buttons (action_button.js): one look everywhere for a button that starts a calculation -------------
   needed = solid blue (pressing it will give a different answer), done = pale green + tick (up to date, nothing to do),
   busy = amber + spinner (running) - the same amber / green as the Request Queue's running / complete. idle = as styled. */
button.act[data-act="needed"] { background: #185fa5 !important; color: #fff !important; border-color: #185fa5 !important; box-shadow: 0 0 0 3px rgba(24,95,165,.15); }
button.act[data-act="needed"]:hover { background: #154f8a !important; }
button.act[data-act="done"], button.act[data-act="done"]:disabled { background: #eaf3de !important; color: #3b6d11 !important; border-color: #c5ddb0 !important; cursor: default; box-shadow: none; }
button.act[data-act="busy"], button.act[data-act="busy"]:disabled { background: #faeeda !important; color: #854f0b !important; border-color: #f0c98e !important; cursor: progress; box-shadow: none; }
.act-spin { display: inline-block; width: 11px; height: 11px; border: 2px solid rgba(133,79,11,.3); border-top-color: #854f0b; border-radius: 50%; animation: act-spin .8s linear infinite; flex: 0 0 auto; }
@keyframes act-spin { to { transform: rotate(360deg); } }
.status { font-size: var(--fs-md); padding: 4px 10px; border-radius: 6px; display: inline-block; }
.status.pending, .status.running { background: #faeeda; color: #854f0b; }
.status.complete { background: #eaf3de; color: #3b6d11; }
.status.failed { background: #fcebeb; color: #a32d2d; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
td, th { padding: 6px 8px; border-bottom: 1px solid #eee; text-align: left; }
td.label { color: #666; }
td.value { text-align: right; font-weight: 500; }
#error { color: #a32d2d; font-size: var(--fs-md); margin-top: 10px; }
.placeholder { color: #999; font-size: var(--fs-md); padding: 40px 0; text-align: center; }

/* --- Sidebar: tinted icon tiles grouped by workflow (Data, Research, Portfolio, Runs) ---
   Hidden at the left edge until the pointer reaches it (or pinned, when the collapsed 56px rail stays on screen);
   hovering the rail slides it out over the page - never pushing it - to show the names and group headings. */
/* Same reasoning as .icon-sidebar's z-index below: must sit above a
   dialog overlay or hovering the left edge to reveal the rail wouldn't
   register while a dialog is open. */
.sidebar-hover-zone { position: fixed; left: 0; top: 0; width: 10px; height: 100vh; z-index: 1300; }
.icon-sidebar {
  position: fixed; left: 0; top: 0; height: 100vh; width: 56px; box-sizing: border-box;
  background: #fff; border-right: 1px solid #dfe4ea; overflow: hidden;
  display: flex; flex-direction: column; gap: 2px; padding: 10px 8px 12px;
  /* Above every dialog overlay (z-index 1000, or 1200 for the report side
     panel) - a dialog being open should never block reaching the sidebar,
     the Help toggle included (see sidebar.js/glossary.js). Still well
     below the glossary popover (3000) and the (i) bubble popover (10000),
     which should show over the sidebar too. */
  z-index: 1300; transform: translateX(-100%);
  transition: transform 0.18s ease, width 0.18s ease, box-shadow 0.18s ease;
}
/* The scrollable middle region - groups can grow past the viewport
   height (more workflow groups, a taller Help/Pin footer, a short
   browser window) without clipping the footer buttons below it. */
.nav-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; }
.nav-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-hover-zone:hover ~ .icon-sidebar, .icon-sidebar:hover, .icon-sidebar:focus-within { transform: translateX(0); }
.icon-sidebar:hover, .icon-sidebar:focus-within { width: 216px; box-shadow: 6px 0 24px rgba(20, 35, 60, 0.12); }
/* group headings: a thin divider when collapsed, the name as well when open */
.nav-grp { flex-shrink: 0; border-top: 1px solid #edf0f4; margin: 6px 2px 0; padding: 7px 4px 3px; height: 13px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #8a94a3; white-space: nowrap; }
.nav-grp:first-child { border-top: none; margin-top: 0; padding-top: 2px; }
.nav-grp span { opacity: 0; transition: opacity 0.12s ease; }
.icon-sidebar:hover .nav-grp span, .icon-sidebar:focus-within .nav-grp span { opacity: 1; }
.nav-row { display: flex; align-items: center; gap: 11px; padding: 4px; border-radius: 9px; text-decoration: none; color: #1f2a37;
  font-size: 13px; white-space: nowrap; flex-shrink: 0; background: none; border: none; cursor: pointer; text-align: left; width: 100%; font-family: inherit; }
.nav-row:hover { background: #f3f6f9; }
.nav-row.active { background: #f0f3f7; font-weight: 600; }
.nav-row:focus-visible { outline: 2px solid #185fa5; outline-offset: 1px; }
.nav-tile { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; transition: box-shadow 0.12s ease; }
.nav-tile svg { width: 18px; height: 18px; }
.nav-label { opacity: 0; transition: opacity 0.12s ease; }
.icon-sidebar:hover .nav-label, .icon-sidebar:focus-within .nav-label { opacity: 1; }
.nav-data .nav-tile { background: var(--nav-data-soft); color: var(--nav-data); }
.nav-research .nav-tile { background: var(--nav-research-soft); color: var(--nav-research); }
.nav-portfolio .nav-tile { background: var(--nav-portfolio-soft); color: var(--nav-portfolio); }
.nav-runs .nav-tile { background: var(--nav-runs-soft); color: var(--nav-runs); }
.nav-gov .nav-tile { background: var(--nav-gov-soft); color: var(--nav-gov); }
.nav-live .nav-tile { background: var(--nav-live-soft); color: var(--nav-live); }
/* the page you're on: its tile filled in its group's colour */
.nav-data.active .nav-tile { background: var(--nav-data); color: #fff; }
.nav-research.active .nav-tile { background: var(--nav-research); color: #fff; }
.nav-portfolio.active .nav-tile { background: var(--nav-portfolio); color: #fff; }
.nav-runs.active .nav-tile { background: var(--nav-runs); color: #fff; }
.nav-gov.active .nav-tile { background: var(--nav-gov); color: #fff; }
.nav-live.active .nav-tile { background: var(--nav-live); color: #fff; }
.nav-brand { cursor: default; font-size: 15px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #1f3b2f; margin-bottom: 2px; margin-top: 4px; }
.nav-brand:hover { background: none; }
.nav-brand .nav-tile { background: none; width: 32px; height: 32px; }
.nav-brand .nav-tile svg { width: 30px; height: 30px; }
.nav-brand .nav-tile { border-radius: 50%; }
.nav-brand.remote-stale .nav-tile { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #d32f2f; }
.nav-brand.remote-deploying .nav-tile { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #e0962a; animation: remote-pulse 1.2s ease-in-out infinite; }
@keyframes remote-pulse { 50% { box-shadow: 0 0 0 2px #fff, 0 0 0 6px rgba(224,150,42,.35); } }
.nav-row.nav-readonly .nav-tile { opacity: .45; filter: grayscale(.6); }
.nav-row.nav-readonly .nav-label { color: #8a94a3; }
.nav-account { flex-shrink: 0; color: #6b7686; text-decoration: none; }
.nav-account .nav-tile { color: #8a94a3; }
.nav-account.on .nav-tile { color: #2c6e14; background: #eaf3e4; }
.nav-help { flex-shrink: 0; color: #6b7686; }
.nav-help .nav-tile { color: #8a94a3; }
.nav-help.on .nav-tile { color: #8a5a00; background: #fbf1df; }
.nav-pin { flex-shrink: 0; color: #6b7686; }
.nav-pin .nav-tile { color: #8a94a3; }
.nav-pin.on .nav-tile { color: #185fa5; background: #e6f1fb; }

/* --- Pinned: the collapsed rail stays on screen and the page moves over for it --- */
.icon-sidebar.pinned { transform: translateX(0); }
body.icon-sidebar-pinned .main, body.icon-sidebar-pinned .home-main { margin-left: 56px; }

/* --- Glossary (glossary.js): small (i) icons next to labels, explaining
   what they mean - rendered into the DOM by each page always, but only
   ever VISIBLE while Help mode is on (toggled from the sidebar, see
   sidebar.js) - a seasoned user who leaves it off sees nothing different
   from a page with no glossary at all. Click (not hover) opens the
   popover, so it's never accidental even when Help mode is on. */
.gl-icon {
  display: none;
  width: 14px; height: 14px;
  margin-left: 4px;
  border-radius: 50%;
  background: #fbf1df;
  color: #8a5a00;
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  cursor: pointer;
  vertical-align: middle;
  user-select: none;
}
body.help-mode-on .gl-icon { display: inline-block; }
.gl-icon:hover, .gl-icon.open { background: #8a5a00; color: #fff; }

.gl-popover {
  position: fixed;
  z-index: 3000;
  max-width: 320px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(20, 35, 60, 0.18);
  padding: 10px 12px;
  font-size: var(--fs-sm);
  color: #333;
  line-height: 1.45;
}
.gl-popover.gl-wide { max-width: min(620px, calc(100vw - 20px)); max-height: calc(100vh - 20px); overflow-y: auto; }
.gl-popover .gl-fn { width: 100%; border-collapse: collapse; margin: 4px 0 8px; }
.gl-popover .gl-fn td { padding: 3px 6px 3px 0; vertical-align: top; border-top: 1px solid #f0f0f0; }
.gl-popover .gl-fn td:first-child { white-space: nowrap; }
.gl-popover code { font-family: ui-monospace, Consolas, monospace; font-size: 0.95em; background: #f5f7fa; padding: 0 3px; border-radius: 3px; }
.gl-popover .gl-sub { font-weight: 600; margin: 8px 0 2px; color: #1f2a37; }
.gl-popover .gl-popover-title { font-weight: 600; margin-bottom: 4px; color: #1f2a37; font-size: var(--fs-md); }

/* Busy indicator: two candlesticks side by side. Each keeps a fixed wick
   (high/low) while its body's open and close move up and down; the body is
   green when it closes above its open, red when below. The two candles run
   out of step. Markup: <span class="busy-candle-group"><span class="busy-candle busy-candle-up"></span><span class="busy-candle busy-candle-down"></span></span> */
.busy-candle-group { display: flex; align-items: center; gap: 10px; }
.busy-candle { position: relative; width: 16px; height: 64px; }
.busy-candle::before { /* wick: high to low, never moves */
  content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; transform: translateX(-50%); border-radius: 2px; }
.busy-candle::after { /* body: open to close */
  content: ""; position: absolute; left: 50%; width: 16px; transform: translateX(-50%); border-radius: 2px; }
.busy-candle-up::after { animation: candle-body-a 2.4s ease-in-out infinite, candle-body-colour-a 2.4s step-end infinite; }
.busy-candle-up::before { animation: candle-wick-colour-a 2.4s step-end infinite; }
.busy-candle-down::after { animation: candle-body-b 2.4s ease-in-out infinite, candle-body-colour-b 2.4s step-end infinite; }
.busy-candle-down::before { animation: candle-wick-colour-b 2.4s step-end infinite; }
/* top/bottom are the body's upper and lower edges (% of the wick). The colour
   flips at the moments the body is thinnest - open and close crossing. */
@keyframes candle-body-a {
  0%   { top: 18%; bottom: 44%; }
  25%  { top: 40%; bottom: 52%; }
  50%  { top: 30%; bottom: 22%; }
  75%  { top: 48%; bottom: 44%; }
  100% { top: 18%; bottom: 44%; }
}
@keyframes candle-body-b {
  0%   { top: 46%; bottom: 47%; }
  25%  { top: 24%; bottom: 36%; }
  50%  { top: 48%; bottom: 44%; }
  75%  { top: 30%; bottom: 20%; }
  100% { top: 46%; bottom: 47%; }
}
@keyframes candle-body-colour-a { 0% { background: #00cc44; box-shadow: 0 0 6px rgba(0,204,68,.7); } 25% { background: #dd2222; box-shadow: 0 0 6px rgba(221,34,34,.7); } 75% { background: #00cc44; box-shadow: 0 0 6px rgba(0,204,68,.7); } }
@keyframes candle-wick-colour-a { 0% { background: #00cc44; } 25% { background: #dd2222; } 75% { background: #00cc44; } }
@keyframes candle-body-colour-b { 0% { background: #dd2222; box-shadow: 0 0 6px rgba(221,34,34,.7); } 50% { background: #00cc44; box-shadow: 0 0 6px rgba(0,204,68,.7); } 100% { background: #dd2222; } }
@keyframes candle-wick-colour-b { 0% { background: #dd2222; } 50% { background: #00cc44; } 100% { background: #dd2222; } }
@media (prefers-reduced-motion: reduce) {
  .busy-candle::after, .busy-candle::before { animation-duration: 6s; }
}

/* --- Segmented tab control: a row of buttons sharing one rounded border,
   the active one filled in - used for mode/tab switching inside a dialog
   (Parameter Scan's Grid/Genetic/Walk-forward/Monte Carlo, Simulated Time
   Series' Build dialog). Markup: <div class="sc-seg-modes" role="tablist">
   <button role="tab" class="on">...</button>...</div> - toggle the "on"
   class in JS, nothing else needed. --- */
.sc-seg-modes { display: inline-flex; border: 1px solid #185fa5; border-radius: 7px; overflow: hidden; }
.sc-seg-modes button { border-radius: 0; background: #fff; color: #185fa5; padding: 6px 14px; margin: 0; border-left: 1px solid #d5e2f0; }
.sc-seg-modes button:first-child { border-left: none; }
.sc-seg-modes button.on { background: #185fa5; color: #fff; }

/* --- Date-range timeline widget (timeline_slider.js): a data bar per item
   with a draggable period across them - shared by Strategy Workspace's
   Backtest settings / new-workspace wizard, and Simulated Time Series'
   Build dialog. --- */
.ws-tl { margin-bottom: 8px; }
.ws-tl-grid { display: flex; gap: 6px; margin-top: 30px; }
.ws-tl-labels { width: 50px; flex: none; padding-top: 4px; }
.ws-tl-labels label { display: flex; align-items: center; justify-content: space-between; gap: 3px; height: 12px; margin: 0; font-size: 10px;
  font-weight: 400; line-height: 12px; color: #666; cursor: pointer; white-space: nowrap; }
.ws-tl-labels input { width: 10px; height: 10px; margin: 0; cursor: pointer; flex: none; }
.ws-tl-labels label.off { color: #b0b6bd; text-decoration: line-through; }
.ws-tl-data.off { opacity: .22; }
.ws-tl-bar { position: relative; flex: 1; background: #f0f2f5; border-radius: 6px; }
.ws-tl-shared { position: absolute; top: 0; bottom: 0; background: #e3e8ee; }
.ws-tl-data { position: absolute; height: 8px; border-radius: 3px; background: #9aa7b6; }
.ws-tl-data.part { background: #e0a050; }
.ws-tl-data.none { background: #d9a3a3; }
.ws-tl-bt { position: absolute; top: -4px; bottom: -4px; border-radius: 5px; background: rgba(44,110,20,.16); border: 2px solid #2c6e14;
  cursor: grab; touch-action: none; min-width: 10px; box-sizing: border-box; }
.ws-tl-bt:hover, .ws-tl-bt.dragging { background: rgba(44,110,20,.24); box-shadow: 0 0 0 2px rgba(44,110,20,.2); }
.ws-tl-bt.dragging { cursor: grabbing; }
.ws-tl-h { position: absolute; top: 0; bottom: 0; width: 12px; cursor: ew-resize; display: flex; align-items: center; justify-content: center; }
.ws-tl-h[data-edge="start"] { left: -7px; }
.ws-tl-h[data-edge="end"] { right: -7px; }
.ws-tl-h::before { content: ""; width: 5px; height: 60%; max-height: 40px; border-radius: 2px; background: #2c6e14; }
.ws-tl-tip { position: absolute; bottom: calc(100% + 8px); transform: translateX(-50%); background: #1f2a37; color: #fff; font-size: 12px;
  padding: 4px 8px; border-radius: 5px; white-space: nowrap; pointer-events: none; z-index: 3; }
.ws-tl-axis { position: relative; height: 20px; margin: 4px 0 0 56px; color: #888; font-size: 11px; }
.ws-tl-axis span { position: absolute; top: 2px; }
.ws-tl-tick { transform: translateX(-50%); }
.ws-tl-end { font-size: 13px; font-weight: 700; color: #1f2a37; top: 0 !important; }
.ws-tl-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 4px; font-size: 12px; color: #666; }
.ws-tl-legend { margin-left: auto; }
.ws-tl-li { white-space: nowrap; }   /* a legend entry's colour key never wraps away from its label */
.ws-tl-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 3px 0 8px; vertical-align: -1px; }
.ws-tl-key.data { background: #9aa7b6; }
.ws-tl-key.shared { background: #e3e8ee; border: 1px solid #ccd3db; }
.ws-tl-key.bt { background: rgba(44,110,20,.16); border: 2px solid #2c6e14; box-sizing: border-box; }
/* the hold-out vault (opts.vault): a box the same height as the period, from its boundary to the hold-out end; when
   editable its left edge is the period's right edge and both ends drag. After the hold-out end: locked, not tested. */
.ws-tl-vault { position: absolute; top: -4px; bottom: -4px; border: 2px solid #a32d2d; border-radius: 5px; box-sizing: border-box; min-width: 10px;
  background: repeating-linear-gradient(135deg, rgba(163,45,45,.16), rgba(163,45,45,.16) 4px, rgba(163,45,45,.04) 4px, rgba(163,45,45,.04) 8px); }
.ws-tl-vault .ws-tl-h::before { background: #a32d2d; }
.ws-tl-vault .ws-tl-h[data-vedge="start"] { left: -7px; }
.ws-tl-vault .ws-tl-h[data-vedge="end"] { right: -7px; }
.ws-tl-vault.dragging { box-shadow: 0 0 0 2px rgba(163,45,45,.2); }
.ws-tl-vault-label { position: absolute; top: -17px; left: 4px; font-size: 10px; font-weight: 700; color: #a32d2d; white-space: nowrap; }
.ws-tl-examined { position: absolute; top: 0; bottom: 0; pointer-events: none; border-left: 1px dashed #b08900; border-right: 1px dashed #b08900;
  background: repeating-linear-gradient(45deg, rgba(176,137,0,.16), rgba(176,137,0,.16) 3px, transparent 3px, transparent 7px); }
.ws-tl-key.exam { background: repeating-linear-gradient(45deg, rgba(176,137,0,.4), rgba(176,137,0,.4) 2px, rgba(176,137,0,.1) 2px, rgba(176,137,0,.1) 4px); border: 1px dashed #b08900; box-sizing: border-box; }
.ws-tl-vault-after { position: absolute; top: 0; bottom: 0; border-radius: 0 6px 6px 0;
  background: repeating-linear-gradient(135deg, rgba(120,120,120,.14), rgba(120,120,120,.14) 3px, transparent 3px, transparent 6px); }
.ws-tl-key.vault { background: repeating-linear-gradient(135deg, rgba(163,45,45,.35), rgba(163,45,45,.35) 2px, rgba(163,45,45,.08) 2px, rgba(163,45,45,.08) 4px); border: 2px solid #a32d2d; box-sizing: border-box; }
/* the Monte Carlo lane, under the markets: the simulated period (purple) and the history it learns from (hatched) */
.ws-tl-lane-label { height: 26px; line-height: 26px; margin-top: 2px; font-size: 10px; font-weight: 700; color: #6f42c1; text-align: right; }
.ws-tl-mclane { position: absolute; left: 0; right: 0; height: 22px; border-top: 1px dashed #d6cdea; }
.ws-tl-mc { position: absolute; height: 18px; border-radius: 4px; background: rgba(111,66,193,.2); border: 2px solid #6f42c1; box-sizing: border-box;
  cursor: grab; touch-action: none; min-width: 10px; }
.ws-tl-mc:hover, .ws-tl-mc.dragging { background: rgba(111,66,193,.3); box-shadow: 0 0 0 2px rgba(111,66,193,.2); }
.ws-tl-mc.dragging { cursor: grabbing; }
.ws-tl-mc .ws-tl-h::before { background: #6f42c1; height: 70%; }
.ws-tl-learn { position: absolute; height: 8px; border-radius: 3px 0 0 3px;
  background: repeating-linear-gradient(135deg, #b9a5e0, #b9a5e0 3px, #ece6f7 3px, #ece6f7 6px); }
.ws-tl-key.mc { background: rgba(111,66,193,.2); border: 2px solid #6f42c1; box-sizing: border-box; }
.ws-tl-key.learn { background: repeating-linear-gradient(135deg, #b9a5e0, #b9a5e0 2px, #ece6f7 2px, #ece6f7 4px); }
/* the forward-simulation lane (opts.forward, Simulated Time Series' Build dialog only) - no "learn" hatch, since
   the Period bar above it already shows the historical fit window; only its length (right edge) drags. */
.ws-tl-fwdlane { position: absolute; left: 0; right: 0; height: 18px; border-top: 1px dashed #c3d8ef; }
.ws-tl-fwd { position: absolute; left: 0; height: 18px; border-radius: 4px; background: rgba(24,95,165,.18); border: 2px solid #185fa5; box-sizing: border-box;
  cursor: ew-resize; touch-action: none; min-width: 10px; }
.ws-tl-fwd:hover, .ws-tl-fwd.dragging { background: rgba(24,95,165,.28); box-shadow: 0 0 0 2px rgba(24,95,165,.2); }
.ws-tl-key.fwd { background: rgba(24,95,165,.18); border: 2px solid #185fa5; box-sizing: border-box; }

/* The Markets & Dates step's timeline (opts.v2 in timeline_slider.js): the market names down the left with their ticks, the rows in a
   scrollable window, and a header that stays put above it - the period / vault labels, the date axis and the entry slider. */
.ws-tl-v2 .ws-tl-head { padding-bottom: 4px; border-bottom: 1px solid #e3e6ea; background: #fff; }
.ws-tl-v2 .ws-tl-hrow { display: flex; gap: 6px; align-items: stretch; }
.ws-tl-v2 .ws-tl-hcell { width: var(--tl-lw); flex: none; font-size: 11px; color: #555; display: flex; align-items: center; justify-content: flex-end; text-align: right; }
.ws-tl-v2 .ws-tl-hbar { position: relative; flex: 1; height: 44px; }
.ws-tl-v2 .ws-tl-hl { position: absolute; top: 0; height: 16px; line-height: 16px; font-size: 11px; font-weight: 700; white-space: nowrap;
  transform: translateX(-50%); padding: 0 6px; background: #fff; border-radius: 3px; }
.ws-tl-v2 .ws-tl-hl.bt { color: #2c6e14; }
.ws-tl-v2 .ws-tl-hl.vault { color: #a32d2d; }
.ws-tl-v2 .ws-tl-axis { position: absolute; left: 0; right: 0; top: 22px; margin: 0; }
.ws-tl-v2 .ws-tl-etrack { position: relative; flex: 1; height: 22px; cursor: pointer; touch-action: none; }
.ws-tl-v2 .ws-tl-etrack::before { content: ""; position: absolute; left: 0; right: 0; top: 10px; height: 3px; border-radius: 2px; background: #d5dbe3; }
.ws-tl-v2 .ws-tl-egrip { position: absolute; top: 3px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: #fff; border: 2px solid #9aa7b6;
  box-sizing: border-box; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.ws-tl-v2 .ws-tl-egrip.on { border-color: #d27a00; background: #ffe2b3; }
.ws-tl-v2 .ws-tl-etrack.dragging .ws-tl-egrip { box-shadow: 0 0 0 3px rgba(210,122,0,.25); }
.ws-tl-v2 .ws-tl-scroll { overflow-y: auto; overflow-x: hidden; padding: 6px 0 2px; }
.ws-tl-v2 .ws-tl-grid { margin-top: 0; }
.ws-tl-v2 .ws-tl-labels { width: var(--tl-lw); padding-top: 4px; }
.ws-tl-v2 .ws-tl-labels label { height: var(--tl-rh); line-height: var(--tl-rh); font-size: 11.5px; justify-content: flex-start; gap: 5px; color: #333; }
.ws-tl-v2 .ws-tl-labels label:hover { background: #eef3fa; }
.ws-tl-v2 .ws-tl-labels input { width: 12px; height: 12px; }
.ws-tl-v2 .ws-tl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ws-tl-v2 .ws-tl-labels label.off { color: #aab1b9; text-decoration: none; }
.ws-tl-v2 .ws-tl-labels label.blocked { color: #c3a0a0; cursor: not-allowed; font-style: italic; }
.ws-tl-v2 .ws-tl-pin { flex: none; font-size: 10px; cursor: pointer; opacity: .85; }
.ws-tl-v2 .ws-tl-entryline { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px dashed #d27a00; pointer-events: none; z-index: 2; }
.ws-tl-v2 .ws-tl-tip { bottom: auto; top: -6px; transform: translate(-50%, -100%); }

/* Simulated Time Series' Build dialog: tab pages inside a fixed-height,
   flex-column box (see simulated_series.html) - the visible page grows to
   fill the space, so Cancel/Build stay pinned at the bottom and switching
   tabs never resizes or re-centers the dialog. */
/* min-width: 0 matters as much as min-height: 0 here - without it, a flex column's child defaults to its
   content's max-content width, and anything inside wide enough (the timeline's commodity rows, a long tab
   label) forces the WHOLE box wider and gives it its own horizontal scrollbar - at which point everything
   above/below this page (including the tab bar) scrolls away with it. With it, this page's own overflow-x:
   hidden is what actually clips, and the box itself never needs to scroll at all (see .ss-new-box below). */
.ss-new-page { flex: 1 1 auto; min-height: 0; min-width: 0; overflow-y: auto; overflow-x: hidden; padding-right: 4px; }
/* The 3-way tab bar: equal-width buttons spanning the full dialog width,
   instead of each sized to its own label (which left "Historical window &
   settings" looking like a stretched, unbalanced bar next to the other two
   short ones). nowrap + centered content keeps every button one line tall
   and its label centered even if a sibling's label would otherwise wrap
   and stretch the whole row taller. Scoped to this class (not the shared
   .sc-seg-modes) so Strategy Workspace's own segmented tab bars are
   unaffected. */
/* flex: 0 0 40px (not just width) pins this row's HEIGHT to an explicit value immune to grow/shrink/stretch -
   belt-and-braces with the button rule below's own height, so resizing the dialog (.ss-new-box) can only ever
   change .ss-new-page's space, never this row's. max-height is a hard backstop on top of that. */
.ss-new-tabs { width: 100%; flex: 0 0 40px; height: 40px; max-height: 40px; overflow: hidden; box-sizing: border-box; }
/* Every button in the app is display:inline-flex by default (the global :where(button) rule) - flex's own
   align-items:center SHOULD center a single line fine, but flex formatting contexts are not where
   text-overflow:ellipsis is reliably specified to work, and in practice that combination is what kept pushing
   the label off-center here. display: block switches this button's own text back to a plain line box, where
   fixed height + matching line-height centering and text-overflow:ellipsis are both unambiguous and
   well-supported - .ss-new-tabs.sc-seg-modes (both classes, matching the actual markup) outranks the shared
   .sc-seg-modes button rule's specificity outright, rather than relying on it merely coming later in the file.
   38px (not 40px) accounts for .sc-seg-modes's own 1px top+bottom border on the row. */
.ss-new-tabs.sc-seg-modes button { display: block !important; flex: 1 1 0 !important; min-width: 0; box-sizing: border-box !important;
  height: 38px !important; max-height: 38px !important; line-height: 38px !important; padding: 0 10px !important; margin: 0 !important;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
/* A drag handle (bottom-right corner, native browser affordance) so a tab
   with more content than fits can be made taller on demand. overflow:
   hidden (not auto) - the box itself must never scroll or need a
   scrollbar of its own, only .ss-new-page does, so the tab bar/header/
   footer (outside that page) stay fixed in place no matter what. */
.ss-new-box { resize: vertical; overflow: hidden; max-width: 96vw; }

/* Forward days / Seasonal period: a range slider paired with an exact
   number box, grouped directly under the historical timeline instead of
   a disconnected settings row. */
.ss-sim-sliders { background: #f7fafd; border: 1px solid #cfe0f3; border-radius: 8px; padding: 10px 14px; margin: 10px 0 16px; }
.ss-slider-row { display: flex; align-items: center; gap: 10px; margin: 10px 0 2px; }
.ss-slider-row label { flex: 0 0 180px; margin: 0; font-weight: 600; font-size: 13px; }
.ss-slider-row input[type="range"] { flex: 1; accent-color: #185fa5; }
.ss-slider-row input[type="number"] { width: 68px; flex: none; margin: 0; }
.ss-slider-row .ss-slider-unit { flex: none; color: #666; font-size: 12px; }
.ss-slider-note { font-size: 11px; color: #888; margin: 0 0 6px 190px; }

/* Parameter rows - one per strategy parameter: label, a Fixed / Range switch, the inputs, the count of values and a
   preview of them. Used by the Strategy Workspace's Parameter Scan dialog and by Parameter Selection (pipeline.html);
   param_rows.js has the helpers both use (coded choices, the values preview).
   Markup: <div class="sc-prow"><div class="sc-plabel"/><div class="sc-seg"><button class="on"/>...</div>
           <div class="sc-pinputs"/><div class="sc-pcount"/><div class="sc-pvals"/></div> */
.sc-prow { display: grid; grid-template-columns: minmax(120px, 190px) auto 1fr auto; align-items: center; column-gap: 10px;
  padding: 7px 0 5px; border-bottom: 1px solid #f0f2f5; }
.sc-plabel { font-size: 13px; color: #222; }
.sc-seg { display: inline-flex; border: 1px solid #c9d3df; border-radius: 6px; overflow: hidden; }
.sc-seg button { background: #fff; color: #556; border-radius: 0; padding: 3px 9px; font-size: 12px; margin: 0; }
.sc-seg button + button { border-left: 1px solid #c9d3df; }
.sc-seg button.on { background: #e8f0fa; color: #185fa5; font-weight: 600; }
.sc-pinputs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sc-pinputs input[type=number] { width: 76px; margin: 0; padding: 4px 7px; }
.sc-pinputs select { margin: 0; padding: 3px 6px; width: auto; }
.sc-arrow { color: #99a; }
.sc-steplbl { font-size: 12px; color: #99a; }
.sc-codes { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.sc-codes label { display: inline-flex; align-items: center; gap: 4px; margin: 0; font-size: 13px; color: #333; cursor: pointer; }
.sc-codes input { width: auto; margin: 0; }
.sc-pcount { font-size: 12px; color: #185fa5; font-weight: 600; white-space: nowrap; }
.sc-pvals { grid-column: 3 / 5; font-size: 12px; color: #6b7686; font-family: Consolas, monospace; padding-top: 2px; }
.sc-pvals:empty { display: none; }

/* Strategy Workspace header: the strategy's details on the left (name + version + progress, the settings button,
   the sizing line), its buttons on the right - wrapping onto a second line, right-aligned, rather than off the window */
.ws-head { display: flex; justify-content: space-between; align-items: center; gap: 10px 18px; flex-wrap: wrap; }  /* buttons centred on the details block */
.ws-head-info { flex: 1 0 auto; max-width: 100%; }   /* never narrower than its own lines - the buttons wrap below instead */
.ws-head-line { display: flex; align-items: baseline; flex-wrap: wrap; row-gap: 2px; }
.ws-head-line .ws-version-label { margin-left: 8px !important; }
.wiz-cost-choice { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; margin: 6px 0; cursor: pointer; }
.wiz-cost-choice input { width: auto; margin-top: 3px; }
.ws-head-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex: 0 1 auto; margin-left: auto; }
