/* ═══════════════════════════════════════════════════════════════════════════
   shell.css — TradeFlare's one look (owner, 2026-11-15: the Wealthsimple standard)
   Dark by default (owner, later 2026-11-15), light when the visitor picks it with the top-bar
   day/night button or on Account / More (data-theme="dark" on <html>, set by
   shell.js from localStorage before the page paints). Every redesigned page uses ONLY these
   tokens: no colour literals in page styles (guarded by tests/test_shell.py).
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: light;  /* the light set; dark (below) is the default, set by shell.js */
  --bg: #ffffff;
  --surface: #f9fafb;        /* quiet panels, folds, stat tiles */
  --card: #ffffff;           /* list rows and cards */
  --line: #e5e7eb;
  --line-2: #d1d5db;         /* inputs, secondary buttons */
  --ink: #0b0e17;            /* headings, numbers */
  --ink-2: #1f2937;          /* body text */
  --muted: #4b5563;          /* secondary text (AA on white) */
  --faint: #6b7280;          /* labels, dates (AA on white) */
  --up: #047857;   --up-bg: #ecfdf5;   --up-line: #a7f3d0;
  --down: #dc2626; --down-bg: #fef2f2; --down-line: #fecaca;
  --warn: #b45309; --warn-bg: #fff7ed; --warn-line: #fed7aa;
  --link: #1d4ed8; --link-bg: #eff6ff; --link-line: #bfdbfe;
  --action: #0b0e17;         /* primary buttons */
  --on-action: #ffffff;
  --chip: #f3f4f6;           /* segmented control track */
  --chip-on: #ffffff;        /* selected segment */
  --chip-shadow: 0 1px 2px rgba(0, 0, 0, .08);
  --pop-shadow: 0 16px 40px rgba(0, 0, 0, .14);
  --radius: 16px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0e17;
  --surface: #131722;
  --card: #131722;
  --line: #232838;
  --line-2: #343b4f;
  --ink: #eef2f7;
  --ink-2: #d9dee8;
  --muted: #aab4c5;
  --faint: #8f99ab;
  --up: #34d399;   --up-bg: #0f2a22;   --up-line: #1f5c47;
  --down: #f87171; --down-bg: #2a1416; --down-line: #5c2327;
  --warn: #fbbf24; --warn-bg: #2a1f0b; --warn-line: #5c4210;
  --link: #8ab4ff; --link-bg: #13213b; --link-line: #23406e;
  --action: #eef2f7;
  --on-action: #0b0e17;
  --chip: #171c2b;
  --chip-on: #262d40;
  --chip-shadow: none;
  --pop-shadow: 0 16px 40px rgba(0, 0, 0, .5);
}

/* ── base ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.shell {
  margin: 0; background: var(--bg); color: var(--ink-2); font-family: var(--font);
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  padding-top: 64px;
}
.shell a { color: var(--link); text-decoration: none; }
.shell a:hover { text-decoration: underline; }
.shell h1, .shell h2, .shell h3 { color: var(--ink); letter-spacing: -0.02em; text-wrap: balance; }
.shell .page-h1, .shell .sec-h, .shell .first h2, .shell .nr-h { margin-top: 0; }
.shell .page-h1 { margin-bottom: 0; }
body.shell.no-nav { padding-top: 0; padding-bottom: 0; }
.shell :focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); } .warn { color: var(--warn); }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.wrap { max-width: 720px; margin: 0 auto; padding: 24px 20px 72px; }
.wrap-wide { max-width: 1040px; margin: 0 auto; padding: 24px 20px 72px; }
.page-h1 { font-size: 28px; font-weight: 800; line-height: 1.15; }
.page-lead { color: var(--muted); font-size: 15px; margin: 6px 0 0; }
.eyebrow { font-size: 13px; color: var(--faint); margin: 0 0 4px; }
.sec-h { font-size: 17px; font-weight: 700; color: var(--ink); margin: 22px 0 10px; }

/* ── top bar (desktop and phone) ───────────────────────────────────────────── */
.shell .top-nav {
  position: fixed; top: 0; left: 0; right: 0; height: 64px; z-index: 1000;
  background: var(--bg); border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
}
.shell .nav-container { max-width: 1200px; width: 100%; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 8px; height: 100%; }
.shell .brand { display: flex; align-items: center; color: var(--ink); margin-right: 14px; flex: none; }
.shell .brand svg { display: block; height: 30px; width: auto; }
.shell .nav-links { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; }
.shell .nav-link {
  color: var(--muted); font-size: 15px; font-weight: 600; padding: 8px 12px; border-radius: 10px;
  white-space: nowrap; text-decoration: none;
}
.shell .nav-link:hover { color: var(--ink); background: var(--surface); text-decoration: none; }
.shell .nav-link.active { color: var(--ink); background: var(--chip); }
.shell .nav-more { position: relative; }
.shell .nav-more > summary { list-style: none; cursor: pointer; }
.shell .nav-more > summary::-webkit-details-marker { display: none; }
.shell .nav-more-pop {
  position: absolute; top: 46px; left: 0; min-width: 260px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--pop-shadow); padding: 6px; z-index: 1100;
}
.shell .nav-more-pop a { display: block; padding: 10px 12px; border-radius: 10px; color: var(--ink); font-weight: 600; font-size: 15px; }
.shell .nav-more-pop a span { display: block; color: var(--faint); font-weight: 500; font-size: 13px; }
.shell .nav-more-pop a:hover { background: var(--surface); text-decoration: none; }
.shell .hamburger {
  display: none; margin-left: auto; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font-size: 20px; align-items: center; justify-content: center; cursor: pointer;
}

/* day/night button in the top bar (shell.js paints the icon and label) */
.shell .theme-toggle, .theme-toggle {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg);
  color: var(--ink); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; margin-left: 8px;
}
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle:hover { background: var(--surface); }

/* account control (nav-auth.js) */
.shell .nav-account { display: flex; align-items: center; margin-left: 8px; position: relative; flex: none; }
.shell .nav-signin {
  color: var(--on-action); background: var(--action); font-size: 14px; font-weight: 700; padding: 0 16px; min-height: 40px;
  display: inline-flex; align-items: center; border-radius: 999px; white-space: nowrap; text-decoration: none;
}
.shell .nav-signin:hover { text-decoration: none; opacity: .9; }
/* visitors: Sign in is the quiet one, Sign up free the filled one */
.shell .nav-account .nav-signin { color: var(--ink); background: transparent; border: 1px solid var(--line-2); }
.shell .nav-signup {
  color: var(--on-action); background: var(--action); font-size: 14px; font-weight: 700; padding: 0 16px; min-height: 40px;
  display: inline-flex; align-items: center; border-radius: 999px; white-space: nowrap; text-decoration: none; margin-left: 8px;
}
.shell .nav-signup:hover { text-decoration: none; opacity: .9; }
@media (max-width: 768px) {
  .shell .nav-account .nav-signin { display: none; }      /* Sign in is in the bottom tab bar */
  .shell .nav-signup { margin-left: 0; padding: 0 14px; }
}
@media (max-width: 400px) {
  .shell .nav-signup { padding: 0 11px; font-size: 13px; }
  .shell .nav-account, .shell .hamburger { margin-left: 5px; }
}
.shell .nav-avatar {
  width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--action); color: var(--on-action);
  cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; position: relative; overflow: hidden;
}
.shell .nav-avatar-i { font-size: 13px; font-weight: 700; }
.shell .nav-avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.shell .nav-dropdown {
  position: absolute; top: 48px; right: 0; min-width: 240px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--pop-shadow); padding: 6px; opacity: 0; visibility: hidden;
  transform: translateY(-6px); transition: opacity .15s, transform .15s, visibility .15s; z-index: 1200;
}
.shell .nav-dropdown.open { opacity: 1; visibility: visible; transform: none; }
.shell .nav-dd-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.shell .nav-dd-name { font-size: 15px; font-weight: 700; color: var(--ink); }
.shell .nav-dd-sub { font-size: 13px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell .nav-dd-tier { display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.shell .nav-dd-item { display: block; color: var(--ink); font-size: 15px; font-weight: 500; padding: 10px 12px; border-radius: 10px; }
.shell .nav-dd-item:hover { background: var(--surface); text-decoration: none; }
.shell .nav-dd-signout { color: var(--muted); }
.shell .nav-dd-div { height: 1px; background: var(--line); margin: 6px 4px; }

/* ── bottom tab bar (phones) ───────────────────────────────────────────────── */
.tabbar { display: none; }

@media (max-width: 480px) {
  .wrap, .wrap-wide { padding-top: 16px; padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 768px) {
  body.shell { padding-top: 56px; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .shell .top-nav { height: 56px; }
  .shell .nav-container { padding: 0 12px; }
  .shell .brand svg { height: 26px; }
  .shell .hamburger { display: flex; margin-left: 8px; order: 3; }
  .shell .theme-toggle { margin-left: auto; order: 1; }
  .shell .nav-account { margin-left: 8px; order: 2; }
  .shell .nav-links {
    display: none; position: absolute; top: 56px; left: 0; right: 0; flex-direction: column; align-items: stretch;
    gap: 2px; padding: 8px 12px 14px; background: var(--bg); border-bottom: 1px solid var(--line);
    box-shadow: var(--pop-shadow); z-index: 1001; min-height: calc(100vh - 56px);
  }
  .shell .nav-links.open { display: flex; }
  .shell .nav-link { font-size: 17px; padding: 12px 12px; }
  .shell .nav-more > summary { display: none; }
  .shell .nav-more-pop { position: static; box-shadow: none; border: 0; padding: 0; min-width: 0; display: block; }
  .shell .nav-more:not([open]) > .nav-more-pop { display: block; }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 999;
    background: var(--bg); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 56px;
    color: var(--faint); font-size: 12px; font-weight: 600; text-decoration: none; border-radius: 12px;
  }
  .tabbar a svg { width: 24px; height: 24px; }
  .tabbar a[aria-current="page"] { color: var(--ink); }
  .tabbar a[aria-current="page"] svg { stroke-width: 2.4; }
}

/* ── components ────────────────────────────────────────────────────────────── */
.edu-line { font-size: 13px; color: var(--faint); margin: 10px 0 0; }
.edu-line summary { cursor: pointer; list-style: none; display: inline; }
.edu-line summary::-webkit-details-marker { display: none; }
.edu-line summary b { font-weight: 600; color: var(--muted); }
.edu-line summary .more { text-decoration: underline; margin-left: 4px; }
.edu-line[open] summary .more { display: none; }
.edu-line p { margin: 6px 0 0; line-height: 1.5; }

.seg { display: flex; background: var(--chip); border-radius: 999px; padding: 4px; }
.seg > a, .seg > button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 10px;
  border: 0; background: transparent; border-radius: 999px; color: var(--faint); font: 600 15px/1 var(--font);
  cursor: pointer; text-decoration: none;
}
.seg > a:hover { text-decoration: none; color: var(--ink); }
.seg > .on, .seg > [aria-selected="true"], .seg > [aria-current="page"] { background: var(--chip-on); color: var(--ink); box-shadow: var(--chip-shadow); }
.seg small { font-size: 13px; font-weight: 500; color: var(--faint); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.row-link { display: flex; align-items: center; gap: 12px; padding: 14px; color: inherit; text-decoration: none; }
.shell a.row-link:hover { text-decoration: none; border-color: var(--line-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border-radius: 14px; font: 700 15px/1 var(--font); cursor: pointer; text-decoration: none; border: 1px solid transparent;
}
.shell .btn:hover { text-decoration: none; }
.btn-primary { background: var(--action); color: var(--on-action); }
.shell a.btn-primary { color: var(--on-action); }
.btn-secondary { background: var(--bg); color: var(--ink); border-color: var(--line-2); }
.shell a.btn-secondary { color: var(--ink); }

.pill { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px; white-space: nowrap; border: 1px solid; }
.pill-buy { color: var(--up); background: var(--up-bg); border-color: var(--up-line); }
.pill-hold { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.pill-sell { color: var(--down); background: var(--down-bg); border-color: var(--down-line); }
.pill-quiet { color: var(--muted); background: var(--surface); border-color: var(--line); }
.chip-mine { font-size: 11px; font-weight: 700; color: var(--link); background: var(--link-bg); border: 1px solid var(--link-line); padding: 2px 7px; border-radius: 999px; white-space: nowrap; }

.alert { display: flex; gap: 12px; align-items: flex-start; background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius); padding: 14px 16px; color: var(--ink-2); }
.alert b { color: var(--ink); }
.notice { font-size: 13px; color: var(--warn); }

.tile-row { display: flex; gap: 10px; }
.tile { flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-width: 0; }
.tile .v { font-size: 24px; font-weight: 800; letter-spacing: -0.6px; color: var(--ink); font-variant-numeric: tabular-nums; }
.tile .l { font-size: 12px; color: var(--muted); }

.logo-tile { width: 42px; height: 42px; border-radius: 12px; flex: none; overflow: hidden; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); font-weight: 800; font-size: 12px; color: var(--ink); }
.logo-tile img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.logo-tile img + span { display: none; }   /* the ticker shows only when there is no logo */

.fold { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 16px; }
.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; min-height: 52px; font-weight: 600; color: var(--ink); }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--faint); border-bottom: 2px solid var(--faint); transform: rotate(45deg); margin: -4px 4px 0 12px; transition: transform .15s; }
.fold[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
.fold > .fold-body { padding: 0 0 14px; }

input.field, select.field, textarea.field {
  width: 100%; min-height: 48px; border: 1px solid var(--line-2); border-radius: 12px; padding: 0 14px;
  font: 500 16px var(--font); color: var(--ink); background: var(--bg);
}
input.field:focus { outline: none; border-color: var(--ink); }

.site-foot { border-top: 1px solid var(--line); margin-top: 24px; padding: 20px; text-align: center; font-size: 13px; color: var(--faint); }
.site-foot a { color: var(--faint); text-decoration: underline; }

/* the bottom legal bar and the finish-setup bar sit above the tab bar on phones */
@media (max-width: 768px) {
  .shell [data-legal-banner], .shell [data-finish-setup] { bottom: calc(76px + env(safe-area-inset-bottom)) !important; }
}

@media (prefers-reduced-motion: reduce) {
  .shell * { transition: none !important; animation: none !important; }
}

/* older pages moved onto the theme (tools_theme_convert.py): they clear the desktop nav with their own
   top padding and expect an in-flow nav on phones, as the old nav.css did */
body.shell.legacy { padding-top: 0; }
@media (max-width: 768px) {
  body.shell.legacy { padding-top: 0 !important; }
  .shell.legacy .top-nav { position: sticky; }
}
