:root {
    color-scheme: light dark;
    --border: #d0d7de;
    --muted: #6b7280;
    --success-bg: #e6f4ea;
    --success-fg: #1e7e34;
    --error-bg: #fdeaea;
    --error-fg: #b02a2a;
    --warning-bg: #fff6e0;
    --warning-fg: #8a6100;
    --info-bg: #e8f0fe;
    --info-fg: #1a56c4;
    --brand-navy: #0F1A2C;
    --brand-gold: #E8B040;
    --brand-green: #3E8E55;
    --login-card-bg: #ffffff;
    --login-card-border: #c9d1db;
    --login-card-shadow: rgba(15, 26, 44, 0.10);
    --login-feature-bg: #f4f6f9;
    --login-muted: #5b6472;
}

@media (prefers-color-scheme: dark) {
    :root {
        --login-card-bg: #161d2b;
        --login-card-border: #3d4a60;
        --login-card-shadow: rgba(0, 0, 0, 0.5);
        --login-feature-bg: #151b27;
        --login-muted: #9aa6b8;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    line-height: 1.4;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
    color: inherit;
}

.topnav {
    display: flex;
    gap: 1.25rem;
    flex: 1;
    margin-left: 1.5rem;
}

.topnav a {
    color: inherit;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0.8;
    padding: 0.2rem 0;
    border-bottom: 2px solid transparent;
}

.topnav a:hover {
    opacity: 1;
}

/* The page you're on: full strength with a blue underline. */
.topnav a.current {
    opacity: 1;
    font-weight: 700;
    border-bottom-color: var(--info-fg);
}

.logout-form {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.wl-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.wl-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}

.wl-card-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.4rem;
}

.wl-badge {
    font-weight: 600;
    color: #8a6100;
}

.account-email {
    color: var(--muted);
    font-size: 0.9rem;
}

.account-status {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-right: 1rem;
    font-size: 0.85rem;
    white-space: nowrap;
}

.account-status .btn {
    padding: 0.3rem 0.7rem;
    font-size: 0.85rem;
}

/* Desktop account dropdown (plan, upgrade, email, logout) behind the ☰ button. */
.account-wrap {
    position: relative;
}

.account-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.25rem 0.6rem;
    font-size: 1.1rem;
    line-height: 1.2;
    color: inherit;
}

.account-toggle[aria-expanded="true"] {
    background: var(--info-bg);
}

.account-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    z-index: 50;
    min-width: 15rem;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    background: Canvas;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(15, 26, 44, 0.15);
}

.account-menu.open {
    display: flex;
}

.account-menu .account-status {
    flex-direction: column;
    align-items: flex-start;
    margin-right: 0;
    white-space: normal;
}

.account-menu .logout-form {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.link-button {
    background: none;
    border: none;
    color: #1a56c4;
    cursor: pointer;
    padding: 0;
    font-size: 0.9rem;
    text-decoration: underline;
}

.content {
    padding: 1.25rem;
    max-width: 1100px;
    margin: 0 auto;
}

body.embedded .content {
    padding: 0.5rem 0;
    max-width: none;
}

.layout.is-loading .main {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.1s;
}

.card {
    max-width: 420px;
    margin: 3rem auto;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.login-banner {
    display: block;
    width: 100%;
    max-width: 880px;
    height: auto;
    margin: 1.5rem auto 0;
    border-radius: 12px;
}

.login-tagline {
    max-width: 880px;
    margin: 1.25rem auto 0;
    padding: 0 16px;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
}

.login-page {
    display: flex;
    gap: 2.5rem;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
    max-width: 880px;
    margin: 2rem auto 3rem;
}

.login-page .card.login-card {
    flex: 1 1 340px;
    max-width: 400px;
    margin: 0;
    padding: 2rem;
    background: var(--login-card-bg);
    border: 1px solid var(--login-card-border);
    border-top: 4px solid var(--brand-gold);
    border-radius: 12px;
    box-shadow: 0 6px 24px var(--login-card-shadow);
}

.login-card h2 {
    margin: 0 0 0.25rem;
    font-size: 1.6rem;
}

.login-sub {
    margin: 0 0 1.5rem;
    font-size: 0.95rem;
    color: var(--login-muted);
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.login-card label {
    font-weight: 600;
    font-size: 0.9rem;
}

.login-card input[type="email"] {
    font: inherit;
    font-size: 1rem;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--login-card-border);
    border-radius: 8px;
    background: transparent;
    color: inherit;
}

.login-card input[type="email"]:focus {
    outline: 2px solid var(--brand-gold);
    outline-offset: 1px;
}

.login-card button[type="submit"] {
    font: inherit;
    font-size: 1rem;
    font-weight: 700;
    padding: 0.75rem 1rem;
    margin-top: 0.4rem;
    border: none;
    border-radius: 8px;
    background: var(--brand-gold);
    color: var(--brand-navy);
}

.login-card button[type="submit"]:hover {
    filter: brightness(1.07);
}

/* Privacy policy and other plain reading pages. */
.legal {
    max-width: 44rem;
    line-height: 1.6;
}

.legal h2 {
    font-size: 1.15rem;
    margin-top: 1.75rem;
}

.legal li {
    margin-bottom: 0.4rem;
}

/* "Continue with Google": Google's light button style (white, grey border, G mark). */
.google-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.7rem 1rem;
    border: 1px solid #747775;
    border-radius: 8px;
    background: #fff;
    color: #1f1f1f;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
}

.google-button:hover {
    background: #f5f7fa;
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0 0.5rem;
    color: #5b6472;
    font-size: 0.85rem;
}

.login-divider::before,
.login-divider::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--border);
}

.login-steps {
    margin: 0.5rem 0 1rem;
    padding-left: 1.3rem;
    line-height: 1.5;
}

.login-steps li {
    margin-bottom: 0.25rem;
}

.login-help {
    font-size: 0.85rem;
    color: var(--login-muted);
    margin: 0.5rem 0 0;
}

.trial-note {
    margin: 1.25rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--login-card-border);
    font-size: 0.88rem;
    color: var(--login-muted);
    text-align: center;
}

.login-features {
    flex: 1 1 340px;
    max-width: 440px;
}

.login-features h2 {
    margin: 0 0 1rem;
    font-size: 1.4rem;
}

.login-features ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.login-features li {
    padding: 0.65rem 0.9rem;
    border-left: 3px solid var(--brand-green);
    border-radius: 0 8px 8px 0;
    background: var(--login-feature-bg);
    line-height: 1.45;
    font-size: 0.93rem;
}

.login-features li strong {
    display: block;
    margin-bottom: 0.1rem;
}

/* Group headings: Reminders / Journal / Market & Sectors, the tagline's three words. */
.login-features h3 {
    margin: 1.1rem 0 0.5rem;
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.login-features h2 + h3 {
    margin-top: 0;
}

.login-also {
    margin: 1rem 0 0;
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--muted);
}

.login-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.controls {
    flex: 0 0 220px;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    position: relative;
}

.layout.collapsed .controls {
    flex: 0 0 auto;
}

.sidebar-toggle {
    align-self: flex-end;
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    width: 1.75rem;
    height: 1.75rem;
    line-height: 1;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.sidebar-toggle:hover {
    color: inherit;
}

.controls label {
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 0.4rem;
}

.controls input, .controls select {
    width: 100%;
    padding: 0.3rem;
    box-sizing: border-box;
}

.controls input[type="checkbox"] {
    width: auto;
}

.controls fieldset {
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-top: 0.5rem;
}

.controls fieldset label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 400;
    margin-top: 0.25rem;
}

.main {
    flex: 1;
    min-width: 0;
}

.watchlist {
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
}

.watchlist h3 {
    margin-top: 0;
}

/* "+ Add XYZ": the main thing to do after a lookup, so the primary blue. */
.wl-add button {
    margin-top: 0.4rem;
    background: var(--info-fg);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.4rem 0.9rem;
    font-weight: 600;
}

.wl-add button:hover {
    opacity: 0.9;
}

.watchlist-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.15rem 0;
}

/* Every symbol link shares one URL shape, so :visited just marks whichever ones
   were clicked at some point -- keep them all one color and mark only the symbol
   the chart is showing. */
.watchlist-row a:not(.link-button),
.watchlist-row a:not(.link-button):visited {
    color: var(--info-fg);
    padding: 0.05rem 0.4rem;
    margin-left: -0.4rem;
    border-radius: 4px;
}

.watchlist-row a.active {
    font-weight: 700;
    text-decoration: none;
    background: var(--info-bg);
    border-left: 3px solid var(--info-fg);
}

.muted {
    color: var(--muted);
    font-size: 0.9rem;
}

.metrics-row {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.metric {
    display: flex;
    flex-direction: column;
    min-width: 100px;
}

.metric-label {
    font-size: 0.8rem;
    color: var(--muted);
}

.metric-value {
    font-size: 1.3rem;
    font-weight: 600;
}

.metric-delta.up { color: var(--success-fg); }
.metric-delta.down { color: var(--error-fg); }

.metric-sub {
    font-size: 0.8rem;
    color: var(--muted);
}

/* Next earnings within EARNINGS_SOON_DAYS (src/data.py). */
.metric-value.earnings-soon,
.metric-sub.earnings-soon {
    color: var(--warning-fg);
}

.wl-earnings {
    margin-left: 0.45rem;
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 400;
}

.wl-legend {
    margin: -0.25rem 0 0.4rem;
    font-size: 0.75rem;
}

.wl-earnings.earnings-soon {
    color: var(--warning-fg);
    font-weight: 600;
}

details {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
}

details summary {
    font-weight: 600;
    cursor: pointer;
}

.alert {
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    margin: 0.4rem 0;
}

.alert-success { background: var(--success-bg); color: var(--success-fg); }
.alert-error { background: var(--error-bg); color: var(--error-fg); }
.alert-warning { background: var(--warning-bg); color: var(--warning-fg); }
.alert-info { background: var(--info-bg); color: var(--info-fg); }
/* Earnings tone: this season's reports in the stock's group, one line per group. */
.earnings-tone p { margin: 0; }
.earnings-tone ul { margin: 0.35rem 0 0; padding-left: 1.2rem; }
.earnings-tone li { margin: 0.2rem 0; }
.earnings-tone .tone-down, .earnings-tone .tone-up { font-weight: 600; }
.earnings-tone .tone-info { padding: 0 0.15rem; color: inherit; }
.earnings-tone .tone-rest { margin: 0.25rem 0 0; font-size: 0.92rem; }
.earnings-tone .tone-readthrough { margin: 0.25rem 0 0; padding: 0.3rem 0.5rem; border-left: 3px solid currentColor; font-size: 0.92rem; }
/* Reminder Alert: brand gold, so a setup doesn't read as the panels' green/amber/red. */
.reminder-tip { margin: 0.2rem 0 0.5rem; font-size: 0.92rem; }
.alert-reminder { background: rgba(232, 176, 64, 0.16); border-left: 4px solid var(--brand-gold); }

.tab-section {
    margin-top: 2rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.signal-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.signal-cell {
    display: flex;
    flex-direction: column;
    min-width: 110px;
}

.signal-name {
    font-size: 0.8rem;
    color: var(--muted);
}

.signal-label {
    font-weight: 600;
}

.signal-value {
    font-size: 0.8rem;
    color: var(--muted);
}

.table-wrap {
    overflow-x: auto;
    margin-bottom: 0.75rem;
}

.analyst-table {
    border-collapse: collapse;
    font-size: 0.85rem;
}

.analyst-table th, .analyst-table td {
    border: 1px solid var(--border);
    padding: 0.25rem 0.5rem;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.progress-bar {
    background: var(--border);
    border-radius: 6px;
    height: 8px;
    margin: 0.4rem 0;
    overflow: hidden;
}

.progress-bar-fill {
    background: var(--info-fg);
    height: 100%;
}

.pnl-up { color: var(--success-fg); }
.pnl-down { color: var(--error-fg); }

[x-cloak] { display: none !important; }

.subtabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.subtabs button, .subtabs a {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.6rem 0.9rem;
    font-size: 0.95rem;
    color: var(--muted);
    margin-bottom: -1px;
    text-decoration: none;
}

.subtabs button.active {
    color: inherit;
    border-bottom-color: var(--info-fg);
    font-weight: 600;
}

.subtabs a:hover {
    color: inherit;
}

.btn {
    display: inline-block;
    background: var(--info-fg);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.btn:hover {
    opacity: 0.9;
}

.turn-ladder {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
}

.turn-ladder li {
    display: flex;
    gap: 0.5rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
}

.turn-ladder li.pending > span:last-child > strong {
    opacity: 0.75;
}

.turn-ladder-mark {
    flex: none;
}

.support-bands {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
}

.support-bands li {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
}

.band-status { font-size: 0.9rem; }
.band-status.down { color: var(--error-fg); }
.band-status.warn { color: var(--warning-fg); }
.band-status.up { color: var(--success-fg); }

.band-toggle {
    flex: none;
    min-width: 3.5rem;
}

.band-toggle.active {
    font-weight: 700;
    color: var(--brand-green);
}

/* Journal "At the time" column: a few summary chips + View, detail lives in the popup. */
.at-the-time {
    min-width: 12rem;
}

.chip {
    display: inline-block;
    padding: 0.05rem 0.45rem;
    margin: 0 0.25rem 0.25rem 0;
    border-radius: 999px;
    font-size: 0.8rem;
    white-space: nowrap;
    border: 1px solid var(--border);
}

.chip-success { background: var(--success-bg); color: var(--success-fg); border-color: transparent; }
.chip-error { background: var(--error-bg); color: var(--error-fg); border-color: transparent; }
.chip-warning { background: var(--warning-bg); color: var(--warning-fg); border-color: transparent; }
.chip-info { background: var(--info-bg); color: var(--info-fg); border-color: transparent; }
.chip-reminder { background: rgba(232, 176, 64, 0.18); border-color: var(--brand-gold); }

/* Order Analysis All / Uptrend / Downtrend switch -- chips as links. */
.trend-switch { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.4rem; margin: 0.5rem 0 1rem; }
.trend-switch .chip { margin: 0; padding: 0.2rem 0.7rem; font-size: 0.9rem; text-decoration: none; color: inherit; }
.trend-switch .chip-info { color: var(--info-fg); font-weight: 600; }

.modal {
    width: min(42rem, calc(100vw - 2rem));
    max-height: 85vh;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: Canvas;
    color: CanvasText;
    box-shadow: 0 12px 40px rgba(15, 26, 44, 0.25);
}

.modal::backdrop {
    background: rgba(15, 26, 44, 0.45);
}

.modal[open] {
    display: flex;
    flex-direction: column;
}

/* Snapshot dialog: drag the bottom-right corner to resize. */
#snapshot-dialog {
    resize: both;
    overflow: hidden;
    min-width: 20rem;
    min-height: 12rem;
}

.modal-inner {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.modal-head h3 {
    margin: 0;
    font-size: 1rem;
}

.modal-close {
    text-decoration: none;
    font-size: 1.1rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
}

/* Enlarged snapshot: wider, and as tall as the window allows (inside the lookup
   iframe the height cap goes entirely, so every section shows for a screenshot). */
.modal.modal-expanded {
    width: min(72rem, calc(100vw - 1rem));
    max-height: calc(100vh - 1rem);
}

/* App tour (YouTube player): 16:9 by default, a narrow 9:16 dialog for the portrait Short. */
#tour-dialog {
    width: min(96rem, calc(100vw - 2rem), calc((94vh - 3.5rem) * 16 / 9));
    max-height: 94vh;
    background: #000;
}

#tour-dialog.tour-portrait {
    width: min(24rem, calc(100vw - 2rem));
}

#tour-dialog .modal-head {
    background: Canvas;
}

/* height: auto so the aspect ratio wins over the 640x390 size YouTube's API stamps on. */
.tour-frame iframe {
    display: block;
    width: min(100%, calc((94vh - 3.5rem) * 16 / 9));
    height: auto;
    aspect-ratio: 16 / 9;
    margin: 0 auto;
    border: 0;
}

.tour-portrait .tour-frame iframe {
    width: min(100%, calc((94vh - 3.5rem) * 9 / 16));
    aspect-ratio: 9 / 16;
}

.tour-hint {
    margin: -0.25rem 0 1rem;
}

/* Phones held upright: the tour takes the whole screen, like a Short. */
@media (max-width: 760px) and (orientation: portrait) {
    #tour-dialog.tour-portrait {
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        border: 0;
        border-radius: 0;
        background: #000;
        color: #fff;
    }

    #tour-dialog.tour-portrait .modal-head {
        background: #000;
        border-bottom-color: #333;
    }

    #tour-dialog.tour-portrait .tour-frame {
        flex: 1;
        min-height: 0;
        display: flex;
    }

    #tour-dialog.tour-portrait .tour-frame iframe {
        width: 100%;
        height: 100%;
        aspect-ratio: auto;
    }
}

.modal-body {
    padding: 0.5rem 1rem 1rem;
    overflow-y: auto;
}

.modal-body details {
    margin: 0.6rem 0;
}

/* Lookup page: "Reminders" header, with the conditions link on the same line. */
.reminders-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    margin: 1.25rem 0 0.25rem;
}

.reminders-head h2 {
    margin: 0;
    font-size: 1.15rem;
}

/* Reminder conditions: plain block that scrolls as a whole -- no flex height math for
   Safari to get wrong; the header stays pinned while the list scrolls. */
#reminder-help[open] {
    display: block;
    overflow-y: auto;
}

#reminder-help .modal-head {
    position: sticky;
    top: 0;
    background: Canvas;
}

.reminder-help h4 {
    margin: 1rem 0 0.25rem;
    font-size: 0.95rem;
}

.reminder-help p,
.reminder-help li {
    margin: 0.25rem 0;
    font-size: 0.9rem;
    line-height: 1.45;
}

.reminder-help ul {
    margin: 0.25rem 0;
    padding-left: 1.25rem;
}

/* Bottom Ladder odds popup: same scrolling block as the reminder conditions. */
#bl-odds[open],
#tl-odds[open] {
    display: block;
    overflow-y: auto;
}

#bl-odds .modal-head,
#tl-odds .modal-head {
    position: sticky;
    top: 0;
    background: Canvas;
}

.odds-link {
    margin: 0.35rem 0 0.5rem;
    font-size: 0.9rem;
}

.odds-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
    font-size: 0.9rem;
}

.odds-table th,
.odds-table td {
    padding: 0.45rem 0.5rem;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.odds-table tbody th {
    text-align: left;
    font-weight: 600;
}

.odds-table th span {
    display: block;
    font-weight: 400;
    font-size: 0.8rem;
    opacity: 0.7;
}

.odds-table th span.nw {
    display: inline;
    white-space: nowrap;
    font-size: inherit;
    opacity: 1;
}

.odds-table td {
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.odds-table td.odds-best {
    color: #1b8a7e;
    background: rgba(38, 166, 154, 0.12);
}

.odds-table td.odds-worst {
    color: #d63c39;
    background: rgba(239, 83, 80, 0.12);
}

/* Forced AI Buy/Sell/Hold calls (lookup AI tab + /ai-calls). */
.call-box {
    margin-top: 1.5rem;
    padding: 0.75rem 1rem;
    border: 1px dashed var(--border);
    border-radius: 8px;
}

.call-box h3 { margin-top: 0; }
.call-buy { color: var(--success-fg); font-weight: 600; }
.call-sell { color: var(--error-fg); font-weight: 600; }
.call-hold { color: var(--warning-fg); font-weight: 600; }

/* Inline spinner for slow submit buttons (AI generation). */
.spinner {
    display: inline-block;
    width: 0.9em;
    height: 0.9em;
    margin-right: 0.35em;
    vertical-align: -0.1em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: sa-spin 0.8s linear infinite;
}

/* Full-screen "working on it" cover while a slow page loads (see base.html). */
.page-loading {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, Canvas 80%, transparent);
}

.page-loading[hidden] { display: none; }

.page-loading p {
    margin: 0 1rem;
    padding: 0.9rem 1.2rem;
    background: Canvas;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
}

@keyframes sa-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .spinner { animation-duration: 2.4s; }
}

/* Mid-session marker next to a price whose daily bar is still forming. */
.live-badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--info-bg);
    color: var(--info-fg);
    white-space: nowrap;
}

/* ---------- Phones ----------
   Everything below only kicks in on narrow screens; the desktop layout is untouched.
   The two toggles (top-bar menu, lookup "Chart settings") are hidden on desktop. */
.menu-toggle,
.more-toggle {
    display: none;
}

.topbar-menu {
    display: contents;
}

.symbol-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

/* Ticker box on Start here (/start). */
.start-form {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

.start-form input {
    font-size: 16px;  /* under 16px, iOS Safari zooms the page in on focus */
    padding: 0.5rem 0.6rem;
    width: 10rem;
    min-width: 0;
    flex: 0 1 10rem;
    text-transform: uppercase;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.start-form button {
    font-size: 16px;
    padding: 0.5rem 1rem;
    white-space: nowrap;
    /* Same look as .btn (Upgrade to Pro). */
    background: var(--info-fg);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 600;
}

.start-form button:hover {
    opacity: 0.9;
}

@media (max-width: 900px) {
    .topbar {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.6rem 0.9rem;
    }

    .menu-toggle {
        display: inline-block;
        background: none;
        border: 1px solid var(--border);
        border-radius: 6px;
        padding: 0.4rem 0.75rem;
        font: inherit;
        font-size: 0.95rem;
        color: inherit;
    }

    .topbar-menu {
        display: none;
    }

    .topbar-menu.open {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
        padding: 0.5rem 0 0.25rem;
    }

    .topnav {
        flex-direction: column;
        gap: 0;
        margin-left: 0;
    }

    .topnav a {
        font-size: 1rem;
        color: inherit;
        padding: 0.6rem 0.25rem;
        border-bottom: 1px solid var(--border);
    }

    .topnav a.current {
        color: var(--info-fg);
        border-bottom-color: var(--border);
        border-left: 3px solid var(--info-fg);
        padding-left: 0.5rem;
    }

    /* Phones: no separate dropdown -- account items sit in the full menu as before. */
    .account-toggle {
        display: none;
    }

    .account-wrap,
    .account-menu,
    .account-menu.open {
        display: contents;
    }

    .account-menu .account-status {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }

    .account-menu .logout-form {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding-top: 0;
        border-top: none;
    }

    .logout-form .link-button {
        font-size: 1rem;
    }
}

@media (max-width: 760px) {
    .content {
        padding: 0.75rem;
    }

    /* Lookup: sidebar stacks above the chart and always shows. */
    .layout {
        flex-direction: column;
        gap: 0.75rem;
    }

    .controls,
    .layout.collapsed .controls {
        flex: none;
        width: 100%;
    }

    .main {
        width: 100%;
    }

    #chart {
        overflow: hidden;
    }

    .sidebar-toggle {
        display: none;
    }

    /* Phones keep the ticker row above the watchlist (desktop puts the watchlist first). */
    .layout .controls-body {
        display: flex !important;
        flex-direction: column;
    }

    .controls-body > form {
        order: -1;
    }

    .more-toggle {
        display: inline-block;
        flex: none;
        font: inherit;
        font-size: 0.9rem;
        padding: 0.45rem 0.7rem;
        border: 1px solid var(--border);
        border-radius: 6px;
        background: none;
        color: inherit;
    }

    .controls input[type="text"] {
        font-size: 16px;  /* under 16px, iOS Safari zooms the page in on focus */
        padding: 0.45rem 0.5rem;
    }

    .controls select {
        font-size: 16px;
    }

    .controls-more {
        display: none;
    }

    .layout.more-open .controls-more {
        display: block;
    }

    .watchlist {
        margin: 0.75rem 0 0;
        padding: 0.5rem 0 0;
        border-bottom: none;
        border-top: 1px solid var(--border);
    }

    .wl-add button {
        margin-top: 0;
        background: revert;
        color: revert;
        border: revert;
        border-radius: revert;
        padding: revert;
        font-weight: revert;
    }

    .watchlist h3 {
        margin: 0 0 0.4rem;
        font-size: 1rem;
    }

    /* Watchlist as a row of tappable chips; Remove only while editing settings. */
    .watchlist-rows {
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .watchlist-row {
        padding: 0;
        gap: 0.3rem;
    }

    .watchlist-row a:not(.link-button),
    .watchlist-row a:not(.link-button):visited {
        margin-left: 0;
        padding: 0.35rem 0.65rem;
        border: 1px solid var(--border);
        border-radius: 999px;
        text-decoration: none;
    }

    .watchlist-row a.active {
        border-left-width: 1px;
        border-color: var(--info-fg);
    }

    .watchlist-row form {
        display: none;
    }

    .layout.more-open .watchlist-row form {
        display: block;
    }

    .layout.more-open .watchlist-rows {
        flex-direction: column;
        gap: 0.25rem;
    }

    .layout.more-open .watchlist-row {
        justify-content: space-between;
    }

    /* Price + stats: two columns instead of one squeezed row. */
    .metrics-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem 1rem;
    }

    .metric {
        min-width: 0;
    }

    .metric:first-child {
        grid-column: 1 / -1;
    }

    .metric-value {
        font-size: 1.15rem;
    }

    details {
        padding: 0.5rem 0.6rem;
    }

    .subtabs button, .subtabs a {
        padding: 0.6rem 0.6rem;
    }

    /* Form fields: full width and 16px (smaller text makes iOS Safari zoom in on tap). */
    /* :where() keeps this low-priority so page-specific field styles (login) still win. */
    .content form :where(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea) {
        display: block;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        font-size: 16px;
        padding: 0.4rem 0.5rem;
        margin: 0.2rem 0 0.5rem;
    }

    .content :where(select) {
        font-size: 16px;
        max-width: 100%;
    }

    .content form :where(button:not(.link-button)) {
        font-size: 1rem;
        padding: 0.45rem 0.9rem;
    }

    .login-card input[type="email"] {
        margin: 0;
    }

    .symbol-row input[type="text"] {
        flex: 1;
        min-width: 0;
        margin: 0;
    }

    .controls fieldset label {
        padding: 0.15rem 0;
    }

    /* Tables fill the width; wide ones scroll sideways inside their .table-wrap box. */
    .table-wrap table {
        width: 100%;
    }

    .modal,
    .modal.modal-expanded {
        width: calc(100vw - 1rem);
        max-width: none;
        max-height: calc(100dvh - 1rem);
    }

    .modal-head {
        padding: 0.6rem 0.75rem;
    }

    .modal-body {
        padding: 0.25rem 0.75rem 1rem;
    }

    .modal-body details {
        padding: 0.5rem 0.6rem;
    }

    #snapshot-dialog {
        resize: none;
        min-width: 0;
    }

    .login-page {
        margin: 1rem auto 2rem;
        padding: 0 0.75rem;
        gap: 1.5rem;
    }

    .login-page .card.login-card {
        flex-basis: 100%;
        padding: 1.25rem;
    }

    .login-features {
        flex-basis: 100%;
    }

    .login-banner {
        margin-top: 0.75rem;
        border-radius: 0;
    }

    .login-tagline {
        font-size: 1.05rem;
    }
}

/* Market page (web/templates/market.html): one row per name -- symbol and name, the
   read, price, watchlist action; the read wraps under the name on phones. */
.mk-asof { margin: 0.25rem 0 0.75rem; }
.mk-filter { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.mk-filter select { font-size: 1rem; padding: 0.3rem 0.4rem; max-width: 100%; }
.mk-breadth { display: flex; flex-wrap: wrap; gap: 0.35rem 1.1rem; padding: 0.6rem 0.8rem; border: 1px solid var(--border); border-radius: 8px; }
.mk-group { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 0.75rem; padding: 0.5rem 0.9rem; }
.mk-group summary { cursor: pointer; display: flex; align-items: center; gap: 0.6rem; padding: 0.25rem 0; }
.mk-group-title { font-weight: 700; }
.mk-count { color: var(--muted); font-weight: 600; }
.mk-new { font-size: 0.75rem; font-weight: 700; color: var(--warning-fg); background: var(--warning-bg); border-radius: 999px; padding: 0.05rem 0.5rem; }
.mk-blurb { margin: 0.2rem 0 0.5rem; font-size: 0.9rem; }
.mk-list { list-style: none; margin: 0; padding: 0; }
.mk-row { display: grid; grid-template-columns: minmax(12rem, 1.2fr) 3fr auto auto; gap: 0.25rem 1rem; align-items: center; padding: 0.45rem 0; border-top: 1px solid var(--border); }
.mk-main { display: flex; align-items: baseline; gap: 0.5rem; min-width: 0; }
.mk-sym { font-weight: 700; color: inherit; }
.mk-name { color: var(--muted); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-read { display: flex; flex-wrap: wrap; gap: 0.15rem 0.8rem; font-size: 0.9rem; }
.mk-price { display: flex; gap: 0.5rem; justify-content: flex-end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mk-action form { margin: 0; }
.mk-action { white-space: nowrap; font-size: 0.9rem; }
.mk-views { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 0.6rem; }
.mk-views a { padding: 0.3rem 0.8rem; border: 1px solid var(--border); border-radius: 999px; color: inherit; text-decoration: none; font-size: 0.95rem; }
.mk-views a[aria-current="page"] { font-weight: 700; border-color: currentColor; }
.mk-etf { display: flex; flex-wrap: wrap; gap: 0.15rem 1rem; }
.mk-cap { color: var(--muted); font-size: 0.8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mk-subhead { font-size: 0.95rem; margin: 0.6rem 0 0.2rem; }

@media (max-width: 760px) {
    .mk-row { grid-template-columns: 1fr auto; }
    .mk-read { grid-column: 1 / -1; grid-row: 2; }
    .mk-action { grid-column: 1 / -1; grid-row: 3; }
}

/* ETFs tab: one sortable table. The fund column stays put while the rest scrolls on a phone. */
.mk-table { width: 100%; }
.mk-table th { white-space: nowrap; padding: 0; }
.mk-table th button { all: unset; cursor: pointer; display: block; padding: 0.3rem 0.5rem; font-weight: 700; }
.mk-table th[aria-sort="ascending"] button::after { content: " ▲"; font-size: 0.7em; }
.mk-table th[aria-sort="descending"] button::after { content: " ▼"; font-size: 0.7em; }
.mk-table td { vertical-align: top; }
.mk-table .mk-fund { position: sticky; left: 0; background: Canvas; min-width: 9rem; }
.mk-table .mk-name { white-space: normal; font-size: 0.8rem; }
.mk-table .mk-detail { font-size: 0.8rem; }
.mk-table .mk-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Market > Earnings season: one group per line, spaced apart. */
.mk-season ul { padding-left: 1.2rem; }
.mk-season > ul > li { margin: 0 0 0.75rem; }
.earnings-tone .tone-sold { margin: 0.25rem 0 0; padding-left: 1.2rem; font-size: 0.92rem; }
/* Market > Sector tone: each group's ladder steps. */
.mk-tone-trigger { margin: 0.3rem 0 0.2rem; }
.mk-steps { list-style: none; margin: 0.2rem 0 0.4rem; padding: 0; }
.mk-steps li { margin: 0.2rem 0; color: var(--muted); }
.mk-steps li.done { color: inherit; }
.mk-tone-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.5rem; margin: 0.6rem 0 0.8rem; }
.mk-tone-strip a { color: inherit; text-decoration: none; padding: 0.15rem 0.5rem; border: 1px solid var(--border); border-radius: 999px; font-size: 0.88rem; white-space: nowrap; }
.mk-tone-strip a[aria-current="true"] { border-color: currentColor; font-weight: 600; }
.mk-tone-strip .chip { font-size: 0.78rem; }
.mk-tone summary { cursor: pointer; font-size: 0.92rem; color: #1a56c4; }
/* Stock page: sector, sector tone and last report as one panel, labels in a column. */
.context-lines {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.3rem 0.75rem;
    margin: -0.25rem 0 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.45;
}
.context-lines dt { color: var(--muted); }
.context-lines dd { margin: 0; min-width: 0; }
.context-lines .tone-group { display: block; }
.context-lines .chip { margin: 0 0.15rem; vertical-align: 1px; }
.sector-tone .tone-chip { cursor: pointer; font: inherit; font-size: 0.8rem; line-height: 1.3; }
.sector-tone .tone-steps { margin: 0.35rem 0 0.2rem; padding: 0.4rem 0.6rem; border-left: 3px solid var(--border); }
@media (max-width: 480px) {
    /* Phone: each label above its value. */
    .context-lines { grid-template-columns: 1fr; gap: 0.1rem; }
    .context-lines dd + dt { margin-top: 0.35rem; }
}
/* Band context tags (src/band_context.py): former role, and the 🔺 squeeze band. */
.band-tag { font-size: 0.85rem; color: var(--muted); }
.band-tag.squeeze { color: inherit; font-weight: 600; }

/* Start here (/start): the app's features in four groups. */
.st-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}
.st-head h1 { margin: 0 0 0.25rem; }
.st-head p { margin: 0; }
.st-tour { border: none; cursor: pointer; white-space: nowrap; margin-top: 0.3rem; }
.st-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1.25rem;
}
.st-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.1rem;
}
.st-card h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.5rem;
    font-size: 1.15rem;
}
.st-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: var(--brand-gold);
    color: var(--brand-navy);
    font-size: 0.9rem;
    font-weight: 800;
    flex: none;
}
.st-card p { margin: 0 0 0.6rem; }
.st-card a.chip { text-decoration: none; color: inherit; font-size: 0.9rem; padding: 0.15rem 0.55rem; }
.st-card a.chip:hover { border-color: var(--info-fg); }
.st-lookup { justify-content: flex-start; margin: 0.75rem 0 0.5rem; }
.st-try .muted { margin-right: 0.25rem; }
.st-list { margin-top: 0.5rem; }
.st-list-head { margin: 0 0 0.3rem; }
.st-count { color: var(--brand-gold); font-weight: 800; margin-left: 0.25rem; }
.st-names { line-height: 1.9; }
.st-more { font-size: 0.85rem; white-space: nowrap; }
.st-actions { display: flex; align-items: center; gap: 1rem; }
.st-foot { margin-top: 1.25rem; }

@media (max-width: 760px) {
    .st-head { flex-direction: column; gap: 0.5rem; }
    .st-tour { margin-top: 0; }
    .st-grid { grid-template-columns: 1fr; gap: 0.75rem; }
}
