/* Finance Analyzer — light/dark theme via data-theme on <html> */
:root, :root[data-theme="light"] {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11,11,11,0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --good: #006300;
  --bad: #d03b3b;
  --warn-bg: #fff7e0;
  --notice-bg: #eef4fc;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4;
  --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  /* Accent and red as FILLS behind --accent-ink text. In light they are the same colour
     as the text/border token, so nothing changes; dark has to darken them, see below. */
  --accent-fill: var(--accent);
  --bad-fill: var(--bad);
  /* Depth. A dark theme cannot borrow the light theme's black shadows — black on black
     is nothing at all — so every elevation and edge cue is a token, not a literal. */
  --shadow: rgba(0,0,0,0.14);
  --shadow-strong: rgba(0,0,0,0.25);
  --edge-shadow: rgba(0,0,0,0.18);
  --backdrop: rgba(0,0,0,0.45);
  --dim: 0.35;               /* "locked"/unearned items */
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255,255,255,0.10);
  --accent: #3987e5;
  --accent-ink: #ffffff;
  --good: #0ca30c;
  --bad: #e66767;
  --warn-bg: #33290e;
  --notice-bg: #142236;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
  --s6: #008300; --s7: #9085e9; --s8: #e66767;
  /* The dark palette lightens --accent and --bad so they read as links and figures on a
     black page — but that same lift drops white text on top of them to 3.6:1 and 3.3:1.
     Fills get their own, deeper shade (5.1:1 and 5.3:1) so a button label, an active nav
     pill and an unread badge stay legible; the lighter tokens keep serving text. */
  --accent-fill: #2f6fc4;
  --bad-fill: #c33a33;
  /* Light-source shadows are invisible here. Elevation gets a deeper black (there is
     still enough surface lightness under a card for it to register), and the horizontal
     scroll cue on a table flips to a faint white edge — a black one simply vanished. */
  --shadow: rgba(0,0,0,0.55);
  --shadow-strong: rgba(0,0,0,0.7);
  --edge-shadow: rgba(255,255,255,0.16);
  --backdrop: rgba(0,0,0,0.7);
  --dim: 0.5;                /* 0.35 white on #1a1a19 is 1.8:1 — unreadable, not merely dim */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/*
 * Page width.
 *
 * Every page now takes the full screen (2026-07-31, user-requested). Dashboard,
 * suggestions, portfolio, messages and the asset page used to stop at 1200px to keep a
 * comfortable reading measure; the data-dense pages already took the screen, and the
 * split meant the content rail jumped width as you moved between them.
 *
 * --page-max stays a separate variable from --shell-max even though they now resolve to
 * the same thing: --shell-max is the topbar and broadcast banner and must be CONSTANT
 * (a sticky header that changes width between pages makes the logo jump sideways, which
 * reads as a bug), while --page-max is the content rail a page could still narrow.
 *
 * The 2100px ceiling is what stops an ultrawide spreading eight columns over a metre of
 * glass — and keeps the content aligned with the topbar, which shares it.
 */
:root { --shell-max: min(2100px, 100%); --page-max: var(--shell-max); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 14px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
code { background: var(--grid); padding: 1px 5px; border-radius: 4px; font-size: 0.85em; }

/* topbar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: var(--shell-max); margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 10px 16px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--ink); font-size: 1.05rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar nav a { padding: 6px 11px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.topbar nav a:hover { background: var(--grid); text-decoration: none; }
.topbar nav a.active { background: var(--accent-fill); color: var(--accent-ink); }
.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-email { color: var(--muted); font-size: 0.85rem; }
/* Available cash, present on every page. Deliberately understated — it is reference
   information, not a call to action, so it must not compete with the nav. The tint is
   mixed from --accent rather than being a literal rgba, so it follows the theme
   (a fixed translucent black disappears on the dark palette). */
.cash-chip {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 3px 10px; border-radius: 999px; font-size: 0.9rem; font-weight: 600;
  color: var(--ink); opacity: 0.62;
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  font-variant-numeric: tabular-nums;   /* the digits must not jitter as it updates */
  transition: opacity 0.15s ease;
}
.cash-chip:hover { opacity: 1; }
.nav-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; color: var(--ink); font-size: 1.1rem; padding: 4px 10px; cursor: pointer; }

/* layout */
.app-main { max-width: var(--page-max); width: 100%; margin: 0 auto; padding: 20px 16px 40px; flex: 1; }
.auth-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.narrow-card { max-width: 560px; }
.muted { color: var(--muted); font-size: 0.9rem; }
.pre-wrap { white-space: pre-wrap; }
.back-link { display: inline-block; margin-bottom: 8px; }

/* stat tiles */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { text-align: left; }
.stat-label { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 1.45rem; font-weight: 700; margin-top: 2px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; cursor: default; }
th[data-sort] { cursor: pointer; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: color-mix(in srgb, var(--grid) 45%, transparent); }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.risk-badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 0.78rem; border: 1px solid var(--border); }
.type-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }

/* forms — one control height everywhere so rows always align */
:root { --ctl-h: 40px; --ctl-h-sm: 30px; }
form label { display: block; margin-bottom: 14px; font-weight: 500; font-size: 0.9rem; }
input, select, textarea {
  width: 100%; padding: 0 12px; margin-top: 6px;
  border: 1px solid var(--baseline); border-radius: 8px;
  background: var(--page); color: var(--ink); font: inherit; font-size: 0.95rem;
  box-sizing: border-box;
}
input, select { height: var(--ctl-h); }
textarea { padding: 8px 12px; min-height: 64px; resize: vertical; }
select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  padding-right: 34px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23898781' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: var(--ctl-h); padding: 0 16px; gap: 6px;
  border-radius: 8px; border: 1px solid var(--baseline);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 0.95rem;
  font-weight: 600; cursor: pointer; white-space: nowrap; box-sizing: border-box;
}
.btn:hover { background: var(--grid); text-decoration: none; }
.btn-primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent-fill); }
.btn-sm { height: var(--ctl-h-sm); padding: 0 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: var(--ctl-h-sm); min-width: var(--ctl-h-sm); padding: 0 8px;
  background: none; border: 1px solid var(--border); border-radius: 8px;
  font-size: 1rem; cursor: pointer; box-sizing: border-box;
}
.form-error { color: var(--bad); font-size: 0.88rem; min-height: 1.2em; margin-bottom: 8px; }
.saved-note { color: var(--good); margin-left: 10px; font-weight: 600; }
.filter-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.filter-row input[type="search"] { width: 260px; max-width: 100%; margin: 0; }
.filter-row select { width: 180px; max-width: 100%; margin: 0; }
.topbar-note {
  position: absolute; z-index: 60; padding: 5px 10px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--ink-2); font-size: 0.8rem; white-space: nowrap; pointer-events: none;
}
.msg-contact-blocked .msg-contact-name { color: var(--muted); }
.appeal-box { margin-top: 14px; text-align: left; }
.appeal-box textarea { width: 100%; margin: 8px 0 0; resize: vertical; }
.appeal-box .muted { margin: 4px 0 0; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 12px; }
.pager:empty { display: none; }
.pager-ctl { display: flex; gap: 8px; align-items: center; }
.pager-ctl select { width: 74px; margin: 0; height: var(--ctl-h-sm); padding: 0 8px; font-size: 0.85rem; }
.pager-ctl .btn[disabled] { opacity: 0.45; cursor: default; }
.settings-inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.settings-inline label { margin: 0; flex: 0 1 auto; }
.settings-inline input, .settings-inline select { width: 160px; margin-top: 6px; }
.settings-inline input[type="number"] { width: 120px; }
@media (max-width: 720px) {
  .settings-inline { align-items: stretch; flex-direction: column; }
  .settings-inline label, .settings-inline input, .settings-inline select, .settings-inline .btn,
  .settings-inline input[type="number"] { width: 100%; }
  .filter-row input[type="search"], .filter-row select { width: 100%; }
  .filter-row .btn { width: 100%; }
}

/* broadcast banner */
.broadcast { background: var(--warn-bg); border-bottom: 1px solid var(--border); }
.broadcast-inner {
  max-width: var(--shell-max); margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: flex-start; gap: 10px; font-size: 0.95rem;
}
.broadcast-inner .pre-wrap { flex: 1; }

/* achievements */
.ach-row { display: flex; flex-wrap: wrap; gap: 8px; }
.ach {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border);
  font-size: 0.9rem; font-weight: 600;
}
.ach-on { background: color-mix(in srgb, var(--accent) 12%, transparent); border-color: var(--accent); }
.ach-off { opacity: var(--dim); filter: grayscale(1); }
.ach-mini { font-size: 0.95rem; letter-spacing: 2px; }

/* instant tooltips */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--page);
  padding: 4px 10px; border-radius: 6px;
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
  z-index: 200; pointer-events: none;
}
[data-tip]:hover::before, [data-tip]:focus-visible::before {
  content: ''; position: absolute; bottom: calc(100% + 2px); left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--ink);
  z-index: 200; pointer-events: none;
}

/* abbreviations with an explanation ("SMA 50", "P/L", "VIX") */
.abbr { border-bottom: 1px dotted currentColor; cursor: help; }
.abbr:focus { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
/* the base [data-tip] is a one-line label; an explanation is a sentence, and it must
   also open on plain :focus, because a tap on a phone never produces :focus-visible */
.abbr:hover::after, .abbr:focus::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--page);
  padding: 7px 11px; border-radius: 6px; z-index: 200; pointer-events: none;
  white-space: normal; width: 250px; max-width: 70vw;
  font-size: 0.76rem; font-weight: 500; line-height: 1.45; text-align: left;
  text-transform: none; letter-spacing: normal;
}
.abbr:hover::before, .abbr:focus::before {
  content: ''; position: absolute; bottom: calc(100% + 2px); left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--ink); z-index: 200; pointer-events: none;
}
/* .table-wrap scrolls, so it clips anything above the header row — drop the tooltip
   below instead, where it lands over the table body and stays inside the box */
.table-wrap .abbr:hover::after, .table-wrap .abbr:focus::after { top: calc(100% + 7px); bottom: auto; }
.table-wrap .abbr:hover::before, .table-wrap .abbr:focus::before {
  top: calc(100% + 2px); bottom: auto;
  border-top-color: transparent; border-bottom-color: var(--ink);
}

/* compact icon actions in table rows */
.row-actions { flex-wrap: nowrap; }
.row-actions .btn-sm { padding: 0 7px; min-width: 30px; font-size: 0.95rem; }

/* messenger */
.badge {
  display: inline-block; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px;
  border-radius: 9px; background: var(--bad-fill); color: #fff;
  font-size: 0.72rem; font-weight: 700; line-height: 18px; text-align: center; vertical-align: 2px;
}
/* full-height messenger: the thread fills the viewport instead of a fixed slice of it */
body.page-messages { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
body.page-messages .app-main { display: flex; flex-direction: column; min-height: 0; padding-bottom: 20px; }
body.page-messages .msg-layout { flex: 1; min-height: 0; margin-bottom: 0; }
body.page-messages .msg-list { min-height: 0; }
.msg-layout { display: grid; grid-template-columns: 280px 1fr; gap: 0; padding: 0; overflow: hidden; }
.msg-contacts { border-right: 1px solid var(--grid); min-height: 0; overflow-y: auto; }
.msg-contact {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 14px; border: none; border-bottom: 1px solid var(--grid);
  background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.msg-contact:hover { background: color-mix(in srgb, var(--grid) 45%, transparent); }
.msg-contact.active { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.msg-contact-info { min-width: 0; flex: 1; }
.msg-contact-name { font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
.msg-contact-last { color: var(--muted); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-thread { display: flex; flex-direction: column; min-height: 0; }
.msg-thread-head { padding: 12px 16px; border-bottom: 1px solid var(--grid); display: flex; align-items: center; gap: 10px; font-weight: 600; }
.msg-list { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; min-height: 240px; }
.msg-bubble {
  /* the thread is now full-screen wide, and 75% of an ultrawide is a 1300px line of chat.
     A bubble is prose, so it keeps a readable measure once the percentage overtakes it. */
  max-width: min(75%, 620px); padding: 8px 12px; border-radius: 14px;
  font-size: 0.95rem; white-space: pre-wrap; word-break: break-word;
}
.msg-mine { align-self: flex-end; background: var(--accent-fill); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg-their { align-self: flex-start; background: var(--grid); border-bottom-left-radius: 4px; }
.msg-time { display: block; font-size: 0.68rem; opacity: 0.7; margin-top: 3px; }
.msg-form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--grid); }
.msg-form input { margin: 0; flex: 1; }
@media (max-width: 720px) {
  /* mobile messenger: minimized avatar rail on the left, no page title (see full-height rules above) */
  body.page-messages .app-main { padding: 8px; }
  body.page-messages h1 { display: none; }
  .msg-layout { grid-template-columns: 80px 1fr; }
  .msg-contact { position: relative; flex-direction: column; gap: 4px; padding: 10px 4px; }
  .msg-contact .avatar { width: 46px; height: 46px; font-size: 1.3rem; }
  .msg-contact-info { width: 100%; flex: none; }
  .msg-contact-name { display: block; font-size: 0.68rem; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .msg-contact-name .badge { display: none; }
  .msg-contact-last { display: none; }
  .msg-contact[data-unread]::after {
    content: attr(data-unread); position: absolute; top: 5px; right: 7px;
    min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
    background: var(--bad-fill); color: #fff;
    font-size: 0.66rem; font-weight: 700; line-height: 16px; text-align: center;
  }
  .msg-list { padding: 10px; }
  .msg-bubble { max-width: 85%; }
  .msg-form { padding: 8px 10px; }
  .msg-form input { font-size: 16px; }

  /* competition leaderboard as stacked cards */
  #compTable, #compTable tbody { display: block; }
  #compTable thead { display: none; }
  #compTable tr {
    display: grid; grid-template-columns: 38px 1fr 1fr 1fr; gap: 2px 10px;
    padding: 10px 2px; border-bottom: 1px solid var(--grid);
  }
  #compTable tr:last-child { border-bottom: none; }
  #compTable td { display: block; border: none; padding: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  #compTable .c-rank { grid-column: 1; grid-row: 1 / span 2; align-self: center; font-size: 1.35rem; text-align: center; }
  #compTable .c-name { grid-column: 2 / 4; grid-row: 1; align-self: center; }
  #compTable .c-ret { grid-column: 4; grid-row: 1; align-self: center; text-align: right; font-size: 1.05rem; }
  #compTable .c-ach { grid-column: 2 / 5; grid-row: 2; font-size: 0.95rem; }
  #compTable .c-total, #compTable .c-real, #compTable .c-unreal {
    grid-row: 3; text-align: left; font-size: 0.82rem; margin-top: 4px;
  }
  #compTable .c-total { grid-column: 2; }
  #compTable .c-real { grid-column: 3; }
  #compTable .c-unreal { grid-column: 4; }
  #compTable .c-total::before, #compTable .c-real::before, #compTable .c-unreal::before {
    content: attr(data-label); display: block; color: var(--muted); font-size: 0.68rem;
    text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
}

/* avatars & user chip */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; overflow: hidden;
  background: var(--accent-fill); color: var(--accent-ink);
  font-size: 0.85rem; font-weight: 700; flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-lg { width: 72px; height: 72px; font-size: 1.8rem; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.user-chip:hover { text-decoration: none; color: var(--ink); }
.profile-avatar-row { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }

/* language switcher */
.lang-switch { display: inline-flex; gap: 2px; align-items: center; font-size: 0.8rem; }
.lang-switch a, .lang-switch .lang-cur { padding: 3px 6px; border-radius: 6px; font-weight: 600; }
.lang-switch a { color: var(--muted); }
.lang-switch a:hover { background: var(--grid); text-decoration: none; }
.lang-switch .lang-cur { background: var(--accent-fill); color: var(--accent-ink); }

/* google auth */
.btn-google { gap: 10px; margin-bottom: 4px; }
.btn-google:hover { text-decoration: none; }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--muted); font-size: 0.85rem; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; border-top: 1px solid var(--grid); }
.notice-ok { border-color: var(--good); }

/* ---------- beginner guide ---------- */
/* The one page on the platform that is pure prose. Every other page benefits from the
   full screen; a paragraph set 2000px wide does not — the eye loses the start of the
   next line. So the PAGE stays full width and the two columns inside it are centred:
   a sticky contents list, and a body capped at a readable measure. */
.guide-layout {
  display: grid; grid-template-columns: 250px minmax(0, 78ch);
  gap: 24px; align-items: start; justify-content: center;
}
.guide-toc { position: sticky; top: 78px; margin-bottom: 0; }
.guide-toc h2 { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.guide-toc ol { margin: 0; padding-left: 20px; }
.guide-toc li { margin-bottom: 7px; font-size: 0.9rem; line-height: 1.35; }
.guide-lede { font-size: 1.05rem; line-height: 1.6; margin-bottom: 0; }
.guide-sec { scroll-margin-top: 78px; }   /* the topbar is sticky — an anchor lands under it */
.guide-sec h2 { font-size: 1.2rem; margin-bottom: 12px; }
.guide-sec p, .guide-sec li { line-height: 1.65; }
.guide-sec p { margin: 0 0 14px; }
.guide-sec p:last-child { margin-bottom: 0; }
.guide-sec ul { margin: 0 0 14px; padding-left: 22px; }
.guide-sec ul:last-child { margin-bottom: 0; }
.guide-sec li { margin-bottom: 10px; }
.guide-sec li:last-child { margin-bottom: 0; }
.guide-end { margin-top: 18px; }
@media (max-width: 1000px) {
  /* no room for a side rail — the contents list becomes the first thing on the page */
  .guide-layout { grid-template-columns: minmax(0, 1fr); }
  .guide-toc { position: static; margin-bottom: 16px; }
}

/* theme toggle — the glyph is the ACTION, and it comes from CSS rather than the markup so
   it is already right at first paint. The inline head script sets data-theme before the
   page draws, but app.js only runs at the end of <body>: a glyph set from JS would flash
   the wrong one on every single page load. app.js still owns the title/aria-label. */
#themeToggle::after, #themeToggleM::after { content: '🌙'; }
:root[data-theme="dark"] #themeToggle::after,
:root[data-theme="dark"] #themeToggleM::after { content: '☀️'; }

/* auth */
.auth-card { width: 100%; max-width: 380px; position: relative; padding: 26px 26px 18px; }
.auth-card h1 { text-align: center; }
.auth-links { text-align: center; font-size: 0.9rem; }
.theme-corner { position: absolute; top: 12px; right: 12px; }

/* charts */
.chart-box { position: relative; height: 260px; }
.chart-tall { height: 340px; }
.spark-cell canvas { width: 110px; height: 30px; }

/* suggestions */
.sug-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.sug-card { border-left: 4px solid var(--accent); }
.sug-card.sug-sell { border-left-color: var(--bad); }
.sug-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sug-action { font-weight: 700; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.05em; }
.sug-block { margin: 8px 0; font-size: 0.9rem; }
.sug-block strong { display: block; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 2px; }
.sug-actions { display: flex; gap: 8px; margin-top: 10px; }
.sug-status { font-size: 0.8rem; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--border); }

/* suggestion metric chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  border: 1px solid var(--border); font-size: 0.78rem; font-weight: 600;
  background: color-mix(in srgb, var(--grid) 40%, transparent);
}
.chip.pos { color: var(--good); }
.chip.neg { color: var(--bad); }
.chip-risk-low { color: var(--good); border-color: var(--good); }
.chip-risk-medium { color: var(--s4); border-color: var(--s4); }
.chip-risk-high, .chip-risk-very_high { color: var(--bad); border-color: var(--bad); }

/* geopolitical effect block on a suggestion */
.sug-geo {
  border-left: 3px solid var(--accent); padding: 6px 0 6px 10px;
  background: color-mix(in srgb, var(--grid) 25%, transparent); border-radius: 0 8px 8px 0;
}
.sug-geo .chip { margin-right: 6px; }
.geo-news { list-style: none; margin: 6px 0 0; padding: 0; }
.geo-news li { padding: 4px 0; font-size: 0.86rem; line-height: 1.45; }

/* news list */
.news-list { list-style: none; margin: 0; padding: 0; }
.news-list li { padding: 8px 0; border-bottom: 1px solid var(--grid); font-size: 0.92rem; line-height: 1.5; }
.news-list li:last-child { border-bottom: none; }
.chip-topic { font-size: 0.72rem; padding: 1px 8px; vertical-align: 1px; color: var(--accent); border-color: var(--accent); }

/* dialogs & notices */
/* max-height matters: a <dialog> taller than the viewport is centred, so it clips at
   the TOP — the heading and first field scroll out of reach with no way back */
.dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--ink); padding: 20px; max-width: 420px; width: 92vw; max-height: 88vh; overflow-y: auto; box-shadow: 0 18px 50px var(--shadow-strong); }
.help-dialog { max-width: 520px; }
.close-info { margin: 12px 0; }
.close-line { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--grid); font-size: 0.95rem; }
.close-line:last-child { border-bottom: none; }
.close-line span { color: var(--muted); }
.help-steps { padding-left: 20px; margin: 12px 0; }
.help-steps li { margin-bottom: 8px; font-size: 0.95rem; }
.dialog::backdrop { background: var(--backdrop); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.notice { background: var(--notice-bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin: 10px 0; font-size: 0.92rem; word-break: break-all; }
.notice-warn { background: var(--warn-bg); word-break: normal; }
/* width:100% is load-bearing — body is a column flexbox, and an `auto` cross-axis
   margin cancels the stretch, so without it the footer shrinks to fit its own text */
.disclaimer { max-width: var(--page-max); width: 100%; margin: 0 auto; padding: 14px 16px 22px; color: var(--muted); font-size: 0.82rem; }
.range-btns .btn.active { background: var(--accent-fill); color: var(--accent-ink); border-color: var(--accent-fill); }
/* a deal book has ten columns — it needs more than the 420px a confirm dialog wants */
/* Profile settings cards laid out across the page instead of one tall column.
   auto-fill + minmax means the column count follows the window with no breakpoints:
   one column on a phone, four or more on a wide monitor. align-items:start keeps a
   short card short rather than stretching it to match its tallest neighbour. */
/* Three columns, each an independent vertical stack: a card sits directly under the
   one above it, so a short card leaves no gap. A plain grid of cards would align them
   into ROWS and every row would be as tall as its tallest card. */
.profile-grid { display: grid; align-items: start; gap: 16px; grid-template-columns: repeat(3, 1fr); }
.profile-col { display: flex; flex-direction: column; gap: 16px; min-height: 40px; }
/* inside a column the width is already set, so the 560px cap would only leave a gap */
.profile-grid .card { max-width: none; margin-bottom: 0; position: relative; }
@media (max-width: 1100px) { .profile-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px)  { .profile-grid { grid-template-columns: 1fr; } }

/* drag to rearrange: a small filled tab in the card's top-left corner. The card gains
   a left gutter so the handle never sits on top of a heading or the avatar row. */
.profile-grid .card { padding-left: 36px; }
.card-drag {
  position: absolute; top: 10px; left: 9px; z-index: 2;
  width: 20px; height: 20px; padding: 0; border: 0; border-radius: 7px;
  background: var(--grid); color: var(--muted);
  font-size: 0.72rem; line-height: 20px; text-align: center;
  cursor: grab; transition: background 0.12s, color 0.12s;
}
.card:hover .card-drag, .card-drag:focus-visible { background: var(--accent-fill); color: var(--accent-ink); }
.card-drag:active { cursor: grabbing; }
.card-dragging { opacity: 0.4; }
/* where the card would land */
.card-drop-marker {
  border: 2px dashed var(--accent); border-radius: 12px; min-height: 48px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
/* no drag target on touch — and with the handle gone the gutter it needed is just
   36px of wasted width on the narrowest screens */
@media (max-width: 720px) {
  .card-drag { display: none; }
  .profile-grid .card { padding-left: 18px; }
}

/* two form fields to a row; .form-span makes a child (a hint line) take the full width.
   Collapses to one column on narrow screens, where half a dialog is too tight to type in */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid > .form-span { grid-column: 1 / -1; margin-top: -6px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* searchable asset picker: an input over the real <select>, which stays the form value */
.combo { position: relative; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 300;
  max-height: 280px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--baseline); border-radius: 8px;
  box-shadow: 0 8px 24px var(--shadow-strong);
}
.combo-item { display: flex; align-items: baseline; gap: 8px; padding: 7px 11px; cursor: pointer; font-size: 0.9rem; }
.combo-item:hover, .combo-item.active { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.combo-sym { font-weight: 700; min-width: 74px; }
.combo-name { color: var(--ink-2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-meta { color: var(--muted); font-size: 0.82rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.combo-empty { padding: 10px 11px; color: var(--muted); font-size: 0.9rem; }
/* the select stays reachable as a fallback, just visually secondary */
#dealAsset { margin-top: 8px; font-size: 0.85rem; }

/* a form whose longest control is an asset picker needs more than confirm-dialog width */
.dialog-form { max-width: 620px; }
/* optgroup headers are the scan targets in a 100-item list — make them read as headers */
.asset-select optgroup { font-weight: 700; font-style: normal; color: var(--muted); }
.asset-select option { font-weight: 400; color: var(--ink); }
.dialog-wide { max-width: 1080px; }
.dialog-wide .table-wrap { max-height: 55vh; overflow-y: auto; }

/* notification preferences */
.pref-set { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px 14px; margin: 0 0 14px; }
.pref-set legend { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 0 6px; }
.pref-row { display: flex; align-items: center; gap: 10px; margin: 0; padding: 5px 0; cursor: pointer; }
.pref-row input[type="checkbox"] { width: 20px; height: 20px; margin: 0; flex: none; }
.pref-row span { font-size: 0.94rem; }

/* indicator toggles above the asset chart */
.chart-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-bottom: 10px; }
.cmp-label { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 0.94rem; }
.cmp-label select { width: 220px; max-width: 45vw; margin: 0; height: var(--ctl-h-sm); padding: 0 8px; font-size: 0.85rem; }
.chart-short { height: 160px; }

/* 24-hour time picker: one dropdown per field, each option a whole "HH:MM" */
.time-select { width: auto; min-width: 104px; margin-top: 6px; font-variant-numeric: tabular-nums; }

/* secondary figure under a table number (e.g. % move under a position's value) */
.cell-sub { display: block; font-size: 0.76rem; font-weight: 600; opacity: 0.85; }

/* status as a colour, not a repeated word down the whole column */
.status-dot {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  vertical-align: -2px; position: relative;
}
.status-dot.is-open { background: var(--good); }
.status-dot.is-closed { background: var(--muted); }
.col-status { white-space: nowrap; }
/* the word is still in the DOM for screen readers — the dot alone is not a label */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* journal tags */
.chip-tag { font-size: 0.72rem; padding: 1px 8px; vertical-align: 1px; color: var(--ink-2); }

/* responsive */
@media (max-width: 900px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
.nav-mobile-extra { display: none; }
.nav-mobile-only { display: none !important; }

@media (max-width: 1400px) {
  .topbar-right .user-email { display: none; } /* avatar alone is enough at mid widths */
}

/* "More" dropdown in the desktop nav */
.nav-more { position: relative; }
.nav-more-btn {
  padding: 6px 11px; border: none; border-radius: 8px; background: none;
  color: var(--ink-2); font: inherit; font-weight: 500; cursor: pointer;
}
.nav-more-btn:hover { background: var(--grid); }
.nav-more.has-active .nav-more-btn { background: var(--accent-fill); color: var(--accent-ink); }
.nav-drop {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 80;
  flex-direction: column; min-width: 180px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px var(--shadow);
}
.nav-more.open .nav-drop { display: flex; }
.nav-drop a { padding: 9px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.nav-drop a:hover { background: var(--grid); text-decoration: none; }
.nav-drop a.active { background: var(--accent-fill); color: var(--accent-ink); }
.icon-btn { position: relative; text-decoration: none; }
.icon-btn:hover { text-decoration: none; }
.icon-btn .badge { position: absolute; top: -7px; right: -8px; margin: 0; }
.icon-active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }

@media (max-width: 720px) {
  .nav-toggle { display: block; order: 3; margin-left: auto; }
  .topbar-right { display: none; }               /* everything moves under the hamburger */
  .topbar nav { display: none; flex-basis: 100%; flex-direction: column; order: 4; }
  .topbar nav.open { display: flex; }
  .topbar nav a { padding: 11px 12px; }          /* touch-friendly targets */
  .nav-mobile-only { display: block !important; } /* Messages/Admin as plain links in the hamburger */
  .nav-more-btn { display: none; }                /* dropdown becomes flat links */
  .nav-drop { display: flex !important; position: static; border: none; box-shadow: none; background: none; padding: 0; }
  .nav-drop a { padding: 11px 12px; }
  .nav-mobile-extra {
    display: flex; flex-direction: column; gap: 12px;
    padding: 12px 12px 6px; margin-top: 6px; border-top: 1px solid var(--grid);
  }
  .nav-mobile-extra .user-chip { display: inline-flex; }
  .nav-mobile-extra .user-email { display: inline; overflow: hidden; text-overflow: ellipsis; }
  .nav-mobile-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
  /* the chip stays out in the header on phones — it is the one number worth seeing
     without opening the menu — but it gives up the gap the brand does not need */
  .topbar-inner { gap: 10px; }
  .cash-chip { font-size: 0.85rem; padding: 3px 8px; }
  .stat-value { font-size: 1.15rem; }
  .chart-box { height: 220px; }
}

/* ---------- touch ergonomics (phones) ---------- */
@media (max-width: 720px) {
  /* iOS Safari zooms the page whenever a focused field is under 16px */
  input, select, textarea { font-size: 16px; }
  /* comfortable hit areas — visual size mostly unchanged, the target grows */
  :root { --ctl-h-sm: 36px; }
  .btn-sm { padding: 0 14px; }
  .icon-btn { min-width: 40px; height: 40px; font-size: 1.15rem; }
  .nav-toggle { min-width: 44px; min-height: 44px; font-size: 1.25rem; }
  .lang-switch { display: inline-flex; gap: 2px; }
  .lang-switch a, .lang-switch .lang-cur {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 40px; min-height: 40px; border-radius: 8px;
  }
  th, td { padding: 10px; }
  /* long unbreakable strings (cron lines, URLs) must not scroll the page sideways */
  code { overflow-wrap: anywhere; word-break: break-word; }
}

/* ---------- wide tables become cards on phones ---------- */
/* .rt is applied by app.js only to tables that do not fit the screen. */
@media (max-width: 720px) {
  table.rt thead { display: none; }
  table.rt, table.rt tbody, table.rt tr, table.rt td { display: block; width: 100%; }
  table.rt tr {
    border: 1px solid var(--border); border-radius: 10px;
    padding: 4px 10px; margin-bottom: 10px;
    background: color-mix(in srgb, var(--grid) 22%, transparent);
  }
  table.rt tr:hover { background: color-mix(in srgb, var(--grid) 22%, transparent); }
  table.rt td {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    border: none; padding: 6px 0; white-space: normal; text-align: right;
  }
  table.rt td + td { border-top: 1px solid var(--grid); }
  table.rt td::before {
    content: attr(data-label); flex: 0 0 42%; text-align: left;
    color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.03em;
  }
  table.rt td:empty { display: none; }
  table.rt .btn-group { justify-content: flex-end; }
}
/* scroll hint for tables that stay scrollable */
.table-wrap {
  background:
    linear-gradient(to right, var(--surface) 30%, transparent) left center / 24px 100% no-repeat,
    linear-gradient(to left, var(--surface) 30%, transparent) right center / 24px 100% no-repeat,
    radial-gradient(farthest-side at 0 50%, var(--edge-shadow), transparent) left center / 12px 100% no-repeat,
    radial-gradient(farthest-side at 100% 50%, var(--edge-shadow), transparent) right center / 12px 100% no-repeat;
  background-attachment: local, local, scroll, scroll;
}

/* ---------- suggestion card: details collapse on phones ---------- */
.sug-more { border: none; padding: 0; margin: 0; }
.sug-more > summary { display: none; }
@media (max-width: 720px) {
  .sug-card { display: flex; flex-direction: column; }
  .sug-actions { order: 8; }
  .sug-more { order: 9; }
  .sug-more > summary {
    display: flex; align-items: center; gap: 6px; min-height: 40px;
    cursor: pointer; color: var(--accent); font-weight: 600; font-size: 0.9rem;
    list-style: none;
  }
  .sug-more > summary::-webkit-details-marker { display: none; }
  .sug-more > summary::after { content: '▾'; }
  .sug-more[open] > summary::after { content: '▴'; }
}

/* ---------- admin: collapsible sections on phones ---------- */
@media (max-width: 720px) {
  .card-collapsible > h2 {
    display: flex; align-items: center; justify-content: space-between;
    min-height: 44px; margin: 0; cursor: pointer;
  }
  .card-collapsible > h2::after { content: '▾'; color: var(--muted); font-size: 0.9rem; }
  .card-collapsible.collapsed > h2::after { content: '▸'; }
  .card-collapsible.collapsed > *:not(h2) { display: none !important; }
}
.code-copy { margin-left: 6px; vertical-align: middle; }
