/* =============================================================================
   app.css — Shared editorial design system for the Trading Advisor.
   Direction: "Soft fintech editorial" + ink-indigo accent. Light only.
   Loaded by every page (after any page-local <style>) so it sets the look
   app-wide and forces the warm-paper editorial palette regardless of legacy
   per-page tokens. Pages keep their own page-specific rules; this owns the
   foundation: tokens, typography, nav, buttons, cards, badges, forms, tables,
   modals, glossary callouts, RTL + mobile.
   ============================================================================= */

/* ---- Type: IBM Plex (Latin) + Plex Sans Arabic + Plex Mono. Cairo = AR fallback.
        SELF-HOSTED (web/fonts/, served at /fonts.css) — bundled with the app, no
        external CDN, so the fonts load instantly on every reload, online or offline.
        (The old Google-Fonts @import made the fonts vanish on any flaky reload.) ---- */
@import url('/fonts.css');

/* =============================================================================
   1 · DESIGN TOKENS  (force the editorial light palette across all pages)
   ============================================================================= */
:root,
html[data-theme="light"],
html[data-theme="dark"] {
  /* Fonts */
  --sans: "IBM Plex Sans", "IBM Plex Sans Arabic", "Cairo", -apple-system,
          BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --ar:   "IBM Plex Sans Arabic", "Cairo", "IBM Plex Sans", -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Radii — soft, rounded */
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --radius-pill: 999px;

  /* Motion */
  --tr: 160ms cubic-bezier(.4, 0, .2, 1);

  /* Warm paper surfaces */
  --app-bg:       #FBFAF6;
  --app-bg-2:     #F6F3EC;   /* subtle gradient stop / banded sections */
  --surface:      #FFFFFF;
  --raised:       #FFFFFF;
  --sunken:       #F4F1EA;
  --border:       #E9E4D9;
  --border-soft:  #F1ECE2;
  --border-strong:#D8D1C2;

  /* Warm ink text */
  --text:        #1B1A16;
  --text-dim:    #5C594F;
  --text-faint:  #908C80;

  /* Accent — ink indigo */
  --brand:       #2B4B8F;
  --brand-hover: #213C73;
  --brand-dim:   #E7EAF3;   /* tint bg */
  --brand-tint:  #F2F4F9;   /* faintest */
  --on-brand:    #FFFFFF;

  --user-bubble: #EEF0F6;

  /* Semantic — editorial, slightly muted but clear for beginners */
  --green:      #15824B;
  --green-bg:   rgba(21,130,75,0.10);
  --green-bd:   rgba(21,130,75,0.30);
  --green-solid:#137043;

  --red:        #C13A30;
  --red-bg:     rgba(193,58,48,0.09);
  --red-bd:     rgba(193,58,48,0.30);
  --red-solid:  #B0322A;

  --amber:      #A8770F;
  --amber-bg:   rgba(168,119,15,0.12);
  --amber-bd:   rgba(168,119,15,0.32);
  --amber-solid:#8F6309;

  --blue:       #2B4B8F;
  --blue-bg:    rgba(43,75,143,0.09);
  --blue-bd:    rgba(43,75,143,0.28);
  --blue-solid: #2B4B8F;

  --gray:       #6E6A5F;
  --gray-bg:    rgba(110,106,95,0.10);
  --gray-bd:    rgba(110,106,95,0.28);
  --gray-solid: #6E6A5F;

  --on-status:  #FFFFFF;

  /* Soft warm shadows */
  --shadow-card:  0 1px 2px rgba(43,37,22,0.04), 0 8px 24px -14px rgba(43,37,22,0.16);
  --shadow-hover: 0 2px 6px rgba(43,37,22,0.06), 0 18px 40px -18px rgba(43,37,22,0.22);
  --shadow-pop:   0 30px 70px -22px rgba(43,37,22,0.30);
  --scrim:        rgba(34,28,16,0.32);
  --scroll:       #DCD6C8;
  --scroll-hover: #C9C2B0;

  --ring: 0 0 0 3px rgba(43,75,143,0.22);   /* focus ring */
}

/* =============================================================================
   2 · BASE / TYPOGRAPHY
   ============================================================================= */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--app-bg);
  background-image:
    radial-gradient(1100px 520px at 78% -8%, #FFFDF8 0%, rgba(255,253,248,0) 60%),
    linear-gradient(180deg, var(--app-bg) 0%, var(--app-bg-2) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
[dir="rtl"] body, [lang="ar"] body { font-family: var(--ar); }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.015em; color: var(--text); line-height: 1.2; }
h1 { font-size: 28px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
p  { margin: 0 0 0.7em; }
a  { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }

.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
.muted   { color: var(--text-dim); }
.faint   { color: var(--text-faint); }
.mono    { font-family: var(--mono); }

/* Editorial eyebrow — small uppercase letterspaced kicker above titles */
.eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--brand);
}
[lang="ar"] .eyebrow { letter-spacing: 0; font-size: 12px; }

::selection { background: rgba(43,75,143,0.16); }

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-xs);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Page container */
.app {
  max-width: 1080px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 22px 88px;
}
.main-col { width: 100%; min-width: 0; margin: 0 auto; }

/* Page heading block (editorial) */
.page-head { padding: 26px 2px 18px; }
.page-head h1 { font-size: 30px; }
.page-head .lede { color: var(--text-dim); font-size: 15px; max-width: 64ch; margin-top: 8px; }
.hairline { height: 1px; background: var(--border); border: 0; margin: 18px 0; }

/* =============================================================================
   3 · TOP NAVIGATION  (rendered by nav.js into #topbar)
   ============================================================================= */
.topbar {
  position: sticky; top: 0; z-index: 80;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px;
  background: color-mix(in srgb, var(--app-bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar-inner {
  width: 100%; max-width: 1080px; margin: 0 auto;
  display: flex; align-items: center; gap: 14px;
}
.brand {
  display: inline-flex; align-items: center; gap: 11px;
  text-decoration: none; color: var(--text); flex: 0 0 auto;
}
.brand .brandmark {
  width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--brand) 0%, #3A60A8 100%);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 17px; letter-spacing: -0.02em;
  box-shadow: 0 6px 16px -6px rgba(43,75,143,0.55);
}
.brand .brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand .brand-name { font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em; }
.brand .brand-sub  { font-size: 10.5px; font-weight: 500; color: var(--text-faint); letter-spacing: 0.02em; }

.topbar .spacer { flex: 1; }

/* Desktop nav.
   The bar is brand + nav + controls on one row, and the nav is 8 nowrap items. Between the
   burger breakpoint (860px) and roughly 1200px that no longer fit, and because .topctl is
   flex:0 0 auto the overflow pushed the whole bar off-screen — every page scrolled sideways
   on a tablet. Two guards: shed the labels first (icons stay, title carries the name), and
   let the strip itself shrink/scroll as a last resort so the PAGE can never scroll. Overflow
   is set on .topnav only — the account dropdown lives in .topctl and must not be clipped. */
.topnav {
  display: flex; align-items: center; gap: 2px;
  flex: 0 1 auto; min-width: 0;
  overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: none; -ms-overflow-style: none;
}
.topnav::-webkit-scrollbar { display: none; height: 0; }
@media (max-width: 1200px) {
  .topnav a { padding: 8px 9px; }
  .topnav a .lbl { display: none; }
  .topnav a .ic { font-size: 17px; }
}
.topnav a {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13.5px; font-weight: 600; color: var(--text-dim);
  padding: 8px 13px; border-radius: var(--radius-sm);
  text-decoration: none; white-space: nowrap;
  transition: background var(--tr), color var(--tr);
}
.topnav a .ic { font-size: 15px; line-height: 1; opacity: 0.9; }
.topnav a:hover { color: var(--text); background: var(--sunken); }
.topnav a.active { color: var(--brand); background: var(--brand-dim); }

/* Right-side controls cluster */
.topctl { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; }

/* Language segmented toggle */
.lang-seg {
  display: inline-flex; align-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: var(--surface); padding: 2px; overflow: hidden;
}
.lang-seg button {
  border: 0; background: none; cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: 12px;
  color: var(--text-faint); padding: 4px 11px; border-radius: var(--radius-pill);
  line-height: 1.6; transition: background var(--tr), color var(--tr);
}
.lang-seg button.on { background: var(--brand); color: #fff; }

/* Icon button (round) */
.icon-btn {
  width: 38px; height: 38px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-dim);
  cursor: pointer; padding: 0; font-size: 16px;
  transition: background var(--tr), border-color var(--tr), color var(--tr);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--sunken); }
.icon-btn svg { width: 19px; height: 19px; display: block; }

/* Account menu — avatar trigger + dropdown (collects Settings · Admin · Language · Sound · Logout) */
.acct-menu { position: relative; display: inline-flex; }
.acct-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-pill); padding: 4px 12px 4px 5px; cursor: pointer;
  font-family: inherit; transition: border-color var(--tr), background var(--tr);
}
[dir="rtl"] .acct-trigger { padding: 4px 5px 4px 12px; }
.acct-trigger:hover { border-color: var(--border-strong); background: var(--sunken); }
.acct-avatar {
  width: 30px; height: 30px; flex: 0 0 auto; border-radius: 50%;
  background: var(--brand-dim); color: var(--brand);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.acct-avatar.lg { width: 38px; height: 38px; font-size: 16px; }
.acct-trigger-name {
  font-size: 13px; font-weight: 600; color: var(--text-dim);
  max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.acct-caret { font-size: 10px; color: var(--text-faint); }

.acct-dropdown {
  position: absolute; top: calc(100% + 10px); inset-inline-end: 0;
  min-width: 248px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop); padding: 8px; z-index: 90;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity var(--tr), transform var(--tr), visibility var(--tr);
}
.acct-dropdown.open { opacity: 1; visibility: visible; transform: none; }
.acct-dd-head { display: flex; align-items: center; gap: 11px; padding: 8px 8px 10px; }
.acct-dd-name { font-size: 14px; font-weight: 700; color: var(--text); }
.acct-dd-role { font-size: 12px; font-weight: 600; color: var(--brand); }
.acct-dropdown a, .acct-dropdown .acct-dd-logout {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 10px 9px; border-radius: var(--radius-sm); border: 0; background: none;
  font-family: inherit; font-size: 14px; font-weight: 500; color: var(--text);
  text-decoration: none; cursor: pointer; text-align: start;
}
.acct-dropdown a .ic, .acct-dropdown .acct-dd-logout .ic { font-size: 17px; width: 22px; text-align: center; }
.acct-dropdown a:hover, .acct-dropdown .acct-dd-logout:hover { background: var(--sunken); }
.acct-dropdown .acct-dd-logout { color: var(--red); }
.acct-dropdown .acct-dd-logout:hover { background: var(--red-bg); }
.acct-dropdown hr { border: 0; border-top: 1px solid var(--border-soft); margin: 6px 4px; }
.acct-dd-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 9px; }
.acct-dd-rl { font-size: 13.5px; font-weight: 500; color: var(--text-dim); }

/* Drawer rows (mobile language/sound) */
.drawer-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 12px; }
.drawer-row > span { font-size: 15px; font-weight: 600; color: var(--text); }

/* Burger + drawer (mobile) */
.navburger { display: none; }
.drawer-overlay {
  position: fixed; inset: 0; background: var(--scrim);
  opacity: 0; visibility: hidden; transition: opacity var(--tr), visibility var(--tr);
  z-index: 95;
}
.drawer-overlay.open { opacity: 1; visibility: visible; }
.drawer {
  position: fixed; top: 0; bottom: 0; inset-inline-end: 0;
  width: min(82vw, 320px);
  background: var(--surface); z-index: 96;
  transform: translateX(100%);
  transition: transform var(--tr); visibility: hidden;
  box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column; padding: 16px;
  overflow-y: auto;
}
[dir="rtl"] .drawer { transform: translateX(-100%); }
.drawer.open { transform: translateX(0) !important; visibility: visible; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.drawer-head .brand-name { font-size: 15px; font-weight: 700; }
.drawer-close {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-dim); cursor: pointer; font-size: 17px;
}
.drawer a {
  display: flex; align-items: center; gap: 11px;
  padding: 13px 12px; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; color: var(--text); text-decoration: none;
}
.drawer a .ic { font-size: 18px; width: 22px; text-align: center; }
.drawer a:hover { background: var(--sunken); }
.drawer a.active { background: var(--brand-dim); color: var(--brand); }
.drawer hr { border: 0; border-top: 1px solid var(--border-soft); margin: 10px 2px; }
body.nav-open { overflow: hidden; }

/* =============================================================================
   4 · BUTTONS
   ============================================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1.2;
  padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--tr), border-color var(--tr), color var(--tr), box-shadow var(--tr), transform var(--tr);
}
.btn:hover { border-color: var(--border-strong); background: var(--sunken); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary {
  background: var(--brand); border-color: var(--brand); color: var(--on-brand);
  box-shadow: 0 8px 20px -10px rgba(43,75,143,0.6);
}
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--sunken); color: var(--text); }
.btn-danger { color: var(--red); border-color: var(--red-bd); background: var(--red-bg); }
.btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: var(--radius-xs); }
.btn-lg { padding: 13px 22px; font-size: 15.5px; border-radius: var(--radius-md); }
.btn-block { width: 100%; }

/* =============================================================================
   5 · CARDS / SURFACES
   ============================================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--tr), border-color var(--tr), transform var(--tr);
}
.card-pad { padding: 20px; }
.card-hover:hover { box-shadow: var(--shadow-hover); border-color: var(--border-strong); }
.surface { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
.sunken  { background: var(--sunken); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); }

/* Stat tile */
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 16px 18px; box-shadow: var(--shadow-card);
}
.stat .stat-label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.stat .stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
[lang="ar"] .stat .stat-label { letter-spacing: 0; text-transform: none; font-size: 12px; }

/* =============================================================================
   6 · BADGES · CHIPS · VERDICTS
   ============================================================================= */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; line-height: 1.5;
  padding: 4px 10px; border-radius: var(--radius-pill);
  background: var(--sunken); border: 1px solid var(--border); color: var(--text-dim);
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; line-height: 1;
  padding: 5px 11px; border-radius: var(--radius-pill);
}
.badge.green { background: var(--green-bg); border: 1px solid var(--green-bd); color: var(--green-solid); }
.badge.red   { background: var(--red-bg);   border: 1px solid var(--red-bd);   color: var(--red-solid); }
.badge.amber { background: var(--amber-bg); border: 1px solid var(--amber-bd); color: var(--amber-solid); }
.badge.blue  { background: var(--blue-bg);  border: 1px solid var(--blue-bd);  color: var(--blue-solid); }
.badge.gray  { background: var(--gray-bg);  border: 1px solid var(--gray-bd);  color: var(--gray-solid); }

/* Verdict badge — bold, clear, beginner-legible */
.verdict-badge {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 700; letter-spacing: 0.01em;
  padding: 8px 16px; border-radius: var(--radius-sm); color: #fff;
}
.verdict-badge .vb-dot { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,0.9); }
.v-buy,  .verdict-badge.buy,  .verdict-badge.add  { background: var(--green-solid); }
.v-sell, .verdict-badge.sell, .verdict-badge.exit { background: var(--red-solid); }
.v-trim, .verdict-badge.trim, .verdict-badge.cover{ background: var(--amber-solid); }
.v-hold, .verdict-badge.hold { background: var(--blue-solid); }
.v-wait, .verdict-badge.wait { background: var(--gray-solid); }

/* Net-score meter */
.meter { display: inline-flex; gap: 3px; align-items: center; }
.meter .seg { width: 16px; height: 7px; border-radius: 3px; background: var(--border); }
.meter .seg.pos { background: var(--green); }
.meter .seg.neg { background: var(--red); }

/* =============================================================================
   7 · FORMS
   ============================================================================= */
label { font-size: 13px; font-weight: 600; color: var(--text-dim); }
input[type="text"], input[type="number"], input[type="password"], input[type="email"],
input[type="search"], select, textarea {
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; width: 100%;
  transition: border-color var(--tr), box-shadow var(--tr);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
select {
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235C594F' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}
[dir="rtl"] select { background-position: left 12px center; padding-right: 12px; padding-left: 32px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--text-faint); font-weight: 400; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; cursor: pointer; background: var(--border-strong);
  border-radius: var(--radius-pill); transition: background var(--tr);
}
.switch .track::before {
  content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform var(--tr); box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::before { transform: translateX(18px); }
[dir="rtl"] .switch input:checked + .track::before { transform: translateX(-18px); }

/* =============================================================================
   8 · TABLES
   ============================================================================= */
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th {
  text-align: start; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-faint); padding: 10px 12px; border-bottom: 1px solid var(--border);
}
[lang="ar"] table.tbl th { letter-spacing: 0; text-transform: none; font-size: 12.5px; }
table.tbl td { padding: 12px; border-bottom: 1px solid var(--border-soft); }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: var(--brand-tint); }

/* =============================================================================
   9 · MODAL
   ============================================================================= */
.modal-overlay {
  position: fixed; inset: 0; background: var(--scrim); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 18px;
  opacity: 0; visibility: hidden; transition: opacity var(--tr), visibility var(--tr);
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
  width: min(560px, 100%); max-height: 88vh; overflow-y: auto; padding: 24px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

/* =============================================================================
   10 · GLOSSARY CALLOUT  (jargon with hover/tap definition)
   ============================================================================= */
.gloss {
  border-bottom: 1.5px dotted var(--brand); cursor: help;
  text-underline-offset: 3px; position: relative;
}
.gloss::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%) translateY(4px);
  background: var(--text); color: #fff; font-size: 12.5px; font-weight: 500; line-height: 1.45;
  padding: 9px 12px; border-radius: var(--radius-sm); width: max-content; max-width: 260px;
  box-shadow: var(--shadow-pop); opacity: 0; visibility: hidden; transition: opacity var(--tr), transform var(--tr);
  z-index: 50; pointer-events: none; white-space: normal; text-align: start;
}
.gloss:hover::after, .gloss:focus::after { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }

/* =============================================================================
   11 · UTILITIES
   ============================================================================= */
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.tac { text-align: center; }
.up   { color: var(--green); }
.down { color: var(--red); }
.hide { display: none !important; }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pulse { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

/* Scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--scroll-hover); }

/* =============================================================================
   12 · RESPONSIVE
   ============================================================================= */
@media (max-width: 860px) {
  .topnav { display: none; }
  .navburger {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text); cursor: pointer; font-size: 19px;
  }
  /* Account menu (dropdown) lives in the burger drawer on mobile; keep the topbar uncluttered. */
  .topbar .acct-menu { display: none; }
  .topbar .brand .brand-sub { display: none; }
  .topctl { gap: 6px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .app { padding: 0 16px 80px; }
  .topbar { padding: 10px 14px; }
  .page-head { padding: 20px 2px 14px; }
  .page-head h1 { font-size: 25px; }
  h1 { font-size: 24px; }
}
/* Account name/links also rendered inside the drawer on mobile (see nav.js). */
.drawer .drawer-acct {
  margin-top: 4px; padding: 12px; border-radius: var(--radius-sm);
  background: var(--sunken); font-size: 13px; font-weight: 600; color: var(--text-dim);
}
@media (min-width: 861px) { .navburger, .drawer, .drawer-overlay { display: none; } }

/* Service-status pill (nav.js) — always-visible health of the background watcher.
   Green = live · amber = paused · gray = live but market closed · red = down (click to start). */
.svc-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface);
  font-size: 12px; font-weight: 600; color: var(--text-dim);
  cursor: default; white-space: nowrap; line-height: 1;
}
.svc-pill .svc-dot { font-size: 10px; line-height: 1; }
.svc-pill.ok    { color: var(--green); border-color: var(--green-bd); background: var(--green-bg); }
/* market closed = STANDBY: calm blue, clearly "healthy / ready", never reads as a problem. */
.svc-pill.standby { color: var(--blue); border-color: var(--blue-bd); background: var(--blue-bg); }
.svc-pill.standby .svc-dot { color: var(--blue); }
.svc-pill.warn  { color: var(--amber); border-color: var(--amber-bd); background: var(--amber-bg); }
.svc-pill.off   { color: var(--red);   border-color: var(--red-bd);   background: var(--red-bg); cursor: pointer; }
.svc-pill.off:hover { background: var(--red); color: #fff; border-color: var(--red); }
.svc-pill.busy  { color: var(--text-dim); cursor: progress; }
.svc-pill.ok .svc-dot, .svc-pill.standby .svc-dot, .svc-pill.warn .svc-dot, .svc-pill.off .svc-dot { animation: svcpulse 2s ease-in-out infinite; }
@keyframes svcpulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@media (max-width: 600px) { .svc-pill .svc-txt { display: none; } .svc-pill { padding: 6px 8px; } }

/* RTL niceties */
[dir="rtl"] .eyebrow,
[dir="rtl"] .stat .stat-label { direction: rtl; }

/* =============================================================================
   13 · OPPORTUNITIES TICKER
   ============================================================================= */
.opp-ticker-wrap {
  overflow: hidden;
  background: var(--sunken);
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
  padding: 8px 16px;
  position: relative;
  display: none;
  align-items: center;
  flex-wrap: nowrap;
}
.opp-ticker-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  padding-inline-end: 16px;
  border-inline-end: 1px solid var(--border);
  margin-inline-end: 16px;
  flex-shrink: 0;
  z-index: 2;
  background: var(--sunken);
}
.opp-ticker-content {
  display: inline-flex;
  animation: ticker-scroll 40s linear infinite;
  padding-left: 100%;
}
.opp-ticker-wrap:hover .opp-ticker-content {
  animation-play-state: paused;
}
@keyframes ticker-scroll {
  0% { transform: translate(0, 0); }
  100% { transform: translate(-100%, 0); }
}
.opp-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 12px;
  margin: 0 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: var(--tr);
}
.opp-chip:hover { border-color: var(--brand); transform: translateY(-1px); }
.opp-chip.GO { background: var(--green-bg); border-color: var(--green-bd); color: var(--green); }
.opp-chip.CAUTION { background: var(--amber-bg); border-color: var(--amber-bd); color: var(--amber); }
/* leaders ticker — sits under the opportunities ticker; lighter background to tell them apart */
.leaders-ticker { background: var(--surface); border-bottom: 1px solid var(--border-soft); }
.leaders-ticker .opp-ticker-label { background: var(--surface); color: var(--green); }
.opp-chip.leader { background: var(--surface); }
