/* ============================================================================
   Upfront Investment — Unified Theme System
   ----------------------------------------------------------------------------
   Light theme = "research terminal"  (Morningstar / Seeking Alpha)
   Dark  theme = "tech / AI terminal" (electric, glowing, data-forward)

   Loaded AFTER main.css so it overrides the legacy hardcoded colors.

   Theme resolution:
     - theme-init (inline, in <head>) resolves the stored preference
       ('system' | 'light' | 'dark') into a concrete value and sets
       <html data-theme="light|dark"> BEFORE first paint (no FOUC).
     - A prefers-color-scheme fallback covers the no-JS / pre-paint case.
   ============================================================================ */

/* ------------------------------- TOKENS ---------------------------------- */
:root {
  color-scheme: light;

  /* surfaces */
  --page-bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --line: #e5e9f0;

  /* text */
  --tx: #101828;
  --tx-2: #5a6478;
  --tx-3: #8b95a7;

  /* brand + data */
  --brand: #2b57d6;
  --brand-2: #c96a17;        /* peer / 2nd series */
  --bench: #98a2b3;          /* benchmark line */
  --up: #0b8a4b;
  --up-soft: #e6f4ec;
  --down: #d1364a;
  --down-soft: #fbe9ec;
  --hold: #b0740a;           /* premium / locked accent */
  --veil: rgba(255, 255, 255, .55);

  /* on-brand ink (text that sits on a --brand fill) */
  --on-brand: #ffffff;

  /* navbar (dark in both themes) */
  --nav-bg: #0f1626;
  --nav-blur: none;
  --nav-border: transparent;
  --nav-tx: #aeb9cc;
  --nav-tx-strong: #ffffff;
  --nav-mark: linear-gradient(135deg, #2b57d6, #5b8cff);

  /* typography */
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;

  /* shape */
  --radius: 12px;
  --radius-lg: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 12px 32px -12px rgba(16, 24, 40, .22);

  /* decorative page background (dark theme only) */
  --page-bg-image: none;
}

/* Dark tokens — set explicitly by theme-init (preferred path). */
:root[data-theme="dark"] {
  color-scheme: dark;

  --page-bg: #080b16;
  --surface: #121a2e;
  --surface-2: #0f1626;
  --line: #26324f;

  --tx: #eaf0ff;
  --tx-2: #93a2c9;
  --tx-3: #5f6f96;

  --brand: #7c9bff;
  --brand-2: #22d3ee;
  --bench: #5f6f96;
  --up: #2ee6a6;
  --up-soft: rgba(46, 230, 166, .13);
  --down: #ff5d7a;
  --down-soft: rgba(255, 93, 122, .14);
  --hold: #ffcf5c;
  --veil: rgba(9, 13, 26, .66);

  --on-brand: #0a0d13;

  --nav-bg: rgba(9, 13, 26, .72);
  --nav-blur: saturate(140%) blur(10px);
  --nav-border: rgba(124, 155, 255, .16);
  --nav-tx: #9aa6b8;
  --nav-tx-strong: #ffffff;
  --nav-mark: linear-gradient(135deg, #7c5cff, #22d3ee);

  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 18px 40px -14px rgba(0, 0, 0, .6);

  --page-bg-image:
    radial-gradient(85% 55% at 88% -8%, rgba(124, 92, 255, .30), transparent 55%),
    radial-gradient(65% 52% at 1% -2%, rgba(34, 211, 238, .17), transparent 52%),
    radial-gradient(70% 65% at 50% 128%, rgba(124, 92, 255, .14), transparent 60%);
}

/* No-JS / pre-paint fallback: honor the OS scheme when no explicit choice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --page-bg: #080b16;
    --surface: #121a2e;
    --surface-2: #0f1626;
    --line: #26324f;
    --tx: #eaf0ff;
    --tx-2: #93a2c9;
    --tx-3: #5f6f96;
    --brand: #7c9bff;
    --brand-2: #22d3ee;
    --bench: #5f6f96;
    --up: #2ee6a6;
    --up-soft: rgba(46, 230, 166, .13);
    --down: #ff5d7a;
    --down-soft: rgba(255, 93, 122, .14);
    --hold: #ffcf5c;
    --veil: rgba(9, 13, 26, .66);
    --on-brand: #0a0d13;
    --nav-bg: rgba(9, 13, 26, .72);
    --nav-blur: saturate(140%) blur(10px);
    --nav-border: rgba(124, 155, 255, .16);
    --nav-tx: #9aa6b8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 18px 40px -14px rgba(0, 0, 0, .6);
  }
}

/* ------------------------------- BASE ------------------------------------ */
body {
  background-color: var(--page-bg);
  background-image: var(--page-bg-image);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--tx);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}

h1, h2, h3, h4, h5, h6 { color: var(--tx); }
a { color: var(--brand); }

::selection { background: color-mix(in srgb, var(--brand) 22%, transparent); }

/* Legacy shared surfaces pulled onto tokens */
.content-section {
  background: var(--surface);
  border-color: var(--line);
  color: var(--tx);
}

/* Utility helpers reused by re-skinned pages */
.uf-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.uf-pos { color: var(--up); }
.uf-neg { color: var(--down); }

/* ------------------------------- NAVBAR ---------------------------------- */
.site-header .navbar,
.navbar.bg-dark.fixed-top {
  background: var(--nav-bg) !important;
  -webkit-backdrop-filter: var(--nav-blur);
  backdrop-filter: var(--nav-blur);
  border-bottom: 1px solid var(--nav-border);
}
.site-header .navbar-nav .nav-link { color: var(--nav-tx); }
.site-header .navbar-nav .nav-link:hover,
.site-header .navbar-nav .nav-link.active { color: var(--nav-tx-strong); }
.navbar-dark .navbar-brand { color: var(--nav-tx-strong); }

/* Theme toggle button in the navbar */
.uf-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  width: 34px;
  height: 34px;
  margin: 0 6px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 9px;
  background: rgba(255, 255, 255, .06);
  color: #dbe3f4;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}
.uf-theme-toggle:hover {
  background: rgba(255, 255, 255, .14);
  border-color: rgba(255, 255, 255, .32);
  color: #fff;
}
:root[data-theme="dark"] .uf-theme-toggle {
  border-color: rgba(124, 155, 255, .28);
  background: rgba(124, 155, 255, .10);
  color: #cdd8ff;
}
:root[data-theme="dark"] .uf-theme-toggle:hover {
  box-shadow: 0 0 14px rgba(124, 155, 255, .35);
}

/* ------------------------------- FOOTER ---------------------------------- */
.site-footer.bg-light {
  background: var(--surface) !important;
  border-top: 1px solid var(--line) !important;
}
.site-footer .text-muted { color: var(--tx-3) !important; }
.site-footer a.text-muted:hover { color: var(--brand) !important; }
:root[data-theme="dark"] .social-icon { filter: invert(1) brightness(1.6); opacity: .55; }

/* --------------------------- SLIDE-OUT DRAWER ---------------------------- */
.side-menu {
  background: var(--surface);
  color: var(--tx);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px -18px rgba(0, 0, 0, .5);
}
.side-menu h1, .side-menu h2, .side-menu h3, .side-menu h4, .side-menu h5,
.side-menu label, .side-menu .form-control-label { color: var(--tx); }
.side-menu-overlay { background: rgba(3, 6, 14, .5); }
:root[data-theme="dark"] .side-menu-overlay { background: rgba(3, 6, 14, .7); }

/* --------------------- BOOTSTRAP COMPONENT OVERRIDES --------------------- */
/* Cards */
.card {
  background: var(--surface);
  border-color: var(--line);
  color: var(--tx);
}
.card-header, .card-footer {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--tx);
}

/* Dropdowns (user menu, etc.) */
.dropdown-menu {
  background: var(--surface);
  border-color: var(--line);
  color: var(--tx);
  box-shadow: var(--shadow);
}
.dropdown-item { color: var(--tx); }
.dropdown-item:hover, .dropdown-item:focus {
  background: var(--surface-2);
  color: var(--tx);
}
.dropdown-divider { border-color: var(--line); }
.user-dropdown .dropdown-item { color: var(--tx); }
.user-dropdown .dropdown-item i { color: var(--tx-3); }

/* Forms */
.form-control {
  background: var(--surface);
  border-color: var(--line);
  color: var(--tx);
}
.form-control:focus {
  background: var(--surface);
  color: var(--tx);
  border-color: var(--brand);
  box-shadow: 0 0 0 .18rem color-mix(in srgb, var(--brand) 25%, transparent);
}
.form-control::placeholder { color: var(--tx-3); }
.form-control:disabled, .form-control[readonly] { background: var(--surface-2); }
.input-group-text {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--tx-2);
}

/* Modals */
.modal-content {
  background: var(--surface);
  color: var(--tx);
  border: 1px solid var(--line);
}
.modal-header, .modal-footer { border-color: var(--line); }
.modal-backdrop.show { opacity: .55; }
.close, .btn-close { color: var(--tx); text-shadow: none; }

/* Tables */
.table { color: var(--tx); }
.table th, .table td { border-color: var(--line); }
.table thead th { border-color: var(--line); color: var(--tx-2); }

/* List groups / borders / muted text used across pages */
.list-group-item { background: var(--surface); border-color: var(--line); color: var(--tx); }
.border, .border-top, .border-bottom, .border-left, .border-right { border-color: var(--line) !important; }
.bg-white { background: var(--surface) !important; }
.bg-light { background: var(--surface-2) !important; }
.text-muted { color: var(--tx-3) !important; }
hr { border-top-color: var(--line); }

/* Generic buttons */
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-outline-secondary { color: var(--tx-2); border-color: var(--line); }
.btn-outline-secondary:hover { background: var(--surface-2); color: var(--tx); }

/* ---------------------- PREMIUM PROMPTS / OVERLAYS ---------------------- */
.content-overlay { background: var(--veil); }
.premium-prompt,
.prediction-upgrade-prompt .premium-prompt {
  /* !important to beat main.css's forced `background: white` on this box */
  background: var(--surface) !important;
  border: 1px solid var(--hold) !important;
  color: var(--tx) !important;
  box-shadow: var(--shadow) !important;
}
.premium-prompt h5 { color: var(--tx) !important; }
.premium-prompt p { color: var(--tx-2) !important; }
:root[data-theme="dark"] .premium-prompt,
:root[data-theme="dark"] .prediction-upgrade-prompt .premium-prompt {
  box-shadow: 0 0 34px -8px rgba(124, 92, 255, .5);
}

/* ----------------- LEGACY READABILITY (pre-reskin pages) ----------------- */
/* Keeps not-yet-rebuilt page bodies readable in dark mode by mapping common
   Bootstrap light surfaces + a few app-specific classes onto theme tokens. */
.thead-light th,
.table .thead-light th {
  background: var(--surface-2) !important;
  color: var(--tx-2) !important;
  border-color: var(--line) !important;
}
.table-hover tbody tr:hover,
.table-hover tbody tr:hover > td,
.table-hover tbody tr:hover > th {
  background-color: var(--surface-2) !important;
  color: var(--tx);
}
.card-body { background: var(--surface); color: var(--tx); }
.card-title, .card-text { color: var(--tx); }
/* metric-cell hardcodes a light #f8f9fa background in the page's inline <style>,
   which renders after theme.css — hence !important to reclaim it for dark mode. */
.metric-cell { background-color: var(--surface-2) !important; color: var(--tx) !important; }
.help-icon { color: var(--tx-3); }
.symbol-cell { color: var(--tx); }
/* Other inline-styled light panels on the compare page */
.prediction-upgrade-prompt { background-color: var(--surface-2) !important; }
.spinner-container { background-color: var(--veil) !important; }
/* Chart loading overlays hardcode a white 80% veil inline (compare + model pages),
   which renders as a jarring light box in dark mode — reclaim it for the theme. */
[id$="LoadingOverlay"] { background: var(--veil) !important; }
/* Bootstrap contextual/subtle backgrounds that assume a white page */
.bg-secondary { background: var(--surface-2) !important; }
.jumbotron, .well { background: var(--surface-2); color: var(--tx); }
:root[data-theme="dark"] .table-bordered,
:root[data-theme="dark"] .table-bordered td,
:root[data-theme="dark"] .table-bordered th { border-color: var(--line); }

/* ============================================================================
   COMPONENT LIBRARY  (scoped to .uf — applied on re-skinned page bodies)
   Faithful to the artifact mockup; variable-driven so it themes automatically.
   ============================================================================ */
.uf { font-family: var(--font-ui); color: var(--tx); }
.uf .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.uf .pos { color: var(--up); }
.uf .neg { color: var(--down); }

/* Intro / lead text */
.uf .intro { font-size: 13px; color: var(--tx-2); margin: 0 0 14px; max-width: 80ch; }

/* Card */
.uf .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  box-shadow: none;
}
.uf .card > .ch {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 15px; border-bottom: 1px solid var(--line);
}
.uf .card .ch h3 { margin: 0; font-size: 13.5px; font-weight: 700; color: var(--tx); }
.uf .card .ch .sub { color: var(--tx-3); font-size: 11.5px; }
.uf .card > .cb { padding: 15px; }

/* Ticker header */
.uf .tickrow { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; margin-bottom: 14px; }
.uf .tick { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; }
.uf .tick .sym { font-weight: 800; font-size: 19px; }
.uf .tick .co { color: var(--tx-3); font-size: 11px; margin-top: 1px; }
.uf .tick .px { font-family: var(--font-mono); font-size: 24px; font-weight: 700; margin-top: 9px; letter-spacing: -.02em; }
.uf .tick .chg { font-family: var(--font-mono); font-size: 12.5px; font-weight: 700; margin-top: 2px; }
.uf .vs { align-self: center; width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 800; font-size: 12px; color: var(--tx-3); }

/* Search / compare bar */
.uf .searchbar { display: flex; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; margin-bottom: 14px; }
.uf .searchbar .fld { flex: 1; font-family: var(--font-mono); font-size: 13px; color: var(--tx); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; }
.uf .searchbar .fld small { color: var(--tx-3); font-family: var(--font-ui); display: block; font-size: 10px; }
.uf .searchbar .vs2 { color: var(--tx-3); font-weight: 800; font-size: 12px; }
.uf .searchbar .go { background: var(--brand); color: var(--on-brand); border-radius: 9px; padding: 10px 18px; font-weight: 700; font-size: 13.5px; border: none; cursor: pointer; }

/* Toolbar / tabs / toggles */
.uf .toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.uf .daterange { font-family: var(--font-mono); font-size: 11.5px; color: var(--tx-3); }
.uf .sel { font-size: 12px; font-weight: 700; color: var(--tx); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 5px 10px; }
.uf .tabs { display: flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; }
.uf .tabs span { font-size: 11px; font-weight: 700; color: var(--tx-2); padding: 4px 8px; border-radius: 5px; font-family: var(--font-mono); cursor: pointer; }
.uf .tabs span.on { background: var(--surface); color: var(--brand); }
.uf .toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--tx-2); font-weight: 600; }
.uf .toggle .sw2 { width: 30px; height: 17px; border-radius: 10px; background: var(--brand); position: relative; }
.uf .toggle .sw2::after { content: ""; position: absolute; top: 2px; right: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; }

/* Legend row */
.uf .legend-row { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--tx-2); align-items: center; margin-bottom: 10px; }
.uf .lg { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-family: var(--font-mono); }
.uf .lg .sw { width: 14px; height: 3px; border-radius: 2px; }
.uf .lg .sw.dash { background: linear-gradient(90deg, var(--bench) 0 60%, transparent 60%); background-size: 6px 3px; }

/* Chips */
.uf .chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 3px 8px; }
.uf .chip.live { background: var(--up-soft); color: var(--up); }
.uf .chip.live .d { width: 7px; height: 7px; border-radius: 50%; background: var(--up); }
.uf .chip.closed { background: var(--surface-2); color: var(--tx-2); }

/* Chart */
.uf .chart svg { display: block; width: 100%; height: auto; }

/* Metrics / compare table */
.uf table { width: 100%; border-collapse: collapse; font-size: 12.5px; table-layout: fixed; }
.uf table th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--tx-3); text-align: right; padding: 9px 16px; border-bottom: 1px solid var(--line); font-weight: 700; }
.uf table th.mid { text-align: center; }
.uf table th.lft, .uf table td.lft { text-align: left; }
.uf table td { padding: 9px 16px; border-bottom: 1px solid var(--line); font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; color: var(--tx); white-space: nowrap; }
.uf table td.metric { text-align: center; font-family: var(--font-ui); color: var(--tx-2); font-size: 12px; white-space: normal; }
.uf table tbody tr:last-child td { border-bottom: none; }
.uf table .pill { background: none; color: var(--up); font-weight: 700; padding: 0; }
.uf table td:has(.pill) { background: var(--up-soft); }
.uf table.cmp th:nth-child(1), .uf table.cmp td:nth-child(1) { width: 30%; text-align: right; }
.uf table.cmp th:nth-child(2), .uf table.cmp td:nth-child(2) { width: 40%; }
.uf table.cmp th:nth-child(3), .uf table.cmp td:nth-child(3) { width: 30%; text-align: left; }
.uf table.cmp td.metric { color: var(--tx-2); font-weight: 600; }

/* AI recommendation gauges */
.uf .rec { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.uf .gauge .gl { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.uf .gauge .gs { font-family: var(--font-mono); font-weight: 700; font-size: 15px; }
.uf .gbar { position: relative; height: 9px; border-radius: 6px; background: linear-gradient(90deg, var(--down), var(--hold), var(--up)); }
.uf .gbar .mk { position: absolute; top: -4px; width: 4px; height: 17px; border-radius: 3px; background: var(--tx); box-shadow: 0 0 0 2px var(--surface); }
.uf .gends { display: flex; justify-content: space-between; font-size: 9.5px; color: var(--tx-3); margin-top: 5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.uf .recbadge { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; color: var(--on-brand); background: var(--up); border-radius: 9px; padding: 8px 14px; }
.uf .summary { font-size: 13px; color: var(--tx-2); line-height: 1.6; }
.uf .summary b { color: var(--tx); }
.uf .forecast { display: inline-flex; gap: 8px; align-items: center; font-size: 12px; color: var(--tx-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 11px; }
.uf .forecast .v { font-family: var(--font-mono); font-weight: 700; color: var(--up); }

/* KPI tiles */
.uf .uz-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.uf .uz-tile { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 13px 15px; }
.uf .uz-tile .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--tx-2); font-weight: 700; }
.uf .uz-tile .v { font-family: var(--font-mono); font-size: 20px; font-weight: 700; margin-top: 6px; color: var(--tx); letter-spacing: -.01em; }
.uf .uz-tile .s { font-size: 11px; color: var(--tx-3); margin-top: 2px; }

/* Premium lock veil */
.uf .uz-lock { position: relative; }
.uf .uz-lock .blur { filter: blur(4px); opacity: .5; pointer-events: none; }
.uf .uz-lock .veil { position: absolute; inset: 0; display: grid; place-items: center; background: var(--veil); }
.uf .uz-lock .box { background: var(--surface); border: 1px solid var(--hold); border-radius: var(--radius); padding: 14px 18px; text-align: center; max-width: 290px; box-shadow: var(--shadow); }
.uf .uz-lock .box .lk { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--hold); }
.uf .uz-lock .box .up { display: inline-block; background: var(--hold); color: #fff; border-radius: var(--radius-sm); padding: 7px 14px; font-size: 12.5px; font-weight: 700; }

/* ---------------------- DARK "TECH/AI" GLOW TREATMENTS ------------------- */
/* Applied only when the resolved theme is dark (data-theme set by JS). */
:root[data-theme="dark"] .uf .card {
  background: linear-gradient(180deg, rgba(124, 155, 255, .07), rgba(124, 155, 255, .015));
  border-color: rgba(124, 155, 255, .16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), 0 26px 50px -32px rgba(90, 120, 255, .7);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
:root[data-theme="dark"] .uf .card .ch { border-bottom-color: rgba(124, 155, 255, .14); }
:root[data-theme="dark"] .uf .card .ch h3 { position: relative; padding-left: 14px; }
:root[data-theme="dark"] .uf .card .ch h3::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 4px; height: 15px; border-radius: 3px;
  background: linear-gradient(180deg, #7c9bff, #22d3ee);
  box-shadow: 0 0 8px rgba(124, 155, 255, .7);
}
:root[data-theme="dark"] .uf .tick,
:root[data-theme="dark"] .uf .searchbar,
:root[data-theme="dark"] .uf .forecast,
:root[data-theme="dark"] .uf .uz-tile {
  background: linear-gradient(180deg, rgba(124, 155, 255, .06), rgba(124, 155, 255, .02));
  border-color: rgba(124, 155, 255, .16);
}
:root[data-theme="dark"] .uf .searchbar .fld {
  background: rgba(124, 155, 255, .05);
  border-color: rgba(124, 155, 255, .16);
}
:root[data-theme="dark"] .uf .searchbar .go,
:root[data-theme="dark"] .uf .recbadge {
  background: linear-gradient(135deg, #7c5cff, #22c3e0);
  color: #fff;
  box-shadow: 0 8px 22px -8px rgba(90, 110, 255, .7);
}
:root[data-theme="dark"] .uf .recbadge::before { content: "\2726 "; opacity: .95; }
:root[data-theme="dark"] .uf .gbar {
  background: linear-gradient(90deg, #ff5d7a, #ffcf5c, #2ee6a6);
  box-shadow: 0 0 14px rgba(46, 230, 166, .22);
}
:root[data-theme="dark"] .uf .gbar .mk { background: #eaf0ff; box-shadow: 0 0 9px rgba(234, 240, 255, .95); }
:root[data-theme="dark"] .uf .tick .px,
:root[data-theme="dark"] .uf .gs,
:root[data-theme="dark"] .uf .uz-tile .v { text-shadow: 0 0 20px rgba(124, 155, 255, .4); }
:root[data-theme="dark"] .uf .chart svg polyline { filter: drop-shadow(0 0 3px rgba(124, 155, 255, .45)); }
:root[data-theme="dark"] .uf .chip.live .d { box-shadow: 0 0 9px var(--up); }
:root[data-theme="dark"] .uf .tabs span.on { background: rgba(255, 255, 255, .06); }

/* ------------------------------- RESPONSIVE ------------------------------ */
@media (max-width: 860px) {
  .uf .rec, .uf .uz-tiles { grid-template-columns: 1fr 1fr; }
  .uf .tickrow { grid-template-columns: 1fr; }
  .uf .vs { justify-self: center; }
}
@media (max-width: 560px) {
  .uf .rec, .uf .uz-tiles { grid-template-columns: 1fr; }
}

/* ============================================================================
   PAGE-BODY BRIDGE  —  map this app's Bootstrap chrome onto the .uf component
   language so re-skinned page bodies (Home / compare first) adopt the mockup
   look WITHOUT renaming any JS-referenced hooks. Everything is scoped to .uf,
   which also lets these two-class selectors out-specify the template's own
   single-class inline <style> rules.
   ============================================================================ */

/* The outer .content-section stops being a card and becomes a plain body
   container; the inner .uf .card now carry the surface + glow. */
.uf.content-section {
  background: transparent;
  border: none;
  box-shadow: none;
}

/* Bootstrap card header / body -> mockup .ch / .cb */
.uf .card > .card-header {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.uf .card > .card-header h5 { font-size: 14px; font-weight: 700; letter-spacing: -.01em; color: var(--tx); }
.uf .card > .card-body { background: transparent; }
:root[data-theme="dark"] .uf .card > .card-header { background: rgba(124, 155, 255, .05); }

/* Search / compare bar -> mockup .searchbar. Fields get the .fld look at all
   widths; the bordered box wrapper is desktop-only so the mobile stacked layout
   (inputs row + button row) keeps its native spacing. */
.uf #stock_input .form-control {
  font-family: var(--font-mono);
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--tx);
}
.uf #stock_input .btn-primary { border-radius: 9px; font-weight: 700; }
:root[data-theme="dark"] .uf #stock_input .form-control {
  background: rgba(124, 155, 255, .05);
  border-color: rgba(124, 155, 255, .16);
}
@media (min-width: 768px) {
  .uf #stock_input {
    display: inline-flex;
    align-items: flex-start;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 8px;
    box-shadow: var(--shadow);
  }
  :root[data-theme="dark"] .uf #stock_input {
    background: linear-gradient(180deg, rgba(124, 155, 255, .06), rgba(124, 155, 255, .02));
    border-color: rgba(124, 155, 255, .16);
  }
}

/* Time-range buttons -> mockup .tabs pills */
.uf #timeRangeToolbar .btn-outline-info {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11.5px;
  color: var(--tx-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.uf #timeRangeToolbar .btn-outline-info:hover { color: var(--tx); background: var(--surface); }
.uf #timeRangeToolbar .btn-outline-info.active {
  background: var(--surface);
  color: var(--brand);
  border-color: var(--brand);
}
:root[data-theme="dark"] .uf #timeRangeToolbar .btn-outline-info.active { background: rgba(255, 255, 255, .06); }

/* Metric dropdown + date-range button -> mockup .sel */
.uf #metricDropdown,
.uf #compareDateRangeBtn {
  font-weight: 700;
  color: var(--tx);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.uf #metricDropdown:hover,
.uf #compareDateRangeBtn:hover { background: var(--surface); color: var(--tx); }

/* AI recommendation gauge: the .progress bar -> mockup .gbar gradient track with
   a score marker chip. Bar width (inline, server-set) still positions the chip. */
.uf .progress {
  height: 9px !important;
  background: linear-gradient(90deg, var(--down), var(--hold), var(--up)) !important;
  border-radius: 6px !important;
  overflow: visible;
}
.uf .progress:before,
.uf .progress:after { display: none !important; }
.uf .progress .progress-bar {
  background: transparent !important;
  box-shadow: none !important;
}
.uf .progress.blue .progress-value,
.uf .progress .progress-value {
  width: auto;
  min-width: 32px;
  height: 22px;
  line-height: 20px;
  padding: 0 8px;
  top: -7px;
  right: -16px;
  border-radius: 7px;
  background: var(--surface) !important;
  border: 1px solid var(--line) !important;
  color: var(--tx) !important;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow);
}
:root[data-theme="dark"] .uf .progress { box-shadow: 0 0 14px rgba(46, 230, 166, .22); }

/* Metric-axis (middle) cells: transparent + muted per the mockup .cmp look
   (drops the pre-reskin readability tint now that this body is themed). The
   real-time flash only ever touches the value cells (cells[0] / cells[2]). */
.uf table td.metric-cell {
  background: transparent !important;
  color: var(--tx-2) !important;
}

/* Financial Metrics winner marking — mockup .cmp style: the winning value cell gets
   a full-cell soft-green tint + green bold number; the losing cell stays neutral (no
   badge, no red). Replaces the old green pill badge + red-loser treatment. */
.uf table td.metric-win {
  background: var(--up-soft) !important;
  color: var(--up) !important;
  font-weight: 700;
}

/* Home "AI Model Recommendation" card — the two per-stock gauges in a .rec grid.
   Give the score-chip room above the bar and label the gauges. */
.uf .rec .gauge { min-width: 0; }
.uf .rec .gl { justify-content: center; }
.uf .rec .gl-name { font-weight: 800; font-size: 13px; color: var(--tx); text-align: center; }
.uf .rec .gauge .progress { margin: 18px 0 6px; }
.uf .rec .gauge .btn-warning { margin-top: 10px; }
.uf .recommendation-summary-container { border-top: 1px solid var(--line); padding-top: 12px; }

/* Model page stat tiles: 3-up on desktop, positive/negative value colouring */
@media (min-width: 861px) { .uf .uz-tiles.cols-3 { grid-template-columns: repeat(3, 1fr); } }
.uf .uz-tile .v.pos { color: var(--up); }
.uf .uz-tile .v.neg { color: var(--down); }

/* Model page typography: the card headers were big Bootstrap .text-info (32px teal)
   and the page title was an oversized h1 — normalize to the compact .uf look so the
   Model page reads as the same design system as Home. */
.uf .card > .card-header h2,
.uf .card > .card-header h3 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--tx) !important;   /* beats Bootstrap .text-info !important */
  margin-bottom: 0;
}
.uf .card > .card-header h2 i,
.uf .card > .card-header h3 i { color: var(--brand); font-size: .95em; }
.uf h1:not(.sr-only) { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }

/* Model Top Holdings: on wide screens flow the list into two dense columns and
   let the card shrink to fit (it was a tall single-column scroll box). Below the
   breakpoint it keeps the native single-column scroll. */
/* The 2-column header (below) only shows on wide screens; the table's own <thead>
   handles the single-column mobile view. */
.uf .holdings-colhead { display: none; }
@media (min-width: 992px) {
  .uf #portfolioComponents .card-body { height: auto !important; overflow: visible !important; }
  /* Repeat the column labels above each of the two columns, aligned to the row cells. */
  .uf .holdings-colhead { display: flex; gap: 32px; margin-bottom: 4px; }
  .uf .holdings-colhead .hc-g { flex: 1; display: flex; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
  .uf .holdings-colhead span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--tx-3); font-weight: 700; padding: 0 6px; }
  .uf .holdings-colhead .hc-s { flex: 0 0 4.25rem; }
  .uf .holdings-colhead .hc-c { flex: 1 1 auto; }
  .uf .holdings-colhead .hc-w { flex: 0 0 3.5rem; text-align: right; }
  .uf #portfolioComponents .card-body > .position-relative { min-height: 0 !important; }
  .uf #portfolioComponents .table-responsive { overflow: visible !important; }
  .uf #portfolioComponentsTable { display: block; max-height: none !important; }
  .uf #portfolioComponentsTable thead { display: none; }  /* header labels can't map to 2 columns */
  .uf #portfolioComponentsBody {
    display: block;
    column-count: 2;
    column-gap: 32px;
    max-height: none !important;
    overflow: visible !important;
  }
  .uf #portfolioComponentsBody tr {
    display: flex;
    align-items: center;
    gap: 8px;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    border-bottom: 1px solid var(--line);
    padding: 3px 0;
  }
  .uf #portfolioComponentsBody td { border: none !important; padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .uf #portfolioComponentsBody td:nth-child(1) { flex: 0 0 4.25rem; font-weight: 700; text-align: left; }
  .uf #portfolioComponentsBody td:nth-child(2) { flex: 1 1 auto; min-width: 0; color: var(--tx-2); text-align: left; }
  .uf #portfolioComponentsBody td:nth-child(3) { flex: 0 0 3.5rem; text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
}

/* ============================================================================
   FLOW-PAGE DARK-MODE READABILITY  (About / pricing / FAQ, Account, Upgrade)
   These pages are not reskinned yet and hardcode light colours in their page
   <style>/inline attrs. Those rules are non-!important, so !important here wins
   despite theme.css loading first. Selectors are page-unique (ids / bespoke
   classes) so they don't touch the reskinned Home/Model. Generic selectors
   (.card-header, .modal-title) are fixed inside the templates instead.
   ============================================================================ */

/* Bootstrap text utilities the base layer missed (theme-neutral in both modes) */
.text-secondary { color: var(--tx-2) !important; }
.text-dark, .text-black { color: var(--tx) !important; }

/* Dark-only: controls + alerts Bootstrap pins to light values */
:root[data-theme="dark"] .btn-outline-dark { color: var(--tx); border-color: var(--line); }
:root[data-theme="dark"] .btn-outline-dark:hover { background: var(--surface-2); color: var(--tx); }
:root[data-theme="dark"] .btn-dark { background: var(--surface-2); border-color: var(--line); }
:root[data-theme="dark"] .alert-info { background: rgba(124, 155, 255, .12); border-color: rgba(124, 155, 255, .28); color: var(--tx); }
:root[data-theme="dark"] .alert-success { background: var(--up-soft); border-color: rgba(46, 230, 166, .30); color: var(--tx); }
:root[data-theme="dark"] .alert-warning { background: rgba(255, 207, 92, .14); border-color: rgba(255, 207, 92, .32); color: var(--tx); }
:root[data-theme="dark"] .alert-danger { background: var(--down-soft); border-color: rgba(255, 93, 122, .30); color: var(--tx); }

/* About — pricing tiers */
#pricing { background: var(--surface-2) !important; }
.tier-card { background: var(--surface) !important; border-color: var(--line) !important; }
.tier-card .tier-price { color: var(--tx) !important; }
.tier-card .tier-price small { color: var(--tx-3) !important; }
.tier-features li { color: var(--tx-2) !important; }
.tier-features li.muted, .tier-features .fa-minus { color: var(--tx-3) !important; }

/* About — FAQ / Common Questions */
#faqAccordion .card-header { background: var(--surface-2) !important; }
#faqAccordion .card-header button { color: var(--tx) !important; }
.faq-group-title { color: var(--tx) !important; border-bottom-color: var(--line) !important; }
.faq-pill { background: var(--surface) !important; color: var(--tx-2) !important; border-color: var(--line) !important; }
.faq-pill .faq-count { background: var(--surface-2) !important; color: var(--tx-2) !important; }

/* About — shared chrome */
.section-eyebrow { color: var(--tx-3) !important; }
.hub-section + .hub-section { border-top-color: var(--line) !important; }
.hub-nav a { background: color-mix(in srgb, var(--tx) 20%, transparent) !important; }
.hub-nav a:hover, .hub-nav a.active { background: var(--brand) !important; }

/* Account page */
.account-title { color: var(--tx) !important; border-bottom-color: var(--line) !important; }
.email-text { color: var(--tx) !important; }
.default-payment-method { background: var(--surface-2) !important; }

/* Upgrade sidebar — investment-disclaimer box */
#disclaimer-content { background: var(--surface-2) !important; border-left-color: var(--hold) !important; }
