.viz-root {
  color-scheme: light;
  --surface-1:      #ffffff;
  --surface-2:      #edeade;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  /* #73716a measured ~4.06:1 against --surface-2 -- under WCAG AA's 4.5:1 for the 11-12px text
     this token is mostly used on (.hint, table chip labels, the skipped-panel disclosure). #5f5d54
     clears 5.4:1+ against both surfaces while staying visibly lighter than --text-secondary, so the
     primary/secondary/muted emphasis ladder is unchanged -- just no longer failing on this exact bg. */
  --text-muted:     #5f5d54;
  --gridline:       #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,0.10);
  --series-close:   #2a78d6;
  --series-ma50:    #eb6834;
  --series-ma200:   #4a3aa7;
  --series-signal:  #e87ba4;
  --series-ema10:   #0d9488;
  --series-ema20:   #b45309;
  --status-good:    #0ca30c;
  --status-critical:#d03b3b;
  --status-neutral: #898781;
  --action-primary: #2870c9;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Code", "Consolas", monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --focus-ring: 0 0 0 2px var(--surface-1), 0 0 0 4px var(--series-close);
  --shadow-card: 0 1px 2px rgba(30,24,10,0.04), 0 18px 36px -22px rgba(30,24,10,0.24);
  --shadow-hover: 0 1px 2px rgba(30,24,10,0.05), 0 22px 44px -20px rgba(30,24,10,0.30);
  --page-glow: radial-gradient(1100px 460px at 50% -140px, color-mix(in srgb, var(--series-close) 9%, transparent), transparent 70%);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 150ms;
  --dur-base: 220ms;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --surface-1: #1e1e1c; --surface-2: #08090a;
    --text-primary: #ffffff; --text-secondary: #c3c2b7; --text-muted: #898781;
    --gridline: #2c2c2a; --baseline: #383835; --border: rgba(255,255,255,0.10);
    --series-close: #3987e5; --series-ma50: #d95926; --series-ma200: #9085e9; --series-signal: #d55181;
    --series-ema10: #2dd4bf; --series-ema20: #d99a3d;
    --status-good: #0ca30c; --status-critical: #e66767; --status-neutral: #898781;
    --action-primary: #2a6ec2;
    --shadow-card: 0 1px 2px rgba(0,0,0,0.4), 0 20px 40px -20px rgba(0,0,0,0.65);
    --shadow-hover: 0 1px 2px rgba(0,0,0,0.45), 0 26px 52px -20px rgba(0,0,0,0.75);
    --page-glow: radial-gradient(1100px 460px at 50% -140px, color-mix(in srgb, var(--series-close) 16%, transparent), transparent 70%);
  }
}
:root[data-theme="dark"] .viz-root {
  color-scheme: dark;
  --surface-1: #1e1e1c; --surface-2: #08090a;
  --text-primary: #ffffff; --text-secondary: #c3c2b7; --text-muted: #898781;
  --gridline: #2c2c2a; --baseline: #383835; --border: rgba(255,255,255,0.10);
  --series-close: #3987e5; --series-ma50: #d95926; --series-ma200: #9085e9; --series-signal: #d55181;
  --series-ema10: #2dd4bf; --series-ema20: #d99a3d;
  --status-good: #0ca30c; --status-critical: #e66767; --status-neutral: #898781;
  --action-primary: #2a6ec2;
  --shadow-card: 0 1px 2px rgba(0,0,0,0.4), 0 20px 40px -20px rgba(0,0,0,0.65);
  --shadow-hover: 0 1px 2px rgba(0,0,0,0.45), 0 26px 52px -20px rgba(0,0,0,0.75);
  --page-glow: radial-gradient(1100px 460px at 50% -140px, color-mix(in srgb, var(--series-close) 16%, transparent), transparent 70%);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font-sans); background: var(--surface-2); overflow-x: hidden; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
/* Arabic pages (help-ar.html): Inter has no Arabic glyphs, so use Cairo -- shapes both Arabic and
   Latin text well, so ticker codes / "MA50" etc. staying in Latin script still look consistent. */
html:lang(ar) body { font-family: "Cairo", var(--font-sans); }
/* Monospace styling suits Latin glossary terms styled like code/tickers, not Arabic prose terms. */
html:lang(ar) .glossary dt { font-family: "Cairo", var(--font-sans); }
.viz-root { background: var(--page-glow), var(--surface-2); color: var(--text-primary); min-height: 100vh; padding: 24px 16px 48px; }
.wrap { max-width: 1080px; margin: 0 auto; }
/* Trend Screen's table is much wider (17 columns) than the chart-centric pages, so it gets more
   room to breathe before falling back to the table wrapper's own horizontal scroll. Scoped to
   screen.html only -- the other pages read better at the narrower width. */
.wide-page .wrap,
.wide-page .top-nav-inner { max-width: 1600px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

.top-nav {
  position: sticky; top: 0; z-index: 30; margin: -24px -16px 24px; padding: 0 16px;
  background: color-mix(in srgb, var(--surface-1) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.top-nav-inner { max-width: 1080px; margin: 0 auto; padding: 12px 0; display: flex; align-items: center; gap: 24px; }
.top-nav-brand {
  font-family: var(--font-mono); font-weight: 700; font-size: 14px; letter-spacing: 0.02em;
  color: var(--text-primary); text-decoration: none; flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 8px;
}
/* Small brand mark so the wordmark reads as a product, not a plain nav label. */
.top-nav-brand::before {
  content: ""; width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0;
  background: var(--series-close);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--series-close) 18%, transparent);
}
/* wrap: with 5 links (6 on the help pages, which carry a language toggle) these no longer fit
   on one row at narrower desktop widths */
.top-nav-links { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.top-nav-link {
  font-size: 13px; font-weight: 600; color: var(--text-secondary); text-decoration: none;
  padding: 7px 12px; border-radius: var(--radius-sm); position: relative;
  transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.top-nav-link:hover { color: var(--text-primary); background: var(--surface-2); }
.top-nav-link.active { color: var(--text-primary); background: color-mix(in srgb, var(--series-close) 14%, var(--surface-1)); }
.top-nav-link.active::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -6px; height: 2px;
  background: var(--series-close); border-radius: 1px;
}
.top-nav-link:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.top-nav-link.lang-link { margin-left: 8px; padding-left: 12px; border-left: 1px solid var(--border); }
[dir="rtl"] .top-nav-link.lang-link { margin-left: 0; margin-right: 8px; padding-left: 10px; padding-right: 12px; border-left: none; border-right: 1px solid var(--border); }

.header h1 { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 4px; }
/* Prose stays at a readable line length even on the wide page -- only the table/controls below
   use the extra room. */
.wide-page .header .sub,
.wide-page .caveat { max-width: 900px; }
.result-title { font-size: 18px; font-weight: 600; margin: 4px 0 10px; }
.result-title .ticker-code { color: var(--text-secondary); font-weight: 500; font-size: 14px; margin-left: 6px; }
.header .sub { color: var(--text-secondary); font-size: 13px; }
#themeToggle {
  flex-shrink: 0; line-height: 1; width: 36px; height: 36px;
  border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface-1);
  color: var(--text-primary); cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
#themeToggle svg { width: 17px; height: 17px; }
#themeToggle:hover { border-color: var(--series-close); background: color-mix(in srgb, var(--series-close) 8%, var(--surface-1)); transform: translateY(-1px); }
#themeToggle:active { transform: translateY(0) scale(0.94); }
#themeToggle:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.search-row { display: flex; gap: 8px; margin: 18px 0; align-items: flex-start; }
.sector-select {
  font: inherit; font-size: 14px; padding: 9px 10px; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
  cursor: pointer; flex-shrink: 0; max-width: 220px; transition: border-color 150ms ease-out;
}
.sector-select:hover { border-color: var(--baseline); }
.sector-select:focus-visible { outline: none; border-color: var(--series-close); box-shadow: var(--focus-ring); }
.ticker-search { position: relative; width: 320px; }
.ticker-search input {
  font: inherit; font-size: 14px; padding: 9px 12px; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
  width: 100%; font-family: var(--font-mono);
  transition: border-color 150ms ease-out;
}
.ticker-search input:hover { border-color: var(--baseline); }
.ticker-search input:focus-visible { outline: none; border-color: var(--series-close); box-shadow: var(--focus-ring); }
.ticker-suggestions {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
  margin: 0; padding: 4px; list-style: none; max-height: 320px; overflow-y: auto;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.16);
}
.ticker-suggestions.open { display: block; }
.ticker-suggestions li {
  display: flex; align-items: baseline; gap: 8px; padding: 7px 9px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px;
}
.ticker-suggestions li .sym { font-family: var(--font-mono); font-weight: 600; flex-shrink: 0; }
.ticker-suggestions li .cname { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticker-suggestions li:hover, .ticker-suggestions li.active { background: color-mix(in srgb, var(--series-close) 12%, var(--surface-1)); }
.ticker-suggestions li.empty { color: var(--text-muted); font-style: italic; cursor: default; }
.ticker-suggestions li.empty:hover { background: none; }
.search-row button {
  font: inherit; font-size: 14px; font-weight: 600; padding: 9px 18px; border-radius: var(--radius-md);
  border: none; background: var(--action-primary); color: #fff; cursor: pointer;
  box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--action-primary) 55%, transparent);
  transition: filter var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.search-row button:hover:not(:disabled) { filter: brightness(1.1); box-shadow: 0 6px 18px -4px color-mix(in srgb, var(--action-primary) 65%, transparent); transform: translateY(-1px); }
.search-row button:active:not(:disabled) { transform: translateY(0) scale(0.97); }
.search-row button:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.search-row button:disabled { opacity: 0.6; cursor: default; }
.hint { font-size: 12px; color: var(--text-muted); margin: -12px 0 16px; }

#errorBox {
  display: none; background: color-mix(in srgb, var(--status-critical) 12%, transparent);
  border: 1px solid var(--status-critical); color: var(--status-critical);
  border-radius: var(--radius-md); padding: 10px 14px; font-size: 13px; margin-bottom: 16px;
}

#resultArea { display: none; }
#resultArea.loading { opacity: 0.5; pointer-events: none; transition: opacity 150ms ease-out; }

.status-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 20px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 12px; font-size: 12px;
  color: var(--text-secondary); font-family: var(--font-mono);
}
.pill strong { color: var(--text-primary); font-weight: 600; }
.pill.fail { color: var(--status-critical); border-color: var(--status-critical); }
.pill .change.good { color: var(--status-good); }
.pill .change.critical { color: var(--status-critical); }

.range-sliders { display: flex; gap: 24px; flex-wrap: wrap; margin: 0 0 14px; }
.range-slider { flex: 1; min-width: 220px; }
.range-slider .rs-label { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.range-slider .rs-track-row { display: flex; align-items: center; gap: 8px; }
.range-slider .rs-bound { font-size: 12px; font-family: var(--font-mono); color: var(--text-secondary); flex-shrink: 0; }
.range-slider .rs-track { position: relative; flex: 1; height: 4px; background: var(--gridline); border-radius: 2px; }
.range-slider .rs-marker {
  position: absolute; top: 50%; width: 8px; height: 8px; border-radius: 50%;
  background: var(--series-close); border: 2px solid var(--surface-2); transform: translate(-50%, -50%);
}

.return-strip { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 20px; }
.return-strip .rp-item {
  flex: 1; min-width: 74px; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px; text-align: center;
}
.return-strip .rp-label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.return-strip .rp-value { font-size: 13px; font-weight: 600; font-family: var(--font-mono); }
.return-strip .rp-value.good { color: var(--status-good); }
.return-strip .rp-value.critical { color: var(--status-critical); }

.advice-card {
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}
.advice-card.none { background: var(--surface-1); color: var(--text-secondary); font-style: italic; font-size: 13px; }
/* This card is the tool's single most important output -- give it a visible accent so a live
   setup reads as distinct from the muted, italic "none" state above at a glance, not just on
   close reading. Brand blue rather than status-good: a detected setup isn't a promised win. */
.advice-card.setup {
  background: var(--surface-1);
  border-left: 3px solid var(--series-close);
  box-shadow: var(--shadow-hover);
}
[dir="rtl"] .advice-card.setup { border-left: none; border-right: 3px solid var(--series-close); }
.advice-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 10px; color: var(--text-secondary); }
.setup-block { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 10px; }
.setup-block .item .label { font-size: 11px; color: var(--text-muted); }
.setup-block .item .value { font-size: 17px; font-weight: 600; font-family: var(--font-mono); }
.setup-note { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.setup-note strong { color: var(--text-primary); }
.setup-block-sep { border-top: 1px solid var(--gridline); margin: 14px 0; }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 20px; }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 14px; box-shadow: var(--shadow-card); }
.kpi .label { font-size: 11px; color: var(--text-secondary); margin-bottom: 4px; }
.kpi .value { font-size: 20px; font-weight: 600; font-family: var(--font-mono); }
.kpi .value.good { color: var(--status-good); }
.kpi .value.critical { color: var(--status-critical); }

.controls { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; row-gap: 8px; }
/* One shared chip/button look for every small toggle-style control across the app -- .controls
   button, .table-tab and .refresh-btn (further down) had drifted 1-2px apart in padding despite
   being the same visual family (range/indicator toggles, table-view tabs, a refresh action).
   Consolidated here so they can't silently drift again; .table-tab/.refresh-btn now just alias in. */
.controls button, .table-tab, .refresh-btn {
  font: inherit; font-size: 12px; color: var(--text-secondary); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 12px; cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.controls button:hover, .table-tab:hover, .refresh-btn:hover:not(:disabled) { border-color: var(--baseline); color: var(--text-primary); }
.controls button:active, .table-tab:active { transform: scale(0.96); }
.controls button:focus-visible, .table-tab:focus-visible, .refresh-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.controls button.active, .table-tab.active { color: var(--text-primary); border-color: var(--series-close); box-shadow: inset 0 0 0 1px var(--series-close); font-weight: 600; }
.controls .spacer { flex: 1; }
.controls .control-divider { width: 1px; height: 18px; background: var(--border); margin: 0 2px; }
.controls .control-inline {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-secondary);
}
.controls .control-inline input {
  font: inherit; font-size: 12px; color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 7px;
  font-family: var(--font-mono); transition: border-color 150ms ease-out;
}
.controls .control-inline input:hover { border-color: var(--baseline); }
.controls .control-inline input:focus-visible { outline: none; border-color: var(--series-close); box-shadow: var(--focus-ring); }
.controls .control-inline input[type="number"] { width: 64px; }
.controls .control-inline input[type="date"] { width: 132px; }
.controls .control-inline select {
  font: inherit; font-size: 12px; color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 7px;
  font-family: var(--font-mono); cursor: pointer; transition: border-color 150ms ease-out;
}
.controls .control-inline select:hover { border-color: var(--baseline); }
.controls .control-inline select:focus-visible { outline: none; border-color: var(--series-close); box-shadow: var(--focus-ring); }
#resultsControls { margin-top: 20px; }
#sectorControls { margin-top: 8px; }
#sectorChecks { display: contents; }
#rangeHint { margin: -2px 0 12px; font-family: var(--font-mono); }
.controls .control-label { font-size: 12px; color: var(--text-muted); }
.controls .control-check {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-secondary);
  cursor: pointer; user-select: none; transition: color 150ms ease-out;
}
.controls .control-check:hover { color: var(--text-primary); }
.controls .control-check input { cursor: pointer; }
.controls .control-check input:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 2px; }
#indicatorControls { margin-bottom: 14px; }

.chart-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 16px 8px; position: relative; box-shadow: var(--shadow-card); }
#chart { overflow: visible; display: block; }
svg text { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; fill: var(--text-muted); font-size: 10.5px; }
.chart-hover-target:focus-visible { outline: 2px solid var(--series-close); outline-offset: -2px; }
svg .axis-line { stroke: var(--baseline); stroke-width: 1; }
svg .grid-line { stroke: var(--gridline); stroke-width: 1; }
.panel-label { fill: var(--text-secondary); font-size: 11px; font-weight: 600; }

.legend { display: flex; flex-wrap: wrap; gap: 16px; padding: 10px 4px 14px; font-size: 12px; color: var(--text-secondary); }
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch-line { width: 16px; height: 2px; border-radius: 1px; display: inline-block; }
.legend .swatch-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
/* CSS-triangle swatches for Semsem cross markers -- shaped distinctly from the round trade-outcome
   dots above so the two marker families (trade result vs. EMA cross) never read as the same thing. */
.legend .swatch-triangle-up, .legend .swatch-triangle-down {
  width: 0; height: 0; display: inline-block;
  border-left: 5px solid transparent; border-right: 5px solid transparent;
}
.legend .swatch-triangle-up { border-bottom: 8px solid; }
.legend .swatch-triangle-down { border-top: 8px solid; }

#tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: color-mix(in srgb, var(--surface-1) 90%, transparent);
  backdrop-filter: blur(10px) saturate(1.3); -webkit-backdrop-filter: blur(10px) saturate(1.3);
  border: 1px solid var(--border); border-radius: var(--radius-md); padding: 9px 11px; font-size: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18); display: none; min-width: 190px; line-height: 1.5;
}
#tooltip .t-date { font-weight: 600; margin-bottom: 4px; color: var(--text-primary); }
#tooltip .t-row { display: flex; justify-content: space-between; gap: 14px; color: var(--text-secondary); }
#tooltip .t-row strong { color: var(--text-primary); font-weight: 600; font-family: var(--font-mono); }
#tooltip .t-key { display: inline-block; width: 12px; height: 2px; margin-right: 5px; vertical-align: middle; }

.table-toggle-wrap { margin: 20px 0 8px; }
table.trades {
  width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-card);
}
table.trades th, table.trades td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--gridline); }
table.trades th {
  color: var(--text-secondary); font-weight: 600; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.04em; background: var(--surface-2);
}
/* Native title tooltips have no visual cue by default -- this "?" badge is what tells users a
   header is hoverable for an explanation. */
table.trades th[title] { cursor: help; }
table.trades th[title]::after {
  content: "?"; display: inline-flex; align-items: center; justify-content: center;
  width: 12px; height: 12px; margin-left: 5px; border-radius: 50%;
  background: var(--surface-1); border: 1px solid var(--border); color: var(--text-muted);
  font-size: 9px; font-weight: 700; line-height: 1; vertical-align: middle;
}
table.trades td.num { font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
table.trades tbody tr { transition: background-color var(--dur-fast) var(--ease-out); }
table.trades tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
table.trades tbody tr:hover { background: color-mix(in srgb, var(--series-close) 7%, transparent); }
table.trades tbody tr:last-child td { border-bottom: none; }
table.trades .outcome-badge { display: inline-block; padding: 2px 8px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 600; }
table.trades .outcome-target { background: color-mix(in srgb, var(--status-good) 16%, transparent); color: var(--status-good); }
table.trades .outcome-stop { background: color-mix(in srgb, var(--status-critical) 16%, transparent); color: var(--status-critical); }
table.trades .outcome-time_stop { background: color-mix(in srgb, var(--status-neutral) 20%, transparent); color: var(--text-secondary); }
#tablesWrap { display: block; overflow-x: auto; }
table.trades td.change.good { color: var(--status-good); }
table.trades td.change.critical { color: var(--status-critical); }
/* Base look for .table-tab now lives on the shared .controls button / .table-tab / .refresh-btn
   rule near the top of this file -- only the layout wrapper stays here. */
.table-tabs { display: flex; gap: 6px; margin-top: 8px; }
.table-panel-hidden { display: none; }

.caveat { margin-top: 22px; padding: 14px 16px; border-radius: var(--radius-lg); background: var(--surface-1); border: 1px solid var(--border); font-size: 12px; color: var(--text-secondary); line-height: 1.6; }
.caveat strong { color: var(--text-primary); }

.progress-area { margin: 8px 0 20px; }
.progress-track { height: 6px; border-radius: 3px; background: var(--gridline); overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%; border-radius: 3px; transition: width var(--dur-base) var(--ease-out);
  background: linear-gradient(90deg, var(--action-primary) 0%, var(--series-close) 50%, var(--action-primary) 100%);
  background-size: 200% 100%; animation: progress-shimmer 1.6s linear infinite;
}
@keyframes progress-shimmer {
  0% { background-position: 0% 0; }
  100% { background-position: -200% 0; }
}
.progress-text { margin: 8px 0 0; font-family: var(--font-mono); }

.scan-empty {
  margin: 8px 0 20px; padding: 18px 18px 18px 52px; border-radius: var(--radius-lg);
  background: var(--surface-1); border: 1px solid var(--border);
  font-size: 13px; color: var(--text-secondary); line-height: 1.6; position: relative;
}
.scan-empty strong { color: var(--text-primary); }
/* A quiet "nothing found" glyph so an empty scan reads as a calm, expected state at a glance
   rather than a wall of text that looks like an error message. */
.scan-empty::before {
  content: ""; position: absolute; left: 18px; top: 18px; width: 22px; height: 22px;
  background-color: var(--text-muted); opacity: 0.6;
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="7"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>') center / contain no-repeat;
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="7"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>') center / contain no-repeat;
}

.scan-sym { font-family: var(--font-mono); font-weight: 600; }
.scan-name { color: var(--text-secondary); }
.scan-more { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

.detail-link {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: #fff;
  background: var(--action-primary); border-radius: var(--radius-sm); padding: 4px 10px;
  text-decoration: none; white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease-out), filter var(--dur-fast) var(--ease-out);
}
.detail-link::after { content: "\2192"; font-weight: 700; transition: transform var(--dur-fast) var(--ease-out); }
.detail-link:hover { filter: brightness(1.1); }
.detail-link:hover::after { transform: translateX(2px); }
.detail-link:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Base look now lives on the shared .controls button / .table-tab / .refresh-btn rule near the
   top of this file -- only the disabled state is specific to this control. */
.refresh-btn:disabled { opacity: 0.6; cursor: default; }

.tf-tabs { margin: 4px 0 14px; flex-wrap: wrap; }
.tf-chip {
  display: inline-flex; align-items: center; font-family: var(--font-mono); font-size: 11px;
  font-weight: 600; border-radius: var(--radius-sm); padding: 2px 6px; white-space: nowrap;
}
.tf-chip-hit { color: var(--status-good); background: color-mix(in srgb, var(--status-good) 14%, transparent); }
.tf-chip-miss { color: var(--text-muted); background: var(--surface-2); }
.tf-chip-na { color: var(--text-muted); background: transparent; opacity: 0.5; }
.metric-critical-chip { color: var(--status-critical); background: color-mix(in srgb, var(--status-critical) 14%, transparent); }

.prov-mark { color: var(--action-primary); font-weight: 700; cursor: help; }

/* Trend Screen Tier 1/2 metric cells (R:R, RS, Vol) -- reuses the same good/critical tokens as
   table.trades td.change above, just under generic names since these columns aren't %-change. */
.metric-good { color: var(--status-good); font-weight: 600; }
.metric-neutral { color: var(--text-secondary); }
.metric-critical { color: var(--status-critical); font-weight: 600; }

.sector-warning { border-color: var(--status-neutral); }

.trend-stats-panel { border-color: var(--action-primary); margin: 14px 0; }
.trend-stats-panel .pill { margin: 4px 6px 0 0; }

/* --- Semsem page (semsem.html) --- */

/* Current value beside each filter slider. Tabular figures so the row doesn't jitter as it moves. */
.controls .control-value {
  font-size: 12px; font-weight: 600; color: var(--text-primary);
  min-width: 38px; font-variant-numeric: tabular-nums;
}
.controls input[type="range"] { accent-color: var(--action-primary); width: 120px; vertical-align: middle; }
/* Every other control in the app gets the custom --focus-ring on keyboard focus; range inputs
   were falling back to the browser's default outline (which doesn't follow the thumb shape well
   across browsers) -- an outline reads consistently here instead. */
.controls input[type="range"]:focus-visible { outline: 2px solid var(--series-close); outline-offset: 3px; }

.filter-note { margin: 10px 0 14px; }

.section-title { font-size: 15px; font-weight: 700; margin: 28px 0 4px; color: var(--text-primary); }

/* Watchlist caveat needs to stand out from the page's other caveat boxes -- it's warning about a
   materially weaker claim (an unbacktested projection) than everything else on the page. */
.watchlist-caveat {
  border-color: var(--status-warn, var(--action-primary));
  background: color-mix(in srgb, var(--status-warn, var(--action-primary)) 6%, transparent);
  margin: 10px 0 14px;
}

/* Inline caution paragraph inside a help guide-card -- used where a feature's honest backtest
   result is weaker than its headline number suggests. */
.guide-card .warn-text {
  border-left: 3px solid var(--status-warn, var(--action-primary));
  padding: 8px 0 8px 12px;
  background: color-mix(in srgb, var(--status-warn, var(--action-primary)) 7%, transparent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
[dir="rtl"] .guide-card .warn-text {
  border-left: none;
  border-right: 3px solid var(--status-warn, var(--action-primary));
  padding: 8px 12px 8px 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

/* Rows outside the user's cross-age / run-up filters. Shown rather than hidden so a fresh cross
   can be compared against one that has already run -- that comparison is the point of the page. */
.trades tr.row-muted { opacity: 0.5; }
.trades tr.row-muted:hover { opacity: 0.8; }

.guide-card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 22px; margin-bottom: 16px; box-shadow: var(--shadow-card);
  transition: box-shadow var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
.guide-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.guide-card h2 { font-size: 15px; font-weight: 700; margin: 0 0 10px; color: var(--text-primary); }
.guide-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 10px; flex-wrap: wrap; }
.guide-card-head h2 { margin: 0; }
.guide-card-head .detail-link { flex-shrink: 0; }
.guide-card p { font-size: 14px; line-height: 1.7; color: var(--text-secondary); margin: 0 0 12px; }
.guide-card p:last-child { margin-bottom: 0; }
.guide-card p strong { color: var(--text-primary); }
.guide-card ul, .guide-card ol { margin: 0 0 12px; padding-left: 20px; font-size: 14px; line-height: 1.7; color: var(--text-secondary); }
.guide-card ul:last-child, .guide-card ol:last-child { margin-bottom: 0; }
.guide-card li { margin-bottom: 6px; }
.guide-card li strong { color: var(--text-primary); }
.glossary dt { font-family: var(--font-mono); font-weight: 700; color: var(--text-primary); font-size: 13px; margin-top: 12px; }
.glossary dt:first-child { margin-top: 0; }
.glossary dd { margin: 3px 0 0; font-size: 13px; line-height: 1.6; color: var(--text-secondary); }

.chart-demo {
  margin: 4px 0 14px; padding: 10px 10px 2px; border-radius: var(--radius-lg);
  border: 1px solid var(--border); background: var(--surface-2);
}
.chart-demo svg { display: block; width: 100%; height: auto; }
.chart-demo .demo-caption { font-size: 11px; color: var(--text-muted); text-align: center; margin: 2px 0 6px; }
.chart-demo .legend { justify-content: center; padding-top: 0; }

/* Current-price guide line: a slow pulse, echoing the same dashed line on the real chart. */
.demo-current-price { animation: demo-price-pulse 2.6s ease-in-out infinite; }
@keyframes demo-price-pulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 0.75; }
}

/* The example trade "plays out": the entry-to-exit line draws itself in, then the exit dot pops
   in once it "arrives" -- a loop, so a visitor doesn't have to do anything to see it happen. */
.demo-trade-line { stroke-dasharray: 200; animation: demo-trade-draw 3.4s ease-in-out infinite; }
@keyframes demo-trade-draw {
  0% { stroke-dashoffset: 200; opacity: 0; }
  12% { opacity: 0.6; }
  55%, 100% { stroke-dashoffset: 0; opacity: 0.6; }
}
.demo-exit-dot {
  transform-box: fill-box; transform-origin: center;
  animation: demo-exit-pop 3.4s ease-in-out infinite;
}
@keyframes demo-exit-pop {
  0%, 50% { transform: scale(0); opacity: 0; }
  62% { transform: scale(1.5); opacity: 1; }
  75%, 100% { transform: scale(1); opacity: 1; }
}

/* Walk-forward timeline (help.html): a marker sweeps left-to-right across the in-sample /
   out-of-sample split, and a checkmark fades in once it's swept past the out-of-sample side. */
.demo-sweep-bar { animation: demo-sweep-move 4s linear infinite; }
@keyframes demo-sweep-move {
  0% { transform: translateX(0); }
  100% { transform: translateX(560px); }
}
.demo-check { animation: demo-check-fade 4s ease-in-out infinite; }
@keyframes demo-check-fade {
  0%, 72% { opacity: 0; }
  82%, 100% { opacity: 1; }
}

/* R-multiple diagram (help.html Glossary): a dot travels from entry up into the reward zone,
   looping, to show the "target hit" path the +2R figure describes. */
.r-demo { max-width: 320px; margin-left: auto; margin-right: auto; }
.demo-r-dot {
  transform-box: fill-box; transform-origin: center;
  animation: demo-r-travel 3s ease-in-out infinite;
}
@keyframes demo-r-travel {
  0% { transform: translateY(0); opacity: 0; }
  10% { opacity: 1; }
  85% { transform: translateY(-80px); opacity: 1; }
  100% { transform: translateY(-80px); opacity: 0; }
}

/* Pattern sparkline icons (help.html): a small dot pulses at each pattern's trigger point, each
   on its own delay so the row doesn't pulse in lockstep. */
.pattern-icons { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 10px 0 16px; }
.pattern-icon {
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2);
  padding: 8px 8px 6px; text-align: center;
}
.pattern-icon svg { display: block; width: 100%; height: auto; }
.pattern-icon .icon-label { font-size: 11px; font-weight: 700; color: var(--text-primary); margin-top: 4px; }
.pattern-dot {
  transform-box: fill-box; transform-origin: center;
  animation: demo-pattern-pulse 1.8s ease-in-out infinite;
}
@keyframes demo-pattern-pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.7); opacity: 1; }
}

/* MTF agreement chips (help.html Trend Screen section): checkmarks fade in one at a time, left
   to right, then reset together -- a compact stand-in for "these timeframes agree." */
.mtf-demo { display: flex; gap: 10px; margin: 10px 0 4px; flex-wrap: wrap; }
.mtf-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface-2);
  font-size: 12px; color: var(--text-secondary); font-weight: 600;
}
.mtf-chip .chip-check {
  color: var(--status-good); font-weight: 700;
  animation: mtf-chip-check 4.8s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 0.5s);
}
@keyframes mtf-chip-check {
  0%, 8% { opacity: 0; transform: scale(0.5); }
  16%, 82% { opacity: 1; transform: scale(1); }
  90%, 100% { opacity: 0; transform: scale(0.5); }
}

.site-footer {
  margin-top: 24px; padding: 14px 16px; border-radius: var(--radius-lg);
  background: var(--surface-1); border: 1px solid var(--border); box-shadow: var(--shadow-card);
  text-align: center; font-size: 15px; color: var(--text-secondary);
}
.site-footer a { color: var(--series-close); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.site-footer a:hover { color: var(--action-primary); }

/* Themed scrollbars -- the OS default (esp. on Windows) reads as an un-styled leftover next to
   everything else here being on the theme, and it's most visible exactly where it matters most:
   the wide tables' horizontal scroll. Firefox + WebKit/Blink properties both needed, no shared shorthand. */
.viz-root, .viz-root * { scrollbar-width: thin; scrollbar-color: var(--baseline) transparent; }
.viz-root ::-webkit-scrollbar { width: 10px; height: 10px; }
.viz-root ::-webkit-scrollbar-track { background: transparent; }
.viz-root ::-webkit-scrollbar-thumb { background-color: var(--baseline); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
.viz-root ::-webkit-scrollbar-thumb:hover { background-color: var(--text-muted); }

/* ===========================
   Responsive (mobile)
   =========================== */
@media (max-width: 640px) {
  .viz-root { padding: 16px 12px 32px; }
  .wrap { max-width: 100%; }

  /* Nav: brand + toggle stay on one row, links drop to a full-width row of even-width tap targets */
  .top-nav { margin: -16px -12px 20px; padding: 0 12px; }
  .top-nav-inner { flex-wrap: wrap; gap: 10px 12px; padding: 10px 0; }
  .top-nav-brand { order: 1; font-size: 13px; }
  #themeToggle { order: 2; margin-left: auto; width: 44px; height: 44px; }
  #themeToggle svg { width: 19px; height: 19px; }
  .top-nav-links { order: 3; flex-basis: 100%; gap: 4px; }
  /* `flex: 1` (equal widths) worked at 4 links but starves them at 5-6 -- ~60px each at 360px is
     too narrow for "Trend Screen". Size to content and let the row wrap instead. */
  .top-nav-link { flex: 1 1 auto; text-align: center; padding: 9px 8px; font-size: 12.5px; }

  .header h1 { font-size: 17px; }
  .header .sub { font-size: 12.5px; }

  /* Search: stack sector filter, ticker search, and submit instead of squeezing into one row */
  .search-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .sector-select { max-width: none; width: 100%; }
  .ticker-search { width: 100%; }
  .search-row button { padding: 12px 18px; min-height: 44px; }

  .range-sliders { gap: 14px; }
  .range-slider { min-width: 100%; }

  .controls { gap: 8px 10px; }
  .controls button,
  .table-tab,
  .refresh-btn { padding: 11px 14px; min-height: 44px; }
  .controls .control-inline input[type="date"] { width: 122px; }
  .controls .control-inline input[type="number"] { width: 60px; }

  .chart-card { padding: 12px 10px 6px; }
  .legend { gap: 8px 14px; font-size: 11.5px; }

  /* Force horizontal scroll instead of cramped multi-line cells in dense tables */
  table.trades th, table.trades td { white-space: nowrap; }

  .kpi-row { gap: 8px; }
  .kpi .value { font-size: 18px; }
  .setup-block .item .value { font-size: 16px; }

  .guide-card { padding: 14px 16px; }
  .site-footer { font-size: 14px; }
}

/* Skipped-ticker disclosure (scan / screen / semsem) -- see public/skipped.js.
   Deliberately quiet: it sits below the results as a diagnostic, not a headline. */
.skipped-panel {
  margin-top: 18px; padding: 10px 14px; border-radius: var(--radius-md);
  background: var(--surface-1); border: 1px solid var(--border);
  font-size: 12px; color: var(--text-secondary); line-height: 1.6;
}
.skipped-panel > summary {
  cursor: pointer; color: var(--text-muted); font-size: 12px;
  list-style: none; user-select: none;
}
.skipped-panel > summary::-webkit-details-marker { display: none; }
.skipped-panel > summary::before { content: "\25B8 "; display: inline-block; margin-inline-end: 6px; }
.skipped-panel[open] > summary::before { content: "\25BE "; }
.skipped-panel > summary:hover { color: var(--text-primary); }
.skipped-group-title { margin: 12px 0 2px; color: var(--text-primary); font-weight: 600; font-size: 12px; }
.skipped-codes { margin: 0; font-family: var(--font-mono, ui-monospace, monospace); font-size: 11px; color: var(--text-muted); word-break: break-word; }
.skipped-note { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 11px; }
