/*
 * dashboard_theme.css
 *
 * Shared client-side theme for all AlphaFutures dashboard pages:
 *   /                 (opportunities)
 *   /radar            (radar leaderboard)
 *   /btc-strength     (BTC Strength bot runs)
 *   /cryptofusion     (CryptoFusion Master signals + runs)
 *   /crypto-hunter    (Crypto Hunter research radar)
 *   /consensus        (cross-bot consensus)
 *
 * "Terminal" theme (2026-10-11, replaces "Neon Signal"): neutral near-black
 * stage, flat hairline-bordered panels, small radii, no glow. One calm cyan
 * accent for interactive chrome; green/red stay semantic for long/short.
 * Every number (scores, prices, counts, levels) is set in JetBrains Mono
 * with tabular figures so columns line up; Persian text stays in
 * Vazirmatn (also the fallback for Persian glyphs inside --mono).
 * Spacing scale: 4/8/12/16/24px.
 *
 * Page templates carry their own inline <style> blocks AFTER this file, so
 * the overrides at the bottom ("page-level overrides") use `html body`
 * selectors to win on specificity without touching the Python templates.
 *
 * Bidi note: text-bearing elements use `unicode-bidi: plaintext` so each
 * block aligns by its own first strong character (Persian right, English/
 * numeric left) with no markup changes on the Python/HTML side.
 */

:root {
  color-scheme: dark;
  --bg: oklch(0.135 0.006 250);
  --panel: oklch(0.17 0.008 250);
  --panel-soft: oklch(0.205 0.009 250);
  --panel-raised: oklch(0.19 0.009 250);
  --head: oklch(0.155 0.007 250);
  --border: oklch(0.3 0.011 250);
  --border-soft: oklch(0.24 0.009 250);
  --text: oklch(0.95 0.005 250);
  --muted: oklch(0.72 0.012 250);
  --muted-soft: oklch(0.6 0.012 250);
  --green: oklch(0.78 0.16 150);
  --yellow: oklch(0.84 0.14 80);
  --gray: oklch(0.66 0.012 250);
  --red: oklch(0.7 0.19 25);
  --accent: oklch(0.8 0.12 205);
  --accent-weak: oklch(0.8 0.12 205 / 0.14);
  --green-weak: oklch(0.78 0.16 150 / 0.13);
  --red-weak: oklch(0.7 0.19 25 / 0.13);
  --yellow-weak: oklch(0.84 0.14 80 / 0.12);
  --shadow: none;
  --shadow-raised: 0 12px 32px oklch(0 0 0 / 0.5);
  --glow-accent: none;
  --glow-green: none;
  --radius: 6px;
  --radius-sm: 4px;
  --mono: "JetBrains Mono", "Vazirmatn", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --sans: "Vazirmatn", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --gutter: 24px;
}

* { box-sizing: border-box; }

::selection { background: oklch(0.8 0.12 205 / 0.35); color: var(--text); }

* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted-soft); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  /* Persian glyphs carry more vertical detail than Latin; 1.6 keeps
     multi-line notes readable while staying dense. */
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { unicode-bidi: plaintext; color: var(--accent); text-underline-offset: 3px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- nav --- */
nav {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 48px;
  padding: 0 var(--gutter);
  background: oklch(0.115 0.006 250 / 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 10;
}
nav a {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 0 14px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
nav a:hover { color: var(--text); background: oklch(1 0 0 / 0.03); }
nav a.active {
  color: var(--text);
  font-weight: 700;
  border-bottom-color: var(--accent);
  background: linear-gradient(to top, var(--accent-weak), transparent 70%);
}
nav .spacer { flex: 1; }
.nav-links { display: flex; align-items: stretch; gap: 0; }
.nav-toggle {
  display: none;
  align-items: center;
  align-self: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  unicode-bidi: plaintext;
}
.nav-toggle-icon {
  position: relative;
  width: 16px; height: 12px; flex: 0 0 auto;
}
.nav-toggle-icon::before, .nav-toggle-icon::after {
  content: ""; position: absolute; left: 0; right: 0;
  height: 2px; border-radius: 2px; background: currentColor;
}
.nav-toggle-icon::before { top: 0; box-shadow: 0 5px 0 currentColor; }
.nav-toggle-icon::after { bottom: 0; }
.sound-toggle {
  display: inline-flex;
  align-items: center;
  align-self: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.sound-toggle:hover { color: var(--text); }
.sound-toggle.on { color: var(--green); border-color: oklch(0.78 0.16 150 / 0.45); background: var(--green-weak); }

/* ------------------------------------------------------------- headers -- */
header { padding: 24px var(--gutter) 4px; }
h1 {
  font-family: var(--sans);
  font-size: 24px;
  font-weight: 800;
  margin: 0 0 4px;
  letter-spacing: 0;
}
h1 a { color: var(--accent); text-decoration: none; }
h2 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 24px var(--gutter) 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
  unicode-bidi: plaintext;
}
#status { padding: 0 var(--gutter) 16px; color: var(--muted); font-size: 12.5px; unicode-bidi: plaintext; }
#status .ok { color: var(--green); font-weight: 600; }
#status .err { color: var(--red); font-weight: 600; }

/* ---------------------------------------------------------- stat cards -- */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0;
  margin: 4px var(--gutter) 24px;
  padding: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}
.stat-card {
  position: relative;
  background: transparent;
  border: 0;
  border-inline-start: 1px solid var(--border-soft);
  border-radius: 0;
  box-shadow: none;
  padding: 14px 18px;
  min-width: 0;
  overflow: hidden;
}
.stat-card:first-child { border-inline-start: 0; }
.stat-card::before { content: none; }
.stat-card:hover { background: oklch(1 0 0 / 0.02); }
.stat-card .label {
  color: var(--muted-soft);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  unicode-bidi: plaintext;
}
.stat-card .value {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  unicode-bidi: plaintext;
  color: var(--text);
  text-shadow: none;
}
.stat-card .value.green { color: var(--green); text-shadow: none; }
.stat-card .value.yellow { color: var(--yellow); text-shadow: none; }
.stat-card .value.red { color: var(--red); text-shadow: none; }
.stat-card .sub { color: var(--muted-soft); font-size: 12px; margin-top: 4px; unicode-bidi: plaintext; }

/* ----------------------------------------------------------- controls --- */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 0 var(--gutter) 12px;
  unicode-bidi: plaintext;
}
.controls input[type="search"],
.controls input[type="number"],
input[type="search"], input[type="number"], input[type="text"] {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.controls input[type="search"] {
  min-width: 220px;
  flex: 1 1 220px;
  max-width: 340px;
}
.controls input[type="number"], input[type="number"] {
  min-width: 0;
  flex: 0 0 auto;
  font-family: var(--mono);
  appearance: textfield;
  -webkit-appearance: textfield;
}
input[type="search"]:focus, input[type="number"]:focus, input[type="text"]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-weak);
}
.controls label { unicode-bidi: plaintext; }
select, .controls select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font: inherit;
  font-size: 12px;
}
.filter-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease;
  unicode-bidi: plaintext;
}
.filter-btn:hover { color: var(--text); border-color: var(--muted-soft); background: oklch(1 0 0 / 0.03); }
.filter-btn.active {
  color: var(--accent);
  background: var(--accent-weak);
  border-color: oklch(0.8 0.12 205 / 0.6);
  font-weight: 700;
  box-shadow: none;
}

/* -------------------------------------------------------------- tables -- */
.table-wrap {
  overflow-x: auto;
  padding: 0 var(--gutter) 24px;
}
table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 860px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: none;
  font-size: 13px;
}
th, td {
  padding: 7px 12px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-soft);
  unicode-bidi: plaintext;
}
th {
  color: var(--muted-soft);
  font-weight: 700;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  background: var(--head);
  position: sticky;
  top: 0;
  z-index: 1;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th .sort-arrow { font-size: 10px; margin-left: 4px; color: var(--accent); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: oklch(1 0 0 / 0.015); }
tbody tr { transition: background 0.08s ease; }
tbody tr:hover { background: var(--panel-soft); }
td.num { font-variant-numeric: tabular-nums; font-family: var(--mono); font-weight: 500; }

/* ------------------------------------------------------------ statuses -- */
.long { color: var(--green); font-weight: 700; }
.short { color: var(--red); font-weight: 700; }
/* Heat-map score badges: the tinted cell reads at a glance. */
.score-high, .score-mid, .score-low {
  display: inline-block;
  min-width: 46px;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: center;
}
.score-high { color: var(--green); background: var(--green-weak); text-shadow: none; }
.score-mid { color: var(--yellow); background: var(--yellow-weak); }
.score-low { color: var(--gray); background: oklch(1 0 0 / 0.05); font-weight: 500; }
.muted { color: var(--muted); unicode-bidi: plaintext; }

/* --------------------------------------------------------- age badges -- */
.age-badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  white-space: nowrap;
}
.age-badge.stale {
  color: var(--yellow);
  border-color: oklch(0.84 0.14 80 / 0.45);
  background: var(--yellow-weak);
  font-weight: 600;
}
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--muted);
  unicode-bidi: plaintext;
}
.badge.pdf, .badge.csv { color: var(--accent); border-color: oklch(0.8 0.12 205 / 0.45); }

.src-badge { transition: border-color 0.12s ease; }
.src-badge .dot { box-shadow: none; }

/* ----------------------------------------------- confluence badge (radar) -- */
.confluence-badge {
  display: inline-block;
  font-size: 11px;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid oklch(0.78 0.16 150 / 0.5);
  color: var(--green);
  background: var(--green-weak);
  font-weight: 700;
  white-space: nowrap;
  cursor: help;
}

/* ---------------------------------------------------------- trend cells -- */
canvas.sparkline { display: block; width: 60px; height: 20px; }
.trend-collecting {
  color: var(--muted-soft);
  font-size: 11px;
  display: inline-block;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------ alert flashing -- */
@keyframes alertFlash {
  0%   { background: oklch(0.78 0.16 150 / 0.35); }
  100% { background: transparent; }
}
tr.alert-flash { animation: alertFlash 5s ease-out forwards; }

/* ---------------------------------------------------------- chart modal -- */
.chart-btn {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  color: var(--accent);
  border: 1px solid oklch(0.8 0.12 205 / 0.45);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  line-height: 1.5;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.chart-btn:hover { background: var(--accent-weak); border-color: var(--accent); }

.chart-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: oklch(0.05 0.004 250 / 0.8);
  backdrop-filter: blur(3px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.chart-modal-overlay.open { display: flex; }
.chart-modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-raised);
  width: min(1280px, 100%);
  max-height: 92vh;
  overflow: auto;
  padding: 16px;
}
.chart-modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
}
.chart-title {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 16px;
  flex: 1;
  unicode-bidi: plaintext;
}
.chart-tf { display: flex; gap: 4px; }
.chart-close {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 18px;
  line-height: 1;
  padding: 4px 10px;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.chart-close:hover { color: var(--red); border-color: var(--red); }

.chart-layout { display: flex; gap: 12px; align-items: flex-start; }
.chart-body-wrap { flex: 1 1 auto; min-width: 0; }
.chart-body { width: 100%; min-height: 420px; }
.chart-msg { padding: 24px 8px; text-align: center; font-size: 14px; color: var(--muted); }

.chart-panel {
  flex: 0 0 240px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chart-panel-block {
  background: var(--head);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.chart-panel-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted-soft);
  margin-bottom: 8px;
  unicode-bidi: plaintext;
}
.chart-panel-score {
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.chart-panel-direction {
  display: inline-block;
  margin-top: 10px;
  padding: 2px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
}
.chart-panel-direction.long { color: var(--green); border-color: oklch(0.78 0.16 150 / 0.5); background: var(--green-weak); }
.chart-panel-direction.short { color: var(--red); border-color: oklch(0.7 0.19 25 / 0.5); background: var(--red-weak); }
.chart-panel-direction.muted { color: var(--muted); }
.chart-panel-level-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-soft);
  unicode-bidi: plaintext;
}
.chart-panel-level-row:last-child { border-bottom: none; padding-bottom: 0; }
.chart-panel-level-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.chart-panel-level-value {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --------------------------------------------------------------- toast -- */
.app-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--panel-raised);
  color: var(--text);
  border: 1px solid oklch(0.8 0.12 205 / 0.55);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  box-shadow: var(--shadow-raised);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
}
.app-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (max-width: 640px) {
  .chart-modal { padding: 10px; }
  .chart-body { min-height: 300px; }
  .chart-layout { flex-direction: column; }
  .chart-panel { flex: 1 1 auto; flex-direction: row; flex-wrap: wrap; }
  .chart-panel-block { flex: 1 1 160px; }
}

/* --------------------------------------------------------------- empty -- */
#empty, #empty-signals, #empty-runs, .empty {
  padding: 24px;
  margin: 0 var(--gutter) 24px;
  color: var(--muted-soft);
  font-size: 13px;
  text-align: center;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  unicode-bidi: plaintext;
}

/* ---------------------------------------------------------- details --- */
summary {
  cursor: pointer;
  list-style: none;
  unicode-bidi: plaintext;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  margin-inline-start: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  vertical-align: middle;
  opacity: 0.6;
}
details[open] > summary::after { transform: rotate(-135deg); }

/* ------------------------------------------------------------- RTL ---- */
html[dir="rtl"] th, html[dir="rtl"] td { text-align: right; }
th .sort-arrow { margin-left: 0; margin-inline-start: 4px; }
.live-dot::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); margin-inline-end: 6px;
  animation: livePulse 2s ease-in-out infinite; vertical-align: middle; }
@keyframes livePulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .live-dot::before { animation: none; } }

/* ------------------------------------------------ page-level overrides -- */
/* Inline <style> blocks in the page templates load after this file; the
   `html body` prefix lifts specificity so the terminal look wins there too. */
html body .bot-badge, html body .ch-bot-badge {
  border-radius: var(--radius-sm);
  border-color: var(--border-soft);
  font-size: 11px;
  padding: 0 6px;
}
html body .ch-bot-badge.long { border-color: oklch(0.78 0.16 150 / 0.5); }
html body .ch-bot-badge.short { border-color: oklch(0.7 0.19 25 / 0.5); }
html body .src-badge {
  border-radius: var(--radius-sm);
  border-color: var(--border-soft);
  background: var(--panel);
  padding: 2px 8px;
}
html body .src-badge .dot { width: 12px; height: 12px; color: var(--bg); }
html body .lv {
  border-radius: var(--radius-sm);
  background: transparent;
  border-color: var(--border-soft);
  padding: 1px 6px;
}
html body .lv bdi { font-family: var(--mono); font-weight: 500; }
html body .lv-sl bdi { color: var(--red); }
html body .lv-tp bdi { color: var(--green); }
html body .dup-chip { border-radius: var(--radius-sm); }

/* Section panels on the opportunities page (recent events, consensus,
   disagreement, correlation risk, sizing). */
html body #recent-events,
html body #consensus-highlight,
html body #consensus-disagreement,
html body #correlation-risk,
html body #sizing-controls {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 0 var(--gutter) 12px;
}
html body #sizing-controls { padding: 8px 12px; gap: 8px; }
html body #recent-events > summary,
html body #consensus-highlight > summary,
html body #consensus-disagreement > summary,
html body #correlation-risk > summary { font-size: 13.5px; }
/* Each panel's meaning (warning / consensus / recent) is carried by a faint tint of its colour, a
   matching hairline and the colour of its title icon, not by a thick side stripe. */
html body #consensus-disagreement,
html body #correlation-risk {
  border-color: oklch(0.84 0.14 80 / 0.3);
  background: color-mix(in oklch, var(--panel), var(--yellow) 5%);
}
html body #consensus-highlight {
  border-color: oklch(0.78 0.16 150 / 0.3);
  background: color-mix(in oklch, var(--panel), var(--green) 5%);
}
html body #recent-events {
  border-color: oklch(0.8 0.12 205 / 0.3);
  background: color-mix(in oklch, var(--panel), var(--accent) 5%);
}
html body #consensus-disagreement > summary .ic,
html body #correlation-risk > summary .ic { color: var(--yellow); }
html body #consensus-highlight > summary .ic { color: var(--green); }
html body #recent-events > summary .ic { color: var(--accent); }
html body .re-row, html body .ch-row {
  border-radius: var(--radius-sm);
  background: transparent;
  border-bottom: 1px solid var(--border-soft);
  padding: 5px 6px;
}
html body .re-row:last-child, html body .ch-row:last-child { border-bottom: 0; }
html body .re-row:hover, html body .ch-row:hover { background: var(--panel-soft); }
html body .re-row .re-sym, html body .ch-row .ch-symbol, html body .op-card-symbol {
  font-family: var(--mono);
  font-weight: 600;
}
html body .ch-row .ch-count, html body .re-new-badge, html body .month-badge {
  border-radius: var(--radius-sm);
}
@keyframes reFlash { 0% { background: oklch(0.78 0.16 150 / 0.22); } 100% { background: transparent; } }

html body .op-card {
  border-radius: var(--radius);
  box-shadow: none;
  background: var(--panel);
  padding: 12px 14px;
}
html body .group-controls select { background: var(--panel); border-radius: var(--radius-sm); }
html body .group-note {
  color: var(--muted);
  font-size: 13px;
  margin: 0 var(--gutter) 10px;
  padding: 6px 12px;
  background: var(--panel);
  border-radius: var(--radius-sm);
}
/* the template's `html[dir="rtl"] .group-note` 3px side stripe: this selector outranks it */
html[dir] body .group-note { border: 1px solid var(--border-soft); }
html body .why-badge { border-color: var(--muted-soft); }

/* Monthly report archive */
html body .month-card {
  border-color: var(--border-soft);
  border-radius: var(--radius);
  background: var(--panel);
}
html body .month-card.is-current {
  border-color: oklch(0.84 0.14 80 / 0.4);
  background: color-mix(in oklch, var(--panel), var(--yellow) 5%);
}
html body .month-title, html body .month-metric-value { font-family: var(--mono); font-weight: 600; }

/* --------------------------------------------------------- loading ---- */
/* Stat values render "—" until the first API response; a soft shimmer
   makes that read as "loading" rather than "no data". */
@keyframes skel { 0% { opacity: 0.35; } 50% { opacity: 0.8; } 100% { opacity: 0.35; } }
.stat-card .value:empty, .stat-card .value.loading { animation: skel 1.4s ease-in-out infinite; }

/* ----------------------------------------------------------- responsive -- */
@media (max-width: 640px) {
  :root { --gutter: 12px; }
  nav {
    flex-wrap: wrap;
    align-items: center;
    padding-top: 8px;
    padding-bottom: 8px;
    min-height: 0;
  }
  .nav-links {
    display: none;
    order: 10;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding-top: 6px;
    margin-top: 8px;
    border-top: 1px solid var(--border-soft);
  }
  .nav-links.open { display: flex; }
  .nav-toggle { display: inline-flex; }
  .nav-toggle-label { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  nav a {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-soft);
  }
  nav a:last-child { border-bottom: 0; }
  nav a.active {
    border-bottom-color: var(--border-soft);
    border-inline-start: 3px solid var(--accent);
    background: var(--accent-weak);
  }
  nav .spacer { flex: 1; }
  h1 { font-size: 20px; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .stat-card { padding: 12px 14px; border-top: 1px solid var(--border-soft); }
  .stat-card:nth-child(-n+2) { border-top: 0; }
  .stat-card:nth-child(odd) { border-inline-start: 0; }
  .stat-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stat-card .value { font-size: 22px; }
  .controls input[type="search"] { flex-basis: 100%; min-width: 0; }
}

/* ------------------------------------------------ favorites (stars) --- */
.fav-btn {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0 2px;
  margin-inline-end: 4px;
  font-size: 15px;
  line-height: 1;
  color: var(--muted-soft);
  cursor: pointer;
  vertical-align: -1px;
}
.fav-btn:hover { color: var(--yellow); }
.fav-btn.on { color: var(--yellow); }
.fav-filter.active { color: var(--yellow); background: var(--yellow-weak); border-color: oklch(0.84 0.14 80 / 0.55); }
.fav-count { font-family: var(--mono); font-size: 11px; }

/* CryptoFusion SHORT analysed on a spot market, listed with futures positions. */
.route-tag {
  display: inline-block;
  margin-inline-start: 4px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  cursor: help;
}

/* --------------------------------------------- engine track record --- */
.wr-chip {
  display: inline-block;
  margin-inline-start: 4px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  cursor: help;
}
.wr-chip .wr-n { font-family: var(--mono); color: var(--muted-soft); font-size: 10px; }
.wr-chip.good { color: var(--green); border-color: oklch(0.78 0.16 150 / 0.45); background: var(--green-weak); }
.wr-chip.bad { color: var(--red); border-color: oklch(0.7 0.19 25 / 0.45); background: var(--red-weak); }
.wr-chip.flat { color: var(--yellow); border-color: oklch(0.84 0.14 80 / 0.4); }

/* ------------------------------------------------------- pulse strip --- */
.pulse-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 var(--gutter) 14px;
}
.pulse-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--muted);
  font-size: 12.5px;
  text-decoration: none;
  transition: border-color 0.12s ease, color 0.12s ease;
}
.pulse-chip:hover { color: var(--text); border-color: var(--border); }
.pulse-chip b { font-family: var(--mono); font-weight: 600; color: var(--text); }
.pulse-chip.good:not(.zero) b { color: var(--green); }
.pulse-chip.warn:not(.zero) b { color: var(--yellow); }
.pulse-chip.zero { opacity: 0.6; }
.panels-wrap { margin-top: 8px; }
.panels-wrap > h2 { margin-top: 32px; }

/* ------------------------------------------------- loading skeletons --- */
@keyframes skelSweep { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.skel {
  display: block;
  height: 12px;
  width: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--panel-soft) 25%, oklch(0.26 0.01 250) 50%, var(--panel-soft) 75%);
  background-size: 200% 100%;
  animation: skelSweep 1.3s linear infinite;
}
.skel.short { width: 55%; margin-top: 10px; }
tr.skel-row td { padding-top: 12px; padding-bottom: 12px; }
tr.skel-row:hover { background: transparent; }
.skel-card { min-height: 84px; }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* --------------------------------------------- performance additions --- */
.perf-explain { max-width: 90ch; line-height: 1.8; font-size: 12.5px; }
tr.row-total td { background: var(--head); font-weight: 700; border-top: 1px solid var(--border); }
#ledger-csv { text-decoration: none; }

/* ---------------------------------------------------- mobile tab bar --- */
.tabbar, .tabbar-sheet { display: none; }
@media (max-width: 640px) {
  body.has-tabbar { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  body.has-tabbar nav .nav-toggle { display: none; }
  .tabbar {
    display: flex;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 50;
    height: calc(58px + env(safe-area-inset-bottom));
    padding: 0 4px env(safe-area-inset-bottom);
    background: oklch(0.12 0.006 250 / 0.97);
    border-top: 1px solid var(--border-soft);
  }
  .tabbar a, .tabbar button {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 0 4px;
    border: 0;
    border-top: 2px solid transparent;
    background: transparent;
    color: var(--muted-soft);
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
  }
  .tabbar a.active, .tabbar button.active {
    color: var(--accent);
    border-top-color: var(--accent);
    background: linear-gradient(to bottom, var(--accent-weak), transparent 80%);
  }
  .tabbar-sheet:not([hidden]) {
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: auto 8px calc(66px + env(safe-area-inset-bottom)) 8px;
    z-index: 51;
    padding: 6px;
    background: var(--panel-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-raised);
  }
  .tabbar-sheet a {
    unicode-bidi: normal;
    text-align: right;
    padding: 12px 10px;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px solid var(--border-soft);
  }
  .tabbar-sheet a:last-child { border-bottom: 0; }
  .tabbar-sheet a.active { color: var(--accent); }
  .pulse-strip .pulse-chip { flex: 1 1 calc(50% - 6px); justify-content: space-between; }
}

/* ------------------------------------------------------- market strip --- */
.mkt-strip {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
  padding: 0 var(--gutter);
  min-height: 34px;
  background: var(--head);
  border-bottom: 1px solid var(--border-soft);
  font-size: 12px;
}
.mkt-strip::-webkit-scrollbar { display: none; }
.mk-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 0 12px;
  border-inline-start: 1px solid var(--border-soft);
  cursor: default;
}
.mk-item:first-child { border-inline-start: 0; padding-inline-start: 0; }
.mk-k { color: var(--muted-soft); font-weight: 600; }
.mk-v { font-family: var(--mono); color: var(--text); font-weight: 500; }
.mk-v.up { color: var(--green); }
.mk-v.down { color: var(--red); }
.mk-item .skel { display: inline-block; height: 10px; vertical-align: middle; }

/* --------------------------------------------------------- symbol links --- */
a.sym-link { color: inherit; text-decoration: none; font-weight: 700; }
a.sym-link:hover { color: var(--accent); text-decoration: underline; }

/* --------------------------------------------- Persian script fixes --- */
/* Letter-spacing pulls apart the joined letters of Persian/Arabic script,
   and text-transform: uppercase does nothing for it. The tracked uppercase
   label style above (h2, th, stat-card/chart-panel labels, h1's negative
   tracking) was written for the old LTR English chrome, so reset it on
   the Persian-first pages. */
html[dir="rtl"] h1,
html[dir="rtl"] h2,
html[dir="rtl"] th,
html[dir="rtl"] .stat-card .label,
html[dir="rtl"] .chart-panel-label {
  letter-spacing: 0;
  text-transform: none;
}

/* ------------------------------------------------ touch + mobile input -- */
/* Touch screens: grow the small pill/chip buttons to ~40px+ tap targets. */
@media (pointer: coarse) {
  .filter-btn, .chart-btn, .sound-toggle, .nav-toggle, .chart-close { min-height: 40px; }
  nav a { padding-top: 11px; padding-bottom: 11px; }
}
/* iOS Safari zooms the page when a focused field's font is under 16px. */
@media (max-width: 640px) {
  input, select, textarea { font-size: 16px !important; }
}

/* ------------------------------------------------- polish 2026-10-14 -- */
/* Buttons don't inherit the page font by default (the sound toggle fell back to Arial). */
.sound-toggle { font-family: inherit; }
.sound-toggle svg { flex: 0 0 auto; }
/* Skip link: off-screen until focused by keyboard, then a visible chip at the top. */
.skip-link {
  position: absolute;
  top: 8px;
  inset-inline-start: 8px;
  z-index: 300;
  padding: 10px 14px;
  background: var(--panel-raised);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }
#main:focus { outline: none; }
/* Inline stroke icons (replacing colour emoji): sit on the text's middle, take its colour. */
.ic { display: inline-block; vertical-align: -0.15em; flex: 0 0 auto; }
/* Persian words in the market strip (regime, breadth) read in the body face, not mono. */
.mk-v.fa { font-family: var(--sans); }

/* Opportunities table: the levels cell (entry / stop / targets) ran 600px on one line and
   pushed the last column off a 1366px screen. Let the chips wrap inside a capped cell. */
html body td .lv-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  max-width: 360px;
  white-space: normal;
}
html body td .lv-row .lv { white-space: nowrap; }
html body td:has(> .lv-row) { white-space: normal; min-width: 240px; }

/* Touch screens and phones: every control at least 44px tall. */
@media (pointer: coarse), (max-width: 640px) {
  .filter-btn, .chart-btn, .sound-toggle, .nav-toggle, .chart-close, .pulse-chip {
    min-height: 44px;
  }
  .filter-btn, .chart-btn, .pulse-chip { display: inline-flex; align-items: center; justify-content: center; }
  .controls input[type="search"], .controls input[type="number"], input[type="number"], select { min-height: 44px; }
  a.back-to-landing { display: inline-flex; align-items: center; min-height: 44px; }
}

@media (max-width: 640px) {
  /* With the bottom tab bar the top bar held nothing but the sound toggle, a whole row.
     dashboard_shared.js moves the toggle into the page header; drop the empty bar. */
  body.snd-in-header > nav { display: none; }
  body.snd-in-header header:has(> .sound-toggle) { position: relative; padding-inline-end: calc(var(--gutter) + 52px); }
  body.snd-in-header header > .sound-toggle {
    position: absolute;
    top: 14px;
    inset-inline-end: var(--gutter);
    width: 44px;
    padding: 0;
    justify-content: center;
  }
  .sound-toggle .sound-label { display: none; }
  /* Wide tables scroll sideways: fade the far (left, in RTL) edge so the cut reads as "more". */
  .table-wrap {
    -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent);
            mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent);
  }
}

/* ------------------------------------------------------ reduced motion -- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
