/* ============================================================================
   SEMANTIC COLOUR ROLES  --  the only palette
   ============================================================================
   Every theme supplies exactly these eight. Nothing else is a theme's business:

     --bg           the page
     --surface      a card sitting on the page
     --border       the edge of a card
     --text         primary reading colour
     --text-muted   labels, secondary prose
     --accent       interactivity -- links, focus, the active tab
     --up           direction: gain
     --down         direction: loss

   Everything below is DERIVED from those, so a theme cannot supply a set that
   half-works. Colour means one of three things here: direction (up/down),
   interactivity (accent), or state (warn/info). Anything decorative is a bug --
   the Trade Journal stat cards used to carry five different border colours that
   encoded nothing and survived every theme switch.

   Derived values use color-mix, so themes stay eight lines instead of thirty.
*/
:root {
  /* --- the eight roles: default theme --- */
  --bg:          #070910;
  --surface:     #131720;
  --border:      #1e2840;
  --text:        #e4eaf8;
  --text-muted:  #5a6a90;
  --accent:      #00e5c8;
  --up:          #3dffa0;
  --down:        #ff5e7a;

  /* --- state, overridable but rarely --- */
  --warn:        #ffcb47;
  --info:        #47b4ff;

  /* --- derived. themes never set these --- */
  --surface-2:   color-mix(in srgb, var(--surface) 88%, var(--text) 7%);
  --surface-3:   color-mix(in srgb, var(--surface) 78%, var(--text) 12%);
  --border-soft: color-mix(in srgb, var(--border) 45%, transparent);
  --text-faint:  color-mix(in srgb, var(--text-muted) 62%, var(--bg));
  --accent-dim:  color-mix(in srgb, var(--accent) 16%, var(--bg));
  --up-dim:      color-mix(in srgb, var(--up) 14%, var(--bg));
  --down-dim:    color-mix(in srgb, var(--down) 14%, var(--bg));
  --warn-dim:    color-mix(in srgb, var(--warn) 14%, var(--bg));
  --info-dim:    color-mix(in srgb, var(--info) 14%, var(--bg));

  /* --- type: sans for language, mono for figures --- */
  --font: 'Syne', sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

/* ============================================================================
   COMPATIBILITY ALIASES
   ============================================================================
   ~300 CSS rules and every inline style in js/app.js still name the old
   variables. Rather than rewrite all of them at once -- which would be a very
   large diff with no way to test each rule -- they now resolve through the
   roles. This is the change that makes the theme picker reach every module.
   The aliases are a migration layer and should shrink as rules are rewritten.
*/
:root {
  /* global surfaces */
  --s1: var(--bg);       --s2: var(--surface);  --s3: var(--surface-2);
  --s4: var(--surface-3);
  --border2: var(--border);
  --muted: var(--text-muted);
  --faint: var(--text-faint);

  /* named hues -> roles. green/red were only ever direction. */
  --green: var(--up);       --green-d: var(--up-dim);
  --red: var(--down);       --red-d: var(--down-dim);
  --yellow: var(--warn);    --yellow-d: var(--warn-dim);
  --blue: var(--info);      --blue-d: var(--info-dim);
  --teal: var(--accent);    --teal-d: var(--accent-dim);
  --purple: var(--accent);  --purple-d: var(--accent-dim);
  --orange: var(--warn);

  /* Swing Watchlist */
  --sw-bg: var(--bg);            --sw-surface: var(--surface);
  --sw-surface2: var(--surface-2); --sw-surface3: var(--surface-3);
  --sw-border: var(--border);    --sw-text: var(--text);
  --sw-muted: var(--text-muted); --sw-faint: var(--text-faint);
  --sw-green: var(--up);         --sw-green-bg: var(--up-dim);
  --sw-red: var(--down);         --sw-red-bg: var(--down-dim);
  --sw-yellow: var(--warn);      --sw-yellow-bg: var(--warn-dim);
  --sw-blue: var(--info);        --sw-blue-bg: var(--info-dim);
  --sw-teal: var(--accent);
  --sw-font: var(--font);        --sw-mono: var(--mono);

  /* Catalyst Finder */
  --cf-bg: var(--bg);       --cf-s1: var(--surface);   --cf-s2: var(--surface);
  --cf-s3: var(--surface-2); --cf-s4: var(--surface-3);
  --cf-border: var(--border); --cf-border2: var(--border);
  --cf-text: var(--text);   --cf-muted: var(--text-muted); --cf-faint: var(--text-faint);
  --cf-green: var(--up);    --cf-green-d: var(--up-dim);
  --cf-red: var(--down);    --cf-red-d: var(--down-dim);
  --cf-yellow: var(--warn); --cf-yellow-d: var(--warn-dim);
  --cf-blue: var(--info);   --cf-blue-d: var(--info-dim);
  --cf-purple: var(--accent); --cf-purple-d: var(--accent-dim);
  --cf-orange: var(--warn); --cf-orange-d: var(--warn-dim);
  --cf-teal: var(--accent); --cf-teal-d: var(--accent-dim);
  --cf-font: var(--font);   --cf-mono: var(--mono);

  /* Market Intel */
  --mi-bg: var(--bg);       --mi-s1: var(--surface);   --mi-s2: var(--surface);
  --mi-s3: var(--surface-2);
  --mi-border: var(--border); --mi-border2: var(--border);
  --mi-text: var(--text);   --mi-muted: var(--text-muted); --mi-faint: var(--text-faint);
  --mi-green: var(--up);    --mi-green-d: var(--up-dim);
  --mi-red: var(--down);    --mi-red-d: var(--down-dim);
  --mi-yellow: var(--warn); --mi-yellow-d: var(--warn-dim);
  --mi-blue: var(--info);   --mi-blue-d: var(--info-dim);
  --mi-purple: var(--accent); --mi-purple-d: var(--accent-dim);
  --mi-teal: var(--accent); --mi-teal-d: var(--accent-dim);
  --mi-font: var(--font);   --mi-mono: var(--mono);
}

/* ===== SUITE SHELL ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: var(--bg); }

/* The `hidden` attribute must actually hide.
 *
 * The browser implements it as `[hidden] { display: none }` in its own default
 * stylesheet, which ANY author rule setting `display` outranks. That is not
 * theoretical: `#preview-banner { display: flex }` and
 * `.account-item { display: flex }` both beat it, so a signed-in user was shown
 * the preview banner reading "nothing is saved" while their data was saving,
 * and the Contact link appeared even when no address was configured.
 *
 * `!important` is the right tool here rather than a smell: `hidden` means
 * hidden, and nothing should be able to argue with it. Code that wants an
 * element visible removes the attribute. */
[hidden] { display: none !important; }


/* ===== THEME SYSTEM ===== */
/* Default (Hackerman / Dark Base) is set by :root above */

:root.theme-ultraviolet {
  --bg:#0a0010;         --surface:#160022;   --border:#2d0060;
  --text:#e8d5ff;     --text-muted:#8855cc;
  --accent:#c850ff; --up:#00f0a0;             --down:#ff2080;
}
:root.theme-subzero {
  --bg:#000d1a;         --surface:#001828;   --border:#003366;
  --text:#cceeff;     --text-muted:#4488bb;
  --accent:#00ccff; --up:#00ffcc;             --down:#ff4466;
}
:root.theme-frutti-di-mare {
  --bg:#0a0f08;         --surface:#111a0e;   --border:#1d3018;
  --text:#dff5d5;     --text-muted:#6a9955;
  --accent:#40e0a0; --up:#7fff5a;             --down:#ff6b5a;
}
:root.theme-purple-haze {
  --bg:#0d0810;         --surface:#191020;   --border:#33204a;
  --text:#ecdcff;     --text-muted:#8a6bb5;
  --accent:#bb88ff; --up:#7dffb0;             --down:#ff5f8a;
}
:root.theme-vaporwave {
  --bg:#0d0818;         --surface:#1a1030;   --border:#3a1f60;
  --text:#ffe0f5;     --text-muted:#9d6fbf;
  --accent:#ff80e0; --up:#5ffbf1;             --down:#ff5f7e;
}
:root.theme-rose-quartz {
  --bg:#120608;         --surface:#210d12;   --border:#45202c;
  --text:#ffe4ea;     --text-muted:#b57a8a;
  --accent:#ff9ab0; --up:#7fe0a8;             --down:#ff5f7a;
}
:root.theme-hackerman {
  --bg:#010601;         --surface:#041004;   --border:#0a2f0a;
  --text:#c8ffc8;     --text-muted:#3f9f3f;
  --accent:#00ff41; --up:#00ff41;             --down:#ff3355;
}
:root.theme-lambda {
  --bg:#06080e;         --surface:#0e1420;   --border:#1e2e4a;
  --text:#dbe6ff;     --text-muted:#5a7099;
  --accent:#4488ee; --up:#3ddc97;             --down:#ff5f7a;
}
:root.theme-after-eight {
  --bg:#030804;         --surface:#0a140c;   --border:#16301f;
  --text:#d6ffe6;     --text-muted:#4f9070;
  --accent:#aaffcc; --up:#5affa0;             --down:#ff5f7a;
}
:root.theme-pay-to-win {
  --bg:#0d0900;         --surface:#1a1400;   --border:#3d2f00;
  --text:#fff3cc;     --text-muted:#a8912f;
  --accent:#ffd700; --up:#7fff8a;             --down:#ff5f5f;
}
:root.theme-white-wolf {
  --bg:#f5f7fa;         --surface:#ffffff;   --border:#dbe2ee;
  --text:#1a2035;     --text-muted:#61708f;
  --accent:#2255cc; --up:#0f9d58;             --down:#d93025;
}
:root.theme-shylily {
  --bg:#060815;         --surface:#0d1226;   --border:#1e2a52;
  --text:#dce6ff;     --text-muted:#6274a8;
  --accent:#66ffcc; --up:#66ffcc;             --down:#ff6b9d;
}
:root.theme-minecraft {
  --bg:#1a1200;         --surface:#241a05;   --border:#4a3800;
  --text:#f0e6c8;     --text-muted:#9b8a52;
  --accent:#44ff44; --up:#44ff44;             --down:#ff5555;
}
:root.theme-anime {
  --bg:#08050e;         --surface:#120a1c;   --border:#2d1a44;
  --text:#f5e6ff;     --text-muted:#8a6ba8;
  --accent:#ff88dd; --up:#7dffc0;             --down:#ff5f8a;
}
:root.theme-miku {
  --bg:#030e10;         --surface:#061c22;   --border:#104448;
  --text:#ccfff5;     --text-muted:#339ea8;
  --accent:#39c5bb; --up:#39c5bb;             --down:#ff5566;
}

/* Dynamic suite bar theming */
.suite-bar { background: var(--s1) !important; border-bottom-color: var(--border) !important; }
.suite-logo { color: var(--accent, var(--teal)) !important; }
.suite-tab.active { color: var(--accent, var(--teal)) !important; border-bottom-color: var(--accent, var(--teal)) !important; }
.suite-tab:hover { color: var(--text) !important; }
.nav-btn.active { color: var(--accent, var(--teal)) !important; }
.nav-btn.active::before { background: var(--accent, var(--teal)) !important; }

/* Theme picker dropdown */
#themePickerBtn {
  padding: 0 12px; height: 28px; border-radius: 7px;
  border: 1px solid var(--border2); background: var(--s2);
  color: var(--muted); cursor: pointer;
  font-family: 'Syne', sans-serif; font-size: 11px; font-weight: 600;
  transition: all .15s; margin-right: 4px; white-space: nowrap;
}
#themePickerBtn:hover { border-color: var(--accent, var(--teal)); color: var(--accent, var(--teal)); }

#themeDropdown {
  display: none; position: fixed; top: 46px; right: 10px;
  background: var(--s2); border: 1px solid var(--border2);
  border-radius: 12px; padding: 12px;
  z-index: 99999; width: 340px; max-width: calc(100vw - 20px);
  box-shadow: 0 16px 48px rgba(0,0,0,.8);
}
#themeDropdown.open { display: block; }
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.theme-chip {
  padding: 7px 6px; border-radius: 8px; border: 1px solid var(--border);
  cursor: pointer; text-align: center;
  font-family: 'JetBrains Mono', monospace; font-size: 9px;
  font-weight: 600; letter-spacing: .03em;
  transition: all .15s; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}
.theme-chip:hover { transform: scale(1.04); }
.theme-chip.active { border-width: 2px; }

/* Background customizer */
#bgCustomizer {
  display: none; position: fixed; top: 46px; right: 10px;
  background: var(--s2); border: 1px solid var(--border2);
  border-radius: 12px; padding: 16px;
  z-index: 99999; width: 280px; max-width: calc(100vw - 20px);
  box-shadow: 0 16px 48px rgba(0,0,0,.8);
}
#bgCustomizer.open { display: block; }
.bg-label {
  font-family: 'JetBrains Mono', monospace; font-size: 10px;
  color: var(--muted); text-transform: uppercase; letter-spacing: .08em;
  margin-bottom: 6px; margin-top: 10px;
}
.bg-label:first-child { margin-top: 0; }

/* API mode badge */
#modeBadge {
  padding: 0 10px; height: 22px; border-radius: 5px;
  font-family: 'JetBrains Mono', monospace; font-size: 9px; font-weight: 600;
  display: flex; align-items: center; margin-right: 6px;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
#modeBadge.mode-free {
  background: #0a2918; color: #3dffa0; border: 1px solid #0f4a28;
}
#modeBadge.mode-api {
  background: #1a1200; color: #ffd700; border: 1px solid #4a3800;
}

.suite-bar {
  display: flex; align-items: center;
  background: #0a0d14; border-bottom: 2px solid #1a2235;
  padding: 0 16px; height: 42px; flex-shrink: 0; z-index: 9999; position: relative;
}
.suite-logo {
  font-family: 'Syne', 'DM Sans', sans-serif; font-size: 13px; font-weight: 700;
  color: #00e5c8; letter-spacing: .06em; margin-right: 18px; white-space: nowrap;
}
.suite-logo em { color: #2a3550; font-style: normal; }
.suite-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 0 16px; height: 100%; border: none; background: transparent;
  color: #4a5a80; cursor: pointer;
  font-family: 'Syne', 'DM Sans', sans-serif; font-size: 12px; font-weight: 600;
  border-bottom: 2px solid transparent; position: relative; top: 1px;
  transition: color .15s, border-color .15s; white-space: nowrap;
}
.suite-tab:hover { color: #c0cce8; }
.suite-tab.active { color: #00e5c8; border-bottom-color: #00e5c8; }
.suite-spacer { flex: 1; }
.suite-hint { font-family: 'JetBrains Mono', 'DM Mono', monospace; font-size: 10px; color: #1e2840; }
.suite-content { height: calc(100vh - 42px); overflow: hidden; position: relative; display: flex; flex-direction: column; }

/* ===== TRADE JOURNAL STYLES ===== */

:root {
  --bg: #070910;
  --s1: #0d1018;
  --s2: #131720;
  --s3: #1a2030;
  --s4: #212840;
  --border: #1e2840;
  --border2: #28344f;
  --text: #e4eaf8;
  --muted: #5a6a90;
  --faint: #2a3550;
  --green: #3dffa0;
  --green-d: #0a2918;
  --red: #ff5e7a;
  --red-d: #250a12;
  --yellow: #ffcb47;
  --yellow-d: #241a05;
  --blue: #47b4ff;
  --blue-d: #051a28;
  --purple: #b47fff;
  --purple-d: #160d28;
  --teal: #00e5c8;
  --teal-d: #012018;
  --orange: #ff8c47;
  --font: 'Syne', sans-serif;
  --mono: 'JetBrains Mono', monospace;
}
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 13px; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--faint); border-radius: 2px; }

/* SHELL */
.shell { display: flex; height: calc(100vh - 42px); }

/* LEFT NAV */
.nav {
  width: 54px; background: var(--s1); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0; gap: 4px; flex-shrink: 0; z-index: 10;
}
.nav-logo {
  font-family: var(--mono); font-size: 11px; color: var(--teal); font-weight: 500;
  letter-spacing: .15em; writing-mode: vertical-rl; transform: rotate(180deg);
  margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border);
  width: 100%; text-align: center;
}
.nav-btn {
  width: 38px; height: 38px; border-radius: 10px; border: none;
  background: transparent; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; transition: all .15s; position: relative;
}
.nav-btn:hover { background: var(--s3); color: var(--text); }
.nav-btn.active { background: var(--s3); color: var(--teal); }
.nav-btn.active::before {
  content: ''; position: absolute; left: -1px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; background: var(--teal); border-radius: 0 2px 2px 0;
}
.nav-tip {
  position: absolute; left: 52px; background: var(--s3); color: var(--text);
  padding: 4px 8px; border-radius: 6px; font-size: 11px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 100;
  border: 1px solid var(--border2);
}
.nav-btn:hover .nav-tip { opacity: 1; }
.nav-spacer { flex: 1; }

/* MAIN AREA */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* TOP BAR */
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 18px;
  background: var(--s1); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.topbar-title { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.topbar-sub { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.spacer { flex: 1; }
.tbtn {
  padding: 6px 14px; border-radius: 8px; border: 1px solid var(--border2);
  background: var(--s2); color: var(--text); cursor: pointer; font-family: var(--font);
  font-size: 12px; font-weight: 600; transition: all .15s; white-space: nowrap;
}
.tbtn:hover { border-color: var(--teal); color: var(--teal); }
.tbtn-teal { border-color: var(--teal); color: var(--teal); }
.tbtn-red { border-color: var(--red); color: var(--red); }
.tbtn-sm { padding: 4px 10px; font-size: 11px; }

/* PAGES */
.page { display: none; flex: 1; overflow-y: auto; padding: 20px; -webkit-overflow-scrolling: touch; }
.page.active { display: block; }

/* ===== DASHBOARD ===== */
.dash-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 18px; }
/* One border on every card. The five top-bars here -- green, red, blue,
   yellow, purple -- encoded nothing: they were assigned per position, so
   'Avg Win' was always green and 'Max Drawdown' always red whatever the
   numbers said. Five colours that survive every theme switch and mean
   nothing is decoration, and decoration competes with the two colours
   that do mean something. */
.stat-card {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 14px; padding: 14px 16px; position: relative; overflow: hidden;
}
/* Labels are language, so they set in sans. Mono is reserved for figures,
   tickers and tables, where column alignment is the point. */
.stat-label { font-family: var(--font); font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }
/* One dominant number per card. 26px against a 10px label and an 11px
   sub is a clear three-step hierarchy; 22/9/11 was nearly flat. */
.stat-val { font-family: var(--mono); font-size: 26px; font-weight: 500; line-height: 1; letter-spacing: -.01em; }
.stat-sub { font-family: var(--font); font-size: 11px; color: var(--text-faint); margin-top: 5px; }
/* Direction only. A figure is coloured when it is a gain or a loss; the
   rest read in --text, which is what makes the coloured ones carry. */
.stat-val { color: var(--text); }
.stat-val.up   { color: var(--up); }
.stat-val.down { color: var(--down); }
/* Legacy hooks, kept so existing markup does not lose its meaning while
   the templates are migrated: g/r were gain/loss, the rest were decorative. */
.g .stat-val { color: var(--up); }
.r .stat-val { color: var(--down); }
.b .stat-val, .y .stat-val, .p .stat-val { color: var(--text); }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.dash-grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-bottom: 14px; }
/* A card is a surface one step off the page with a quiet edge. Outlined
   boxes on flat black read as wireframe -- the border was doing the work
   the background should do. */
.card {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 14px; padding: 16px;
}
.card-title {
  font-family: var(--font); font-size: 10px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.card-title span { flex: 1; }

/* EQUITY CURVE */
.equity-svg { width: 100%; height: 160px; }

/* CALENDAR HEATMAP */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-day {
  aspect-ratio: 1; border-radius: 3px; display: flex; align-items: center;
  justify-content: center; font-family: var(--mono); font-size: 8px; cursor: default;
}
.cal-labels { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-bottom: 4px; }
.cal-lbl { font-family: var(--mono); font-size: 8px; color: var(--muted); text-align: center; }

/* HEATMAP */
.heatmap { display: grid; grid-template-columns: 40px repeat(24, 1fr); gap: 2px; font-family: var(--mono); font-size: 8px; }
.hm-row-label { color: var(--muted); display: flex; align-items: center; }
.hm-cell { aspect-ratio: 1; border-radius: 2px; cursor: pointer; transition: opacity .1s; }
.hm-cell:hover { opacity: .8; }
.hm-col-labels { display: grid; grid-template-columns: 40px repeat(24, 1fr); gap: 2px; margin-bottom: 4px; }
.hm-col-lbl { text-align: center; color: var(--muted); font-size: 7px; }

/* STRATEGY TABLE */
.strat-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.strat-table th { font-family: var(--mono); font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; font-weight: 500; }
.strat-table td { padding: 8px 8px; border-bottom: 1px solid var(--faint); }
.strat-table tr:last-child td { border-bottom: none; }
.strat-table tr:hover td { background: var(--s2); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 20px; font-family: var(--mono); font-size: 10px; font-weight: 500; }
.pill-g { background: var(--green-d); color: var(--green); }
.pill-r { background: var(--red-d); color: var(--red); }
.pill-y { background: var(--yellow-d); color: var(--yellow); }
.pill-b { background: var(--blue-d); color: var(--blue); }
.pill-p { background: var(--purple-d); color: var(--purple); }

/* WIN BAR */
.win-bar { height: 4px; border-radius: 2px; background: var(--s4); margin-top: 4px; overflow: hidden; }
.win-fill { height: 100%; border-radius: 2px; background: var(--green); }

/* RECENT TRADES */
.trade-row {
  display: grid; grid-template-columns: 70px 60px 50px 60px 60px 60px 1fr 40px;
  gap: 6px; align-items: center; padding: 8px 10px; border-radius: 8px;
  margin-bottom: 3px; font-size: 12px; cursor: pointer; transition: background .1s;
}
.trade-row:hover { background: var(--s2); }
.trade-row-hd { color: var(--muted); font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: .06em; padding: 4px 10px; }

/* ===== TRADE LOG ===== */
.log-toolbar { display: flex; gap: 8px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.log-inp {
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border2);
  background: var(--s2); color: var(--text); font-family: var(--mono); font-size: 12px;
  transition: border-color .2s;
}
.log-inp:focus { outline: none; border-color: var(--teal); }
.log-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.log-table th {
  font-family: var(--mono); font-size: 9px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .06em; padding: 8px 10px; border-bottom: 1px solid var(--border);
  text-align: left; font-weight: 500; white-space: nowrap;
}
.log-table td { padding: 9px 10px; border-bottom: 1px solid var(--faint); vertical-align: middle; }
.log-table tr:hover td { background: var(--s2); }
.log-table tr:last-child td { border-bottom: none; }


/* TICKER CHIPS */
.ticker-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 0; }
.ticker-chip {
  display: flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px;
  background: var(--s3); border: 1px solid var(--border2); font-family: var(--mono);
  font-size: 11px; cursor: pointer; transition: all .15s; user-select: none;
}
.ticker-chip:hover { border-color: var(--teal); color: var(--teal); }
.ticker-chip .rm { color: var(--muted); font-size: 10px; transition: color .1s; }
.ticker-chip:hover .rm { color: var(--red); }
.ticker-chip.dragging { opacity: .4; }
.ticker-add-inp {
  padding: 4px 10px; border-radius: 20px; border: 1px dashed var(--border2);
  background: transparent; color: var(--text); font-family: var(--mono); font-size: 11px;
  width: 90px; transition: border-color .2s;
}
.ticker-add-inp:focus { outline: none; border-color: var(--teal); width: 120px; }

/* ===== ANALYTICS ===== */
.analytics-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }

/* DRAWDOWN */
.drawdown-svg { width: 100%; height: 120px; }

/* ===== CALCULATOR ===== */
.calc-tabs { display: flex; gap: 2px; background: var(--s2); border-radius: 10px; padding: 3px; margin-bottom: 16px; width: fit-content; }
.calc-tab { padding: 6px 16px; border-radius: 7px; border: none; background: transparent; color: var(--muted); cursor: pointer; font-family: var(--font); font-size: 12px; font-weight: 600; transition: all .15s; }
.calc-tab.active { background: var(--s3); color: var(--text); }
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.calc-section { background: var(--s1); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.calc-label { font-family: var(--mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 5px; }
.calc-inp {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border2);
  background: var(--s2); color: var(--text); font-family: var(--mono); font-size: 13px;
  margin-bottom: 10px; transition: border-color .2s;
}
.calc-inp:focus { outline: none; border-color: var(--teal); }
.calc-result {
  background: var(--s2); border-radius: 10px; padding: 14px; margin-top: 4px;
  border: 1px solid var(--border);
}
.calc-result-val { font-family: var(--mono); font-size: 24px; font-weight: 500; color: var(--teal); }
.calc-result-label { font-size: 11px; color: var(--muted); margin-top: 3px; }
.calc-breakdown { margin-top: 10px; }
.calc-line { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--faint); font-family: var(--mono); font-size: 11px; }
.calc-line:last-child { border-bottom: none; }
.calc-line-lbl { color: var(--muted); }

/* ===== AI CHAT ===== */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 110px); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px 0; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg-avatar {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.msg-ai .msg-avatar { background: var(--teal-d); color: var(--teal); }
.msg-user .msg-avatar { background: var(--purple-d); color: var(--purple); }
.msg-user { flex-direction: row-reverse; }
.msg-body {
  background: var(--s2); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 14px; max-width: 75%; font-size: 13px; line-height: 1.6;
}
.msg-user .msg-body { background: var(--purple-d); border-color: var(--purple-d); }
.msg-ai .msg-body { }
.chat-bar {
  display: flex; gap: 8px; padding: 12px 0 0; border-top: 1px solid var(--border); margin-top: 12px;
}
.chat-inp {
  flex: 1; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border2);
  background: var(--s2); color: var(--text); font-family: var(--font); font-size: 13px;
  resize: none; height: 44px; transition: border-color .2s;
}
.chat-inp:focus { outline: none; border-color: var(--teal); }
.chat-send {
  padding: 0 18px; border-radius: 10px; border: none; background: var(--teal);
  color: var(--bg); cursor: pointer; font-family: var(--font); font-size: 13px; font-weight: 700;
  transition: opacity .15s;
}
.chat-send:hover { opacity: .85; }
.chat-send:disabled { opacity: .4; cursor: not-allowed; }
.chat-prompts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chat-prompt-btn {
  padding: 5px 12px; border-radius: 20px; border: 1px solid var(--border2);
  background: var(--s2); color: var(--muted); cursor: pointer; font-size: 11px;
  transition: all .15s;
}
.chat-prompt-btn:hover { border-color: var(--teal); color: var(--teal); }

/* MODAL */
.overlay { position: fixed; inset: 0; background: #00000099; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal { background: var(--s1); border: 1px solid var(--border2); border-radius: 16px; padding: 22px; width: min(560px, 92vw); max-height: 88vh; overflow-y: auto; }
.modal-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; color: var(--text); }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-wrap { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.field-lbl { font-family: var(--mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.field {
  padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border2);
  background: var(--s2); color: var(--text); font-family: var(--mono); font-size: 12px;
  width: 100%; transition: border-color .2s;
}
.field:focus { outline: none; border-color: var(--teal); }
.field-full { grid-column: 1 / -1; }

.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* misc */
.green { color: var(--green); } .red { color: var(--red); } .yellow { color: var(--yellow); }
.blue { color: var(--blue); } .purple { color: var(--purple); } .muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 40px; color: var(--muted); font-family: var(--mono); font-size: 12px; text-align: center; }


/* ===== CATALYST FINDER STYLES (scoped to .cf-page) ===== */

/* The --cf-* palette that stood here is gone. It was scoped to .cf-page, which
   beat the :root aliases on specificity, so Catalyst Finder kept its own
   colours through every theme switch. Those names are aliases onto the
   semantic roles now. */
  .cf-page {overflow-x:hidden}
  .cf-page ::-webkit-scrollbar {width:3px;height:3px}
  .cf-page ::-webkit-scrollbar-track {background:transparent}
  .cf-page ::-webkit-scrollbar-thumb {background:var(--cf-border2);border-radius:2px}

/* TOPBAR */
  .cf-page .topbar {
  display:flex;align-items:center;gap:10px;padding:10px 18px;
  background:var(--cf-s1);border-bottom:1px solid var(--cf-border);
  position:sticky;top:0;z-index:50;flex-wrap:wrap;
}
  .cf-page .logo {font-family:var(--cf-mono);font-size:13px;font-weight:500;color:var(--cf-teal);letter-spacing:.05em;white-space:nowrap}
  .cf-page .logo em {color:var(--cf-muted);font-style:normal}
  .cf-page .spacer {flex:1}

/* SEARCH BAR */
  .cf-page .search-wrap {display:flex;gap:6px;align-items:center;flex:1;max-width:480px}
  .cf-page .search-inp {
  flex:1;padding:8px 12px;border-radius:10px;
  border:1px solid var(--cf-border2);background:var(--cf-s2);
  color:var(--cf-text);font-family:var(--cf-mono);font-size:13px;
  transition:border-color .2s;
}
  .cf-page .search-inp:focus {outline:none;border-color:var(--cf-teal)}
  .cf-page .search-inp::placeholder {color:var(--cf-muted)}
  .cf-page .btn {
  padding:7px 16px;border-radius:10px;border:1px solid var(--cf-border2);
  background:var(--cf-s2);color:var(--cf-text);cursor:pointer;
  font-family:var(--cf-font);font-size:12px;font-weight:600;
  transition:all .15s;white-space:nowrap;
}
  .cf-page .btn:hover {border-color:var(--cf-teal);color:var(--cf-teal)}
  .cf-page .btn-teal {border-color:var(--cf-teal);color:var(--cf-teal)}
  .cf-page .btn-sm {padding:4px 10px;font-size:11px}
  .cf-page .btn-red {border-color:var(--cf-red);color:var(--cf-red)}

/* MODE TOGGLE */
  .cf-page .mode-toggle {display:flex;background:var(--cf-s2);border-radius:8px;padding:3px;border:1px solid var(--cf-border);gap:2px}
  .cf-page .mode-btn {padding:4px 12px;border-radius:6px;border:none;background:transparent;color:var(--cf-muted);cursor:pointer;font-family:var(--cf-mono);font-size:11px;transition:all .15s}
  .cf-page .mode-btn.active {background:var(--cf-s3);color:var(--cf-teal)}

/* LAYOUT */
  .cf-page .layout {display:grid;grid-template-columns:1fr;min-height:calc(100vh - 92px);overflow:visible}

/* MONITOR SIDEBAR */
  .cf-page .monitor-sidebar {
  border-right:1px solid var(--cf-border);background:var(--cf-s1);
  display:flex;flex-direction:column;
}
  .cf-page .sidebar-head {
  padding:10px 12px;border-bottom:1px solid var(--cf-border);
  display:flex;align-items:center;justify-content:space-between;
}
  .cf-page .sidebar-title {font-family:var(--cf-mono);font-size:10px;color:var(--cf-muted);text-transform:uppercase;letter-spacing:.1em}
  .cf-page .monitor-add {display:flex;gap:6px;padding:10px 12px;border-bottom:1px solid var(--cf-border)}
  .cf-page .monitor-add input {flex:1;padding:5px 8px;border-radius:7px;border:1px solid var(--cf-border2);background:var(--cf-s2);color:var(--cf-text);font-family:var(--cf-mono);font-size:12px}
  .cf-page .monitor-add input:focus {outline:none;border-color:var(--cf-teal)}
  .cf-page .monitor-list {flex:1;overflow-y:auto}
  .cf-page .monitor-row {
  display:flex;align-items:center;gap:8px;padding:9px 12px;
  border-bottom:1px solid var(--cf-faint);cursor:pointer;transition:background .1s;
  position:relative;
}
  .cf-page .monitor-row:hover {background:var(--cf-s2)}
  .cf-page .monitor-row.active {background:var(--cf-s3)}
  .cf-page .monitor-row.active::before {content:'';position:absolute;left:0;top:0;bottom:0;width:3px;background:var(--cf-teal);border-radius:0 2px 2px 0}
  .cf-page .m-ticker {font-family:var(--cf-mono);font-size:13px;font-weight:500;flex:1}
  .cf-page .m-status {font-family:var(--cf-mono);font-size:9px;padding:2px 6px;border-radius:4px}
  .cf-page .m-high {background:var(--cf-green-d);color:var(--cf-green)}
  .cf-page .m-med {background:var(--cf-yellow-d);color:var(--cf-yellow)}
  .cf-page .m-low {background:var(--cf-blue-d);color:var(--cf-blue)}
  .cf-page .m-none {background:var(--cf-s3);color:var(--cf-muted)}
  .cf-page .m-loading {background:var(--cf-purple-d);color:var(--cf-purple)}
  .cf-page .m-del {opacity:0;border:none;background:transparent;color:var(--cf-red);cursor:pointer;font-size:12px;padding:0 2px;transition:opacity .1s}
  .cf-page .monitor-row:hover .m-del {opacity:1}
  .cf-page .refresh-indicator {font-family:var(--cf-mono);font-size:9px;color:var(--cf-muted);padding:6px 12px;border-top:1px solid var(--cf-border);text-align:center}

/* MAIN CONTENT */
  .cf-page .content {overflow-y:auto;padding:20px;min-height:400px}

/* SEARCH RESULT */
  .cf-page .result-header {
  display:flex;align-items:center;gap:14px;margin-bottom:18px;
  padding-bottom:14px;border-bottom:1px solid var(--cf-border);
}
  .cf-page .result-ticker {font-family:var(--cf-mono);font-size:28px;font-weight:500;color:var(--cf-teal)}
  .cf-page .result-meta {flex:1}
  .cf-page .result-company {font-size:14px;font-weight:600;margin-bottom:2px}
  .cf-page .result-price {font-family:var(--cf-mono);font-size:13px;color:var(--cf-muted)}
  .cf-page .overall-badge {
  padding:8px 16px;border-radius:10px;font-family:var(--cf-mono);
  font-size:13px;font-weight:500;text-align:center;
}
  .cf-page .badge-high {background:var(--cf-green-d);color:var(--cf-green);border:1px solid #00f5a033}
  .cf-page .badge-med {background:var(--cf-yellow-d);color:var(--cf-yellow);border:1px solid #ffd60a33}
  .cf-page .badge-low {background:var(--cf-blue-d);color:var(--cf-blue);border:1px solid #4da6ff33}
  .cf-page .badge-none {background:var(--cf-s3);color:var(--cf-muted);border:1px solid var(--cf-border)}

/* CATALYST CARDS */
  .cf-page .catalysts-grid {display:flex;flex-direction:column;gap:10px}
  .cf-page .cat-card {
  background:var(--cf-s1);border:1px solid var(--cf-border);
  border-radius:14px;padding:14px 16px;
  display:flex;gap:14px;align-items:flex-start;
  transition:border-color .15s;position:relative;overflow:hidden;
}
  .cf-page .cat-card::before {
  content:'';position:absolute;left:0;top:0;bottom:0;width:3px;
}
  .cf-page .cat-card.rank-high::before {background:var(--cf-green)}
  .cf-page .cat-card.rank-med::before {background:var(--cf-yellow)}
  .cf-page .cat-card.rank-low::before {background:var(--cf-blue)}
  .cf-page .cat-card.rank-none::before {background:var(--cf-muted)}
  .cf-page .cat-card:hover {border-color:var(--cf-border2)}
  .cf-page .cat-icon {font-size:22px;flex-shrink:0;margin-top:1px}
  .cf-page .cat-body {flex:1;min-width:0}
  .cf-page .cat-top {display:flex;align-items:center;gap:8px;margin-bottom:5px;flex-wrap:wrap}
  .cf-page .cat-headline {font-size:13px;font-weight:600;line-height:1.4;flex:1}
  .cf-page .cat-rank {
  font-family:var(--cf-mono);font-size:10px;padding:2px 8px;border-radius:5px;
  font-weight:500;white-space:nowrap;flex-shrink:0;
}
  .cf-page .rank-high .cat-rank {background:var(--cf-green-d);color:var(--cf-green)}
  .cf-page .rank-med .cat-rank {background:var(--cf-yellow-d);color:var(--cf-yellow)}
  .cf-page .rank-low .cat-rank {background:var(--cf-blue-d);color:var(--cf-blue)}
  .cf-page .rank-none .cat-rank {background:var(--cf-s3);color:var(--cf-muted)}
  .cf-page .cat-type {font-family:var(--cf-mono);font-size:9px;color:var(--cf-muted);text-transform:uppercase;letter-spacing:.08em;margin-bottom:4px}
  .cf-page .cat-reason {font-size:12px;color:var(--cf-muted);line-height:1.55;margin-bottom:6px}
  .cf-page .cat-meta {display:flex;gap:10px;align-items:center;flex-wrap:wrap}
  .cf-page .cat-source {font-family:var(--cf-mono);font-size:10px;color:var(--cf-muted)}
  .cf-page .cat-date {font-family:var(--cf-mono);font-size:10px;color:var(--cf-faint)}
  .cf-page .cat-link {font-family:var(--cf-mono);font-size:10px;color:var(--cf-teal);text-decoration:none}
  .cf-page .cat-link:hover {text-decoration:underline}

/* SCORE BAR */
  .cf-page .score-section {margin-bottom:18px}
  .cf-page .score-row {display:flex;align-items:center;gap:10px;margin-bottom:6px}
  .cf-page .score-label {font-family:var(--cf-mono);font-size:11px;color:var(--cf-muted);width:120px;flex-shrink:0}
  .cf-page .score-bar {flex:1;height:5px;background:var(--cf-s4);border-radius:3px;overflow:hidden}
  .cf-page .score-fill {height:100%;border-radius:3px;transition:width .4s}
  .cf-page .score-val {font-family:var(--cf-mono);font-size:11px;width:30px;text-align:right}

/* EMPTY / LOADING */
  .cf-page .empty {display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:60px 20px;color:var(--cf-muted);font-family:var(--cf-mono);font-size:12px;text-align:center;min-height:300px}
  .cf-page .empty-icon {font-size:36px;opacity:.5}
  .cf-page .pulse {animation:pulse 1.5s ease-in-out infinite}
@keyframes pulse{0%,100%{opacity:.4}50%{opacity:1}}
  .cf-page .spin {animation:spin 1s linear infinite;display:inline-block}
@keyframes spin{to{transform:rotate(360deg)}}

/* AI ANALYSIS BOX */
  .cf-page .ai-box {
  background:var(--cf-purple-d);border:1px solid #b06dff33;border-radius:14px;
  padding:14px 16px;margin-bottom:16px;
}
  .cf-page .ai-box-title {font-family:var(--cf-mono);font-size:10px;color:var(--cf-purple);text-transform:uppercase;letter-spacing:.1em;margin-bottom:8px;display:flex;align-items:center;gap:6px}
  .cf-page .ai-box-text {font-size:12px;color:var(--cf-text);line-height:1.7}

/* FILTER BAR */
  .cf-page .filter-bar {display:flex;gap:6px;margin-bottom:14px;flex-wrap:wrap}
  .cf-page .filter-btn {padding:4px 10px;border-radius:6px;border:1px solid var(--cf-border);background:transparent;color:var(--cf-muted);cursor:pointer;font-family:var(--cf-mono);font-size:10px;transition:all .12s}
  .cf-page .filter-btn.on {border-color:var(--cf-teal);color:var(--cf-teal);background:var(--cf-teal-d)}
  .cf-page .filter-btn.f-high.on {border-color:var(--cf-green);color:var(--cf-green);background:var(--cf-green-d)}
  .cf-page .filter-btn.f-med.on {border-color:var(--cf-yellow);color:var(--cf-yellow);background:var(--cf-yellow-d)}
  .cf-page .filter-btn.f-low.on {border-color:var(--cf-blue);color:var(--cf-blue);background:var(--cf-blue-d)}

/* STATS ROW */
  .cf-page .stats-row {display:flex;gap:8px;margin-bottom:16px}
  .cf-page .mini-stat {background:var(--cf-s1);border:1px solid var(--cf-border);border-radius:10px;padding:10px 14px;flex:1;text-align:center}
  .cf-page .mini-stat .v {font-family:var(--cf-mono);font-size:18px;font-weight:500}
  .cf-page .mini-stat .l {font-size:10px;color:var(--cf-muted);margin-top:2px}
  .cf-page .green {color:var(--cf-green)}
.cf-page .yellow{color:var(--cf-yellow)}
.cf-page .blue{color:var(--cf-blue)}
.cf-page .red{color:var(--cf-red)}
.cf-page .purple{color:var(--cf-purple)}

.cf-page {
  display: none;
  width: 100%;
  height: calc(100vh - 42px);
  overflow: hidden;
  overflow-y: auto;
  position: relative;
  background: var(--cf-bg, #06080f);
  color: var(--cf-text, #dde8ff);
  font-family: var(--cf-font, 'Syne', sans-serif);
}
.cf-page.active-cf {
  display: block;
  position: fixed;
  top: 42px;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(100vh - 42px);
  z-index: 100;
  overflow-y: auto;
}


/* ===== SWING TRACKER STYLES (scoped to .sw-page) ===== */

/* The --sw-* palette that stood here is gone. Those names are now aliases
   onto the semantic roles at the top of this file, which is what lets a
   theme switch reach this module at all. */
  /* .sw-page.light removed with the palette: it hardcoded a second set of
     colours that no theme could reach. A light theme is a theme now
     (see White Wolf), not a per-module override. */
*{box-sizing:border-box;margin:0;padding:0}
  /* sw-page: flex column fills exactly suite-content height */
  .sw-page {background:var(--sw-bg);color:var(--sw-text);font-family:var(--sw-font);font-size:13px;
    display:flex;flex-direction:column;height:100%;overflow:hidden}

  .sw-page .topbar {display:flex;align-items:center;gap:8px;padding:9px 14px;background:var(--sw-surface);
    border-bottom:1px solid var(--sw-border);flex-wrap:nowrap;flex-shrink:0;overflow-x:auto}
  .sw-page .logo {font-family:var(--sw-mono);font-size:13px;color:var(--sw-teal);font-weight:500;white-space:nowrap;margin-right:4px}
  .sw-page .logo span {color:var(--sw-muted)}
  .sw-page .spacer {flex:1;min-width:4px}
  .sw-page .inp {padding:5px 9px;border-radius:8px;border:1px solid var(--sw-border);background:var(--sw-surface2);color:var(--sw-text);font-family:var(--sw-mono);font-size:12px;transition:border-color .2s;flex-shrink:0}
  .sw-page .inp:focus {outline:none;border-color:var(--sw-teal)}
  .sw-page .btn {padding:5px 12px;border-radius:8px;border:1px solid var(--sw-border);background:var(--sw-surface2);color:var(--sw-text);cursor:pointer;font-family:var(--sw-font);font-size:12px;font-weight:500;transition:all .15s;white-space:nowrap;flex-shrink:0}
  .sw-page .btn:hover {border-color:var(--sw-teal);color:var(--sw-teal)}
  .sw-page .btn-teal {border-color:var(--sw-teal);color:var(--sw-teal)}
  .sw-page .btn-red {border-color:var(--sw-red);color:var(--sw-red)}
  .sw-page .btn-sm {padding:3px 8px;font-size:11px}

  /* layout: takes all remaining height after topbar, grid splits into 3 columns */
  .sw-page .layout {display:grid;grid-template-columns:240px 1fr 330px;flex:1;min-height:0;overflow:hidden}

/* SIDEBAR — must have min-height:0 so grid doesn't expand it beyond the layout height */
  .sw-page .sidebar {border-right:1px solid var(--sw-border);background:var(--sw-surface);display:flex;flex-direction:column;min-height:0;overflow:hidden}
  .sw-page .sidebar-search {padding:8px 10px;border-bottom:1px solid var(--sw-border);display:flex;gap:6px;align-items:center;flex-shrink:0}
  .sw-page .sidebar-search input {flex:1;padding:5px 8px;border-radius:7px;border:1px solid var(--sw-border);background:var(--sw-surface2);color:var(--sw-text);font-family:var(--sw-mono);font-size:11px}
  .sw-page .sidebar-search input:focus {outline:none;border-color:var(--sw-teal)}
  .sw-page .sort-btn {padding:3px 7px;border-radius:6px;border:1px solid var(--sw-border);background:transparent;color:var(--sw-muted);cursor:pointer;font-family:var(--sw-mono);font-size:10px;transition:all .15s;white-space:nowrap}
  .sw-page .sort-btn.active {border-color:var(--sw-teal);color:var(--sw-teal)}
  /* sidebar-list: takes all remaining sidebar height and scrolls */
  .sw-page .sidebar-list {flex:1;overflow-y:auto;overflow-x:hidden;min-height:0;-webkit-overflow-scrolling:touch}
  .sw-page .sec-hd {display:flex;align-items:center;gap:6px;padding:6px 12px;cursor:pointer;user-select:none;transition:background .1s}
  .sw-page .sec-hd:hover {background:var(--sw-surface2)}
  .sw-page .sec-name {font-family:var(--sw-mono);font-size:10px;color:var(--sw-muted);text-transform:uppercase;letter-spacing:.08em;flex:1;font-weight:500}
  .sw-page .sec-count {font-family:var(--sw-mono);font-size:10px;color:var(--sw-faint)}
  .sw-page .chev {font-size:8px;color:var(--sw-faint);transition:transform .2s}
  .sw-page .sec-hd.open .chev {transform:rotate(90deg)}
  .sw-page .sec-tickers {display:none}
  .sw-page .sec-tickers.open {display:block}
  .sw-page .t-row {display:flex;align-items:center;gap:4px;padding:5px 10px 5px 20px;cursor:pointer;transition:background .1s;position:relative}
  .sw-page .t-row:hover {background:var(--sw-surface2)}
  .sw-page .t-row.active {background:var(--sw-surface3)}
  .sw-page .t-row.active::before {content:'';position:absolute;left:0;top:0;bottom:0;width:3px;background:var(--sw-teal);border-radius:0 2px 2px 0}
  .sw-page .t-name {font-family:var(--sw-mono);font-size:12px;font-weight:500;flex:1}
  .sw-page .t-pchg {font-family:var(--sw-mono);font-size:9px}
  .sw-page .t-price {font-family:var(--sw-mono);font-size:10px;color:var(--sw-muted)}
  .sw-page .t-bias {font-size:9px;font-family:var(--sw-mono);padding:1px 4px;border-radius:4px}
  .sw-page .b-long {background:var(--sw-green-bg);color:var(--sw-green)}
  .sw-page .b-short {background:var(--sw-red-bg);color:var(--sw-red)}
  .sw-page .b-watch {background:var(--sw-yellow-bg);color:var(--sw-yellow)}
  .sw-page .b-temp {background:#1a0f2e;color:#c084fc}
  .sw-page .del-x {opacity:0;border:none;background:transparent;color:var(--sw-red);cursor:pointer;font-size:11px;padding:0 2px}
  .sw-page .t-row:hover .del-x {opacity:1}

/* MAIN */
  .sw-page .main {display:flex;flex-direction:column;overflow:hidden;background:var(--sw-bg);min-height:0}
  .sw-page .chart-hdr {padding:10px 14px 8px;border-bottom:1px solid var(--sw-border);display:flex;align-items:center;gap:10px;flex-wrap:wrap;background:var(--sw-surface)}
  .sw-page .chart-ticker {font-family:var(--sw-mono);font-size:18px;font-weight:500;color:var(--sw-teal)}
  .sw-page .chart-price {font-family:var(--sw-mono);font-size:16px;font-weight:500}
  .sw-page .chart-chg {font-family:var(--sw-mono);font-size:12px;padding:2px 7px;border-radius:6px}
  .sw-page .up {color:var(--sw-green);background:var(--sw-green-bg)}
  .sw-page .dn {color:var(--sw-red);background:var(--sw-red-bg)}
  .sw-page .chart-wrap {flex:1;position:relative;min-height:0}
  .sw-page #tv-widget {width:100%;height:100%}
  .sw-page .chart-empty {display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:10px;color:var(--sw-muted);font-family:var(--sw-mono);font-size:12px}

/* NEWS - improved */
  .sw-page .news-strip {height:200px;border-top:1px solid var(--sw-border);overflow-y:auto;background:var(--sw-surface);flex-shrink:0}
  .sw-page .news-hdr {display:flex;align-items:center;gap:8px;padding:8px 14px 6px;border-bottom:1px solid var(--sw-border);position:sticky;top:0;background:var(--sw-surface);z-index:1}
  .sw-page .news-hdr-title {font-family:var(--sw-mono);font-size:10px;color:var(--sw-muted);text-transform:uppercase;letter-spacing:.08em;flex:1}
  .sw-page .news-filter-btn {padding:2px 7px;border-radius:5px;border:1px solid var(--sw-border);background:transparent;color:var(--sw-muted);cursor:pointer;font-family:var(--sw-mono);font-size:9px;transition:all .12s}
  .sw-page .news-filter-btn.on {border-color:var(--sw-teal);color:var(--sw-teal);background:var(--sw-blue-bg)}
  .sw-page .news-items {padding:4px 0}
  .sw-page .news-item {display:flex;gap:10px;padding:7px 14px;border-bottom:1px solid var(--sw-faint);cursor:pointer;transition:background .1s;align-items:flex-start}
  .sw-page .news-item:hover {background:var(--sw-surface2)}
  .sw-page .news-item:last-child {border-bottom:none}
  .sw-page .news-item-left {flex:1;min-width:0}
  .sw-page .news-hl {font-size:12px;line-height:1.45;color:var(--sw-text)}
  .sw-page .news-hl a {color:var(--sw-text);text-decoration:none}
  .sw-page .news-hl a:hover {color:var(--sw-teal)}
  .sw-page .news-meta {font-family:var(--sw-mono);font-size:10px;color:var(--sw-muted);margin-top:2px;display:flex;gap:6px;align-items:center}
  .sw-page .news-importance {font-family:var(--sw-mono);font-size:11px;flex-shrink:0;margin-top:1px}
  .sw-page .ntag {display:inline-block;padding:1px 6px;border-radius:4px;font-size:9px;font-family:var(--sw-mono);margin-right:4px;font-weight:500}
  .sw-page .t-hot {background:#3a0f0f;color:var(--sw-red)}
  .sw-page .t-bull {background:var(--sw-green-bg);color:var(--sw-green)}
  .sw-page .t-ev {background:var(--sw-blue-bg);color:var(--sw-blue)}
  .sw-page .t-warn {background:var(--sw-yellow-bg);color:var(--sw-yellow)}
  .sw-page .t-neutral {background:var(--sw-surface3);color:var(--sw-muted)}
  .sw-page .imp-high {color:var(--sw-red)}
  .sw-page .imp-med {color:var(--sw-yellow)}
  .sw-page .imp-low {color:var(--sw-muted)}

/* DETAIL */
  .sw-page .detail {border-left:1px solid var(--sw-border);overflow-y:auto;overflow-x:hidden;padding:13px;background:var(--sw-surface);-webkit-overflow-scrolling:touch;min-height:0}
  .sw-page .d-tick {font-family:var(--sw-mono);font-size:17px;font-weight:500;color:var(--sw-teal)}
  .sw-page .d-sec {font-size:11px;color:var(--sw-muted);margin-bottom:10px}
  .sw-page .lbl {font-family:var(--sw-mono);font-size:10px;color:var(--sw-muted);text-transform:uppercase;letter-spacing:.08em;margin:11px 0 4px}
  .sw-page .bias-row {display:flex;gap:4px}
  .sw-page .bias-btn {flex:1;padding:5px;border-radius:8px;border:1px solid var(--sw-border);background:transparent;color:var(--sw-muted);cursor:pointer;font-family:var(--sw-mono);font-size:11px;transition:all .15s;text-align:center}
  .sw-page .on-long {background:var(--sw-green-bg);color:var(--sw-green);border-color:#22c55e44}
  .sw-page .on-short {background:var(--sw-red-bg);color:var(--sw-red);border-color:#f8717144}
  .sw-page .on-watch {background:var(--sw-yellow-bg);color:var(--sw-yellow);border-color:#fbbf2444}
  .sw-page .on-temp {background:#1a0f2e;color:#c084fc;border-color:#a855f744}
/* CRITICAL: field uses onchange/onblur not oninput, so re-render never fires mid-type */
  .sw-page .field {width:100%;padding:6px 8px;border-radius:8px;border:1px solid var(--sw-border);background:var(--sw-surface2);color:var(--sw-text);font-family:var(--sw-mono);font-size:12px;margin-bottom:5px;transition:border-color .15s}
  .sw-page .field:focus {outline:none;border-color:var(--sw-teal)}
  .sw-page .grid3 {display:grid;grid-template-columns:1fr 1fr 1fr;gap:4px;margin-bottom:5px}
  .sw-page .grid2 {display:grid;grid-template-columns:1fr 1fr;gap:4px;margin-bottom:5px}
  .sw-page .sline {display:flex;justify-content:space-between;align-items:center;padding:4px 0;border-bottom:1px solid var(--sw-border);font-family:var(--sw-mono);font-size:11px}
  .sw-page .sline:last-child {border-bottom:none}
  .sw-page .slbl {color:var(--sw-muted)}
  .sw-page .good {color:var(--sw-green)}.mid{color:var(--sw-yellow)}.bad{color:var(--sw-red)}
  .sw-page .chip {display:inline-block;padding:2px 9px;border-radius:20px;font-family:var(--sw-mono);font-size:11px;font-weight:500}
  .sw-page .chip-good {background:var(--sw-green-bg);color:var(--sw-green)}
  .sw-page .chip-mid {background:var(--sw-yellow-bg);color:var(--sw-yellow)}
  .sw-page .chip-bad {background:var(--sw-red-bg);color:var(--sw-red)}
  .sw-page .fib-row {display:flex;justify-content:space-between;padding:4px 8px;border-radius:6px;margin-bottom:3px;font-family:var(--sw-mono);font-size:11px}
  .sw-page .fib-100 {background:var(--sw-green-bg);color:var(--sw-green)}
  .sw-page .fib-618 {background:#0f1e3a;color:var(--sw-blue)}
  .sw-page .fib-50 {background:#1a1030;color:#a78bfa}
  .sw-page .fib-382 {background:var(--sw-yellow-bg);color:var(--sw-yellow)}
  .sw-page .fib-0 {background:var(--sw-red-bg);color:var(--sw-red)}
  .sw-page .share-wrap {display:flex;align-items:center;gap:8px;margin-bottom:6px}
  .sw-page .share-val {font-family:var(--sw-mono);font-size:11px;color:var(--sw-teal)}
  .sw-page .link-out {display:inline-block;padding:5px 10px;border-radius:7px;border:1px solid var(--sw-border);color:var(--sw-muted);text-decoration:none;font-family:var(--sw-mono);font-size:11px;transition:all .15s}
  .sw-page .link-out:hover {border-color:var(--sw-teal);color:var(--sw-teal)}

/* MODALS */
  .sw-page .overlay {position:fixed;inset:0;background:#00000099;z-index:100;display:flex;align-items:center;justify-content:center}
  .sw-page .modal {background:var(--sw-surface);border:1px solid var(--sw-border);border-radius:14px;padding:20px;min-width:380px;max-width:92vw;max-height:85vh;overflow-y:auto}
  .sw-page .modal-title {font-family:var(--sw-mono);font-size:14px;color:var(--sw-teal);margin-bottom:14px}
  .sw-page .m-row {display:flex;gap:8px;margin-bottom:8px;align-items:center}
  .sw-page .sec-item {display:flex;align-items:center;gap:8px;background:var(--sw-surface2);border-radius:8px;padding:8px 10px;margin-bottom:5px}
  .sw-page .sec-item-name {font-family:var(--sw-mono);font-size:12px;flex:1}
  .sw-page .stats-grid {display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:14px}
  .sw-page .stat-box {background:var(--sw-surface2);border-radius:10px;padding:12px;text-align:center;border:1px solid var(--sw-border)}
  .sw-page .stat-box .val {font-family:var(--sw-mono);font-size:20px;font-weight:500}
  .sw-page .stat-box .lbl2 {font-size:10px;color:var(--sw-muted);margin-top:2px}
  .sw-page .jtable {width:100%;font-size:11px;border-collapse:collapse;font-family:var(--sw-mono)}
  .sw-page .jtable td, .sw-page .jtable th {border-bottom:1px solid var(--sw-border);padding:6px}
  .sw-page .jtable th {color:var(--sw-muted);font-weight:400}
  .sw-page .dump-area {width:100%;height:110px;padding:8px;border-radius:8px;border:1px solid var(--sw-border);background:var(--sw-surface2);color:var(--sw-text);font-family:var(--sw-mono);font-size:12px;resize:vertical}

/* DRAG DROP */
  .sw-page .t-row[draggable] {cursor:grab}
  .sw-page .t-row.drag-over {background:var(--sw-surface3)!important;border-top:2px solid var(--sw-teal)}
  .sw-page ::-webkit-scrollbar {width:4px;height:4px}
  .sw-page ::-webkit-scrollbar-track {background:transparent}
  .sw-page ::-webkit-scrollbar-thumb {background:var(--sw-faint);border-radius:2px}

/* SW page fills tab content area */
.sw-page {
  display: none;
  width: 100%;
  height: calc(100vh - 42px);
  position: relative;
  overflow: hidden;
}
.sw-page.active-tab {
  /* flex, NOT block. The rule above sets flex-direction:column and .layout
     below relies on `flex:1` to fill the height left over after .topbar. This
     selector is more specific than the base `.sw-page`, so `display:block`
     here silently made that `flex:1` inert: .layout then sized to its tallest
     child instead of to the page, and everything below the news feed rendered
     as dead space. It looked correct as soon as you picked a ticker, because
     the content then happened to fill the column. */
  display: flex;
}

/* Mobile SW layout — stack columns vertically */
@media (max-width: 768px) {
  .sw-page .layout {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto 1fr auto !important;
    height: calc(100vh - 92px);
    overflow-y: auto;
  }
  .sw-page .sidebar {
    border-right: none !important;
    border-bottom: 1px solid var(--sw-border);
    max-height: 200px;
    overflow-y: auto;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .sw-page .sidebar-search {
    width: 100%;
  }
  .sw-page .sidebar-list {
    width: 100%;
    max-height: 150px;
  }
  .sw-page .main {
    min-height: 300px;
  }
  .sw-page .chart-wrap {
    min-height: 200px;
  }
  .sw-page .news-strip {
    height: auto;
    max-height: 220px;
  }
  .sw-page .detail {
    border-left: none !important;
    border-top: 1px solid var(--sw-border);
    overflow-y: auto;
    max-height: none;
  }
  .sw-page .topbar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
  }
  .sw-page .topbar .spacer { display: none; }
  /* Make input/button row wrap nicely */
  .sw-page #newTicker { font-size: 16px; width: 100px !important; }
  .sw-page #accountSize, .sw-page #riskPct { font-size: 16px; }
  /* Larger tap targets */
  .sw-page .btn { padding: 7px 12px; }
  .sw-page .t-row { padding: 8px 10px 8px 18px; }
  .sw-page .grid3 { grid-template-columns: 1fr 1fr; }
}


/* ===== MARKET INTELLIGENCE STYLES ===== */
/* The --mi-* palette that stood here is gone. Those names are now aliases
   onto the semantic roles at the top of this file, which is what lets a
   theme switch reach this module at all. */


#page-mi {
  display: none;
  width: 100%;
  height: calc(100vh - 42px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--mi-bg);
  color: var(--mi-text);
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  position: relative;
}
#page-mi.active-mi {
  display: block;
  position: fixed;
  top: 42px;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(100vh - 42px);
  z-index: 100;
  overflow-y: auto;
}
.mi-page {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}
.mi-section {
  background: var(--mi-s1);
  border: 1px solid var(--mi-border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}
.mi-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--mi-muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 12px;
}
.mi-grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.mi-search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.mi-inp {
  flex: 1;
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid var(--mi-border2);
  background: var(--mi-s2);
  color: var(--mi-text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  transition: border-color .2s;
}
.mi-inp:focus { outline: none; border-color: var(--mi-teal); }
.mi-btn {
  padding: 8px 18px;
  border-radius: 9px;
  border: 1px solid var(--mi-teal);
  background: var(--mi-teal-d);
  color: var(--mi-teal);
  cursor: pointer;
  font-family: 'Syne', sans-serif;
  font-size: 12px;
  font-weight: 700;
  transition: all .15s;
  white-space: nowrap;
}
.mi-btn:hover { background: var(--mi-teal); color: var(--mi-bg); }
.mi-refresh-btn {
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--mi-border2);
  background: transparent;
  color: var(--mi-muted);
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  transition: all .15s;
}
.mi-refresh-btn:hover { border-color: var(--mi-teal); color: var(--mi-teal); }


/* ================================================================
   MOBILE RESPONSIVE — Edge Suite v9
   ================================================================ */
@media (max-width: 768px) {
  .suite-bar { padding: 0 8px; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .suite-bar::-webkit-scrollbar { display: none; }
  .suite-logo { font-size: 12px; padding: 0 6px; flex-shrink: 0; }
  .suite-tab { padding: 0 8px; font-size: 10px; flex-shrink: 0; }
  .suite-hint { display: none; }
  #modeBadge { font-size: 8px; padding: 0 6px; white-space: nowrap; flex-shrink: 0; }
  #themePickerBtn, #bgBtn { font-size: 9px; padding: 0 7px; flex-shrink: 0; }
  #suite-conn-status { display: none; }

  .shell { flex-direction: column-reverse; }
  .nav { width: 100% !important; height: 52px !important; flex-direction: row !important; padding: 0 4px !important; border-right: none !important; border-top: 1px solid var(--border) !important; justify-content: space-around !important; overflow-x: auto; gap: 0 !important; }
  .nav-logo { display: none !important; }
  .nav-spacer { display: none !important; }
  .nav-btn { width: 44px; height: 44px; border-radius: 8px; font-size: 18px; flex-shrink: 0; }
  .nav-tip { display: none !important; }
  .nav-btn.active::before { left: 50%; top: auto; bottom: -1px; width: 20px; height: 3px; transform: translateX(-50%); border-radius: 2px 2px 0 0; }

  .suite-content { height: calc(100dvh - 92px); overflow-y: auto; -webkit-overflow-scrolling: touch; overflow-x: hidden; }
  .page { padding: 10px; padding-bottom: 20px; }
  .topbar { padding: 8px 12px; flex-wrap: wrap; }

  .dash-stats { grid-template-columns: 1fr 1fr !important; gap: 8px; }
  .dash-grid { grid-template-columns: 1fr !important; }
  .dash-grid3 { grid-template-columns: 1fr !important; }
  .stat-val { font-size: 18px; }

  .ind-grid { grid-template-columns: 1fr !important; }
  .mi-regime-grid { grid-template-columns: 1fr !important; }
  #page-mi { height: auto; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  /* Ensure MI page doesn't create a phantom black box on mobile */
  #page-mi .mi-page { min-height: auto; }
  /* MI regime grid stacks on mobile */
  [style*="grid-template-columns:minmax(170px,200px)"] { grid-template-columns: 1fr !important; }

  #themeDropdown { right: 4px; left: 4px; width: auto; max-width: none; }
  #bgCustomizer { right: 4px; left: 4px; width: auto; max-width: none; }
  .theme-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

@media (max-width: 768px) {
  /* suite-content scrolls on mobile (sw-page is taller than viewport) */
  .suite-content {
    height: calc(100dvh - 42px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    display: block !important;
  }

  /* sw-page: normal block, height auto — suite-content handles scrolling */
  .sw-page {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    flex-direction: column !important;
  }

  /* `display` is scoped to .active-tab, and the two are NOT interchangeable.
     On `.sw-page` the !important beat switchTab's inline `display: none`, so
     below 768px the Swing Watchlist stayed on screen under every other tab --
     open Market Intel on a phone and you got the watchlist stacked above it.
     switchTab adds and removes .active-tab, so scoping it here lets the inline
     hide work again while the active page still gets its flex column. */
  .sw-page.active-tab {
    display: flex !important;
  }

  /* Topbar: horizontal scroll instead of wrapping — keeps it 1 row */
  .sw-page .topbar {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    padding: 8px 10px;
    gap: 6px;
    /* hide scrollbar visually */
    scrollbar-width: none;
  }
  .sw-page .topbar::-webkit-scrollbar { display: none; }
  .sw-page #newTicker { font-size: 16px !important; width: 90px !important; }
  .sw-page #accountSize { width: 80px !important; font-size: 16px !important; }
  .sw-page #riskPct { width: 46px !important; font-size: 16px !important; }

  /* layout: stack sidebar → main → detail vertically */
  .sw-page .layout {
    display: flex !important;
    flex-direction: column !important;
    flex: none !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    grid-template-columns: unset !important;
  }

  /* Sidebar: fixed height box, internal scroll */
  .sw-page .sidebar {
    width: 100% !important;
    height: 260px !important;
    max-height: 260px !important;
    min-height: 260px !important;
    border-right: none !important;
    border-bottom: 1px solid var(--sw-border);
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    flex-shrink: 0;
  }
  .sw-page .sidebar-list {
    flex: 1 !important;
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch;
    min-height: 0 !important;
  }
  /* Always show all tickers on mobile */
  .sw-page .sec-tickers { display: block !important; }

  /* Main chart area */
  .sw-page .main {
    flex: none !important;
    height: auto !important;
    overflow: visible !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
  }
  .sw-page .chart-wrap { height: 260px !important; flex: none !important; overflow: hidden !important; }
  .sw-page .news-strip { height: 200px !important; }

  /* Detail panel: full height auto */
  .sw-page .detail {
    border-left: none !important;
    border-top: 1px solid var(--sw-border);
    overflow-y: visible !important;
    height: auto !important;
    padding-bottom: 80px;
  }
  .sw-page .grid3 { grid-template-columns: 1fr 1fr !important; }
  .sw-page .news-hdr { flex-wrap: wrap; gap: 4px; }
}

@media (max-width: 768px) {
  .cf-page .layout { grid-template-columns: 1fr !important; height: auto !important; display: flex !important; flex-direction: column !important; }
  .cf-page .sidebar-left, .cf-page .sidebar { height: 200px; border-right: none !important; border-bottom: 1px solid var(--border); flex-shrink: 0; }
  .cf-page .monitor-list { max-height: 140px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

  /* CF content area: allow full scroll on mobile, no height:100% trap */
  .cf-page .content {
    height: auto !important;
    min-height: 400px;
    overflow-y: visible !important;
    padding: 12px 10px;
    /* ensure the page wrapper scrolls, not the inner div */
  }

  /* CF page itself must scroll on mobile (suite-content handles it) */
  .cf-page {
    height: auto !important;
    min-height: calc(100dvh - 94px);
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* CF topbar mobile: search takes full row, button always visible */
  .cf-page .topbar { padding: 8px 10px; gap: 6px; flex-wrap: wrap; align-items: center; }
  .cf-page .logo { display: none; } /* hide logo to save space */
  .cf-page .search-wrap {
    flex: 1 1 100% !important;
    max-width: 100% !important;
    order: 2;
    display: flex !important;
    gap: 6px;
    align-items: center;
  }
  .cf-page .search-inp {
    flex: 1 !important;
    min-width: 0 !important;
    font-size: 16px !important; /* prevent iOS zoom */
    padding: 10px 12px;
  }
  /* Search button: always visible, never hidden */
  .cf-page .btn.btn-teal {
    flex-shrink: 0 !important;
    padding: 10px 16px;
    font-size: 13px;
    white-space: nowrap;
  }
  .cf-page .mode-toggle { order: 1; flex-shrink: 0; }
  .cf-page .spacer { display: none; }
  #cf-watchlist-sel { max-width: 110px !important; font-size: 12px !important; flex-shrink: 0; }

  /* CF monitor sidebar compact */
  .cf-page .monitor-sidebar { height: auto !important; max-height: 220px; }

  /* CF result header stack on mobile */
  .cf-page .result-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .cf-page .result-ticker { font-size: 22px; }

  /* CF catalyst cards full-width */
  .cf-page .cat-grid { grid-template-columns: 1fr !important; }

  /* Market regime grid: stack on mobile */
  .mi-regime-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 480px) {
  .cf-page .topbar { padding: 6px 8px; }
  .cf-page .search-wrap { gap: 4px; }
  .cf-page .btn.btn-teal { padding: 9px 12px; font-size: 12px; }
}

@media (max-width: 480px) {
  .dash-stats { grid-template-columns: 1fr !important; }
  .suite-tab { font-size: 9px; padding: 0 5px; }
  .nav-btn { width: 38px; height: 38px; font-size: 16px; }
  .sw-page .grid3 { grid-template-columns: 1fr 1fr; }
}

/* ===== BEGINNER MODE ===== */
.beginner-tip {
  display: none;
  background: #1a1200;
  border: 1px solid #4a3200;
  border-radius: 8px;
  padding: 8px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: #ccaa44;
  line-height: 1.6;
  margin-top: 6px;
}
body.beginner-mode .beginner-tip {
  display: block;
}
body.beginner-mode #beginnerModeBtn {
  border-color: #ffcb47 !important;
  color: #ffcb47 !important;
}

/* ===== ONBOARDING OVERLAY ===== */
#onboardingOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 999999;
  align-items: center;
  justify-content: center;
}
#onboardingOverlay.open { display: flex; }
.onboard-card {
  background: #0d1018;
  border: 1px solid #28344f;
  border-radius: 20px;
  padding: 32px;
  max-width: 540px;
  width: 92vw;
  box-shadow: 0 30px 80px rgba(0,0,0,0.8);
}
.onboard-steps { display: flex; gap: 6px; margin-bottom: 24px; }
.onboard-step-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #1e2840; transition: background .3s;
}
.onboard-step-dot.active { background: #00e5c8; }
.onboard-step-dot.done { background: #28344f; }

/* ── Hover, in CSS ────────────────────────────────────────────────────────
   31 onmouseover/onmouseout pairs in app.js template literals did nothing
   but restyle on hover. They needed no delegation and no bridge entry --
   :hover is the mechanism. Colour here means interactivity, so it is
   --accent throughout, and it follows the theme now, which the inline
   versions could not: they wrote a literal back on mouseout.
   ------------------------------------------------------------------- */

/* An outline button carries its colour on border and text, so the hover
   tint derives from that colour rather than a hardcoded hex. This replaced
   six one-off tints (#051828, #002820, #051a28, #150828, #1e0e02,
   #012018) that were each a hand-darkened version of the button's own
   colour and none of which changed with the theme. */
.btn-outline { transition: background .15s; }
.btn-outline:hover { background: color-mix(in srgb, currentColor 14%, transparent); }

.hov-text { transition: color .15s; }
.hov-text:hover { color: var(--accent); }

.hov-border { transition: border-color .15s; }
.hov-border:hover { border-color: var(--accent); }

/* Edge and label together. */
.hov-accent { transition: border-color .15s, color .15s; }
.hov-accent:hover { border-color: var(--accent); color: var(--accent); }

.hov-surface { transition: background .15s; }
.hov-surface:hover { background: var(--surface-2); }

/* Per-item colour, set as --hov-border where the element is built. */
.hov-border-var:hover { border-color: var(--hov-border, var(--accent)); }

.hov-lift { transition: transform .15s; }
.hov-lift:hover { transform: scale(1.04); }

.hov-underline:hover { text-decoration: underline; }

.hov-bright { opacity: .85; transition: opacity .15s; }
.hov-bright:hover { opacity: 1; }

/* ── Toolbar buttons ──────────────────────────────────────────────────────
   The five controls at the right of the suite bar. Their colour and border
   were written into the style attribute, and an inline declaration beats a
   stylesheet rule, so :hover could not have worked while they stayed --
   which is why each one carried a pair of mouse handlers instead.

   Two of them restored a STATE-dependent colour on mouseout: the Guide
   button read window._beginnerMode, the API button read the stored key. So
   the state is a class now and CSS expresses all four combinations.
   ------------------------------------------------------------------- */
.tool-btn {
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: border-color .15s, color .15s;
}
.tool-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Beginner mode on. --warn, because it is a mode that is switched on, not
   a direction and not an action. */
.tool-btn.is-on { border-color: var(--warn); color: var(--warn); }
.tool-btn.is-on:hover { border-color: var(--warn); color: var(--warn); }

/* An API key is stored. */
.tool-btn.is-set { color: var(--up); }
.tool-btn.is-set:hover { border-color: var(--accent); color: var(--accent); }

/* The one filled call-to-action: onboarding's Next. */
.btn-primary {
  background: color-mix(in srgb, currentColor 10%, transparent);
  transition: background .15s;
}
.btn-primary:hover { background: color-mix(in srgb, currentColor 22%, transparent); }

/* Muted text that comes up one step on hover, rather than to the accent:
   these are secondary controls (Back, Skip tour) and should not read as
   the primary action. */
.hov-text-strong { transition: color .15s; }
.hov-text-strong:hover { color: var(--text); }

.field-focus { transition: border-color .15s; }
.field-focus:focus { border-color: var(--accent); outline: none; }

/* ── Coach panel ──────────────────────────────────────────────────────────
   Every colour is a role, so it follows the theme like everything else.
   One dominant element per row: the message text. Labels step down.
   ------------------------------------------------------------------- */
/* Sized from the viewport, not height:100%. There is no sized ancestor --
   the panel first lived inside .main, which collapses to 0x0 when the Trade
   Journal is hidden, and moving it out did not help because body is not
   sized either. Both times the content was in the DOM and invisible. */
#coach-page {
  padding: 18px 26px 22px;
  height: calc(100vh - 46px);
  box-sizing: border-box;
}

.coach-shell {
  display: flex; flex-direction: column; gap: 14px;
  max-width: 860px; margin: 0 auto; height: 100%; min-height: 0;
}

.coach-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.coach-title {
  font-family: var(--font); font-size: 20px; font-weight: 700;
  color: var(--text); letter-spacing: -.01em;
}
.coach-sub { font-family: var(--font); font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.coach-head-right { display: flex; align-items: center; gap: 8px; }
.coach-btn { padding: 0 10px; height: 26px; border-radius: 7px; background: var(--surface);
             cursor: pointer; font-family: var(--font); font-size: 11px; }

/* Which model answered. Never decorative: 'offline reference' means the
   answer could not see the screen, and that has to be visible. */
.coach-provider {
  font-family: var(--mono); font-size: 10px; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 6px; text-transform: lowercase;
  border: 1px solid var(--border-soft); color: var(--text-muted);
}
.coach-provider:empty { display: none; }
.coach-provider.is-live { color: var(--up); border-color: color-mix(in srgb, var(--up) 40%, transparent); }
.coach-provider.is-reference { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }

.coach-log {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border-soft);
}

.coach-msg {
  font-family: var(--font); font-size: 13px; line-height: 1.65;
  max-width: 88%; padding: 10px 13px; border-radius: 12px;
  overflow-wrap: anywhere;
}
.coach-you {
  align-self: flex-end; color: var(--bg);
  background: var(--accent); font-weight: 500;
}
.coach-coach { align-self: flex-start; color: var(--text); background: var(--surface-2); }
.coach-note {
  align-self: center; max-width: 100%; text-align: center;
  font-size: 11px; color: var(--warn); background: transparent; padding: 2px;
}

.coach-h { font-weight: 700; margin: 8px 0 2px; color: var(--text); }
.coach-li { padding-left: 14px; position: relative; }
.coach-li::before { content: '\2022'; position: absolute; left: 2px; color: var(--text-muted); }
.coach-gap { height: 8px; }
.coach-code { font-family: var(--mono); font-size: 12px; padding: 1px 5px;
              border-radius: 4px; background: var(--bg); color: var(--accent); }
.coach-pre { font-family: var(--mono); font-size: 12px; padding: 10px 12px;
             border-radius: 8px; background: var(--bg); overflow-x: auto;
             border: 1px solid var(--border-soft); }

.coach-composer { display: flex; gap: 10px; align-items: flex-end; }
.coach-input {
  flex: 1; resize: none; min-height: 42px; max-height: 160px;
  padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-family: var(--font); font-size: 13px; line-height: 1.5;
  transition: border-color .15s;
}
.coach-input:focus { border-color: var(--accent); outline: none; }
.coach-input::placeholder { color: var(--text-muted); }

.coach-send {
  padding: 0 20px; height: 42px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent); font-family: var(--font); font-size: 13px; font-weight: 600;
  transition: background .15s;
}
.coach-send:hover { background: color-mix(in srgb, var(--accent) 26%, transparent); }

.coach-foot { font-family: var(--font); font-size: 10px; color: var(--text-muted); text-align: center; }


/* Standing disclaimer, used anywhere the app prints a number someone might
   act on: entry/stop/target levels, the verdict card. Deliberately quiet
   rather than a banner -- it has to be readable without being the thing you
   look at. */
.advice-note {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-faint);
  line-height: 1.5;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--border-soft);
}
