/* ============================================================
   tr8 — quant terminal
   neon-on-black, monospace, hairline grid
   ============================================================ */

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

:root {
    /* surfaces — cool near-black */
    --bg:        #07090d;
    --bg-grid:   rgba(120, 150, 190, 0.035);
    --panel:     #0a0d13;
    --panel-2:   #0e121a;
    --raised:    #11161f;

    /* hairlines */
    --line:        rgba(125, 150, 185, 0.12);
    --line-strong: rgba(125, 150, 185, 0.22);

    /* text */
    --text:    #c7d2e2;
    --dim:     #6c788b;
    --faint:   #444e5e;

    /* signal palette — neon */
    --accent:     #4d9fff;
    --accent-2:   #7bb8ff;
    --accent-soft: rgba(77, 159, 255, 0.14);
    --up:    #2fe39a;
    --up-soft: rgba(47, 227, 154, 0.13);
    --down:  #ff5d73;
    --down-soft: rgba(255, 93, 115, 0.13);
    --warn:  #ffb454;

    --glow: 0.55;

    --r: 3px;
    --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

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

html, body { height: 100%; }

body {
    font-family: var(--mono);
    background-color: var(--bg);
    background-image:
        linear-gradient(var(--bg-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
    background-size: 38px 38px;
    background-position: -1px -1px;
    color: var(--text);
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-variant-numeric: tabular-nums;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background: radial-gradient(120% 80% at 50% -10%, transparent 55%, rgba(0,0,0,0.55) 100%);
}

.app { position: relative; z-index: 1; height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }

.num { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.mono-up   { color: var(--up); }
.mono-down { color: var(--down); }
.up-glow   { text-shadow: 0 0 calc(12px * var(--glow)) rgba(47,227,154,0.6); }
.down-glow { text-shadow: 0 0 calc(12px * var(--glow)) rgba(255,93,115,0.6); }

/* ============================================================
   HEADER
   ============================================================ */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: 56px;
    padding: 0 1.25rem;
    background: rgba(7, 9, 13, 0.82);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line-strong);
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 0.55rem;
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    color: var(--text);
}
.brand .mark {
    width: 14px; height: 14px;
    background: var(--accent);
    box-shadow: 0 0 calc(14px * var(--glow)) var(--accent);
    transform: translateY(1px) rotate(45deg);
    border-radius: 1px;
    align-self: center;
}
.brand-name { letter-spacing: -0.04em; }
.brand b { color: var(--accent); font-weight: 800; }
.brand .cursor {
    display: inline-block;
    width: 8px; height: 1.05rem;
    background: var(--accent);
    transform: translateY(2px);
    animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.nav { display: flex; gap: 2px; margin-left: 0.5rem; }
.nav button {
    font-family: var(--mono);
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--dim);
    background: transparent;
    border: 1px solid transparent;
    padding: 0.4rem 0.85rem;
    border-radius: var(--r);
    cursor: pointer;
    transition: color .15s, background .15s, border-color .15s;
}
.nav button:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.nav button.active {
    color: var(--accent);
    background: var(--accent-soft);
    border-color: rgba(77,159,255,0.32);
}
/* "new opportunities" notification dot on a nav tab */
.nav button.has-new { position: relative; }
.nav button.has-new::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 4px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--down);
    box-shadow: 0 0 6px rgba(255,93,115,0.6);
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 1.25rem; }

.clock { font-size: 0.74rem; color: var(--dim); letter-spacing: 0.04em; }
.clock b { color: var(--text); font-weight: 500; }

.status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--up);
    padding: 0.32rem 0.6rem;
    border: 1px solid var(--up-soft);
    background: var(--up-soft);
    border-radius: var(--r);
    transition: color .2s, background .2s, border-color .2s;
}
.status .dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--up);
    box-shadow: 0 0 calc(8px * var(--glow)) var(--up);
    animation: livepulse 1.6s ease-in-out infinite;
}
.status.down { color: var(--down); background: var(--down-soft); border-color: var(--down-soft); }
.status.down .dot { background: var(--down); box-shadow: 0 0 calc(8px * var(--glow)) var(--down); }
@keyframes livepulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ============================================================
   TICKER TAPE
   ============================================================ */
.ticker {
    display: flex;
    align-items: center;
    height: 34px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
    overflow: hidden;
    position: relative;
}
.ticker::after {
    content: "";
    position: absolute; inset: 0;
    pointer-events: none;
    background: linear-gradient(90deg, var(--panel) 0%, transparent 5%, transparent 95%, var(--panel) 100%);
}
.ticker-track {
    display: flex;
    gap: 2.5rem;
    white-space: nowrap;
    padding-left: 1.25rem;
    animation: marquee 38s linear infinite;
}
@keyframes marquee { to { transform: translateX(-50%); } }
.tick { display: inline-flex; align-items: baseline; gap: 0.5rem; font-size: 0.76rem; }
.tick .sym { color: var(--text); font-weight: 700; letter-spacing: 0.02em; }
.tick .px  { color: var(--dim); }
.tick .chg { font-weight: 600; }

/* ============================================================
   LAYOUT
   ============================================================ */
.main { flex: 1; min-height: 0; width: 100%; max-width: 1480px; margin: 0 auto; padding: 1.25rem; display: flex; flex-direction: column; overflow-y: auto; }

.kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line-strong);
    border-radius: var(--r);
    overflow: hidden;
    margin-bottom: 1.25rem;
}
.kpi {
    background: var(--panel);
    padding: 1rem 1.15rem 1.05rem;
    position: relative;
    min-height: 96px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.kpi .k-label {
    font-size: 0.66rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--dim);
    display: flex; align-items: center; gap: 0.5rem;
}
.kpi .k-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
    line-height: 1;
}
.kpi .k-value.accent { color: var(--accent); text-shadow: 0 0 calc(16px * var(--glow)) rgba(77,159,255,0.45); }
.kpi .k-sub {
    font-size: 0.74rem;
    color: var(--dim);
    display: flex; align-items: center; gap: 0.4rem;
    white-space: nowrap;
}
.kpi .spark { position: absolute; right: 0; bottom: 0; width: 60%; height: 38px; opacity: 0.85; }

/* ===== Markets card ===== */
.markets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.9rem;
    padding: 0.2rem 0.1rem;
}
.mkt {
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--panel-2);
    padding: 0.7rem 0.8rem 0.6rem;
}
.mkt-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.55rem; }
.mkt-name { font-weight: 700; font-size: 0.82rem; letter-spacing: 0.01em; color: var(--text); }
.mkt-state { font-size: 0.68rem; letter-spacing: 0.04em; color: var(--dim); }
.mkt.open .mkt-state { color: var(--up); }
.mkt-bar {
    position: relative;
    height: 6px;
    border-radius: 3px;
    background: var(--raised);
    overflow: visible;
}
.mkt-fill { height: 100%; border-radius: 3px; background: var(--line-strong); }
.mkt.open .mkt-fill { background: linear-gradient(90deg, var(--up-soft), var(--up)); }
.mkt-now {
    position: absolute; top: 50%;
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--up);
    transform: translate(-50%, -50%);
    box-shadow: 0 0 calc(8px * var(--glow)) var(--up);
}
.mkt-foot {
    display: flex; justify-content: space-between;
    margin-top: 0.4rem;
    font-size: 0.66rem; color: var(--faint);
    font-family: var(--mono);
}
.mkt-clock { color: var(--dim); }
.mkt.open .mkt-clock { color: var(--up); }
.pill {
    display: inline-flex; align-items: center; gap: 0.35rem;
    font-size: 0.64rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
    padding: 0.22rem 0.5rem;
    border-radius: 2px;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid rgba(77,159,255,0.28);
}

.grid {
    display: grid;
    grid-template-columns: 1.65fr 1fr;
    gap: 1.25rem;
    align-items: start;
}
.col { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }

/* ============================================================
   PANELS
   ============================================================ */
.panel {
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: var(--r);
    min-width: 0;
}
.panel-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    user-select: none;
}
.panel-head h2 {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text);
}
/* Collapse affordance: a chevron that rotates when the panel is folded. */
.panel-head h2::before {
    content: '▾';
    display: inline-block;
    margin-right: 0.5rem;
    font-size: 0.72em;
    color: var(--dim);
    transition: transform .15s ease;
}
.panel.collapsed .panel-head h2::before { transform: rotate(-90deg); }
.panel.collapsed .panel-head { border-bottom-color: transparent; }
/* Hide everything but the header when collapsed. */
.panel.collapsed > :not(.panel-head) { display: none !important; }
.panel-head .meta {
    margin-left: auto;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    color: var(--dim);
    text-transform: uppercase;
    white-space: nowrap;
}
.panel-body { padding: 1rem; }

/* timeframe toggle */
.tf { display: flex; gap: 2px; margin-left: auto; }
.tf button {
    font-family: var(--mono);
    font-size: 0.64rem; font-weight: 600; letter-spacing: 0.08em;
    color: var(--dim);
    background: transparent;
    border: 1px solid transparent;
    padding: 0.25rem 0.5rem;
    border-radius: 2px;
    cursor: pointer;
}
.tf button:hover { color: var(--text); }
.tf button.active { color: var(--accent); background: var(--accent-soft); border-color: rgba(77,159,255,0.28); }

/* equity chart */
.chart-wrap { position: relative; height: 268px; padding: 0.5rem 0.25rem 0; }
.chart-wrap canvas { width: 100% !important; }
.chart-readout {
    position: absolute; top: 0.5rem; left: 1rem; z-index: 2;
    display: flex; align-items: baseline; gap: 0.6rem;
}
.chart-readout .big { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.03em; }

/* ============================================================
   POSITIONS TABLE
   ============================================================ */
table.tbl { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
table.tbl thead th {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--dim);
    text-align: right;
    padding: 0 0.85rem 0.6rem;
}
table.tbl thead th:first-child { text-align: left; }
table.tbl tbody td {
    padding: 0.6rem 0.85rem;
    text-align: right;
    border-top: 1px solid var(--line);
    color: var(--text);
    white-space: nowrap;
}
table.tbl tbody td:first-child { text-align: left; }
table.tbl tbody tr { cursor: pointer; transition: background .12s; position: relative; }
table.tbl tbody tr:hover { background: rgba(255,255,255,0.025); }
table.tbl tbody tr.sel { background: var(--accent-soft); }
table.tbl tbody tr.sel td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.sym-cell { font-weight: 700; letter-spacing: 0.02em; }
.sym-cell .dotcol { display: inline-block; width: 7px; height: 7px; border-radius: 1px; margin-right: 0.55rem; }
.muted { color: var(--dim); }
.pl { font-weight: 600; }
.pl .arr { font-size: 0.7em; }
.tbl-empty td { text-align: center !important; color: var(--faint); padding: 1.6rem 0; }

/* ============================================================
   SIGNALS
   ============================================================ */
.signals { display: flex; flex-direction: column; }
.signals.scroll-list { max-height: 540px; overflow-y: auto; }
.signal {
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 0.55rem;
}
.signal:first-child { border-top: none; }
.signal-top { display: flex; align-items: center; gap: 0.6rem; }
.signal-sym { font-weight: 700; font-size: 0.92rem; letter-spacing: 0.02em; }
.signal-top .spacer { margin-left: auto; }
.side {
    font-size: 0.62rem; font-weight: 700; letter-spacing: 0.12em;
    padding: 0.2rem 0.5rem; border-radius: 2px;
}
.side.buy  { color: var(--up);   background: var(--up-soft);   border: 1px solid rgba(47,227,154,0.3); }
.side.sell { color: var(--down); background: var(--down-soft); border: 1px solid rgba(255,93,115,0.3); }
.side.hold { color: var(--dim);  background: rgba(255,255,255,0.04); border: 1px solid var(--line-strong); }

.conf {
    display: flex; align-items: center; gap: 0.6rem;
    font-size: 0.66rem; color: var(--dim); letter-spacing: 0.06em; text-transform: uppercase;
}
.conf-bar { flex: 1; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.06); overflow: hidden; }
.conf-bar i {
    display: block; height: 100%;
    background: var(--accent);
    box-shadow: 0 0 calc(8px * var(--glow)) rgba(77,159,255,0.5);
    transition: width .6s ease;
}
.signal.buy  .conf-bar i { background: var(--up);   box-shadow: 0 0 calc(8px*var(--glow)) rgba(47,227,154,0.5); }
.signal.sell .conf-bar i { background: var(--down); box-shadow: 0 0 calc(8px*var(--glow)) rgba(255,93,115,0.5); }
.conf b { color: var(--text); font-weight: 600; }
.signal-reason { font-size: 0.74rem; color: var(--dim); }
.signal-reason b { color: var(--text); font-weight: 600; }

/* ============================================================
   TRADES
   ============================================================ */
.trades { display: flex; flex-direction: column; max-height: 280px; overflow-y: auto; }
.trade {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.62rem 1rem;
    border-top: 1px solid var(--line);
    font-size: 0.76rem;
}
.trade:first-child { border-top: none; }
.trade.flash { animation: flashrow 1.2s ease-out; }
@keyframes flashrow { 0% { background: var(--accent-soft); } 100% { background: transparent; } }
.trade .t-sym { font-weight: 700; width: 48px; }
.trade .t-side { font-size: 0.58rem; font-weight: 700; letter-spacing: 0.1em; padding: 0.14rem 0.4rem; border-radius: 2px; }
.trade .t-side.buy  { color: var(--up);   background: var(--up-soft); }
.trade .t-side.sell { color: var(--down); background: var(--down-soft); }
/* Lab chart readout: tooltip values shown below the canvas, not over it. */
.lab-readout {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem 1.1rem;
    min-height: 1.9rem; padding: 0.45rem 1rem 0.55rem;
    border-top: 1px solid var(--line);
    font-family: 'JetBrains Mono', monospace; font-size: 0.68rem; color: var(--dim);
}
.lab-readout .lr-when { color: var(--faint); }
.lab-readout .lr-item { display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap; }
.lab-readout .lr-item i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.lab-readout .lr-item b { color: var(--text); font-weight: 600; }
.lab-readout .lr-hint { color: var(--faint); }

.trade .t-detail { color: var(--text); }
.trade .t-pnl { margin-left: auto; font-weight: 600; }
.trade .t-pnl ~ .t-time, .trade .t-pnl ~ .txn-del { margin-left: 0.2rem; }
.trade .t-time { margin-left: auto; color: var(--faint); font-size: 0.7rem; }

.empty { padding: 1.6rem 1rem; text-align: center; color: var(--faint); font-size: 0.76rem; }

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
    border-top: 1px solid var(--line);
    padding: 0.9rem 1.25rem;
    display: flex; gap: 1rem; flex-wrap: wrap;
    font-size: 0.7rem; color: var(--faint);
    letter-spacing: 0.04em;
}
.footer .sep { color: var(--line-strong); }
.footer .right { margin-left: auto; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Opportunities + Research: the card fills the available view height and scrolls
   internally, so the footer stays visible (desktop + mobile). */
#tab-opportunities.active,
#tab-research.active { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#tab-opportunities > .panel,
#tab-research > .panel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#oppGrid,
#researchGrid { flex: 1; min-height: 0; max-height: none; overflow-y: auto; }

/* ============================================================
   FORMS / BUTTONS (backtest + research modules)
   ============================================================ */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.85rem; padding: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label { font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.field input, .field select {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: var(--r);
    padding: 0.45rem 0.6rem;
    min-width: 130px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }

.btn {
    font-family: var(--mono);
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
    padding: 0.5rem 1rem;
    border-radius: var(--r);
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s, opacity .15s;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { color: #051018; background: var(--accent); border: 1px solid var(--accent); box-shadow: 0 0 calc(14px*var(--glow)) rgba(77,159,255,0.4); }
.btn-primary:hover:not(:disabled) { background: var(--accent-2); }
.btn-ghost { color: var(--dim); background: transparent; border: 1px solid var(--line-strong); }
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--accent); }
/* Overlay toggles (news/trades on the stock chart): lit while their overlay is on. */
.btn-ghost.ov-active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft, rgba(77,159,255,0.12)); }

/* metric cards (backtest results) */
.metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line-strong);
    border-radius: var(--r);
    overflow: hidden;
    margin: 0 1rem 1rem;
}
.metric { background: var(--panel); padding: 0.85rem 1rem; display: flex; flex-direction: column; gap: 0.35rem; }
.metric .m-label { font-size: 0.6rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.metric .m-value { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }

/* research cards */
.research-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    padding: 1rem;
}
.rcard { background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: var(--r); padding: 1rem; }
.rcard-top { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.6rem; }
.rcard-sym { font-weight: 700; font-size: 1rem; }
.rcard-px { color: var(--dim); font-size: 0.78rem; }
.rcard .rec { margin-left: auto; }
.rcard-rationale { font-size: 0.78rem; color: var(--text); margin-bottom: 0.55rem; }
.rcard-points { list-style: none; display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.6rem; }
.rcard-points li { font-size: 0.74rem; color: var(--dim); padding-left: 0.9rem; position: relative; }
.rcard-points li::before { content: "›"; position: absolute; left: 0; color: var(--accent); }
.rcard-foot { font-size: 0.64rem; color: var(--faint); letter-spacing: 0.04em; }
/* Clickable symbols that open the per-stock price+news chart. */
.stock-link { cursor: pointer; }
.stock-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.stock-legend {
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
    margin-top: 0.6rem; font-size: 0.7rem; color: var(--dim);
}
.stock-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.stock-legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
/* One-headline-at-a-time reader below the chart. */
.stock-news-panel {
    display: flex; align-items: stretch; gap: 0.5rem;
    margin-top: 0.7rem; padding: 0.6rem 0.7rem;
    background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: var(--r);
    min-height: 56px;
}
.stock-news-panel .snp-empty { align-self: center; font-size: 0.78rem; }
.snp-nav {
    flex: 0 0 auto; width: 34px;
    background: transparent; color: var(--dim); border: 1px solid var(--line-strong);
    border-radius: var(--r); font-size: 1.1rem; cursor: pointer; transition: color .15s, border-color .15s;
}
.snp-nav:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.snp-nav:disabled { opacity: 0.3; cursor: default; }
.snp-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.3rem; justify-content: center; }
.snp-meta { font-size: 0.66rem; color: var(--dim); letter-spacing: 0.04em; display: flex; align-items: center; gap: 0.45rem; }
.snp-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.snp-title { font-size: 0.86rem; font-weight: 600; color: var(--text); text-decoration: none; line-height: 1.35; }
.snp-title:hover { color: var(--accent); text-decoration: underline; }
.snp-summary {
    font-size: 0.72rem; color: var(--dim); line-height: 1.4;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.opp-group {
    grid-column: 1 / -1;
    font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--dim);
    padding: 0.3rem 0.1rem; margin-top: 0.2rem;
    border-bottom: 1px solid var(--line);
}
.opp-group:first-child { margin-top: 0; }
.opp-basis {
    font-size: 0.58rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
    padding: 0.08rem 0.34rem; border-radius: 0.28rem; margin-left: 0.45rem;
    border: 1px solid var(--line);
}
.opp-basis.value { color: #6fd3ff; border-color: rgba(111, 211, 255, 0.4); }
.opp-basis.dip { color: #ffc56f; border-color: rgba(255, 197, 111, 0.4); }

/* sector filter chips above the opportunity cards */
.opp-sectors {
    grid-column: 1 / -1;
    display: flex; gap: 0.4rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.15rem;
}
.opp-sectors::-webkit-scrollbar { display: none; }
.opp-sector-chip {
    flex: 0 0 auto;
    font-family: var(--mono);
    font-size: 0.64rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--dim); background: transparent;
    border: 1px solid var(--line-strong); border-radius: 999px;
    padding: 0.3rem 0.7rem;
    white-space: nowrap;
    cursor: pointer;
    transition: color .15s, background .15s, border-color .15s;
}
.opp-sector-chip:hover { color: var(--text); border-color: var(--dim); }
.opp-sector-chip.active { color: var(--accent); background: var(--accent-soft); border-color: rgba(77,159,255,0.32); }

/* collapsible opportunity cards: compact header row + body */
.opp-card { padding: 0.85rem 1rem; }
.opp-head { display: flex; align-items: center; gap: 0.55rem; min-width: 0; user-select: none; }
.opp-head .rcard-sym { flex: 0 0 auto; }
.opp-flag { flex: 0 0 auto; font-size: 0.78rem; }
.opp-name {
    flex: 1 1 auto; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 0.72rem; color: var(--dim);
}
.opp-score { flex: 0 0 auto; font-size: 0.72rem; font-weight: 700; color: var(--accent-2); }
.opp-head .rec { flex: 0 0 auto; }
.opp-caret { display: none; flex: 0 0 auto; color: var(--dim); font-size: 0.72rem; transition: transform .15s ease; }
.opp-card.open .opp-caret { transform: rotate(180deg); }
.opp-body { margin-top: 0.6rem; }
.opp-body .opp-metrics { margin-bottom: 0.5rem; }
.opp-metrics .opp-basis { margin-left: 0; margin-right: 0.2rem; }
.opp-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
#oppGrid > .empty { grid-column: 1 / -1; }

/* mobile: collapse cards by default, tighten spacing so 3-4 headers fit a phone */
@media (max-width: 720px) {
    .opp-caret { display: inline-block; }
    .opp-head { cursor: pointer; }
    .opp-card { padding: 0.55rem 0.7rem; }
    .opp-card:not(.open) .opp-body { display: none; }
    .opp-head .rcard-sym { font-size: 0.86rem; }
    .opp-name { font-size: 0.66rem; }
    .opp-score { font-size: 0.66rem; }
    .opp-head .rec { font-size: 0.56rem; padding: 0.16rem 0.4rem; }
    #oppGrid.research-grid { grid-template-columns: 1fr; gap: 0.5rem; padding: 0.7rem; }
}

/* trading-settings modal form */
.ts-intro { margin: 0 0 0.2rem; font-size: 0.78rem; color: var(--dim); }
.ts-form { display: flex; flex-direction: column; }
.ts-field { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
.ts-field:last-child { border-bottom: none; padding-bottom: 0; }
.ts-field-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.ts-field-row label { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.ts-select, .ts-num {
    background: var(--bg); color: var(--text);
    border: 1px solid var(--line-strong); border-radius: 6px;
    padding: 0.4rem 0.55rem; font-size: 0.82rem; font-family: var(--mono);
    transition: border-color 0.12s ease;
}
.ts-select { width: 12rem; }
.ts-num { width: 6.5rem; text-align: right; }
.ts-select:focus, .ts-num:focus { outline: none; border-color: var(--accent); }
.ts-hint { margin: 0; font-size: 0.68rem; line-height: 1.45; color: var(--dim); }

/* research verdict-history sparkline */
.rcard-spark-wrap { display: flex; align-items: center; gap: 0.5rem; margin: 0.4rem 0 0.1rem; }
.rcard-spark { width: 120px; height: 20px; flex: none; }
.rcard-spark-label { font-size: 0.62rem; color: var(--dim); letter-spacing: 0.02em; }
.opp-metrics {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--dim);
    letter-spacing: 0.02em;
    margin-bottom: 0.55rem;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid var(--line);
}
/* Notification-preference toggles in the Telegram dialog. */
.notify-prefs { display: flex; flex-direction: column; gap: 0.1rem; margin: 0.6rem 0; }
.notify-prefs label {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.5rem 0.4rem; border-radius: var(--r);
    font-size: 0.82rem; cursor: pointer;
}
.notify-prefs label:hover { background: rgba(255,255,255,0.03); }
.notify-prefs input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ============================================================
   TOASTS
   ============================================================ */
.toasts { position: fixed; top: 70px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
    min-width: 240px; max-width: 340px;
    background: var(--panel-2);
    border: 1px solid var(--line-strong);
    border-left: 2px solid var(--accent);
    border-radius: var(--r);
    padding: 0.7rem 0.9rem;
    font-size: 0.74rem;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    animation: toastin .25s ease-out;
}
.toast.buy  { border-left-color: var(--up); }
.toast.sell { border-left-color: var(--down); }
.toast .t-h { font-weight: 700; letter-spacing: 0.06em; margin-bottom: 0.15rem; text-transform: uppercase; font-size: 0.66rem; }
.toast.buy .t-h { color: var(--up); }
.toast.sell .t-h { color: var(--down); }
.toast .t-b { color: var(--dim); }
@keyframes toastin { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--dim); }

/* ============================================================
   PORTFOLIO TAB
   ============================================================ */
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.64rem; }
.btn.danger { color: var(--down); border-color: var(--down-soft); }
.btn.danger:hover:not(:disabled) { color: #fff; background: var(--down); border-color: var(--down); }

.pf-layout { display: grid; grid-template-columns: 248px 1fr; gap: 1.25rem; align-items: start; }
.pf-sidebar { position: sticky; top: 72px; }
.pf-sidebar .panel-head { gap: 0.5rem; }
.pf-sidebar .panel-head h2 { margin-right: auto; }
.pf-list { display: flex; flex-direction: column; max-height: 70vh; overflow-y: auto; }
.pf-item {
    display: flex; flex-direction: column; gap: 0.25rem;
    padding: 0.7rem 1rem;
    border-top: 1px solid var(--line);
    cursor: pointer;
    transition: background .12s;
}
.pf-item:first-child { border-top: none; }
.pf-item:hover { background: rgba(255,255,255,0.03); }
.pf-item.sel { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.pf-item .pf-item-name { font-weight: 700; letter-spacing: 0.02em; display: flex; align-items: baseline; gap: 0.4rem; }
.pf-item .pf-item-name .ccy { font-size: 0.6rem; color: var(--faint); font-weight: 500; }
.pf-item .pf-item-row { display: flex; align-items: baseline; gap: 0.5rem; font-size: 0.74rem; }
.pf-item .pf-item-val { color: var(--text); }
.pf-list-empty { padding: 1.4rem 1rem; color: var(--faint); font-size: 0.74rem; text-align: center; }

.pf-detail-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.pf-detail-head h1 { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em; }
.pf-actions { margin-left: auto; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.pf-kpis { margin-bottom: 1.25rem; }

/* chat */
.pf-chat { margin-top: 1.25rem; }
.chat-log {
    display: flex; flex-direction: column; gap: 0.7rem;
    padding: 1rem; max-height: 360px; overflow-y: auto;
}
.chat-hint { color: var(--faint); font-size: 0.76rem; line-height: 1.6; }
.chat-hint b { color: var(--dim); font-weight: 600; }
.chat-msg { display: flex; flex-direction: column; gap: 0.25rem; max-width: 82%; }
.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-msg.assistant { align-self: flex-start; }
.chat-bubble {
    padding: 0.6rem 0.85rem; border-radius: var(--r); font-size: 0.8rem; line-height: 1.55;
    white-space: pre-wrap; word-break: break-word;
}
.chat-msg.user .chat-bubble { background: var(--accent-soft); border: 1px solid rgba(77,159,255,0.28); color: var(--text); }
.chat-msg.assistant .chat-bubble { background: var(--panel-2); border: 1px solid var(--line-strong); color: var(--text); }
.chat-meta { font-size: 0.6rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.chat-grounded { color: var(--accent); }
.chat-typing .chat-bubble { color: var(--dim); font-style: italic; }
.chat-input { display: flex; gap: 0.6rem; padding: 0.85rem 1rem; border-top: 1px solid var(--line); }
.chat-input input {
    flex: 1; font-family: var(--mono); font-size: 0.82rem; color: var(--text);
    background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r);
    padding: 0.55rem 0.75rem;
}
.chat-input input:focus { outline: none; border-color: var(--accent); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(3, 5, 8, 0.72); backdrop-filter: blur(3px);
    display: none; align-items: flex-start; justify-content: center;
    padding: 8vh 1rem 1rem; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
    width: 100%; max-width: 560px;
    background: var(--panel); border: 1px solid var(--line-strong);
    border-radius: var(--r); box-shadow: 0 20px 70px rgba(0,0,0,0.6);
    animation: toastin .2s ease-out;
}
.modal.wide { max-width: 1080px; }

/* research panel: scroll instead of pushing the page down */
.scroll-grid { max-height: 440px; overflow-y: auto; }
/* full-grid modal body scrolls within the viewport */
.modal .research-grid { max-height: 72vh; overflow-y: auto; padding: 1rem; }
.modal-head { display: flex; align-items: center; padding: 0.9rem 1.1rem; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.modal-head .x { margin-left: auto; cursor: pointer; color: var(--dim); font-size: 1.1rem; line-height: 1; background: none; border: none; }
.modal-head .x:hover { color: var(--text); }
.modal-body { padding: 1.1rem; }
.modal-body .field { margin-bottom: 0.85rem; }
.modal-body .field input, .modal-body .field select, .modal-body .field textarea {
    width: 100%; box-sizing: border-box;
    font-family: var(--mono); font-size: 0.82rem; color: var(--text);
    background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r);
    padding: 0.5rem 0.6rem;
}
.modal-body textarea { resize: vertical; min-height: 120px; }
.modal-body .field input:focus, .modal-body .field select:focus, .modal-body .field textarea:focus { outline: none; border-color: var(--accent); }
.modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
.modal-foot { display: flex; gap: 0.6rem; justify-content: flex-end; padding: 0.9rem 1.1rem; border-top: 1px solid var(--line); }
.modal-help { font-size: 0.72rem; color: var(--dim); line-height: 1.55; margin-bottom: 0.85rem; }
.modal-help code { color: var(--accent-2); background: var(--bg); padding: 0.05rem 0.3rem; border-radius: 2px; }

/* segmented buy/sell toggle */
.seg { display: flex; gap: 2px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r); padding: 2px; }
.seg button {
    flex: 1; font-family: var(--mono); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em;
    padding: 0.4rem; border: none; background: transparent; color: var(--dim); cursor: pointer; border-radius: 2px;
}
.seg button.on.buy { background: var(--up-soft); color: var(--up); }
.seg button.on.sell { background: var(--down-soft); color: var(--down); }

/* import preview table */
.import-preview { max-height: 300px; overflow-y: auto; margin-top: 0.5rem; border: 1px solid var(--line); border-radius: var(--r); }
.import-preview table { width: 100%; border-collapse: collapse; font-size: 0.72rem; }
.import-preview th { position: sticky; top: 0; background: var(--panel-2); color: var(--dim); font-weight: 600; text-transform: uppercase; font-size: 0.58rem; letter-spacing: 0.1em; padding: 0.45rem 0.6rem; text-align: left; }
.import-preview td { padding: 0.4rem 0.6rem; border-top: 1px solid var(--line); white-space: nowrap; }
.import-preview tr.bad td { color: var(--faint); }
.import-preview .sym-in { width: 92px; font-family: var(--mono); font-size: 0.72rem; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 2px; color: var(--text); padding: 0.2rem 0.35rem; }
.import-preview .sym-in.bad { border-color: var(--down); }
.import-warn { font-size: 0.72rem; color: var(--warn); margin-top: 0.6rem; line-height: 1.5; }

.txn-del { margin-left: auto; cursor: pointer; color: var(--faint); background: none; border: none; font-size: 0.85rem; }
.txn-del:hover { color: var(--down); }

/* holdings group subheaders + research toggle */
table.tbl tbody tr.grp { cursor: default; }
table.tbl tbody tr.grp:hover { background: transparent; }
table.tbl tbody tr.grp td {
    border-top: 1px solid var(--line-strong);
    padding: 0.5rem 0.85rem 0.3rem;
    font-size: 0.62rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--accent-2);
    background: rgba(255,255,255,0.015);
}
.res-toggle {
    font-family: var(--mono); font-size: 0.58rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
    padding: 0.2rem 0.45rem; border-radius: 2px; cursor: pointer;
    color: var(--faint); background: transparent; border: 1px solid var(--line-strong);
}
.res-toggle:hover:not(:disabled) { color: var(--text); border-color: var(--dim); }
.res-toggle.on { color: var(--up); background: var(--up-soft); border-color: rgba(47,227,154,0.4); }
.res-toggle:disabled { opacity: 0.5; cursor: default; }

/* watchlist */
.wl-add { display: flex; gap: 0.5rem; margin-bottom: 0.85rem; }
.wl-add input {
    flex: 1; font-family: var(--mono); font-size: 0.82rem; color: var(--text);
    background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r); padding: 0.45rem 0.6rem;
}
.wl-add input:focus { outline: none; border-color: var(--accent); }
.wl-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 0.5rem; }
.wl-item {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.35rem 0.4rem 0.35rem 0.6rem;
    background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: var(--r);
}
.wl-item .wl-sym { font-weight: 700; letter-spacing: 0.02em; font-size: 0.78rem; margin-right: auto; }
.wl-item .wl-del { cursor: pointer; color: var(--faint); background: none; border: none; font-size: 0.8rem; padding: 0 0.15rem; }
.wl-item .wl-del:hover { color: var(--down); }
.wl-hint { font-size: 0.7rem; color: var(--faint); margin-top: 0.85rem; line-height: 1.5; }
.wl-hint b { color: var(--dim); }
.wl-empty { color: var(--faint); font-size: 0.76rem; padding: 0.6rem 0.2rem; }

/* IPO calendar status pills */
.ipo-status {
    font-size: 0.6rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
    padding: 0.16rem 0.45rem; border-radius: 2px;
    color: var(--dim); background: rgba(255,255,255,0.04); border: 1px solid var(--line-strong);
}
.ipo-status.priced { color: var(--up); background: var(--up-soft); border-color: rgba(47,227,154,0.3); }
.ipo-status.expected { color: var(--accent); background: var(--accent-soft); border-color: rgba(77,159,255,0.28); }
.ipo-status.withdrawn { color: var(--down); background: var(--down-soft); border-color: rgba(255,93,115,0.3); }

/* chat add-to-watchlist chips */
.chat-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.4rem; }
.add-chip {
    font-family: var(--mono); font-size: 0.66rem; font-weight: 700; letter-spacing: 0.06em;
    padding: 0.25rem 0.55rem; border-radius: 2px; cursor: pointer;
    color: var(--accent); background: var(--accent-soft); border: 1px solid rgba(77,159,255,0.32);
}
.add-chip:hover:not(:disabled) { background: var(--accent); color: #051018; }
.add-chip:disabled { opacity: 0.5; cursor: default; }

/* responsive */
@media (max-width: 1080px) {
    .grid { grid-template-columns: 1fr; }
    .kpis, .metrics, .pf-kpis { grid-template-columns: repeat(2, 1fr); }
    .pf-layout { grid-template-columns: 1fr; }
    .pf-sidebar { position: static; }
}
@media (max-width: 640px) {
    .kpis, .metrics, .pf-kpis { grid-template-columns: 1fr; }
    .modal-row { grid-template-columns: 1fr; }

    /* Keep brand + status + clock + account on the top row; the tabs wrap to
       their own scrollable row directly underneath. */
    .topbar {
        flex-wrap: wrap;
        height: auto;
        gap: 0.4rem 0.75rem;
        padding: 0.5rem 0.85rem;
    }
    .topbar-right { margin-left: auto; gap: 0.6rem; min-width: 0; }
    #acctEmail {
        display: inline-block; max-width: 90px;
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
        vertical-align: bottom;
    }
    .nav {
        order: 3;
        flex-basis: 100%;
        margin-left: 0;
        gap: 2px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .nav::-webkit-scrollbar { display: none; }
    .nav button { flex: 0 0 auto; padding: 0.4rem 0.7rem; font-size: 0.68rem; }

    /* Wide, no-wrap tables (Positions, Backtest, IPOs) scroll inside their panel
       instead of pushing the page off-screen. */
    .panel-body { overflow-x: auto; }
}

/* ===== auth: login/register overlay ===== */
.auth-overlay {
    position: fixed; inset: 0; z-index: 200;
    display: flex; align-items: center; justify-content: center;
    background: rgba(4, 6, 10, 0.92); backdrop-filter: blur(4px);
}
.auth-card {
    width: 340px; max-width: 90vw; padding: 1.9rem 1.7rem;
    background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px;
    display: flex; flex-direction: column; gap: 0.85rem;
}
.auth-brand { font-size: 1.5rem; font-weight: 800; letter-spacing: 0.04em; }
.auth-brand b { color: var(--accent); }
.auth-tabs { display: flex; gap: 0.4rem; }
.auth-tabs button {
    flex: 1; font-family: var(--mono); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em;
    text-transform: uppercase; padding: 0.45rem; cursor: pointer; border-radius: var(--r);
    color: var(--dim); background: transparent; border: 1px solid var(--line-strong);
}
.auth-tabs button.active { color: var(--accent); background: var(--accent-soft); border-color: rgba(77,159,255,0.3); }
.auth-card input {
    font-family: var(--mono); font-size: 0.85rem; color: var(--text);
    background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r); padding: 0.55rem 0.65rem;
}
.auth-card input:focus { outline: none; border-color: var(--accent); }
.auth-submit {
    font-family: var(--mono); font-size: 0.85rem; font-weight: 700; cursor: pointer;
    padding: 0.6rem; border: none; border-radius: var(--r); background: var(--accent); color: #051019;
}
.auth-submit:hover { filter: brightness(1.08); }
.auth-err { color: var(--down); font-size: 0.74rem; min-height: 1em; }

/* ===== account menu (topbar) ===== */
.acct { position: relative; }
.acct-btn {
    font-family: var(--mono); font-size: 0.72rem; color: var(--text); cursor: pointer;
    background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: var(--r); padding: 0.32rem 0.55rem;
}
.acct-btn:hover { border-color: var(--dim); }
.acct-caret { color: var(--dim); }
.acct-menu {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 160px;
    background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--r);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4); padding: 0.3rem; display: flex; flex-direction: column; gap: 0.15rem;
}
.acct-item {
    font-family: var(--mono); font-size: 0.76rem; text-align: left; color: var(--text); cursor: pointer;
    background: none; border: none; border-radius: 3px; padding: 0.45rem 0.55rem;
}
.acct-item:hover { background: rgba(255,255,255,0.05); }

/* ===== help: "?" topbar button + "How tr8 works" modal ===== */
.help-btn {
    flex: 0 0 auto;
    width: 26px; height: 26px;
    display: inline-flex; align-items: center; justify-content: center;
    font-family: var(--mono); font-size: 0.76rem; font-weight: 700; line-height: 1;
    color: var(--dim); background: transparent;
    border: 1px solid var(--line-strong); border-radius: 999px;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.help-btn:hover { color: var(--accent); border-color: var(--accent); }

.help-body { max-height: 72vh; overflow-y: auto; }
.help-sec { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-2); margin-bottom: 0.55rem; }
.help-sec:last-child { margin-bottom: 0; }
.help-sec-head {
    width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
    font-family: var(--mono); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
    text-align: left; color: var(--dim); background: none; border: none;
    padding: 0.65rem 0.8rem; cursor: pointer;
    transition: color .15s;
}
.help-sec-head:hover { color: var(--text); }
.help-sec.open .help-sec-head { color: var(--accent); }
.help-caret { flex: 0 0 auto; color: var(--dim); font-size: 0.7rem; transition: transform .15s ease; }
.help-sec.open .help-caret { transform: rotate(180deg); }
.help-sec-body { display: none; padding: 0 0.8rem 0.75rem; }
.help-sec.open .help-sec-body { display: block; }
.help-sec-body p { margin: 0 0 0.6rem; font-size: 0.74rem; line-height: 1.6; color: var(--dim); }
.help-sec-body p:last-child { margin-bottom: 0; }

/* strategy entries: code-styled key chip + name */
.help-strat { padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
.help-strat:last-child { border-bottom: none; padding-bottom: 0; }
.help-strat:first-child { padding-top: 0; }
.help-strat-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.3rem; flex-wrap: wrap; }
.help-strat-head b { font-size: 0.76rem; color: var(--text); }
.help-key {
    flex: 0 0 auto;
    font-family: var(--mono); font-size: 0.64rem; font-weight: 700; letter-spacing: 0.04em;
    color: var(--accent-2); background: var(--bg);
    border: 1px solid var(--line-strong); border-radius: 999px;
    padding: 0.14rem 0.5rem;
    white-space: nowrap;
}

/* ===== strategy lab ===== */
.lab-intro { padding: 0.85rem 1rem 0; font-size: 0.76rem; color: var(--dim); line-height: 1.6; }
/* the comparison table is wide & no-wrap — scroll sideways on small screens */
.lab-tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl tbody tr.lab-top td { background: var(--accent-soft); }
table.tbl tbody tr.lab-top td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
/* range buttons + expand control above the equity-curve chart */
.lab-chart-head { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 1rem 0; }
.lab-chart-head .tf { margin-left: 0; }
.lab-expand { margin-left: auto; font-size: 0.85rem; line-height: 1; padding: 0.18rem 0.5rem; }
.lab-modal-tf { margin-left: 0; }

/* ===== admin: invites modal ===== */
.inv-create { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 1rem; }
.inv-create-hint { flex: 1; font-size: 0.7rem; color: var(--dim); line-height: 1.5; }
.inv-list { border-top: 1px solid var(--line); }
.inv-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.1rem; border-bottom: 1px solid var(--line); }
.inv-code {
    flex: 0 1 auto; min-width: 0;
    font-family: var(--mono); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
    color: var(--accent-2); background: var(--bg);
    border: 1px solid var(--line-strong); border-radius: 999px;
    padding: 0.18rem 0.55rem;
    overflow-wrap: anywhere;
}
.inv-date { margin-left: auto; flex: 0 0 auto; font-size: 0.68rem; color: var(--dim); }
.inv-acts { display: flex; gap: 0.3rem; flex: 0 0 auto; }
.inv-acts .btn-sm { padding: 0.26rem 0.5rem; font-size: 0.7rem; line-height: 1; }
.inv-new { animation: invflash 1.8s ease-out; }
@keyframes invflash {
    0%, 35% { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
    100% { background: transparent; box-shadow: none; }
}
.inv-empty { padding: 1.4rem 0.5rem; text-align: center; font-size: 0.74rem; color: var(--faint); border-bottom: 1px solid var(--line); }
.inv-used { margin-top: 1rem; opacity: 0.6; }
.inv-used summary {
    cursor: pointer; user-select: none;
    font-size: 0.64rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--dim); padding: 0.3rem 0;
}
.inv-used summary:hover { color: var(--text); }
.inv-used .inv-row { border-bottom: 1px solid var(--line); }
.inv-by { margin-left: auto; font-size: 0.7rem; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
@media (max-width: 480px) {
    .inv-create { flex-wrap: wrap; }
    .inv-row { flex-wrap: wrap; row-gap: 0.35rem; }
    .inv-code { flex: 1 1 100%; }
    .inv-date { margin-left: 0; }
    .inv-acts { margin-left: auto; }
    .inv-by { flex: 1 1 100%; margin-left: 0; white-space: normal; overflow-wrap: anywhere; }
}

/* ===== admin: manage-users modal (mobile fit) ===== */
.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.users-tbl tbody tr { cursor: default; }
.users-tbl .user-email { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) {
    /* the modal itself must never push past the viewport */
    .modal, .modal.wide { max-width: calc(100vw - 2rem); }
}
@media (max-width: 600px) {
    .users-tbl { font-size: 0.7rem; }
    .users-tbl .hide-sm { display: none; }
    .users-tbl thead th { padding: 0 0.4rem 0.45rem; }
    .users-tbl tbody td { padding: 0.45rem 0.4rem; }
    .users-tbl .user-email { max-width: 110px; }
    .users-tbl .btn-sm { padding: 0.26rem 0.4rem; font-size: 0.58rem; }
}
