﻿:root {
    /* COLORS */
    --bg: #020617;
    --panel: rgba(15,23,42,.92);
    --border: rgba(31,41,55,.85);
    --muted: #9ca3af;
    --text: #e5e7eb;
    --accent: #38bdf8;
    --accent2: #1d4ed8;
    --link: #7dd3fc;
    --linkHover: #bae6fd;
    --ok: #22c55e;
    --warn: #f59e0b;
    --bad: #ef4444;
    --msg: #fde68a;
    /* SPACING SCALE (4px base) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    /* COMPONENT SIZING */
    --header-h: 56px;
    --bottom-bar-h: 64px;
    --card-pad: var(--space-3);
    --section-gap: var(--space-4);
    --input-h: 44px;
    --btn-h: 44px;
    --tab-h: 40px;
    /* RADII */
    --radius-1: 8px;
    --radius-2: 12px;
    --radius-3: 16px;
    --radius-full: 999px;
    /* TABLE SIZING */
    --table-min-width: 600px;
    /* SPACING TOKENS (consistent padding) */
    --pad-card: 14px;
    --gap-section: 12px;
    --gap-tight: 8px;
}

/* MOBILE VARIABLE OVERRIDES (≤520px) */
@media (max-width: 520px) {
    :root {
        --header-h: 44px;
        --bottom-bar-h: 56px;
        --card-pad: var(--space-2);
        --section-gap: var(--space-2);
        --space-5: 16px;
        --space-6: 20px;
        --tab-h: 36px;
        --table-min-width: 480px;
    }
}

/* EXTRA SMALL (≤375px iPhone SE) */
@media (max-width: 375px) {
    :root {
        --card-pad: var(--space-1);
        --section-gap: var(--space-1);
        --table-min-width: 420px;
    }
}

/* CTA disabled state for Action Center */
.cta-disabled {
    opacity: 0.45 !important;
    cursor: not-allowed !important;
    filter: grayscale(0.6);
    pointer-events: none !important;
}

    .cta-disabled:hover, .cta-disabled:active, .cta-disabled:focus {
        transform: none !important;
        box-shadow: none !important;
    }

/* ========================================
2. RESET & BASE
======================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    height: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    min-height: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

    /* ========================================
3. DEBUG MODE
Toggle: ?debug=layout in URL

COLOR LEGEND:
- RED:     header (.top-nav), sticky bars
- BLUE:    main content area (.main)
- GREEN:   chat/scroll container (.chat)
- ORANGE:  input row (.input-row)
- CYAN:    messages (.msg) - dashed
- MAGENTA: modals (.modal)
- YELLOW:  tab containers (#vpTabs, .tab-bar)
- LIME:    table wrappers (.tablewrap)
- WHITE:   btnrow containers (.btnrow)
======================================== */
    body.debug-layout .top-nav {
        outline: 3px solid red !important;
        outline-offset: -3px;
    }

    body.debug-layout .main {
        outline: 3px solid blue !important;
        outline-offset: -3px;
    }

    body.debug-layout .chat {
        outline: 3px solid green !important;
        outline-offset: -3px;
    }

    body.debug-layout .input-row {
        outline: 3px solid orange !important;
        outline-offset: -3px;
    }

    body.debug-layout .msg {
        outline: 1px dashed cyan !important;
    }

    body.debug-layout .modal {
        outline: 3px solid magenta !important;
        outline-offset: -3px;
    }

    body.debug-layout #vpTabs,
    body.debug-layout .tab-bar,
    body.debug-layout .sub-tabs {
        outline: 3px solid yellow !important;
        outline-offset: -3px;
    }

    body.debug-layout .tablewrap,
    body.debug-layout .hscroll {
        outline: 3px solid lime !important;
        outline-offset: -3px;
    }

    body.debug-layout .btnrow {
        outline: 2px dashed white !important;
    }

    body.debug-layout .mobile-sticky-bar {
        outline: 3px solid red !important;
        outline-offset: -3px;
    }

    body.debug-layout .pill-row {
        outline: 1px dashed #f0f !important;
    }

    body.debug-layout::before {
        content: "DEBUG: red=header blue=main green=chat orange=input yellow=tabs lime=tables";
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0,0,0,.9);
        color: #fff;
        padding: 4px 8px;
        font-size: 9px;
        z-index: 99999;
        text-align: center;
        font-family: monospace;
    }

    body.debug-layout::after {
        content: "DEBUG LAYOUT";
        position: fixed;
        top: 0;
        right: 0;
        background: red;
        color: white;
        padding: 2px 8px;
        font-size: 10px;
        font-weight: bold;
        z-index: 99999;
    }

/* ========================================
4. HEADER (Fixed height)
======================================== */
.top-nav {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.nav-logo {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-full);
    background: radial-gradient(circle at 30% 30%, #38bdf8 0, #0ea5e9 40%, #1e293b 80%);
    box-shadow: 0 0 16px rgba(56,189,248,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 900;
    color: #020617;
    flex-shrink: 0;
}

.nav-title {
    font-weight: 650;
    font-size: 15px;
    letter-spacing: .04em;
}

.nav-links {
    display: flex;
    gap: var(--space-6);
    font-size: 13px;
    color: var(--muted);
    flex: 1;
    justify-content: center;
}

.nav-link {
    cursor: pointer;
    position: relative;
    padding-bottom: 2px;
}

    .nav-link.active {
        color: var(--text);
    }

        .nav-link.active::after {
            content: "";
            position: absolute;
            left: 0;
            right: 0;
            bottom: -6px;
            height: 2px;
            border-radius: var(--radius-full);
            background: linear-gradient(90deg, #38bdf8, #22c55e);
        }

.nav-right {
    font-size: 11px;
    color: var(--muted);
}

/* ========================================
5. DESKTOP LAYOUT
======================================== */
.layout {
    display: flex;
    gap: var(--space-5);
    padding: var(--space-5) var(--space-6) var(--space-6);
    min-height: calc(100vh - var(--header-h));
}

.sidebar {
    width: 260px;
    border-radius: var(--radius-3);
    padding: var(--space-4);
    background: radial-gradient(circle at top left, rgba(15,23,42,.9), #020617 65%);
    border: 1px solid rgba(15,23,42,.9);
    box-shadow: 0 22px 55px rgba(15,23,42,.95);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 15px;
    font-weight: 650;
}

.sidebar-sub {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.45;
}

.highlight-strip {
    padding: var(--space-2);
    border-radius: var(--radius-2);
    border: 1px solid rgba(56,189,248,.35);
    background: radial-gradient(circle at top left, rgba(56,189,248,.18), rgba(2,6,23,.2));
    font-size: 12px;
    font-weight: 900;
}

.steps {
    list-style: none;
    padding: 0;
    margin: 0;
}

.step-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: var(--space-2);
    border-radius: var(--radius-full);
    margin-bottom: var(--space-1);
    font-size: 12px;
    color: var(--muted);
    border: 1px solid transparent;
}

    .step-item.active {
        border-color: rgba(56,189,248,.8);
        background: radial-gradient(circle at left, rgba(56,189,248,.18), transparent 70%);
        color: var(--text);
    }

    .step-item.completed {
        border-color: rgba(34,197,94,.6);
        background: radial-gradient(circle at left, rgba(34,197,94,.14), transparent 70%);
        color: var(--text);
    }

.sidebar-tip {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.4;
}

/* ========================================
6. MAIN CONTENT AREA
======================================== */
.main {
    flex: 1;
    max-width: 980px;
    margin: 0 auto;
    border-radius: var(--radius-3);
    padding: var(--card-pad) var(--space-4);
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: 0 22px 55px rgba(0,0,0,.9);
    display: flex;
    flex-direction: column;
    gap: var(--section-gap);
}

.panel-title {
    font-size: 15px;
    font-weight: 650;
}

.panel-sub {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
}

/* ========================================
7. CHAT / SCROLL CONTAINER
======================================== */
.chat {
    border-radius: var(--radius-2);
    padding: var(--card-pad);
    background: rgba(15,23,42,.5);
    border: 1px solid var(--border);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.msg {
    max-width: 92%;
    margin-bottom: var(--space-2);
    line-height: 1.5;
    font-size: 13px;
    padding: var(--card-pad);
    border-radius: var(--radius-2);
    position: relative;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

    .msg.ai {
        background: linear-gradient(135deg, #020617, #020617);
        border: 1px solid rgba(30,64,175,.6);
        box-shadow: 0 12px 28px rgba(15,23,42,.9);
    }

    .msg.user {
        margin-left: auto;
        background: #020617;
        border-radius: 16px 16px 2px 16px;
        border: 1px solid rgba(56,189,248,.65);
        box-shadow: 0 8px 22px rgba(15,23,42,.9);
        padding-right: 28px;
    }

.msg-step {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    margin-bottom: var(--space-1);
    font-weight: 900;
}

.edit-icon {
    position: absolute;
    right: var(--space-2);
    top: var(--space-2);
    font-size: 12px;
    opacity: .7;
    cursor: pointer;
    color: var(--muted);
    background: transparent;
    border: none;
    padding: 0;
}

/* ========================================
8. INPUT ROW
======================================== */
.input-row {
    margin-top: var(--space-2);
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

    .input-row input {
        flex: 1;
        padding: var(--space-3);
        border-radius: var(--radius-full);
        border: 1px solid var(--border);
        background: var(--panel);
        color: var(--text);
        font-size: 14px;
        min-height: var(--input-h);
        outline: none;
    }

.send-btn {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-full);
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #f9fafb;
    font-size: 13px;
    font-weight: 700;
    min-height: var(--btn-h);
    cursor: pointer;
    flex-shrink: 0;
}

/* ========================================
9. FOOTER
======================================== */
.footer {
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--muted);
    border-top: 1px solid var(--border);
    gap: var(--space-2);
}

.footer-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-full);
    border: 1px solid rgba(56,189,248,.35);
    background: rgba(56,189,248,.10);
    color: var(--text);
    font-weight: 900;
}

/* ========================================
10. BUTTONS
======================================== */
.btn {
    border: 1px solid rgba(148,163,184,.55);
    background: var(--panel);
    color: var(--text);
    border-radius: var(--radius-2);
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    min-height: var(--btn-h);
    transition: all 0.15s ease;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}
/* Centered buttons allow full text wrap (higher specificity than .btn) */
.btnrow.centered .btn {
    white-space: normal;
    text-overflow: clip;
    overflow: visible;
    line-height: 1.4;
}
/* Disclosure buttons also allow wrap */
.disc-body .btn,
.disclosure .btn {
    white-space: normal;
    text-overflow: clip;
    overflow: visible;
    line-height: 1.4;
}

.btn:hover {
    border-color: rgba(148,163,184,.8);
    background: rgba(30,41,59,.9);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* PRIMARY: solid fill, main forward action (1 per screen) */
.btn-primary {
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #f9fafb;
    box-shadow: 0 8px 20px rgba(56,189,248,.3);
    padding: var(--space-3) var(--space-5);
    font-size: 15px;
}

    .btn-primary:hover {
        box-shadow: 0 12px 28px rgba(56,189,248,.4);
    }

/* SECONDARY: outline style, important but not forward */
.btn-secondary {
    border: 1px solid rgba(56,189,248,.5);
    background: rgba(56,189,248,.08);
    color: #7dd3fc;
    font-weight: 700;
}

    .btn-secondary:hover {
        border-color: rgba(56,189,248,.8);
        background: rgba(56,189,248,.15);
    }

/* TERTIARY: text-only, for back/cancel/learn more */
.btn-tertiary {
    border: none;
    background: transparent;
    color: var(--muted);
    padding: var(--space-2) var(--space-4);
    font-weight: 600;
    box-shadow: none;
}

    .btn-tertiary:hover {
        color: var(--text);
        background: rgba(148,163,184,.1);
    }

/* Execution flow button - gradient blue (next action) */
.btn-exec-next {
    border: none;
    background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 50%, #0284c7 100%);
    color: #ffffff;
    box-shadow: 0 8px 20px rgba(56,189,248,.4);
    font-weight: 700;
}

    .btn-exec-next:hover {
        background: linear-gradient(135deg, #7dd3fc 0%, #38bdf8 50%, #0ea5e9 100%);
        box-shadow: 0 10px 24px rgba(56,189,248,.5);
    }

/* Execution flow button - glass green (completed) */
.btn-exec-done {
    border: 1px solid rgba(34,197,94,.5);
    background: rgba(34,197,94,.15);
    color: #86efac;
    box-shadow: 0 4px 12px rgba(34,197,94,.2);
    font-weight: 600;
    cursor: pointer;
}

    .btn-exec-done:hover {
        background: rgba(34,197,94,.25);
        box-shadow: 0 6px 16px rgba(34,197,94,.3);
    }

/* Execution flow button - disabled/waiting */
.btn-exec-wait {
    border: 1px solid rgba(148,163,184,.3);
    background: rgba(15,23,42,.4);
    color: rgba(148,163,184,.5);
    cursor: not-allowed;
    opacity: 0.5;
    position: relative;
}

    .btn-exec-wait::after {
        content: "🔒";
        margin-left: 4px;
        font-size: 10px;
    }

/* Disabled button universal styles */
.btn:disabled,
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Order settings text */
.order-settings-text {
    font-size: 11px;
    color: #ffffff;
}

/* ========================================
11. PILLS & TAGS
======================================== */
.pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-full);
    border: 1px solid rgba(148,163,184,.4);
    background: rgba(15,23,42,.6);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

    .pill:hover {
        border-color: rgba(56,189,248,.6);
        background: rgba(56,189,248,.1);
    }

    .pill.active {
        border-color: rgba(34,197,94,.8);
        background: rgba(34,197,94,.2);
        color: #22c55e;
        font-weight: 700;
    }

.tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    border: 1px solid rgba(34,197,94,.35);
    background: rgba(34,197,94,.12);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-full);
    font-weight: 950;
    font-size: 12px;
    color: #dcfce7;
}

/* ========================================
12. DISCLOSURES
======================================== */
details.disclosure {
    border: 1px solid rgba(31,41,55,.65);
    border-radius: var(--radius-2);
    background: rgba(15,23,42,.18);
    margin-top: var(--space-2);
    overflow: hidden;
}

    details.disclosure > summary {
        cursor: pointer;
        padding: var(--space-2) var(--space-3);
        font-weight: 950;
        font-size: 12px;
        list-style: none;
        display: flex;
        gap: var(--space-2);
        align-items: center;
    }

        details.disclosure > summary::-webkit-details-marker {
            display: none;
        }

.chev {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    border: 1px solid rgba(148,163,184,.35);
    background: rgba(2,6,23,.22);
    font-size: 12px;
    transform: rotate(0deg);
    transition: transform .12s ease;
    flex: 0 0 auto;
}

details.disclosure[open] .chev {
    transform: rotate(90deg);
}

.disc-body {
    padding: 0 var(--space-3) var(--space-3);
}

/* INFO DISCLOSURE BUTTON - More prominent style */
details.info-disclosure {
    background: rgba(56,189,248,.08);
    border: 1px solid rgba(56,189,248,.25);
}

    details.info-disclosure > summary.info-btn {
        width: 100%;
        padding: 10px 14px;
        font-size: 12px;
        font-weight: 600;
        color: #38bdf8;
        background: rgba(56,189,248,.12);
        border-radius: var(--radius-2) var(--radius-2) 0 0;
    }

    details.info-disclosure[open] > summary.info-btn {
        border-radius: var(--radius-2) var(--radius-2) 0 0;
    }

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(56,189,248,.2);
    font-size: 11px;
    margin-right: 6px;
}

.muted {
    color: var(--muted);
    font-size: 12px;
    font-weight: 450;
    white-space: pre-line;
}

.msgline {
    color: var(--msg);
    font-size: 12px;
    font-weight: 900;
    margin-top: var(--space-2);
}

/* ========================================
13. MODALS
======================================== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.65);
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    z-index: 1000;
}

    .overlay.open {
        display: flex;
    }

.modal {
    width: min(1040px, 100%);
    border-radius: var(--radius-3);
    border: 1px solid rgba(31,41,55,.85);
    background: radial-gradient(circle at top left, rgba(15,23,42,.95), #020617 70%);
    box-shadow: 0 30px 90px rgba(0,0,0,.85);
    overflow: hidden;
    max-height: min(86vh, 920px);
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-4) var(--space-2);
    border-bottom: 1px solid rgba(31,41,55,.65);
    align-items: flex-start;
    flex-shrink: 0;
}

.modal-title {
    font-size: 16px;
    font-weight: 950;
}

.modal-sub {
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
}

.close {
    border: 1px solid rgba(148,163,184,.55);
    background: rgba(15,23,42,.85);
    color: var(--text);
    border-radius: var(--radius-full);
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
    font-size: 12px;
    font-weight: 950;
    min-height: 36px;
    flex-shrink: 0;
}

.modal-body {
    padding: var(--space-3) var(--space-4) var(--space-4);
    overflow: auto;
    flex: 1 1 auto;
}

/* ========================================
14. TABS - NEVER WRAP (Foundation Rule)
All tab containers use: flex + nowrap + overflow-x:auto
======================================== */
.tab-bar,
#vpTabs.vp-tabs,
.sub-tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

    .tab-bar::-webkit-scrollbar,
    #vpTabs.vp-tabs::-webkit-scrollbar,
    .sub-tabs::-webkit-scrollbar {
        display: none;
    }

#vpTabs.vp-tabs {
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-2) var(--space-3) 0;
    margin: var(--space-1) 0 var(--space-2);
    border-bottom: 1px solid rgba(31,41,55,.65);
    background: rgba(15,23,42,.65);
    border-radius: var(--radius-2) var(--radius-2) 0 0;
}

.vp-tab {
    appearance: none;
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 900;
    letter-spacing: .02em;
    padding: var(--space-2) var(--space-1) var(--space-3);
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    flex: 0 0 auto;
    min-height: var(--tab-h);
}

    .vp-tab:hover {
        color: var(--text);
    }

    .vp-tab.active {
        color: var(--text);
    }

        .vp-tab.active::after {
            content: "";
            position: absolute;
            left: 0;
            right: 0;
            bottom: -1px;
            height: 2px;
            border-radius: var(--radius-full);
            background: linear-gradient(90deg, #38bdf8, #22c55e);
        }

/* Sub-tabs for Holdings */
.sub-tabs {
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-1);
}

.sub-tab {
    appearance: none;
    background: rgba(15,23,42,.75);
    border: 1px solid rgba(148,163,184,.35);
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .02em;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-full);
    cursor: pointer;
    white-space: nowrap;
    flex: 0 0 auto;
}

    .sub-tab:hover {
        color: var(--text);
        border-color: rgba(148,163,184,.55);
    }

    .sub-tab.active {
        color: var(--text);
        border-color: rgba(56,189,248,.7);
        background: rgba(56,189,248,.15);
    }

/* ========================================
15. TABLES - Horizontal Scroll with Sticky First Column
(Option A from foundation plan)
======================================== */
.tablewrap {
    border: 1px solid var(--border);
    border-radius: var(--radius-2);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: rgba(2,6,23,.35);
    margin-top: var(--space-2);
}

table {
    width: 100%;
    min-width: var(--table-min-width);
    border-collapse: collapse;
    font-size: 13px;
}

th, td {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid rgba(31,41,55,.6);
    font-weight: 450;
}

th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    font-weight: 900;
    text-align: left;
    background: rgba(15,23,42,.65);
    position: sticky;
    top: 0;
    z-index: 1;
}

/* Sticky first column for tables */
.tablewrap td:first-child,
.tablewrap th:first-child {
    position: sticky;
    left: 0;
    background: rgba(15,23,42,.95);
    z-index: 2;
}

.tablewrap th:first-child {
    z-index: 3;
}

.right {
    text-align: right;
}

/* SHARED EXNET TABLE STYLE (Back Test, Forward Test, Holdings) */
.exnet-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12.5px;
}

    .exnet-table th,
    .exnet-table td {
        padding: 10px 10px;
        font-size: 12.5px;
        border-bottom: 1px solid rgba(255,255,255,.06);
    }

    .exnet-table th {
        font-weight: 600;
        opacity: .9;
        background: rgba(15,23,42,.65);
        text-transform: none;
        letter-spacing: 0;
    }

        .exnet-table td.num,
        .exnet-table th.num {
            text-align: right;
            font-variant-numeric: tabular-nums;
        }

    .exnet-table .ticker-col {
        width: 70px;
        font-family: ui-monospace, monospace;
        font-weight: 600;
    }

    .exnet-table tbody tr:hover {
        background: rgba(56,189,248,.05);
    }

.hscroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-2);
    border: 1px solid var(--border);
    background: rgba(2,6,23,.25);
    margin-top: var(--space-2);
}

table.tech {
    width: max-content;
    min-width: 100%;
    font-size: 12px;
}

    table.tech th, table.tech td {
        white-space: nowrap;
        font-weight: 450;
    }

    table.tech th {
        font-size: 10.5px;
        font-weight: 900;
    }

/* Forward Test table */
table.fwd-test {
    width: 100%;
    font-size: 12px;
}

    table.fwd-test th {
        padding: var(--space-2);
        font-weight: 700;
        text-align: center;
        vertical-align: bottom;
        line-height: 1.3;
    }

    table.fwd-test td {
        padding: var(--space-2);
        text-align: center;
    }

        table.fwd-test th:first-child,
        table.fwd-test td:first-child {
            text-align: left;
        }

    table.fwd-test .right {
        text-align: right;
    }

a.ticker {
    color: var(--link);
    text-decoration: none;
    font-weight: 950;
}

    a.ticker:hover {
        color: var(--linkHover);
        text-decoration: underline;
    }

/* ========================================
ORDER FLOW STEPPER
======================================== */
/* ========================================
ORDER PROGRESS INDICATOR
========================================
A lightweight state indicator (NOT navigation buttons).
- Appears ONLY in Order mode (after clicking "Create Order")
- Shows: Review ✓ → Package → Institution → Send
- Clicking may switch tabs but does NOT enforce flow
- Disappears when exiting Order mode
*/
/* ORDER PROGRESS INDICATOR - DISABLED */
.order-progress {
    display: none !important; /* Rolled back - using original stepper */
}

    .order-progress .step {
        display: flex;
        align-items: center;
        gap: 4px;
        padding: 4px 8px;
        border-radius: 4px;
        color: var(--muted);
        font-weight: 500;
        transition: all .15s;
        cursor: pointer;
    }

        .order-progress .step:hover {
            background: rgba(56,189,248,.1);
        }

        .order-progress .step.done {
            color: #22c55e;
        }

            .order-progress .step.done .step-check {
                display: inline;
            }

            .order-progress .step.done .step-num {
                display: none;
            }

        .order-progress .step.active {
            color: #38bdf8;
            background: rgba(56,189,248,.15);
        }

        .order-progress .step.pending {
            color: var(--muted);
            opacity: .6;
        }

    .order-progress .step-check {
        display: none;
        font-size: 10px;
    }

    .order-progress .step-num {
        font-size: 9px;
        opacity: .7;
    }

    .order-progress .arrow {
        color: var(--muted);
        opacity: .4;
        font-size: 10px;
        margin: 0 2px;
    }
/* Mobile hint - subtle guidance text */
.order-progress-hint {
    display: none;
    width: 100%;
    text-align: center;
    font-size: 10px;
    color: var(--muted);
    padding-top: 6px;
    font-style: italic;
}

/* REMOVED: old order-stepper styles replaced by order-progress */
.order-stepper {
    display: none !important;
}

.order-step, .order-step-hint {
    display: none !important;
}

/* ORDER MODE SEPARATION */
/* In Portfolio mode: hide progress indicator, show tabs + "Create Order" CTA */
.portfolio-overlay[data-ui-mode="portfolio"] .order-progress {
    display: none !important;
}

.portfolio-overlay[data-ui-mode="portfolio"] .create-order-cta {
    display: flex !important;
}

    /* Hide Create Order CTA when portfolio is retrieved or in order flow */
    .portfolio-overlay[data-ui-mode="portfolio"] .create-order-cta.hidden {
        display: none !important;
    }

/* In Order mode: progress indicator disabled */
.portfolio-overlay[data-ui-mode="order"] .order-progress {
    display: none !important;
}

.portfolio-overlay[data-ui-mode="order"] .create-order-cta {
    display: none !important;
}

.portfolio-overlay[data-ui-mode="order"] .disclosure {
    display: none !important;
}

.portfolio-overlay[data-ui-mode="order"] #vpDisclaimer {
    display: none !important;
}

/* Mobile: show hint in Order mode */
@media (max-width: 520px) {
    .portfolio-overlay[data-ui-mode="order"] .order-progress-hint {
        display: block;
    }
}

/* Create Order CTA at bottom of portfolio view */
.create-order-cta {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 8px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(34,197,94,.15), rgba(56,189,248,.15));
    border: 1px solid rgba(34,197,94,.4);
    border-radius: 12px;
    cursor: pointer;
}

    .create-order-cta:hover {
        background: linear-gradient(135deg, rgba(34,197,94,.25), rgba(56,189,248,.25));
    }

.create-order-cta-icon {
    font-size: 20px;
}

.create-order-cta-text {
    font-size: 15px;
    font-weight: 700;
    color: #22c55e;
}

.create-order-cta-sub {
    font-size: 12px;
    color: var(--muted);
}

@media (max-width: 520px) {
    .order-step {
        padding: 5px 8px;
        font-size: 10px;
    }
}

/* ========================================
16. FORMS
======================================== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
    margin-top: var(--space-3);
}

.field {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

    .field label {
        font-size: 11px;
        color: var(--muted);
        font-weight: 900;
        letter-spacing: .06em;
        text-transform: uppercase;
    }

    .field input, .field select {
        padding: var(--space-3);
        border-radius: var(--radius-2);
        border: 1px solid rgba(31,41,55,.9);
        background: rgba(15,23,42,.9);
        color: var(--text);
        outline: none;
        min-height: var(--input-h);
    }

/* ========================================
17. UTILITY CLASSES
======================================== */
.row {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    align-items: center;
}

.btnrow {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    align-items: center;
    margin-top: var(--space-3);
}

    /* Centered onboarding buttons — responsive grid */
    .btnrow.centered {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--space-2) !important;
        justify-items: stretch;
        align-items: stretch;
        max-width: 720px;
        margin: var(--space-3) auto 0 auto;
        width: 100%;
    }
        /* Button sizing inside the grid */
        .btnrow.centered .btn {
            width: 100% !important;
            max-width: none !important;
            font-size: 14px !important;
            padding: 12px 16px !important;
            text-align: center !important;
            justify-content: center !important;
            white-space: normal !important;
            line-height: 1.3 !important;
        }

    /* Onboarding buttons with inline flex-direction:column — responsive grid */
    .btnrow[style*="flex-direction:column"],
    .btnrow[style*="flex-direction: column"],
    .msg .btnrow,
    .msg.ai .btnrow,
    .chat .msg .btnrow,
    div.btnrow[style*="flex-direction"] {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: var(--space-2) !important;
        justify-items: stretch !important;
        align-items: stretch !important;
        max-width: 480px !important;
        margin: var(--space-3) auto 0 auto !important;
        width: 100% !important;
        flex-direction: unset !important;
    }

        .btnrow[style*="flex-direction:column"] .btn,
        .btnrow[style*="flex-direction: column"] .btn,
        .msg .btnrow .btn,
        .msg.ai .btnrow .btn,
        .chat .msg .btnrow .btn,
        div.btnrow[style*="flex-direction"] .btn {
            width: 100% !important;
            max-width: none !important;
            font-size: 14px !important;
            padding: 12px 16px !important;
            text-align: center !important;
            justify-content: center !important;
            white-space: normal !important;
            line-height: 1.3 !important;
        }

        /* Exception: long-text buttons stay flex on desktop */
        .msg .btnrow.long-text,
        .msg.ai .btnrow.long-text,
        .chat .msg .btnrow.long-text,
        div.btnrow.long-text[style*="flex-direction"] {
            display: flex !important;
            flex-direction: row !important;
            flex-wrap: wrap !important;
            grid-template-columns: none !important;
            max-width: none !important;
        }

/* Wide desktop: 3 columns */
@media (min-width: 1100px) {
    .btnrow.centered {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        max-width: 900px !important;
    }

    .btnrow[style*="flex-direction:column"],
    .btnrow[style*="flex-direction: column"],
    .msg .btnrow:not(.long-text),
    .msg.ai .btnrow:not(.long-text),
    .chat .msg .btnrow:not(.long-text),
    div.btnrow[style*="flex-direction"]:not(.long-text) {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        max-width: 600px !important;
    }
}

/* Long-text buttons - DESKTOP DEFAULT: horizontal row with wrap */
.btnrow.long-text {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-2);
    max-width: none;
}

    .btnrow.long-text .btn {
        width: auto;
        white-space: normal;
        line-height: 1.4;
        padding: var(--space-3) var(--space-4);
        font-size: 14px;
    }

.pill-row {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-bottom: var(--space-3);
}

/* Horizontal scroll row - use for any row that must not wrap */
.hscroll-row {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: var(--space-2);
    scrollbar-width: none;
    -ms-overflow-style: none;
}

    .hscroll-row::-webkit-scrollbar {
        display: none;
    }

    .hscroll-row > * {
        flex: 0 0 auto;
        white-space: nowrap;
    }

.mini {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-1);
    border: 1px solid rgba(148,163,184,.55);
    background: rgba(15,23,42,.75);
    color: var(--text);
    font-weight: 950;
    cursor: pointer;
    font-size: 12px;
    min-height: 36px;
    white-space: nowrap;
}

    .mini.primary {
        border: none;
        background: radial-gradient(circle at top left, var(--accent), var(--accent2));
        color: #f9fafb;
    }

    .mini.good {
        border: none;
        background: radial-gradient(circle at top left,#22c55e,#16a34a);
        color: #04110a;
    }

    .mini.bad {
        border: 1px solid rgba(239,68,68,.7);
        background: rgba(239,68,68,.10);
        color: #fecaca;
    }

.pricebox {
    display: flex;
    gap: 8px;
    align-items: center
}

    .pricebox input {
        flex: 1
    }

/* Forward Test model tilt dots */
.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    margin-right: 6px;
    vertical-align: middle
}

    .dot.green {
        background: #22c55e
    }

    .dot.yellow {
        background: #f59e0b
    }

    .dot.red {
        background: #ef4444
    }
/* Loading animation dots */
.loading-dots {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 8px;
}

    .loading-dots span {
        width: 6px;
        height: 6px;
        background: var(--accent);
        border-radius: 50%;
        animation: pulse 1.4s ease-in-out infinite;
    }

        .loading-dots span:nth-child(2) {
            animation-delay: 0.2s;
        }

        .loading-dots span:nth-child(3) {
            animation-delay: 0.4s;
        }

        .loading-dots span:nth-child(4) {
            animation-delay: 0.6s;
        }

        .loading-dots span:nth-child(5) {
            animation-delay: 0.8s;
        }

@keyframes pulse {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.sig-badge {
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

    .sig-badge.positive {
        background: rgba(34,197,94,.15);
        color: #22c55e;
    }

    .sig-badge.negative {
        background: rgba(239,68,68,.15);
        color: #ef4444;
    }

    .sig-badge.neutral {
        background: rgba(100,116,139,.15);
        color: #94a3b8;
    }

.stepmsg {
    color: var(--msg);
    font-weight: 900
}

/* ========================================
TABLET BREAKPOINT (521px - 899px)
======================================== */
@media (min-width:521px) and (max-width:899px) {
    .layout {
        flex-direction: column;
        padding: var(--space-4)
    }

    .sidebar {
        width: 100%
    }

    .main {
        max-width: 100%
    }

    .form-grid {
        grid-template-columns: 1fr
    }
}

/* ========================================
MOBILE LAYOUT SYSTEM (≤520px)
Foundation Pass - Stable Layout

SCROLL CONTRACT:
- html/body: no scroll (height: 100%)
- .layout: fills viewport minus header
- .main: flex container, overflow hidden
- .chat: THE ONLY scroll container
- .input-row: flex-shrink: 0 (always visible)
======================================== */
@media (max-width:520px) {
    /* 1. MOBILE LAYOUT - Minimal, natural scroll
    Let browser handle scrolling - no fixed heights
    -------------------------------------------------- */
    html, body {
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        overflow-x: hidden !important;
        overflow-y: unset !important;
    }

    .layout {
        display: block !important;
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        overflow: unset !important;
        padding: var(--space-1);
        padding-bottom: 150px !important;
    }

    .sidebar {
        display: none !important;
    }

    .main {
        display: block !important;
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        overflow: unset !important;
        width: 100%;
        padding: var(--space-2);
    }

    .chat {
        display: block !important;
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        overflow: unset !important;
    }
    /* 2. HEADER - Sticky at top
    -------------------------------------------------- */
    .top-nav {
        position: sticky !important;
        top: 0 !important;
        z-index: 100 !important;
        height: var(--header-h);
        padding: 0 var(--space-2);
        gap: var(--space-2);
        background: var(--bg) !important;
    }

    .nav-left {
        gap: var(--space-1);
    }

    .nav-logo {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }

    .nav-title {
        font-size: 12px;
    }

    .nav-links {
        gap: var(--space-6);
        font-size: 11px;
        flex: 1;
        justify-content: center;
    }

    .nav-right {
        display: none;
    }
    /* Page header - compact, no dead space */
    .main > div:first-child {
        padding: var(--space-1) 0;
        flex-shrink: 0;
    }

    .panel-title {
        font-size: 12px;
        margin-bottom: 0;
    }

    /*.panel-sub {
        display: none;
    }*/
    /* 3. CHAT MESSAGES
    -------------------------------------------------- */

    .msg {
        max-width: 100%;
        padding: var(--space-2);
        margin-bottom: var(--space-1);
        font-size: 14px;
        line-height: 1.45;
        border-radius: var(--radius-2);
    }
        /* Reduce internal spacing in AI messages */
        .msg.ai {
            padding: var(--space-2);
        }

            .msg.ai > div:first-child {
                margin-top: 0;
            }

            .msg.ai b, .msg.ai strong {
                display: block;
                margin-bottom: var(--space-1);
            }

    .msg-step {
        font-size: 10px;
        margin-bottom: 2px;
    }

    .msg b, .msg strong {
        font-size: 14px;
    }

    .edit-icon {
        right: 4px;
        top: 4px;
        font-size: 11px;
    }
    /* 4. INPUT ROW - Always at bottom of content
    -------------------------------------------------- */
    .input-row {
        display: flex;
        margin-top: var(--space-2);
        padding: var(--space-2);
        padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom, 20px));
        gap: var(--space-2);
        background: var(--bg);
        border-top: 1px solid var(--border);
    }

        .input-row input {
            min-height: var(--input-h);
            padding: var(--space-2) var(--space-3);
            font-size: 14px;
        }

    .send-btn {
        min-height: var(--btn-h);
        min-width: 60px;
        padding: var(--space-2) var(--space-3);
        font-size: 13px;
    }

    .footer {
        display: none;
    }
    /* 5. BUTTONS - Touch-friendly with controlled wrap
    -------------------------------------------------- */
    .btn {
        min-height: var(--btn-h);
        padding: var(--space-2) var(--space-3);
        font-size: 13px;
        border-radius: var(--radius-2);
        line-height: 1.3;
        word-break: normal;
    }

    .btn-primary {
        padding: var(--space-2) var(--space-4);
    }

    .mini {
        min-height: 36px;
        padding: var(--space-2) var(--space-3);
        font-size: 12px;
        white-space: nowrap;
    }
    /* 6. PILLS - 2-column grid with proper sizing
    -------------------------------------------------- */
    .pill {
        padding: var(--space-1) var(--space-2);
        font-size: 13px;
        min-height: 36px;
        /* Allow text to wrap for long labels */
        white-space: normal;
        word-break: normal;
        overflow-wrap: break-word;
        line-height: 1.3;
        text-align: center;
    }

    .pill-row,
    [data-pill-type] {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: var(--space-1) !important;
    }

        .pill-row .pill,
        [data-pill-type] .pill {
            width: 100%;
            text-align: center;
            justify-content: center;
        }
    /* Button rows - compact grid layout for multi-button choices */
    .btnrow {
        gap: var(--space-1);
        margin-top: var(--space-2);
    }

        .btnrow .btn {
            flex: 1 1 auto;
            min-width: 0;
            padding: var(--space-2) var(--space-3);
            font-size: 14px;
        }
        /* Vertical button stack (age bands, etc) - use 2-col grid when many buttons */
        .btnrow[style*="flex-direction: column"],
        .btnrow[style*="flex-direction:column"] {
            display: grid !important;
            grid-template-columns: repeat(2, 1fr) !important;
            gap: var(--space-1) !important;
        }

            .btnrow[style*="flex-direction: column"] .btn,
            .btnrow[style*="flex-direction:column"] .btn {
                width: 100%;
                margin: 0 !important;
            }
        /* STRONGER OVERRIDE: Explicitly force 2-col grid for Steps 1,2,3 (excludes long-text and centered) */
        .msg .btnrow:not(.centered):not(.long-text),
        .btnrow:not(.centered):not(.long-text)[style*="flex-direction:column"] {
            display: grid !important;
            grid-template-columns: repeat(2, 1fr) !important;
            gap: 6px !important;
            max-width: 320px !important;
            margin-left: auto !important;
            margin-right: auto !important;
        }

            .msg .btnrow:not(.centered):not(.long-text) .btn,
            .btnrow:not(.centered):not(.long-text) .btn {
                width: 100% !important;
                margin: 0 !important;
                white-space: nowrap !important;
                overflow: hidden !important;
                text-overflow: ellipsis !important;
            }
        /* EXCEPTION: .btnrow.long-text stays single column with full text (Steps 4, 4.2, 4.3) */
        .btnrow.long-text {
            display: flex !important;
            flex-direction: column !important;
            grid-template-columns: none !important;
            gap: 8px !important;
            max-width: 340px !important;
            margin-left: auto !important;
            margin-right: auto !important;
        }

            .btnrow.long-text .btn {
                width: 100% !important;
                white-space: normal !important;
                text-overflow: clip !important;
                overflow: visible !important;
                line-height: 1.4 !important;
                padding: 10px 14px !important;
                font-size: 13px !important;
            }
        /* Mobile: switch to 1 column */
        .btnrow.centered[style*="flex-direction: column"],
        .btnrow.centered[style*="flex-direction:column"],
        .btnrow.centered {
            grid-template-columns: 1fr !important;
            max-width: 360px !important;
            margin-left: auto !important;
            margin-right: auto !important;
        }

            .msg .btnrow.centered .btn,
            .btnrow.centered .btn {
                width: 100% !important;
                max-width: none !important;
                font-size: 13px !important;
                padding: 10px 14px !important;
                white-space: normal !important;
                line-height: 1.3 !important;
                text-overflow: clip !important;
                overflow: visible !important;
                text-align: center !important;
            }
    /* Disclosure body buttons - allow wrap */
    .disc-body .btn {
        white-space: normal !important;
        text-overflow: clip !important;
        overflow: visible !important;
        line-height: 1.3 !important;
    }
    /* 7. TABS - Horizontal scroll, NEVER wrap
    -------------------------------------------------- */
    #vpTabs.vp-tabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        gap: var(--space-1);
        padding: var(--space-1) var(--space-2) 0;
        margin: var(--space-1) 0;
        /* WRAP instead of scroll - Execution tab always visible */
        flex-wrap: wrap !important;
        overflow-x: visible !important;
    }

    .vp-tab {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
        padding: var(--space-1) var(--space-2);
        font-size: 13px;
        min-height: 36px;
    }

    .sub-tabs {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: var(--space-1);
        margin-bottom: var(--space-2);
    }

    .sub-tab {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
        padding: var(--space-1) var(--space-2);
        font-size: 10px;
        min-height: 28px;
    }
    /* 8. TABLES - Horizontal scroll with sticky first col
    No text wrapping in cells - use horizontal scroll
    -------------------------------------------------- */
    .tablewrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: var(--space-2) calc(-1 * var(--space-2));
        border-radius: var(--radius-1);
    }

        .tablewrap table {
            font-size: 14px;
            min-width: 600px;
            table-layout: auto;
        }

        .tablewrap th,
        .tablewrap td {
            padding: var(--space-2);
            font-size: 14px;
            white-space: nowrap;
            max-width: none;
        }

        .tablewrap th {
            font-size: 12px;
        }
            /* Allow NAME column to wrap slightly but limit width */
            .tablewrap td:nth-child(4),
            .tablewrap th:nth-child(4) {
                white-space: normal;
                max-width: 100px;
                min-width: 80px;
            }

    .hscroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: var(--space-2) calc(-1 * var(--space-2));
    }

    table.tech {
        font-size: 12px;
    }

        table.tech th, table.tech td {
            padding: var(--space-1) var(--space-2);
            font-size: 12px;
            white-space: nowrap;
        }

        table.tech th {
            font-size: 10px;
        }
    /* Form elements - larger touch targets and text */
    select, input[type="text"], input[type="email"], input[type="number"] {
        font-size: 16px !important; /* Prevents iOS zoom */
        min-height: 48px !important;
        padding: 12px 14px !important;
    }
    /* All select elements in modals */
    .modal select,
    .modal-body select,
    .form-grid select {
        font-size: 16px !important;
        min-height: 48px !important;
        padding: 12px 14px !important;
        width: 100% !important;
    }

        .modal select option,
        .modal-body select option {
            font-size: 16px !important;
            padding: 12px !important;
        }

    .field label {
        font-size: 14px !important;
    }
    /* Bank select dropdown options */
    #bankSelect {
        font-size: 18px !important;
        width: 100% !important;
        min-height: 52px !important;
    }

        #bankSelect option {
            font-size: 18px !important;
            padding: 14px !important;
            line-height: 1.5;
        }
    /* Modal content larger fonts */
    .modal-body {
        font-size: 15px;
    }

        .modal-body .muted {
            font-size: 14px;
        }

        .modal-body .field {
            font-size: 15px;
        }
        /* Pills and labels in modals */
        .modal-body .pill {
            font-size: 13px;
        }
    /* Custom bank dropdown styling */
    .bank-option {
        font-size: 18px !important;
        padding: 16px 18px !important;
        min-height: 52px !important;
    }

        .bank-option:active,
        .bank-option:hover {
            background: rgba(56,189,248,.2) !important;
        }

    #bankSelectBtn {
        font-size: 18px !important;
        min-height: 52px !important;
    }

    #bankSelectText {
        font-size: 18px !important;
    }

    #bankSelectList {
        font-size: 18px !important;
    }
    /* 9. MODAL - Full screen with proper scroll
    -------------------------------------------------- */
    .overlay {
        padding: 0 !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
    }

        .overlay .modal {
            display: flex;
            flex-direction: column;
            width: 100% !important;
            max-width: 100% !important;
            height: 100vh !important;
            height: 100dvh !important;
            max-height: 100vh !important;
            max-height: 100dvh !important;
            border-radius: 0 !important;
            overflow: hidden !important;
        }

    .modal-header {
        flex: 0 0 auto;
        padding: var(--space-2) var(--space-3);
        gap: var(--space-2);
    }

    .modal-title {
        font-size: 14px;
    }

    .modal-sub {
        font-size: 10px;
    }

    .close {
        padding: var(--space-2);
        font-size: 11px;
        height: 32px;
        white-space: nowrap;
    }

    .modal-body {
        flex: 1 1 auto;
        min-height: 0;
        padding: var(--space-2);
        padding-bottom: calc(env(safe-area-inset-bottom, 20px) + 120px) !important;
        overflow-y: scroll !important;
        -webkit-overflow-scrolling: touch;
    }

    #vpTabContent,
    .vp-content {
        padding: var(--space-2) !important;
        padding-bottom: 150px !important;
    }
    /* 10. STICKY BOTTOM BAR - For execution, confirmation
    -------------------------------------------------- */
    .mobile-sticky-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: var(--bottom-bar-h);
        padding: var(--space-2) var(--space-3);
        padding-bottom: max(var(--space-2), env(safe-area-inset-bottom));
        background: var(--bg);
        border-top: 1px solid var(--border);
        z-index: 1000;
    }

        .mobile-sticky-bar .primary-cta {
            width: 100%;
            min-height: var(--btn-h);
        }
    /* Content padding when sticky bar present */
    .portfolio-overlay[data-mode="execution"] .modal-body {
        padding-bottom: calc(var(--bottom-bar-h) + var(--space-4)) !important;
    }
    /* Execution tab - ensure all content visible above sticky bar */
    .portfolio-overlay[data-mode="execution"] #vpTabContent,
    .portfolio-overlay[data-mode="execution"] .vp-content {
        padding-bottom: 80px !important;
    }
    /* Execution tab - ensure all content visible */
    #vpTabContent {
        padding-bottom: var(--space-5) !important;
    }
    /* Execution flow step buttons - compact row */
    .vp-content > div[style*="display: flex"][style*="gap"] {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: var(--space-2);
    }
    /* Hide tabs in execution mode */
    .portfolio-overlay[data-mode="execution"] #vpTabs.vp-tabs {
        display: none !important;
    }
    /* 11. MOBILE ORDER CARDS
    -------------------------------------------------- */
    .mobile-order-cards {
        display: none;
    }

    .portfolio-overlay[data-mode="execution"] .mobile-order-cards {
        display: block !important;
    }

    .portfolio-overlay[data-mode="execution"] .tablewrap.hide-mobile {
        display: none !important;
    }

    .mobile-order-card {
        padding: 12px 14px;
        margin-bottom: 10px;
        border-radius: var(--radius-2);
        background: var(--panel);
        border: 1px solid var(--border);
    }

        .mobile-order-card.buy {
            border-left: 3px solid var(--ok);
        }

        .mobile-order-card.sell {
            border-left: 3px solid var(--bad);
        }

        .mobile-order-card .card-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            gap: 8px;
        }

        .mobile-order-card .ticker-name {
            font-size: 16px;
            font-weight: 700;
            color: var(--text);
        }

        .mobile-order-card .ticker-desc {
            font-size: 13px;
            color: var(--muted);
            margin-top: 2px;
        }

        .mobile-order-card .action-badge {
            font-size: 12px;
            font-weight: 700;
            padding: 4px 8px;
            border-radius: 4px;
            text-transform: uppercase;
        }

            .mobile-order-card .action-badge.buy {
                background: rgba(34,197,94,.2);
                color: #22c55e;
            }

            .mobile-order-card .action-badge.sell {
                background: rgba(239,68,68,.2);
                color: #ef4444;
            }

        .mobile-order-card .card-amount {
            font-size: 18px;
            font-weight: 700;
            color: var(--text);
            margin: 8px 0 6px;
        }

        .mobile-order-card .card-meta {
            font-size: 13px;
            color: var(--muted);
        }

        .mobile-order-card .why-trade-drawer {
            margin-top: 10px;
            font-size: 13px;
        }

            .mobile-order-card .why-trade-drawer summary {
                cursor: pointer;
                color: var(--muted);
                font-size: 13px;
            }

        .mobile-order-card .why-content {
            margin-top: 6px;
            font-size: 13px;
            color: var(--muted);
        }

        .mobile-order-card .card-actions {
            margin-top: 10px;
        }
    /* 12. TYPOGRAPHY
    -------------------------------------------------- */
    .muted {
        font-size: 13px;
    }

    .msgline {
        font-size: 13px;
    }

    .stepmsg {
        font-size: 12px;
    }

    a.ticker {
        font-size: 11px;
    }

    details.disclosure > summary {
        padding: var(--space-2) var(--space-3);
        font-size: 14px;
    }

    .disc-body {
        padding: 0 var(--space-3) var(--space-3);
        font-size: 11px;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: var(--space-2);
    }

    .field label {
        font-size: 9px;
    }

    .field input, .field select {
        min-height: var(--input-h);
        padding: var(--space-3);
        font-size: 14px;
    }
}

/* ========================================
EXTRA SMALL (≤375px) - iPhone SE
======================================== */
@media (max-width:375px) {
    :root {
        --card-pad: var(--space-1);
        --section-gap: var(--space-1);
    }

    .btn {
        padding: var(--space-2);
        font-size: 12px;
        min-height: 40px;
    }

    .pill {
        font-size: 10px;
        padding: var(--space-1) var(--space-2);
    }

    .vp-tab {
        font-size: 12px;
        padding: var(--space-1) var(--space-2);
    }

    .tablewrap table {
        min-width: 520px;
    }
    /* More compact btnrow on smallest screens */
    .btnrow {
        gap: 4px !important;
    }

        .btnrow .btn {
            padding: var(--space-1) var(--space-2) !important;
            font-size: 11px !important;
            min-height: 36px !important;
        }
        /* 3-column grid for many options */
        .btnrow[style*="flex-direction: column"],
        .btnrow[style*="flex-direction:column"] {
            grid-template-columns: repeat(3, 1fr) !important;
        }
        /* .btnrow.centered stays single column on tiny screens */
        .btnrow.centered[style*="flex-direction: column"],
        .btnrow.centered[style*="flex-direction:column"],
        .btnrow.centered {
            grid-template-columns: 1fr !important;
            max-width: 320px !important;
            gap: var(--space-2) !important;
        }

            .msg .btnrow.centered .btn,
            .btnrow.centered .btn {
                width: 100% !important;
                max-width: none !important;
                font-size: 12px !important;
                padding: 10px 12px !important;
                white-space: normal !important;
                line-height: 1.3 !important;
                min-height: 44px !important;
                text-overflow: clip !important;
                overflow: visible !important;
                text-align: center !important;
            }
    /* Disclosure body buttons on tiny screens */
    .disc-body .btn {
        white-space: normal !important;
        text-overflow: clip !important;
        overflow: visible !important;
        font-size: 11px !important;
    }
}

/* ========================================
VERY SMALL (≤360px) - Small Android
======================================== */
@media (max-width:360px) {
    .nav-title {
        display: none;
    }

    .msg {
        padding: var(--space-2);
        font-size: 12px;
    }
}

/* ========================================
DESKTOP - Hide mobile-only elements
======================================== */
@media (min-width:521px) {
    .mobile-order-cards {
        display: none !important;
    }

    .mobile-sticky-bar {
        display: none !important;
    }

    .mobile-only {
        display: none !important;
    }
}

/* ========================================
DESKTOP RESETS (≥900px)
Explicit desktop layout enforcement
======================================== */
@media (min-width:900px) {
    /* 1. LAYOUT - Desktop grid structure */
    html, body {
        overflow: visible;
        height: auto;
    }

    .layout {
        display: flex;
        flex-direction: row;
        gap: var(--space-5);
        padding: var(--space-5) var(--space-6) var(--space-6);
        min-height: calc(100vh - var(--header-h));
        height: auto;
        overflow: visible;
    }

    .sidebar {
        display: flex !important;
        width: 260px;
        flex-shrink: 0;
        position: sticky;
        top: calc(var(--header-h) + 16px);
        align-self: flex-start;
        max-height: calc(100vh - var(--header-h) - 32px);
        overflow-y: auto;
    }
        /* Desktop: Increase sidebar pills and labels by 20% */
        .sidebar .pill {
            font-size: 14.4px; /* 12px * 1.2 = 14.4px */
            padding: 9.6px 14.4px; /* (8px 12px) * 1.2 */
        }

        .sidebar .step-item {
            font-size: 14.4px; /* 12px * 1.2 = 14.4px */
            padding: 9.6px; /* 8px * 1.2 */
        }

    .sidebar-title {
        font-size: 18px !important; /* 15px * 1.2 = 18px */
    }

    .sidebar-sub {
        font-size: 14.4px !important; /* 12px * 1.2 = 14.4px */
    }

    .sidebar-tip {
        font-size: 13.2px !important; /* 11px * 1.2 = 13.2px */
    }

    .main {
        flex: 1;
        max-width: 980px;
        margin: 0 auto;
        padding: var(--card-pad) var(--space-4);
        min-height: auto;
        overflow: visible;
    }
    /* 2. HEADER - Full desktop spacing */
    .top-nav {
        height: var(--header-h);
        padding: 0 var(--space-6);
    }

    .nav-left {
        gap: var(--space-2);
    }

    .nav-logo {
        width: 26px;
        height: 26px;
        font-size: 13px;
    }

    .nav-title {
        font-size: 15px;
        display: block;
    }

    .nav-links {
        gap: var(--space-6);
        font-size: 13px;
    }

    .nav-right {
        display: block;
    }

    .panel-title {
        font-size: 15px;
    }

    /*
    .panel-sub {
        display: block;
    }*/
    /* 3. TABS - Horizontal, no wrap */
    #vpTabs.vp-tabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        gap: var(--space-3);
        padding: var(--space-2) var(--space-3) 0;
    }

    .vp-tab {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
        padding: var(--space-2) var(--space-1) var(--space-3);
        font-size: 12.5px;
        min-height: var(--tab-h);
    }

    .sub-tabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        gap: var(--space-2);
    }

    .sub-tab {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
        padding: var(--space-2) var(--space-3);
        font-size: 11px;
    }
    /* 4. TABLES - Proper table layout (no stacked cards) */
    .tablewrap {
        overflow-x: auto;
        margin: var(--space-2) 0;
        border-radius: var(--radius-2);
    }

        .tablewrap table {
            min-width: var(--table-min-width);
            table-layout: auto;
            display: table;
        }

        .tablewrap th,
        .tablewrap td {
            display: table-cell;
            padding: var(--space-2) var(--space-3);
            font-size: 13px;
        }

        .tablewrap th {
            font-size: 11px;
        }

    table.tech {
        display: table;
        font-size: 12px;
    }

        table.tech th, table.tech td {
            display: table-cell;
            padding: var(--space-2);
            font-size: 10.5px;
        }
    /* 5. MODAL - Centered, not full-screen */
    .overlay {
        padding: var(--space-4);
        align-items: center;
        justify-content: center;
    }

        .overlay .modal {
            width: min(1040px, 100%);
            max-width: 1040px;
            height: auto;
            max-height: min(86vh, 920px);
            border-radius: var(--radius-3);
        }

    .modal-header {
        padding: var(--space-4) var(--space-4) var(--space-2);
    }

    .modal-title {
        font-size: 16px;
    }

    .modal-sub {
        font-size: 12px;
    }

    .modal-body {
        padding: var(--space-3) var(--space-4) var(--space-4);
    }
    /* 6. BUTTONS - Desktop sizing */
    .btn {
        min-height: var(--btn-h);
        padding: var(--space-3) var(--space-4);
        font-size: 14px;
    }

    .btnrow {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--space-2);
    }
    /* Keep grid layout for onboarding buttons in messages */
    .msg .btnrow:not(.long-text) {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        max-width: 480px;
        margin-left: auto;
        margin-right: auto;
    }

        .msg .btnrow:not(.long-text) .btn {
            width: 100%;
            white-space: nowrap;
        }
    /* Reset long-text buttons for desktop */
    .btnrow.long-text {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        max-width: none;
        margin-left: 0;
        margin-right: 0;
    }

        .btnrow.long-text .btn {
            width: auto;
            padding: var(--space-3) var(--space-4);
            font-size: 14px;
        }
    /* 7. PILLS - Horizontal row */
    .pill {
        padding: var(--space-2) var(--space-3);
        font-size: 12px;
        white-space: nowrap;
    }

    .pill-row,
    [data-pill-type] {
        display: flex;
        grid-template-columns: none;
        flex-wrap: wrap;
        gap: var(--space-2);
    }
    /* 8. CHAT - Normal scroll */
    .chat {
        flex: 1 1 auto;
        overflow-y: auto;
        padding: var(--card-pad);
    }

    .msg {
        max-width: 92%;
        padding: var(--card-pad);
        font-size: 13px;
    }
    /* 9. FOOTER - Visible */
    .footer {
        display: flex;
    }
    /* 10. TYPOGRAPHY */
    .muted {
        font-size: 12px;
    }

    .msgline {
        font-size: 12px;
    }

    .msg-step {
        font-size: 11px;
    }
    /* 11. FORMS */
    .form-grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-3);
    }

    .field label {
        font-size: 11px;
    }

    .field input, .field select {
        min-height: var(--input-h);
        padding: var(--space-3);
        font-size: 14px;
    }
}

/* Increase font size ONLY for top header nav items: AI Onboarding + Retrieve */
#aiOnboardingNav,
#retrievePortfolioNav {
    font-size: 1.2em;
}


/* Improve visibility of execution flow text */
.order-flow,
.flow-text,
.execution-flow,
#orderFlow {
    font-size: 1.15em;
    font-weight: 500;
}


/* Keep Save next to Close (prevents centered button) */
.vp-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Force header Save button to match your system button proportions */
#vpSaveBtn.btn.btn-primary {
    height: var(--btn-h);
    padding: 0 16px;
    font-size: 13px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Warning box (matches your dark UI) */
.vp-warn-box {
    border: 1px solid rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.08);
    padding: 12px;
    border-radius: 14px;
    color: #fde68a;
}

/* Warning modal button row */
.vp-warn-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 16px;
}