/* TradeLog web — styles.
   Tokens are TradeLog's own (utils/styles.py LIGHT_TOKENS / DARK_TOKENS), so the new
   frontend keeps the app's identity: cool slate surfaces, ink text, one ledger-blue
   accent; green/red only for gain/loss and always paired with a sign or a word.
   Inter for interface text; JetBrains Mono only for figures (tabular, so ₹ columns line up).
   Light is the default (as in the Streamlit app); [data-theme=dark] switches.
   Breakpoints: ≤768 phone (top bar, drawer, bottom nav, cards) · 769–1023 tablet · ≥1024 desktop. */

@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url(../fonts/inter-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url(../fonts/inter-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url(../fonts/inter-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url(../fonts/inter-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url(../fonts/jetbrains-mono-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-display: swap; src: url(../fonts/jetbrains-mono-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 600; font-display: swap; src: url(../fonts/jetbrains-mono-latin-600-normal.woff2) format("woff2"); }

:root {
  --bg: #F6F7F9; --bg2: #EFF1F5; --panel: #FFFFFF; --panel-hover: #EFF1F5; --side: #E8ECF2;
  --fg: #131A26; --fg2: #414D61; --muted: #5D6880; --line: #E3E6EC; --line2: #C9CFDA;
  --accent: #2456C4; --accent-bg: rgba(36, 86, 196, .09); --accent-bg2: rgba(36, 86, 196, .18); --on-accent: #FFFFFF;
  --gain: #0E7A46; --gain-bg: rgba(14, 122, 70, .10); --loss: #C22B2B; --loss-bg: rgba(194, 43, 43, .09);
  --warn: #935500; --warn-bg: rgba(147, 85, 0, .10);
  --ramp-1: #2456C4; --ramp-2: #4A75D6; --ramp-3: #7FA6F0; --ramp-4: #AFC7F5; --ramp-5: #DCE7FB;
  --font-sans: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;
  --r-sm: 6px; --r: 9px; --side-w: 248px; --gutter: 24px;
  color-scheme: light;
}
:root[data-theme=dark] {
  --bg: #0C1017; --bg2: #1B2330; --panel: #141A24; --panel-hover: #1B2330; --side: #101620;
  --fg: #E6EAF2; --fg2: #A9B4C6; --muted: #8A97AD; --line: #242E3D; --line2: #334054;
  --accent: #7FA6F0; --accent-bg: rgba(127, 166, 240, .13); --accent-bg2: rgba(127, 166, 240, .25); --on-accent: #0C1017;
  --gain: #3DD68C; --gain-bg: rgba(61, 214, 140, .12); --loss: #F26D6D; --loss-bg: rgba(242, 109, 109, .12);
  --warn: #E8A33D; --warn-bg: rgba(232, 163, 61, .13);
  --ramp-1: #7FA6F0; --ramp-2: #6288C9; --ramp-3: #4A6BA3; --ramp-4: #35507E; --ramp-5: #253A5C;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 400 14px/1.5 var(--font-sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
code { font-family: var(--font-mono); font-size: .92em; }
.num, .tbl td.n, .hero-value, .metric dd { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--panel); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
.minw0 { min-width: 0; } .grow { flex: 1; } .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.t-muted { color: var(--muted); } .t-gain { color: var(--gain); } .t-loss { color: var(--loss); } .t-warn { color: var(--warn); } .t-accent { color: var(--accent); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ───────────────────────────── shell */
.shell { min-height: 100vh; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
.maincol { min-width: 0; display: flex; flex-direction: column; }
main { padding: 4px var(--gutter) 48px; outline: none; }
.page { display: flex; flex-direction: column; gap: 16px; max-width: 1360px; }
.page.narrow { max-width: 460px; }

.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--side); border-right: 1px solid var(--line);
  padding: 16px 14px 14px; display: flex; flex-direction: column; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.brand .logo { width: 24px; height: 24px; color: var(--accent); }
.logo .ink { fill: var(--fg); opacity: .55; }
.brand .word { font-weight: 700; font-size: 18px; letter-spacing: -.03em; }
.brand .fy { margin-left: auto; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.search input { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line2); border-radius: var(--r-sm); background: var(--panel); }
.actions { display: grid; gap: 6px; }
.nav-groups { display: flex; flex-direction: column; gap: 10px; }
.nav-group h3 { font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 8px 3px; }
.nav { display: block; padding: 6px 10px; border-radius: var(--r-sm); color: var(--fg2); font-weight: 500; text-decoration: none; }
.nav:hover { background: var(--panel-hover); text-decoration: none; color: var(--fg); }
.nav.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.nav.tier1 { color: var(--fg); font-weight: 600; }
.nav.tier3 { font-size: 13.5px; }
.nav.tier4 { font-size: 13px; color: var(--muted); }
.nav-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.foot-btns { padding: 6px 2px 2px; }
.who { font-size: 12px; color: var(--muted); padding: 4px 8px 0; }

.mobilebar, .bottomnav, .scrim { display: none; }

/* strip, trust bar, banners */
.strip { margin: 8px var(--gutter) 0; font-size: 12.5px; color: var(--muted); }
.strip summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; color: var(--fg2); }
.strip summary::-webkit-details-marker { display: none; }
.strip ul { margin: 8px 0 0; padding: 10px 14px 10px 28px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); display: grid; gap: 6px; }
.strip li.critical b { color: var(--warn); }
.strip.ok { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.ok { background: var(--gain); } .dot.warn { background: var(--warn); } .dot.info { background: var(--accent); }
.trustbar { margin: 8px var(--gutter) 0; display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; padding: 6px 10px 6px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); font-size: 13px; color: var(--fg2); }
.tb-item + .tb-item::before { content: ""; display: inline-block; width: 1px; height: 12px; background: var(--line2); margin-right: 14px; vertical-align: -1px; }
.jobbanner { margin: 10px var(--gutter) 0; padding: 8px 12px; border-radius: var(--r); background: var(--accent-bg); color: var(--fg); font-size: 13px; display: flex; gap: 6px 18px; flex-wrap: wrap; }
.jobbanner .job { display: inline-flex; align-items: center; gap: 8px; }
.spin { width: 12px; height: 12px; border: 2px solid var(--accent-bg2); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.banners { display: grid; gap: 6px; margin: 10px var(--gutter) 0; }
.banner { padding: 10px 14px; border-radius: var(--r); font-size: 13.5px; }
.banner.err { background: var(--loss-bg); color: var(--fg); border: 1px solid var(--loss); }

/* page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 18px; }
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -.025em; line-height: 1.2; }
.page-head .sub { color: var(--muted); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 13px; color: var(--muted); padding-top: 14px; margin-bottom: -12px; }

/* panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; }
.panel-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 12px 16px 0; }
.panel-h h2 { font-size: 15px; font-weight: 600; }
.panel-aside { font-size: 12px; color: var(--muted); }
.panel-b { padding: 12px 16px 16px; }
.grid2 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .grid2 { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); } }

/* hero + metrics */
.hero { display: grid; gap: 14px 28px; grid-template-columns: minmax(0, 1fr); padding: 18px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
@media (min-width: 900px) { .hero { grid-template-columns: minmax(260px, auto) minmax(0, 1fr); align-items: center; } }
.hero-label { color: var(--muted); font-size: 13px; }
.hero-value { font-size: 34px; font-weight: 600; letter-spacing: -.03em; line-height: 1.15; margin: 2px 0; }
.hero-sub { font-size: 13.5px; color: var(--fg2); }
.hero-side, .metrics { margin: 0; display: grid; gap: 12px 20px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.hero-side > div, .metric { border-left: 2px solid var(--line); padding-left: 12px; min-width: 0; }
.hero-side dt, .metric dt { font-size: 12.5px; color: var(--muted); }
.hero-side dd, .metric dd { margin: 2px 0 0; font-size: 17px; font-weight: 600; white-space: nowrap; }
.note { font-size: 12px; color: var(--muted); }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--bg2); color: var(--fg2); }
.chip.gain { background: var(--gain-bg); color: var(--gain); } .chip.loss { background: var(--loss-bg); color: var(--loss); }
.chip.warn { background: var(--warn-bg); color: var(--warn); } .chip.accent { background: var(--accent-bg); color: var(--accent); }

/* buttons + forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line2); background: var(--panel); color: var(--fg); font-weight: 500; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--panel-hover); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.danger { background: var(--loss); border-color: var(--loss); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--fg2); }
.btn.ghost:hover { background: var(--panel-hover); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--fg2); }
.field input, .field select, .field textarea { height: 40px; padding: 0 12px; border: 1px solid var(--line2); border-radius: var(--r-sm); background: var(--panel); color: var(--fg); font-size: 14px; }
.check { display: flex; gap: 8px; align-items: center; }
.form { display: grid; gap: 14px; }
.form-err { color: var(--loss); font-size: 13.5px; min-height: 1em; }
.form-err ul { margin: 6px 0 0; padding-left: 18px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.filters .field { min-width: 160px; flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: var(--r-sm); overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 6px 12px; color: var(--fg2); }
.seg button.on { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.seg .cnt { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }

/* table */
.table-wrap { min-width: 0; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.tbl th button { all: unset; cursor: pointer; }
.tbl th button:focus-visible { outline: 2px solid var(--accent); }
.tbl th.n, .tbl td.n { text-align: right; }
.tbl td.ticker { font-weight: 600; }
.tbl tbody tr:hover td { background: var(--panel-hover); }
.tbl tr.group th { background: var(--bg2); color: var(--fg2); font-size: 12.5px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding-top: 10px; font-size: 13px; color: var(--muted); }
.cards { display: none; }
.card-row { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; background: var(--panel); }
.card-row header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.card-row dl { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.card-row dt { font-size: 12px; color: var(--muted); }
.card-row dd { margin: 0; font-weight: 500; }

/* states */
.skeleton { display: grid; gap: 10px; padding: 6px 0; }
.skeleton span { height: 12px; border-radius: 4px; background: linear-gradient(90deg, var(--bg2), var(--line), var(--bg2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { padding: 18px 4px; display: grid; gap: 10px; justify-items: start; color: var(--fg2); }
.notice { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); font-size: 13.5px; }
.notice.pending { border-color: var(--accent-bg2); background: var(--accent-bg); }
.notice.warn { border-color: var(--warn); background: var(--warn-bg); }
.notice.err { border-color: var(--loss); background: var(--loss-bg); }
.unavail { color: var(--muted); }
.unavail .why { margin-left: 6px; font-family: var(--font-sans); font-size: 12px; }
.plan { margin: 0; padding-left: 18px; display: grid; gap: 4px; color: var(--fg2); }
.checks, .actions { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checks li { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 4px 10px; align-items: baseline; }
.checks li > * { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 768px) { .checks li { grid-template-columns: auto minmax(0, 1fr); } .checks li > span { grid-column: 1 / -1; } }
.actions li p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.chart { width: 100%; }

/* settings tiles */
.tiles-group h2 { font-size: 16px; font-weight: 600; }
.tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); margin-top: 10px; }
.tile { display: grid; gap: 3px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); color: var(--fg); text-decoration: none; }
.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile span { color: var(--muted); font-size: 13px; }

/* dialog + toasts */
.dialog { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--fg); padding: 20px; max-width: min(460px, calc(100vw - 32px)); display: grid; gap: 12px; }
.dialog::backdrop { background: rgba(10, 14, 20, .45); }
.dialog h2 { font-size: 17px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--r); box-shadow: 0 6px 24px rgba(10, 14, 20, .14); font-size: 13.5px; }
.toast.success { border-left-color: var(--gain); } .toast.error { border-left-color: var(--loss); } .toast.warn { border-left-color: var(--warn); }
.toast p { color: var(--muted); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.toast .x { margin-left: auto; border: 0; background: transparent; font-size: 18px; line-height: 1; color: var(--muted); }

/* auth pages */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-wrap { width: 100%; max-width: 400px; display: grid; gap: 18px; }
.auth-wrap:has(.wide) { max-width: 520px; }
.auth-head { text-align: center; display: grid; justify-items: center; gap: 6px; }
.auth-head .logo { width: 64px; height: 64px; color: var(--accent); }
.auth-head h1 { font-size: 26px; letter-spacing: -.03em; }
.auth-head .tag { color: var(--muted); font-size: 13.5px; max-width: 46ch; }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px; display: grid; gap: 14px; }
.auth-card h2 { font-size: 15px; font-weight: 600; margin-top: 4px; }
.auth-card .hint, .hint { color: var(--muted); font-size: 13px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12px; }
.pw { display: flex; gap: 6px; }
.pw input { flex: 1; min-width: 0; }
.eye { border: 1px solid var(--line2); background: var(--panel); border-radius: var(--r-sm); padding: 0 10px; font-size: 12.5px; }
.rot { display: grid; gap: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }

/* ───────────────────────────── tablet */
@media (max-width: 1023px) and (min-width: 769px) {
  :root { --side-w: 210px; --gutter: 18px; }
  .hide-sm { display: none; }
}
/* ───────────────────────────── phone */
@media (max-width: 768px) {
  :root { --gutter: 14px; }
  .shell { grid-template-columns: minmax(0, 1fr); padding-bottom: 64px; }
  .mobilebar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; height: 52px; padding: 0 12px;
    background: var(--panel); border-bottom: 1px solid var(--line); }
  .mobilebar .title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobilebar .logo { width: 22px; height: 22px; color: var(--accent); }
  .ham { width: 44px; height: 44px; margin-left: -6px; border: 0; background: transparent; display: grid; place-content: center; gap: 4px; }
  .ham span { display: block; width: 18px; height: 2px; background: var(--fg); border-radius: 1px; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: min(86vw, 320px); transform: translateX(-102%); visibility: hidden;
    transition: transform .18s ease, visibility 0s linear .18s; box-shadow: 0 0 40px rgba(0, 0, 0, .25); }
  .sidebar.open { transform: none; visibility: visible; transition: transform .18s ease; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(10, 14, 20, .4); }
  .bottomnav { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: 60px;
    padding-bottom: env(safe-area-inset-bottom); background: var(--panel); border-top: 1px solid var(--line); }
  .bottomnav a, .bottomnav button { display: grid; place-items: center; align-content: center; gap: 1px; font-size: 11.5px; color: var(--fg2); border: 0; background: transparent; text-decoration: none; min-height: 44px; }
  .bottomnav span { font-size: 18px; line-height: 1; }
  .bottomnav a.active { color: var(--accent); font-weight: 600; }
  .page-head h1 { font-size: 22px; }
  .hero-value { font-size: 28px; }
  .hero-side, .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .hero-side dd, .metric dd { font-size: 14.5px; }
  .hero-side > div, .metric { padding-left: 10px; }
  .hide-sm { display: none; }
  .trustbar { font-size: 12.5px; gap: 4px 10px; }
  .tb-item + .tb-item::before { margin-right: 10px; }
  .btn { min-height: 40px; }
  .cards { display: grid; gap: 8px; }
  .scroll-x.has-cards { display: none; }
  .toasts { bottom: 72px; }
}

/* ═════════════════════════════ Phase 2: page kit (utils/ui.py counterparts) */
.sect { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: 4px; }
.sect-title { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.sect-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 10px 0 0; }
.divider span { flex: 1; height: 1px; background: var(--line2); }
.divider b { font-size: 11.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.divider.accent span { background: var(--accent); opacity: .55; }
.divider.accent b { color: var(--accent); }
.takeaway { border-left: 3px solid var(--line2); padding: 4px 0 4px 10px; font-size: 13px; color: var(--fg2); margin-top: 8px; }
.caption { font-size: 12.5px; color: var(--muted); }
.expander { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.expander > summary { cursor: pointer; padding: 10px 14px; font-weight: 500; font-size: 13.5px; color: var(--fg2); }
.expander[open] > summary { border-bottom: 1px solid var(--line); }
.expander-b { padding: 10px 14px 14px; display: grid; gap: 10px; }
.unavail-dash { color: var(--muted); }
.unavail-why { margin-left: 6px; font-family: var(--font-sans); font-size: 12px; color: var(--muted); }
.spark { width: 100%; height: 72px; display: block; color: var(--accent); }
.spark.gain { color: var(--gain); } .spark.loss { color: var(--loss); }
.allocbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.allocbars li { display: grid; grid-template-columns: minmax(70px, 34%) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.ab-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg2); }
.ab-track { height: 8px; border-radius: 4px; background: var(--bg2); overflow: hidden; }
.ab-fill { display: block; height: 100%; border-radius: 4px; }
.ab-v { min-width: 4.5em; text-align: right; }
.dot.err { background: var(--loss); } .dot.none { background: transparent; border: 1.5px solid var(--muted); }

/* tables: toolbar, show-more, row tones */
.tbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.tcount { font-size: 12.5px; color: var(--muted); }
.tsort select { height: 32px; border: 1px solid var(--line2); border-radius: var(--r-sm); background: var(--panel); padding: 0 8px; font-size: 13px; max-width: 46vw; }
.more { display: flex; justify-content: center; padding-top: 10px; }
.tbl tr.total-row td { font-weight: 700; border-top: 2px solid var(--line2); background: var(--bg2); }
.tbl tr.quiet-row td { color: var(--muted); }
.tbl td .t-gain, .tbl td.t-gain { color: var(--gain); } .tbl td .t-loss { color: var(--loss); }

/* mobile cards (row_cards) */
.mcards, .cards { display: grid; gap: 8px; }
.cards { display: none; }
.mcard { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; background: var(--panel); display: grid; gap: 6px; }
.mcard header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mcard-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow { display: flex; gap: 12px; border-top: 1px solid var(--line); padding-top: 6px; }
.mrow:first-of-type { border-top: 0; padding-top: 0; }
.mcell { flex: 1 1 0; display: flex; flex-direction: column; min-width: 0; }
.mcell:last-child { align-items: flex-end; text-align: right; }
.ml { font-size: 11.5px; color: var(--muted); }
.mv { font-size: 13.5px; font-weight: 500; }
.mrow.emph .mv { font-size: 15px; font-weight: 700; }

/* insight cards / workbench / trust line */
.ins-list { display: grid; gap: 8px; }
.ins-cat { font-size: 13px; color: var(--muted); margin-top: 6px; }
.ins { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--r); background: var(--panel); }
.ins.dot-err { border-left-color: var(--loss); } .ins.dot-warn { border-left-color: var(--warn); } .ins.dot-ok { border-left-color: var(--gain); }
.ins-body { flex: 1; min-width: 0; display: grid; gap: 3px; }
.ins-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.ins-prio { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ins-prio.high { color: var(--loss); } .ins-prio.medium { color: var(--warn); }
.ins-title { font-weight: 600; }
.ins-expl { font-size: 13px; color: var(--fg2); }
.ins-rec { font-size: 13px; color: var(--fg2); }
.ins-reclbl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-right: 4px; }
.ins-act { flex: none; }
.action-center { display: grid; gap: 12px; }
.trustline { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); font-size: 13.5px; }
.trustline > summary { cursor: pointer; padding: 9px 14px; display: flex; align-items: center; gap: 8px; color: var(--fg2); }
.trustline ul { list-style: none; margin: 0; padding: 4px 14px 6px; border-top: 1px solid var(--line); }
.trustline li { display: flex; gap: 8px; align-items: baseline; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 13px; overflow-wrap: anywhere; }
.trustline li .dot { flex: none; transform: translateY(-1px); }
.trustline > .caption { padding: 4px 14px 10px; }
.wb { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 8px; }
.wb-item { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--r); background: var(--panel); }
.wb-item.tone-err { border-left-color: var(--loss); } .wb-item.tone-warn { border-left-color: var(--warn); }
.wb-item > .minw0 { flex: 1; }
.wb-ev { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.ac-rows { display: grid; gap: 12px; } .ac-rows:empty { display: none; }
.acstrip { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.acs { display: inline-flex; gap: 5px; align-items: baseline; padding: 4px 10px; border: 1px solid var(--line); border-left-width: 3px; border-radius: var(--r); background: var(--panel); font-size: 13px; }
.acs b { font-size: 15px; }
.acs-err { border-left-color: var(--loss); } .acs-warn { border-left-color: var(--warn); } .acs-info { border-left-color: var(--accent); } .acs-risk { border-left-color: var(--muted); }
.acs-total { font-size: 12.5px; margin-left: auto; }
.acmore { width: 100%; justify-self: stretch; min-height: 40px; }
.calm { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13.5px; }
.calm span { color: var(--gain); font-size: 17px; }

/* dashboard */
.dash { gap: 14px; }
.heropanel { display: grid; gap: 16px 28px; grid-template-columns: minmax(0, 1fr); padding: 18px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
@media (min-width: 900px) { .heropanel { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: center; } }
.hp-label { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .07em; }
.hp-value { font-size: 34px; font-weight: 650; letter-spacing: -.03em; line-height: 1.15; margin: 2px 0; }
.hp-delta { font-size: 14px; font-weight: 600; }
.hp-line { font-size: 13.5px; color: var(--fg2); margin-top: 4px; }
.hp-chart { margin-top: 8px; }
.hp-metrics { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.hp-m { min-width: 0; border-left: 2px solid var(--line); padding-left: 12px; }
.hp-m dt { font-size: 12px; color: var(--muted); }
.hp-m dd { margin: 2px 0 0; font-size: 18px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hp-m .note { display: block; overflow-wrap: anywhere; }
.map-alloc { display: grid; gap: 16px 28px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) { .map-alloc { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
.map-alloc .sect { margin-bottom: 8px; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 11.5px; color: var(--muted); margin: 4px 2px 0; }
.map-legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.sw.loss { background: var(--loss); } .sw.gain { background: var(--gain); } .sw.mid { background: var(--line2); }
.map-legend .sep { opacity: .55; }
.quiet-rule { border-top: 1px solid var(--line); margin: 14px 0 0; }
.totline { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 2px 2px; border-top: 2px solid var(--line2); }
.btn.block { width: 100%; }
.dash.phone { gap: 10px; }
.mhead { display: flex; justify-content: space-between; align-items: baseline; padding-top: 10px; }
.mhead h1 { font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.mhead span { font-size: 12px; color: var(--muted); }
.mhero { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; }
.mh-l { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.mh-v { font-size: 30px; font-weight: 800; line-height: 1.15; margin: 1px 0 10px; }
.mh-stats { display: flex; gap: 10px; }
.ms { flex: 1; min-width: 0; }
.ms-l { font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.ms-v { font-size: 15.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-v .unavail .why { display: block; margin: 0; font-size: 10.5px; white-space: normal; }
.ms-s { font-size: 10.5px; color: var(--muted); overflow-wrap: anywhere; }
@media (max-width: 768px) {
  .hp-value { font-size: 28px; }
  .hp-m dd { font-size: 15px; }
  .ins, .wb-item { flex-wrap: wrap; }
  .ins-act, .wb-item .btn { width: 100%; }
  .sect { flex-wrap: wrap; }
}
@media (max-width: 768px) { .cards { display: grid; } .scroll-x.has-cards { display: none; } }
.mcards, .cards { grid-template-columns: minmax(0, 1fr); }
.mcard { min-width: 0; }
.mcard header > b { flex: 1; min-width: 0; }
.mcard header .chip { flex: none; }
.mcard { grid-template-columns: minmax(0, 1fr); }
.ms-v { white-space: normal; overflow-wrap: anywhere; font-size: 14.5px; }

/* positions */
.filters .filterlabel { align-self: center; font-size: 11.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.filters .grow2 { flex: 2; }
.filters .field input, .filters .field select { height: 36px; }
.scards { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.scard { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--muted); border-radius: 8px; padding: 9px 14px; min-width: 0; }
.scard.gain { border-left-color: var(--gain); } .scard.loss { border-left-color: var(--loss); }
.scard-l { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.scard-n { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scard-v { font-weight: 700; }
.tabpane { display: grid; gap: 12px; }
.section-sub { font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 6px; }
.section-sub.accent { color: var(--accent); text-transform: uppercase; letter-spacing: .08em; font-size: 11.5px; }
.grp { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; }
.grp-name { text-transform: uppercase; letter-spacing: .05em; color: var(--fg); }
.grp-meta { font-weight: 500; color: var(--muted); }
.grp-pnl { font-weight: 600; }
.tbl tr.tint-g1 td { background: color-mix(in srgb, var(--gain) 5%, transparent); }
.tbl tr.tint-g2 td { background: color-mix(in srgb, var(--gain) 7%, transparent); }
.tbl tr.tint-g3 td { background: color-mix(in srgb, var(--gain) 10%, transparent); }
.tbl tr.tint-l1 td { background: color-mix(in srgb, var(--loss) 5%, transparent); }
.tbl tr.tint-l2 td { background: color-mix(in srgb, var(--loss) 7%, transparent); }
.tbl tr.tint-l3 td { background: color-mix(in srgb, var(--loss) 10%, transparent); }
/* strongest tint level: a restrained left-edge accent keeps the signal the softer wash gives up */
.tbl tr.tint-g3 td:first-child { box-shadow: inset 3px 0 0 var(--gain); } .tbl tr.tint-l3 td:first-child { box-shadow: inset 3px 0 0 var(--loss); }
.mgroup { margin-top: 8px; padding: 8px 12px; background: var(--bg2); border-radius: 8px; border-left: 3px solid var(--gain); }
.mgroup.loss { border-left-color: var(--loss); }
.mgroup-n { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.mpos { display: grid; gap: 4px; }
.mpos .expander > summary { padding: 6px 12px; font-size: 12.5px; }
.mdetails { font-size: 13px; display: grid; gap: 2px; }
@media (max-width: 768px) { .filters .field { min-width: 0; flex: 1 1 100%; } }
@media (max-width: 480px) {
  .scards { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .scard { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; padding: 6px 12px; }
  .scard-l { grid-column: 1 / -1; }
}

/* symbol drill-down */
.dd { display: grid; gap: 12px; min-width: 0; }
.dd-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.dd-head.gain { border-color: color-mix(in srgb, var(--gain) 40%, var(--line)); } .dd-head.loss { border-color: color-mix(in srgb, var(--loss) 40%, var(--line)); }
.dd-sym { font-size: 24px; font-weight: 800; letter-spacing: -.02em; overflow-wrap: anywhere; }
.dd-total { text-align: right; }
.dd-pnl { font-size: 26px; font-weight: 800; }
.dd-kpis { margin: 0; display: grid; gap: 8px; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.dd-kpis > div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 8px; text-align: center; min-width: 0; }
.dd-kpis dt { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.dd-kpis dd { margin: 2px 0 0; font-weight: 700; font-size: 16px; }
.dd-trades { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dd-trade { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 10px 14px; gap: 0; }
.dd-trade.gain { border-color: color-mix(in srgb, var(--gain) 35%, var(--line)); } .dd-trade.loss { border-color: color-mix(in srgb, var(--loss) 35%, var(--line)); }
.dd-trade > div { display: flex; flex-direction: column; min-width: 0; padding: 0 10px; border-right: 1px solid var(--line); overflow-wrap: anywhere; }
.dd-trade > div:first-child { padding-left: 0; } .dd-trade > div:last-child { border-right: 0; }
@media (max-width: 768px) {
  .dd-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dd-trade { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 0; }
  .dd-trade > div { border-right: 0; padding: 0 6px 0 0; }
}
.pills { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.pills-l { font-size: 11px; font-weight: 700; letter-spacing: .1em; color: var(--muted); margin-right: 4px; }
.pill { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 2px 10px; font-size: 12px; }
.splitbar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--bg2); }
.splitbar span { display: block; height: 100%; }
.splitlbl { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; color: var(--fg2); font-size: 13px; }
.health { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.health li { display: flex; gap: 8px; align-items: center; font-size: 13.5px; overflow-wrap: anywhere; }
.divider b { text-align: center; }
.row3 { display: grid; gap: 10px; grid-template-columns: 1.4fr .8fr 1fr; }
.row3 .span2 { grid-column: span 2; }
.editbox { border: 1px solid var(--line); border-radius: var(--r); padding: 12px; background: var(--panel); }
.tl-label { font-size: 11.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.tl-label.accent { color: var(--accent); }
.manage .field { min-width: 180px; }
@media (max-width: 768px) { .row3 { grid-template-columns: minmax(0, 1fr); } .row3 .span2 { grid-column: auto; } }
.kpimini { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-mini { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 9px 12px; }
.kpi-l { font-size: 12px; color: var(--muted); } .kpi-v { font-size: 20px; font-weight: 700; }
.grid4 { display: grid; gap: 10px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.lc { font-size: 11.5px; margin-left: 6px; white-space: nowrap; }
.al-tbl td.acts { display: flex; gap: 6px; }
.al-btns .btn { flex: 1; }
.notifs { list-style: none; margin: 0; padding: 0; } .notifs li { padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
@media (max-width: 768px) { .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.expander-b { grid-template-columns: minmax(0, 1fr); }
.field select, .field input { min-width: 0; width: 100%; }
.ordform { max-width: 640px; }
.grid2c { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ordercard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 18px; }
.oc-side { font-weight: 700; letter-spacing: .04em; } .ordercard.buy .oc-side { color: var(--gain); } .ordercard.sell .oc-side { color: var(--loss); }
.oc-sym { font-size: 20px; font-weight: 700; margin: 2px 0; } .oc-meta { color: var(--fg2); font-size: 13.5px; } .oc-val { margin-top: 8px; font-weight: 600; }
.rule { border: 0; border-top: 1px solid var(--line); margin: 8px 0; width: 100%; }
.h3 { font-size: 18px; font-weight: 650; }
.tip { cursor: help; color: var(--muted); }
.formgrid { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1023px) { .formgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .formgrid { grid-template-columns: minmax(0, 1fr); } }

/* Phase 3: health / insights / activity */
.gauge .g-track { stroke: var(--line2); } .gauge .g-fill { stroke: var(--accent); }
.gauge.gain .g-fill { stroke: var(--gain); } .gauge.warn .g-fill { stroke: var(--warn); } .gauge.loss .g-fill { stroke: var(--loss); }
.hscore { display: flex; align-items: center; gap: 12px; } .hs-v { font-size: 17px; font-weight: 600; }
.dims { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; } .dim { display: inline-flex; gap: 5px; align-items: baseline; }
.small { font-size: 11.5px; }
.hs-expl { font-size: 13.5px; color: var(--fg2); line-height: 1.6; }
.ins-catn { margin-left: 8px; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.hlgrid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.hl { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; }
.hl.loss { border-left: 3px solid var(--loss); } .hl.gain { border-left: 3px solid var(--gain); } .hl.accent { border-left: 3px solid var(--accent); }
.hl-l { font-size: 12px; color: var(--muted); } .hl-v { font-size: 20px; font-weight: 700; } .hl-s { font-size: 12px; color: var(--muted); }

/* ── P&L calendar (P20) — 5-level intensity washes of the gain/loss tones,
   the same alpha steps as pages/calendar.py (_heatmap_color) ─────────────── */
.hm-gain-0 { background: color-mix(in srgb, var(--gain) 14%, transparent); border-color: color-mix(in srgb, var(--gain) 20%, transparent) !important; }
.hm-gain-1 { background: color-mix(in srgb, var(--gain) 24%, transparent); border-color: color-mix(in srgb, var(--gain) 30%, transparent) !important; }
.hm-gain-2 { background: color-mix(in srgb, var(--gain) 36%, transparent); border-color: color-mix(in srgb, var(--gain) 45%, transparent) !important; }
.hm-gain-3 { background: color-mix(in srgb, var(--gain) 52%, transparent); border-color: color-mix(in srgb, var(--gain) 60%, transparent) !important; }
.hm-gain-4 { background: color-mix(in srgb, var(--gain) 70%, transparent); border-color: var(--gain) !important; }
.hm-loss-0 { background: color-mix(in srgb, var(--loss) 14%, transparent); border-color: color-mix(in srgb, var(--loss) 20%, transparent) !important; }
.hm-loss-1 { background: color-mix(in srgb, var(--loss) 24%, transparent); border-color: color-mix(in srgb, var(--loss) 30%, transparent) !important; }
.hm-loss-2 { background: color-mix(in srgb, var(--loss) 36%, transparent); border-color: color-mix(in srgb, var(--loss) 45%, transparent) !important; }
.hm-loss-3 { background: color-mix(in srgb, var(--loss) 52%, transparent); border-color: color-mix(in srgb, var(--loss) 60%, transparent) !important; }
.hm-loss-4 { background: color-mix(in srgb, var(--loss) 70%, transparent); border-color: var(--loss) !important; }
.hm-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 6px; font-size: 11px; color: var(--muted); margin: 8px 0 6px; }
.hm-legend i { display: inline-block; width: 13px; height: 13px; border-radius: 2px; }
.hm-scroll { overflow-x: auto; max-width: 100%; }
.hm-year { border-collapse: separate; border-spacing: 2px; }
.hm-year thead td { font-size: 9px; color: var(--muted); white-space: nowrap; height: 12px; }
.hm-year .hm-dow { font-size: 9px; color: var(--muted); padding-right: 4px; text-align: right; }
.hm-year .hm-c { width: 11px; height: 11px; min-width: 11px; border: 1px solid var(--line); border-radius: 2px; padding: 0; }
.hm-year .hm-empty { background: transparent; }
.hm-flat { background: var(--panel); }
.cal-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; margin: 6px 0; }
.cal-hdr { font-size: 11px; font-weight: 700; letter-spacing: .1em; color: var(--muted); text-align: center; padding: 6px 0; text-transform: uppercase; }
.cal-cell { border-radius: 6px; padding: 7px 8px; min-height: 74px; display: flex; flex-direction: column; justify-content: space-between;
  border: 1px solid var(--line); min-width: 0; overflow: hidden; }
.cal-cell.selected { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-cell.empty { opacity: .35; border-style: dashed; }
.cal-cell.nodata { background: var(--panel); }
.cal-cell.week-col { background: var(--panel2, var(--panel)); justify-content: center; align-items: center; text-align: center; }
.cal-day { font-size: 11px; color: var(--muted); }
.cal-pnl { font-size: 13px; font-weight: 700; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-trades { font-size: 10px; color: var(--muted); margin-top: 2px; }
.wk-label { font-size: 10px; color: var(--muted); text-transform: uppercase; }
.wk-pnl { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
@media (max-width: 900px) { .cal-pnl, .wk-pnl { font-size: 11px; } .cal-cell { padding: 6px 5px; } }
.cal-list { list-style: none; margin: 0 0 6px; padding: 0; }
.cal-list li { display: flex; justify-content: space-between; align-items: baseline; padding: 7px 2px; border-bottom: 1px solid var(--line); font-size: 13px; }
.cal-list-n { font-weight: 400; font-size: 11.5px; font-family: var(--font-sans); }
.daycard { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px;
  border: 1px solid var(--line); border-radius: 10px; margin: 8px 0 12px; background: var(--panel); }
.daycard.gain { border-color: color-mix(in srgb, var(--gain) 27%, transparent); }
.daycard.loss { border-color: color-mix(in srgb, var(--loss) 27%, transparent); }
.daycard-t { font-weight: 700; font-size: 15px; }
.daycard-v { font-size: 24px; font-weight: 700; }
.cal-cell.hm-gain-4 .cal-pnl, .cal-cell.hm-loss-4 .cal-pnl, .cal-cell.hm-gain-3 .cal-pnl, .cal-cell.hm-loss-3 .cal-pnl { color: var(--fg); }

/* ── Performance (P21) ─────────────────────────────────────────────────── */
.tier-label { font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 18px 0 6px; cursor: help; }
.kpi-line { padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); margin: 8px 0; font-size: 13.5px; overflow-wrap: anywhere; }
tr.row-ref td { background: var(--accent-bg); font-weight: 700; }
.notice.info { color: var(--muted); }
.perf-2 { grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 900px) { .perf-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.takeaway.tw-ok { border-left-color: var(--gain); } .takeaway.tw-warn { border-left-color: var(--warn); }
.takeaway.tw-err { border-left-color: var(--loss); } .takeaway.tw-info { border-left-color: var(--accent); }
/* Strategy (P22) — phone ranking cards */
.rankcards { display: grid; gap: 6px; }
.rankcard { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.rankcard-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }

/* ── Tax dashboard (P23) ───────────────────────────────────────────────── */
.tax-ctl { align-items: flex-end; }
.lfield { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 150px; }
.lfield .field { width: 100%; }
.lf-l { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.lfield input { width: 100%; }
.taxkpis { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 12px 0; }
@media (max-width: 900px) { .taxkpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.taxkpi { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 14px 16px; min-height: 120px; display: flex; flex-direction: column; min-width: 0; }
.taxkpi.hl { border-color: color-mix(in srgb, var(--loss) 55%, transparent); }
.taxkpi-l { font-size: 12px; color: var(--muted); min-height: 2.4em; line-height: 1.3; }
.taxkpi-v { font-size: 22px; font-weight: 700; margin: 2px 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.taxkpi-s { font-size: 12px; color: var(--fg2); line-height: 1.35; }
.taxkpi-list { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 6px 8px; margin: 10px 0; }
.taxkpi-row { padding: 8px 8px; }
.taxkpi-row.hl { border-left: 3px solid var(--loss); background: var(--bg2); border-radius: 4px; }
.taxkpi-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; color: var(--fg2); }
.t-muted { color: var(--muted); } .t-soft { color: var(--fg2); } .t-accent { color: var(--accent); }
.kvlist .kv, .kv { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.kvlist .kv:first-child { border-top: none; }
.kv.total { border-top: 2px solid var(--line); font-weight: 700; }
.kv.sm { padding: 3px 0; font-size: 12.5px; border-top: none; }
.kv > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.caption-i { color: var(--muted); font-size: 12px; }
.acards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.acard { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 10px 12px; min-width: 0; }
.acard-h { display: flex; justify-content: space-between; align-items: baseline; }
.acard-k { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 2px 0 4px; }
.bgrp { margin: 10px 0; } .bgrp-h { font-weight: 700; margin-bottom: 6px; }
.bgrp .acard + .acard { margin-top: 8px; }
.notice.ok { border-color: color-mix(in srgb, var(--gain) 35%, transparent); background: color-mix(in srgb, var(--gain) 8%, transparent); }
.notice { margin: 8px 0; }
.notice > div { width: 100%; }
.tax-comp { grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 900px) { .tax-comp { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.sect-k { font-size: 11.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; margin: 6px 0 8px; }
.sect-k.accent { color: var(--accent); } .sect-k.warn { color: var(--warn); }
.ccard { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); overflow: hidden; }
.ccard.b-loss { border-color: var(--loss); } .ccard.b-gain { border-color: var(--gain); }
.cline { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 12px; font-size: 13px; color: var(--fg2); }
.cline > span:last-child { text-align: right; min-width: 90px; white-space: nowrap; }
.cline.bold { background: var(--bg2); font-weight: 700; color: var(--fg); }
.csep { border-top: 1px solid var(--line); margin: 4px 0; }
.optcard { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 12px 14px; margin: 8px 0; }
.optcard.loss { border-color: color-mix(in srgb, var(--loss) 30%, transparent); } .optcard.gain { border-color: color-mix(in srgb, var(--gain) 30%, transparent); }
.optcard.warn { border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.optcard p { margin: 4px 0 0; font-size: 13px; line-height: 1.7; color: var(--fg2); }
.optcard-k { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.optcard-side { text-align: right; min-width: 110px; } .big { font-size: 20px; }
.opt2 { grid-template-columns: minmax(0, 1fr); } @media (min-width: 900px) { .opt2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.nearrow { display: flex; justify-content: space-between; gap: 10px; border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent); border-radius: 8px; padding: 8px 12px; margin-top: 6px; background: var(--bg2); }
.nearrow .r { text-align: right; } .small { font-size: 12px; }
.expgrid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); margin: 8px 0; }
.expgrid .btn { text-align: center; justify-content: center; }
.expledger { display: flex; gap: 8px; align-items: center; } .expledger .field { flex: 1; }
.disclaimer { margin-top: 16px; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; font-size: 12px; color: var(--muted); line-height: 1.8; }
.tax .expander { margin-top: 12px; }
.b { font-weight: 700; }

/* ── System status (P27) ──────────────────────────────────────────────── */
.sysl { list-style: none; margin: 4px 0 8px; padding: 0; }
.sysl li { padding: 5px 0; font-size: 13.5px; overflow-wrap: anywhere; }
.sdot-d { font-size: 11px; }
.machine, .gloss { margin: 0; display: grid; gap: 6px; }
.machine > div { display: grid; grid-template-columns: minmax(0, 180px) minmax(0, 1fr); gap: 8px; font-size: 13px; }
.machine dt { font-weight: 600; } .machine dd { margin: 0; overflow-wrap: anywhere; }
.gloss dt { font-weight: 700; } .gloss dd { margin: 0 0 8px; font-size: 13.5px; }
.gloss .caption { margin: 2px 0; }
.changelog { white-space: pre-wrap; font-size: 12.5px; max-height: 360px; overflow: auto; }
.sys .panel { margin-top: 16px; }

/* ── Daily operations (P5) ─────────────────────────────────────────────── */
.optiles { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 12px 0; }
@media (max-width: 1100px) { .optiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .optiles { grid-template-columns: minmax(0, 1fr); } }
.optile { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 14px; min-width: 0; }
.optile-t { font-weight: 700; min-height: 2.6em; line-height: 1.3; }
.optile .info { color: var(--muted); cursor: help; font-weight: 400; }
.optile-s { min-height: 2.4em; font-size: 12.5px; }
.optile .btn { margin-top: auto; width: 100%; justify-content: center; white-space: normal; }
.rule { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.jobscard { margin: 6px 0 14px; }
.jobscard-h { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 8px 0 6px; }
.jobrow { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.jobrow-l { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.jobrow-r { margin-left: auto; }
.jobrow-d { font-size: 12px; color: var(--muted); margin-left: 18px; overflow-wrap: anywhere; }

/* ── Broker holdings (P6) ──────────────────────────────────────────────── */
.note-box { font-size: 12.5px; color: var(--muted); background: var(--bg2); border-radius: 6px; padding: 10px 14px; margin-bottom: 12px; line-height: 1.8; }
.bh-status { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; background: var(--bg2); border-radius: 6px; padding: 8px 14px; margin-bottom: 8px; }
pre.code { white-space: pre-wrap; font-size: 12.5px; margin: 0; overflow-wrap: anywhere; }
tr.tint-loss td { background: var(--loss-bg); } tr.tint-warn td { background: var(--warn-bg); }
.adjform { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 8px; }
.adjform input { width: 100%; }
.dcell { display: flex; flex-direction: column; gap: 2px; min-width: 0; } .dl { font-size: 11px; color: var(--muted); } .dv { font-size: 13px; overflow-wrap: anywhere; }

/* ── LTP override (P7) ─────────────────────────────────────────────────── */
.ltprows { margin: 10px 0; }
.ltprow { display: grid; grid-template-columns: minmax(0, 2.5fr) minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1.5fr) minmax(0, 1.8fr) minmax(0, .8fr);
  gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.ltprow.hdr { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ltprow input { width: 100%; }
.exch { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 4px; justify-self: start; }
.x-mcx { color: var(--warn); background: var(--warn-bg); } .x-nse { color: var(--accent); background: var(--accent-bg); }
.x-bse { color: var(--gain); background: color-mix(in srgb, var(--gain) 12%, transparent); }
.ltpcard { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ltpcard-h { display: flex; justify-content: space-between; align-items: baseline; }
.ltp textarea { width: 100%; font-family: var(--font-mono); margin-bottom: 8px; }

/* ── Commodity multipliers (P8) ───────────────────────────────────────── */
.intro { font-size: 13.5px; margin: 0 0 12px; }
.h4 { font-size: 15px; margin: 14px 0 6px; }
.cmform { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.cmform .wide2 { flex: 2 1 260px; }
.cm-prev { margin: 10px 0; }
.cm .btn { margin: 4px 0; }

/* ── Discrepant trades (P9) ───────────────────────────────────────────── */
.excl { list-style: none; padding: 0; margin: 6px 0; }
.excl > li { border-bottom: 1px solid var(--line); padding: 8px 0; }
.exc-h { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.sev { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.acqform, .altrow, .bulkrow { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 6px 0; }
.altrow .lfield { flex: 0 1 140px; }
.discrow { display: grid; grid-template-columns: 1.2fr 1.2fr 1.2fr 1.2fr 1fr .8fr 2.7fr; gap: 8px; align-items: center; font-size: 13px; }
.discrow > * { min-width: 0; overflow-wrap: anywhere; }
.discrow.hdr { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 4px 0; border-bottom: 1px solid var(--line); }
.discitem { border-bottom: 1px solid var(--line); padding: 8px 0; }
.disccard { border-bottom: 1px solid var(--line); padding: 10px 0; display: grid; gap: 6px; }
.disccard-h { display: flex; justify-content: space-between; align-items: baseline; }

/* Scheduler (P11) */
.sched .hourscard, .sched .jobcard { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 14px; margin: 12px 0; min-width: 0; }
.sched .hourscard .h4, .sched .jobcard .h4 { margin: 0 0 6px; }
.sched .jobcard-g { align-items: start; margin-bottom: 10px; }
.sched .jobstat { font-size: 13px; overflow-wrap: anywhere; }
.sched .check { margin: 6px 0; }
@media (max-width: 640px) { .sched .grid2c.jobcard-g { grid-template-columns: 1fr; } }

/* CSV Import (P12) / Dividend Import (P13) */
.upload { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 10px 0; border: 1px dashed var(--line); border-radius: var(--r); padding: 12px; background: var(--panel); }
.upload .lf-l { flex-basis: 100%; }
.upload input[type=file] { max-width: 100%; min-width: 0; }
.mapgrid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin: 8px 0; }
.csvimp .section-sub, .divimp .section-sub { margin-top: 18px; }
.impres { margin: 10px 0; display: grid; gap: 6px; }
.divfilters { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 10px 0; }
@media (max-width: 640px) { .divfilters { grid-template-columns: 1fr; } }
.grp-meta { margin-left: 10px; color: var(--muted); font-size: 12px; }
.grp-pnl { margin-left: 10px; font-weight: 600; }
.csvimp .caption code { overflow-wrap: anywhere; word-break: break-all; white-space: normal; }
.divimp > .lfield, .csvimp > .lfield { flex: 0 0 auto; margin: 8px 0; }
.divfilters input, .divfilters select { box-sizing: border-box; width: 100%; min-height: 38px; }

/* US / Crypto books (P24, P25) and Global Investments (P14) */
.tbl tr.tint-gain td { background: color-mix(in srgb, var(--gain) 6%, transparent); }
.tbl tr.tint-loss td { background: color-mix(in srgb, var(--loss) 6%, transparent); }
.gcards { display: grid; gap: 8px; }
.gcard { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 10px 12px; }
.gcard-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ggroup { margin-top: 10px; padding: 8px 12px; border-radius: 8px; background: var(--bg2); border-left: 3px solid var(--line); }
.ggroup.edge-gain { border-left-color: var(--gain); } .ggroup.edge-loss { border-left-color: var(--loss); }
.ggroup-t { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.gcharts { margin-top: 12px; }
@media (max-width: 640px) { .gcharts { grid-template-columns: 1fr; } }
.gtrades { display: grid; gap: 0; }
.gtrow { display: grid; grid-template-columns: 1fr 1.1fr .6fr .9fr .9fr .5fr 1fr 1.1fr auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.gtrades.crypto .gtrow { grid-template-columns: 1.1fr 1.2fr .7fr 1.1fr 1.1fr .6fr 1.2fr auto; }
.gtrow.hdr { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.gtrow > * { min-width: 0; overflow-wrap: anywhere; }
.gtrow .acts { display: flex; gap: 6px; }
.gtcard { border-bottom: 1px solid var(--line); padding: 10px 0; display: grid; gap: 6px; }
.gedit { border: 1px solid var(--accent); border-radius: var(--r); padding: 12px; margin: 8px 0; display: grid; gap: 10px; }
.gedit .grid3 { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .gedit .grid3 { grid-template-columns: 1fr; } }
.ggrid { display: grid; gap: 6px; grid-template-columns: minmax(80px, 160px) minmax(0, 260px); align-items: center; margin: 8px 0; }

/* ── Settings sections (Phase 4) ───────────────────────────────────────────── */
.settings-sec .panel + .panel { margin-top: 16px; }
.narrow-form { max-width: 560px; }
.field.secret > span { display: flex; gap: 8px; align-items: center; }
.row.nowrap { flex-wrap: nowrap; }
ul.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.strat-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.strat-row { display: grid; grid-template-columns: 2.2em minmax(0, 1fr) auto auto auto; gap: 8px 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.strat-edit { padding: 10px 12px; border: 1px solid var(--accent-bg2); border-radius: var(--r); }
@media (max-width: 480px) { .strat-row { grid-template-columns: 2.2em minmax(0, 1fr) auto; } .strat-row > .row { grid-column: 2 / -1; } }
fieldset.segrow { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.segrow legend { padding: 0; margin-bottom: 4px; }
select.mfsel { max-width: 100%; height: 34px; border: 1px solid var(--line2); border-radius: var(--r-sm); background: var(--panel); color: var(--fg); }
select.mfsel.changed { border-color: var(--accent); }
.lfield select { height: 40px; padding: 0 10px; border: 1px solid var(--line2); border-radius: var(--r-sm); background: var(--panel); color: var(--fg); min-width: 0; width: 100%; }
.accent { color: var(--accent); }
.settings-sec .notice .btn { white-space: normal; height: auto; min-height: 32px; text-align: left; max-width: 100%; }
.tm-filters { margin-top: 10px; }
.tm-filters .lfield { flex: 1 1 140px; }
.tm-rows { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.tm-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.tm-cells { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 4px 12px; }
.tm-cells dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.tm-cells dd { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.pager { margin-top: 10px; }
.lfield.shrink { flex: 0 0 auto; }
.pick-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; display: grid; gap: 4px; font-size: 13px; }
.split2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 12px; }
.settings-sec a.btn { white-space: normal; height: auto; min-height: 32px; max-width: 100%; }
.cashcards { margin: 12px 0; }
.cashcards dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.receipt { border: 1px solid color-mix(in srgb, var(--gain) 35%, transparent); background: color-mix(in srgb, var(--gain) 6%, transparent); border-radius: var(--r); padding: 10px 14px; display: grid; gap: 4px; max-width: 520px; margin: 8px 0; }
.receipt .rc-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.cash-entries { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cash-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
@media (max-width: 480px) { .cash-entry { grid-template-columns: minmax(0, 1fr); } }
.brk-row { display: grid; grid-template-columns: 2.2em minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
@media (max-width: 480px) { .brk-row { grid-template-columns: minmax(0, 1fr); } }
.cmform.secrets { margin-top: 4px; }
b.brk, .cash-entry b { overflow-wrap: anywhere; }
pre.code { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; background: var(--panel2, var(--panel)); padding: 8px; border-radius: var(--r-sm); }

/* Global investments — inline Settings unlock for edit / delete (Phase 5) */
.ginv-lock { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0 10px; }
.ginv-unlock { max-width: 460px; margin: 0 0 14px; }

/* ── Table: opt-in sticky header (sticky) and frozen first column (freeze) ─────────────────────
   A sticky header can only stay in view if the table scrolls inside its own box, so a `sticky` table
   is capped at a viewport-relative height (the box is keyboard-focusable; see Table in ui.js).
   Sticky cells need OPAQUE backgrounds or scrolled content shows through: --sticky-bg is the surface the
   table sits on, and the gain/loss row tints are re-laid over it for the frozen cell (--wash).
   border-collapse: separate keeps each cell's own border attached to it while it sticks. */
.tbl-sticky, .tbl-freeze { --sticky-bg: var(--bg); border-collapse: separate; border-spacing: 0; }
.panel .tbl-sticky, .panel .tbl-freeze { --sticky-bg: var(--panel); }
.scroll-x.sticky-y { max-height: none; }   /* flat tables: the page scrolls, the table never gets its own vertical scrollbar */
.scroll-x.sticky-y:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tbl-sticky thead th { background: var(--sticky-bg); }
.tbl-freeze thead th:first-child, .tbl-freeze tbody td:first-child { position: sticky; left: 0; max-width: min(220px, 45vw); overflow: hidden; text-overflow: ellipsis; box-shadow: 1px 0 0 var(--line2); }
.tbl-freeze thead th:first-child { z-index: 4; background: var(--sticky-bg); }
.tbl-freeze tbody td:first-child { z-index: 2; background-color: var(--sticky-bg); background-image: linear-gradient(var(--wash, transparent), var(--wash, transparent)); }
.tbl-freeze tr.tint-g1 { --wash: color-mix(in srgb, var(--gain) 5%, transparent); } .tbl-freeze tr.tint-g2 { --wash: color-mix(in srgb, var(--gain) 7%, transparent); }
.tbl-freeze tr.tint-g3 { --wash: color-mix(in srgb, var(--gain) 10%, transparent); } .tbl-freeze tr.tint-l1 { --wash: color-mix(in srgb, var(--loss) 5%, transparent); }
.tbl-freeze tr.tint-l2 { --wash: color-mix(in srgb, var(--loss) 7%, transparent); } .tbl-freeze tr.tint-l3 { --wash: color-mix(in srgb, var(--loss) 10%, transparent); }
/* a group header spans every column: keep its label in view while the table scrolls sideways */
.tbl-freeze tr.group th > * { position: sticky; left: 10px; width: max-content; max-width: 92vw; }

/* ── Table cards (Table cards=…): optional wide rows, wrapping titles, folded secondary fields ── */
.mcard-t.wrap { white-space: normal; overflow-wrap: anywhere; }
.mcard .mv { overflow-wrap: anywhere; }
.mrow.wide .mcell, .mrow.wide .mcell:last-child { align-items: flex-start; text-align: left; }
.mmore summary { cursor: pointer; display: flex; align-items: center; min-height: 32px; font-size: 12px; color: var(--muted); }
.mmore summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mmore-b { display: grid; gap: 6px; padding-top: 4px; }
.mcard-k { display: block; margin-bottom: 2px; }

/* ── Phase 4: tablet alignment ── */
/* Data-freshness bar: below ~1240px of viewport the full row no longer fits beside the sidebar, so
   the secondary items (already hidden on tablet) drop out before "Refresh prices" wraps onto its own line. */
@media (max-width: 1240px) { .trustbar .hide-sm { display: none; } }
/* Positions filters on a tablet: two controls per row instead of four stacked rows (nothing hidden) */
@media (min-width: 481px) and (max-width: 768px) {
  .filters.filters-2up .field { flex: 1 1 calc(50% - 5px); min-width: 0; }
  .filters.filters-2up .field.grow2 { flex-basis: 100%; }
}
/* Touch screens: a bounded, vertically scrolling table inside a scrolling page traps the finger.
   Keep the horizontal scroll and the frozen first column, drop the vertical box and sticky header. */
@media (pointer: coarse) {
  .scroll-x.sticky-y { max-height: none; }
}

/* ── Phase 7: Positions group headers read as groups, not as stock rows ──
   A header always carries a WORD (Strategy / Direct equity / Unassigned) as well as its band, so the
   distinction never rests on colour alone. Only the Positions page emits these classes. */
.tbl tr.group.g-strategy th, .tbl tr.group.g-direct th, .tbl tr.group.g-none th { padding-top: 13px; padding-bottom: 9px; border-top: 2px solid var(--line2); }
.tbl tr.group.g-strategy th { background: color-mix(in srgb, var(--accent) 9%, var(--bg2)); box-shadow: inset 4px 0 0 var(--accent); }
.tbl tr.group.g-direct th { background: var(--bg2); box-shadow: inset 4px 0 0 var(--fg2); }
.tbl tr.group.g-none th { background: var(--bg2); box-shadow: inset 4px 0 0 var(--muted); }
.grp-strategy, .grp-direct, .grp-none { gap: 4px 18px; padding-left: 6px; }
.grp-id { display: inline-flex; align-items: center; gap: 9px; }
.grp-sum { display: inline-flex; flex-wrap: wrap; gap: 2px 16px; align-items: baseline; }
.grp-kind { flex: none; font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; line-height: 1; padding: 3px 7px; border: 1px solid currentColor; border-radius: 4px; }
.grp-strategy .grp-kind { color: color-mix(in srgb, var(--accent) 62%, var(--fg)); border-color: var(--accent); background: var(--accent-bg); }
.grp-direct .grp-kind { color: var(--fg); background: var(--panel); border-color: var(--fg2); }
.grp-none .grp-kind { color: var(--fg2); }
.grp-strategy .grp-name, .grp-direct .grp-name, .grp-none .grp-name { font-size: 14px; font-weight: 800; letter-spacing: .04em; }
.grp-strategy .grp-meta, .grp-direct .grp-meta, .grp-none .grp-meta { margin-left: 0; font-size: 12.5px; color: var(--fg2); }
.grp-strategy .grp-pnl, .grp-direct .grp-pnl, .grp-none .grp-pnl { margin-left: 0; font-size: 13px; }
/* the frozen header label may not outgrow the visible table: it wraps inside its container instead of being clipped */
.table-wrap:has(> .scroll-x > .tbl-freeze) { container-type: inline-size; }
.tbl-freeze tr.group th > * { max-width: calc(100cqw - 20px); }
/* phone (≤480px) group card */
.mgroup-h { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.mgroup.g-strategy .mgroup-n, .mgroup.g-direct .mgroup-n, .mgroup.g-none .mgroup-n { font-size: 13.5px; font-weight: 800; overflow-wrap: anywhere; }
.mgroup.g-strategy .grp-kind { color: color-mix(in srgb, var(--accent) 62%, var(--fg)); border-color: var(--accent); background: var(--accent-bg); }
.mgroup.g-direct .grp-kind { color: var(--fg); background: var(--panel); border-color: var(--fg2); }
.mgroup.g-none .grp-kind { color: var(--fg2); }
.mgroup.g-strategy, .mgroup.g-direct, .mgroup.g-none { margin-top: 14px; }
.mgroup .caption .num { white-space: nowrap; }          /* "+₹2,52,371.61 (+8.0%)" stays in one piece when the phone card wraps */

/* ── Phase 8: the same labelled group header on Closed Positions and the US portfolio ── */
.ggroup-h { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.ggroup.g-strategy .ggroup-t, .ggroup.g-none .ggroup-t { font-size: 13.5px; font-weight: 800; overflow-wrap: anywhere; }
.ggroup.g-strategy .grp-kind { color: color-mix(in srgb, var(--accent) 62%, var(--fg)); border-color: var(--accent); background: var(--accent-bg); }
.ggroup.g-none .grp-kind { color: var(--fg2); }
.ggroup.g-strategy, .ggroup.g-none { margin-top: 14px; }
.ggroup .caption .b { white-space: nowrap; }

/* amounts never wrap mid-number; on phones big figures show as lakh / crore (Amt) */
.amt, .mh-v, .ms-v, .hp-value, .hero-value, .kpi-v, .mv, .hero-side dd, .metric dd { white-space: nowrap; }
.amt.short { cursor: pointer; border-bottom: 1px dotted var(--muted); }
.ms-v { overflow: hidden; text-overflow: ellipsis; }
.tb-sys { display: inline-flex; align-items: center; gap: 6px; color: var(--fg2); text-decoration: none; }

/* stops table (Journal & risk) */
.stops-tbl .cell-in { width: 92px; text-align: right; font-family: var(--font-mono); }
.stops-tbl tr.no-stop td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.stops-tbl .caption { font-size: 11.5px; white-space: nowrap; }
.kpimini.kpi4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 768px) { .kpimini.kpi4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* full-year heatmap: fills the card, readable squares, month labels no longer collide */
.hm-year { width: 100%; min-width: 720px; table-layout: fixed; border-spacing: 3px; }
.hm-year thead td { font-size: 11px; height: 16px; white-space: nowrap; overflow: visible; color: var(--fg2); }
.hm-year .hm-dow { width: 18px; font-size: 11px; padding-right: 6px; }
.hm-year .hm-c { width: auto; min-width: 0; height: clamp(14px, 1.7vw, 28px); border-radius: 3px; }
.dup-cluster { margin: 8px 0; display: grid; gap: 6px; }
