/* ---------------------------------------------------------------------------
   Regree - base, layout and components.
   Mobile-first: the desktop shell is layered on at >=1024px.
   --------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: var(--fs-md);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.015em; line-height: 1.25; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
p { margin: 0 0 var(--space-3); }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }

img, svg { max-width: 100%; }

hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-4) 0; }

::selection { background: var(--brand-soft); }

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

/* Every figure on screen uses aligned, tabular numerals. */
.num, td.num, .stat-value, .price, table.data td, table.data th {
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

/* --- scrollbars ---------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-full); border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); background-clip: content-box; }

/* ===========================================================================
   App shell
   =========================================================================== */

.shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0 var(--space-4);
    background: color-mix(in srgb, var(--bg-surface) 88%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.topbar__brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: 700;
    font-size: var(--fs-lg);
    letter-spacing: -.02em;
    color: var(--text-primary);
}

/* The wordmark is brand blue with a red/green rule under it. Blue reads on both
   the light and the dark ground, so NO theme filter - an invert here would turn
   the blue orange. (The earlier black wordmark did need one.)
   Aspect is 2.5:1, so height alone sets the size. */
.topbar__logo {
    width: auto;
    height: 42px;
    display: block;
    object-fit: contain;
}

/* The topbar is only 56px tall and has to hold the menu button, theme toggle and
   account menu beside this. Step the logo down rather than let it crowd them. */
@media (max-width: 767px) {
    .topbar__logo { height: 34px; }
}

@media (max-width: 400px) {
    .topbar__logo { height: 28px; }
}

.topbar__suffix {
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
}

.topbar__spacer { flex: 1; }

.topbar__actions { display: flex; align-items: center; gap: var(--space-2); }

.icon-btn {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-strong); }

.shell__body { flex: 1; display: flex; min-height: 0; }

/* --- sidebar --- */
.sidebar {
    position: fixed;
    inset: var(--topbar-h) auto 0 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform var(--dur) var(--ease);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 50;
    padding: var(--space-3) var(--space-2) var(--space-8);
}
.sidebar.is-open { transform: translateX(0); }

.sidebar__group { margin-bottom: var(--space-4); }
.sidebar__label {
    padding: var(--space-2) var(--space-3);
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 9px var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: var(--fs-base);
    font-weight: 500;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.is-active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-item.is-locked { color: var(--text-muted); }
.nav-item__icon { width: 18px; flex: none; display: grid; place-items: center; opacity: .9; }
.nav-item__lock { margin-left: auto; font-size: var(--fs-xs); }

.sidebar__scrim {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 45;
    opacity: 0; pointer-events: none;
    transition: opacity var(--dur) var(--ease);
}
.sidebar__scrim.is-open { opacity: 1; pointer-events: auto; }

/* --- main --- */
.main {
    flex: 1;
    min-width: 0;
    padding: var(--space-4);
    padding-bottom: calc(var(--bottomnav-h) + var(--space-5));
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
}
.page-head__title { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.page-head__sub { color: var(--text-secondary); font-size: var(--fs-sm); margin-top: 2px; }

/* Compact variant for pages where the content is the point and the heading is
   just a label - the strategy builder lost most of a screen to a 35px title and
   a subtitle on its own line. Title and meta share one row, and the heading
   drops to the size of a card title. */
.page-head--tight { margin-bottom: var(--space-3); align-items: baseline; }
.page-head--tight > div { display: flex; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; }
.page-head--tight h1 { font-size: var(--fs-lg); }
.page-head--tight .page-head__sub { margin-top: 0; }

@media (min-width: 768px) {
    /* The breakpoint block below takes every h1 to --fs-3xl; this has to win. */
    .page-head--tight h1 { font-size: var(--fs-xl); }
}

/* --- bottom nav (mobile) --- */
.bottomnav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottomnav-h);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: color-mix(in srgb, var(--bg-surface) 94%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    z-index: 40;
    padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    min-height: 44px;
}
.bottomnav a.is-active { color: var(--brand); }

/* ===========================================================================
   Components
   =========================================================================== */

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
}
.card__head {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.card__title { font-size: var(--fs-md); font-weight: 650; }
.card__body { padding: var(--space-4); }
.card__body--flush { padding: 0; }
.card__foot { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); }

.grid { display: grid; gap: var(--space-3); }
.grid--2 { grid-template-columns: 1fr; }
.grid--3 { grid-template-columns: 1fr; }
.grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* --- stat tiles --- */
.stat {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-3) var(--space-4);
    min-width: 0;
}
.stat__label {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 6px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat__value {
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
    font-size: var(--fs-xl);
    font-weight: 650;
    letter-spacing: -.02em;
    line-height: 1.15;
}
.stat__meta { font-size: var(--fs-xs); color: var(--text-secondary); margin-top: 4px; }

/* --- trend colours: colour is never the only signal, values carry a sign --- */
.is-bull { color: var(--bull); }
.is-bear { color: var(--bear); }
.is-flat { color: var(--text-secondary); }
.bg-bull { background: var(--bull-soft); }
.bg-bear { background: var(--bear-soft); }

/* --- pills & badges --- */
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: var(--fs-xs);
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}
.pill__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill--live { color: var(--bull); background: var(--bull-soft); border-color: color-mix(in srgb, var(--bull) 28%, transparent); }
.pill--live .pill__dot { animation: pulse 2s var(--ease) infinite; }
.pill--delayed { color: var(--warn); background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.pill--closed { color: var(--text-secondary); background: var(--bg-hover); border-color: var(--border); }
.pill--demo { color: var(--brand); background: var(--brand-soft); border-color: var(--brand-border); }
.pill--empty { color: var(--text-muted); background: var(--bg-hover); border-color: var(--border); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-xs);
    font-size: var(--fs-xs);
    font-weight: 600;
    background: var(--bg-hover);
    color: var(--text-secondary);
}
.badge--bull { background: var(--bull-soft); color: var(--bull); }
.badge--bear { background: var(--bear-soft); color: var(--bear); }
.badge--brand { background: var(--brand-soft); color: var(--brand); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--muted { background: var(--bg-hover); color: var(--text-muted); }

/* --- buttons --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    min-height: 38px;
    padding: 0 var(--space-4);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--fs-base);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.btn--danger { background: var(--bear); border-color: var(--bear); color: #fff; }
.btn--danger:hover { filter: brightness(1.08); color: #fff; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn--ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn--sm { min-height: 30px; padding: 0 10px; font-size: var(--fs-sm); }
.btn--block { width: 100%; }

/* --- forms --- */
.field { margin-bottom: var(--space-3); }
.label {
    display: block;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.input, .select, .textarea {
    width: 100%;
    min-height: 38px;
    padding: 8px var(--space-3);
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--fs-base);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
.input::placeholder { color: var(--text-muted); }
.textarea { min-height: 90px; resize: vertical; }
.select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: right 15px center, right 10px center;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 30px;
}
.field__error { color: var(--bear); font-size: var(--fs-xs); margin-top: 4px; }
.field__hint { color: var(--text-muted); font-size: var(--fs-xs); margin-top: 4px; }

.checkbox { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: var(--fs-base); }
.checkbox input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }

.switch { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track {
    width: 38px; height: 22px;
    border-radius: var(--radius-full);
    background: var(--border-strong);
    position: relative;
    transition: background var(--dur) var(--ease);
    flex: none;
}
.switch__track::after {
    content: ''; position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform var(--dur) var(--ease);
}
.switch input:checked + .switch__track { background: var(--brand); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }

/* --- toolbar (symbol + expiry pickers) --- */
.toolbar {
    position: sticky;
    top: var(--topbar-h);
    z-index: 30;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    margin-bottom: var(--space-4);
    background: color-mix(in srgb, var(--bg-surface) 92%, transparent);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
/* --- sidebar collapse handle (desktop) ---
   Fixed to the sidebar's right edge rather than placed in the toolbar: a
   show/hide control reads best attached to the thing it hides. Hidden below
   1024px, where the sidebar is an overlay drawer owned by the topbar
   hamburger. */
.nav-edge { display: none; }

@media (min-width: 1024px) {
    .nav-edge {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        /* Flush against the sidebar's right edge, entirely in the content area.
           It used to straddle the seam at (sidebar-w - 11px), which put half of
           it underneath the sidebar - and the sidebar is z-index 50 against
           this element's 31, so that half was painted over and only an 11px
           sliver showed. Sitting beside the sidebar rather than on it means no
           stacking order can hide it. */
        left: var(--sidebar-w);
        top: 50%;
        transform: translateY(-50%);
        /* Above the sidebar regardless, so the two can never fight again. */
        z-index: 51;
        width: 20px;
        height: 56px;
        padding: 0;
        border: 1px solid var(--border);
        border-left: 0;
        border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
        background: var(--bg-elevated);
        color: var(--text-muted);
        font-size: 11px;
        line-height: 1;
        cursor: pointer;
        box-shadow: var(--shadow-1);
        transition: left var(--dur) var(--ease), color var(--dur) var(--ease),
                    border-color var(--dur) var(--ease), background var(--dur) var(--ease);
    }

    .nav-edge:hover {
        color: var(--text-primary);
        border-color: var(--brand);
        background: var(--bg-hover);
    }

    .nav-edge:focus-visible {
        outline: 2px solid var(--brand);
        outline-offset: 2px;
    }

    /* Collapsed: the sidebar is gone, so the handle rides the screen edge. */
    /* Collapsed: the sidebar is gone, so the handle rides the screen edge. The
       shape is already right-rounded, so only the offset changes. */
    :root[data-nav="collapsed"] .nav-edge { left: 0; }

    .nav-edge__show { display: none; }
    :root[data-nav="collapsed"] .nav-edge__hide { display: none; }
    :root[data-nav="collapsed"] .nav-edge__show { display: inline; }
}

.toolbar .select, .toolbar .input { min-height: 34px; width: auto; min-width: 130px; }
.toolbar__group { display: flex; align-items: center; gap: var(--space-2); }
.toolbar__spacer { flex: 1; }

/* On a phone a toolbar with six controls wraps into six rows, and since it is
   sticky that eats most of the screen before any data is visible. Two per row,
   each filling its half, with the label above its control. */
@media (max-width: 767px) {
    .toolbar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: end;
        max-height: 45vh;
        overflow-y: auto;
    }
    .toolbar__group { flex-direction: column; align-items: stretch; gap: 2px; min-width: 0; }
    .toolbar__group .label { font-size: var(--fs-xs); }
    .toolbar .select, .toolbar .input { min-width: 0; width: 100%; }
    .toolbar__spacer { display: none; }
    /* A segmented pair is two tap targets and needs the full width. The grid
       child is the group, not the control inside it, so the span has to be set
       on whichever group holds one. */
    .toolbar__group:has(.segmented),
    .toolbar .segmented { grid-column: span 2; }
    .toolbar .segmented { display: flex; width: 100%; }
    .toolbar .segmented a, .toolbar .segmented button { flex: 1; text-align: center; min-height: 40px; }
    .toolbar [data-status-pill] { grid-column: span 2; justify-content: center; }
}

.segmented {
    display: inline-flex;
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 2px;
}
.segmented a, .segmented button {
    padding: 6px 12px;
    border: 0; background: transparent;
    border-radius: var(--radius-xs);
    font-family: inherit;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    min-height: 30px;
}
.segmented a.is-active, .segmented button.is-active { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-1); }

/* --- tables --- */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
}

table.data {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--fs-sm);
}
table.data thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--bg-sunken);
    color: var(--text-muted);
    font-size: var(--fs-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    text-align: right;
    padding: 9px var(--space-3);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.data thead th:first-child, table.data tbody td:first-child { text-align: left; }
table.data tbody td {
    padding: 8px var(--space-3);
    text-align: right;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.data tbody tr:hover td { background: var(--bg-hover); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data th a { color: inherit; }

.t-left { text-align: left !important; }
.t-center { text-align: center !important; }
.t-muted { color: var(--text-muted); }
.t-sm { font-size: var(--fs-xs); }
.t-strong { font-weight: 650; color: var(--text-primary); }

/* --- flash messages --- */
.flash-stack { position: fixed; top: calc(var(--topbar-h) + 10px); right: 12px; left: 12px; z-index: 80; display: grid; gap: 8px; pointer-events: none; }
.flash {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 11px var(--space-3);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-2);
    font-size: var(--fs-base);
    pointer-events: auto;
    animation: slide-in 220ms var(--ease);
}
.flash--success { border-left: 3px solid var(--bull); }
.flash--error { border-left: 3px solid var(--bear); }
.flash--warning { border-left: 3px solid var(--warn); }
.flash--info { border-left: 3px solid var(--brand); }
.flash__close { margin-left: auto; background: none; border: 0; color: var(--text-muted); cursor: pointer; font-size: 16px; line-height: 1; }

@keyframes slide-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* --- empty & loading states --- */
.empty {
    text-align: center;
    padding: var(--space-8) var(--space-4);
    color: var(--text-secondary);
}
.empty__icon { font-size: 30px; margin-bottom: var(--space-3); opacity: .55; }
.empty__title { font-weight: 650; color: var(--text-primary); margin-bottom: 6px; }
.empty__text { font-size: var(--fs-base); max-width: 380px; margin: 0 auto var(--space-4); }

.skeleton {
    background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-elevated) 50%, var(--bg-hover) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: var(--radius-xs);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.is-loading { opacity: .55; transition: opacity var(--dur) var(--ease); pointer-events: none; }

/* Value update flash - green/red then fade. */
.flash-up { animation: flash-up 500ms var(--ease); }
.flash-down { animation: flash-down 500ms var(--ease); }
@keyframes flash-up { 0% { background: var(--bull-soft); } 100% { background: transparent; } }
@keyframes flash-down { 0% { background: var(--bear-soft); } 100% { background: transparent; } }

/* --- pagination --- */
.pagination { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; justify-content: center; padding: var(--space-3); }
.pagination a, .pagination span {
    min-width: 34px; height: 34px;
    display: grid; place-items: center;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-secondary);
}
.pagination a:hover { background: var(--bg-hover); color: var(--text-primary); }
.pagination .is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* --- misc utilities --- */
.row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.stack { display: grid; gap: var(--space-3); }
.stack--sm { gap: var(--space-2); }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--space-2); } .mt-3 { margin-top: var(--space-3); } .mt-4 { margin-top: var(--space-4); } .mt-5 { margin-top: var(--space-5); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--space-2); } .mb-3 { margin-bottom: var(--space-3); } .mb-4 { margin-bottom: var(--space-4); } .mb-5 { margin-bottom: var(--space-5); }
.hide { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }

.banner {
    display: flex; align-items: flex-start; gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    margin-bottom: var(--space-4);
    font-size: var(--fs-base);
}
.banner--warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.banner--error { background: var(--bear-soft); border-color: color-mix(in srgb, var(--bear) 30%, transparent); }
.banner--info { background: var(--brand-soft); border-color: var(--brand-border); }

/* ===========================================================================
   Breakpoints
   =========================================================================== */

@media (min-width: 560px) {
    .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .flash-stack { left: auto; width: 380px; }
}

@media (min-width: 768px) {
    .main { padding: var(--space-5); }
    .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    h1 { font-size: var(--fs-3xl); }
}

@media (min-width: 1024px) {
    .sidebar { transform: none; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); }
    .sidebar__scrim { display: none; }
    .shell__body { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
    .bottomnav { display: none; }
    .main { padding-bottom: var(--space-6); }

    /* Collapsing hands the sidebar's 236px to the content. An option chain or a
       219-row futures table is worth that much extra width. The control is
       .nav-edge, on the sidebar's own edge; the topbar hamburger is hidden
       here. */
    .nav-toggle { display: none; }
    :root[data-nav="collapsed"] .shell__body { grid-template-columns: minmax(0, 1fr); }
    :root[data-nav="collapsed"] .sidebar { display: none; }
}

@media (min-width: 1440px) {
    .main { padding: var(--space-5) var(--space-6); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

@media print {
    .topbar, .sidebar, .bottomnav, .toolbar, .flash-stack { display: none !important; }
    body { background: #fff; color: #000; }
}

/* ---------------------------------------------------------------------------
   Striped rows.
   Dense financial tables are read across a row; a faint band per alternate row
   stops the eye drifting a line. The tint is deliberately weaker than the ATM
   band and the ITM shading so it never competes with them for meaning.
   --------------------------------------------------------------------------- */

table.data tbody tr:nth-child(even) td,
table.signals tbody tr:nth-child(even) td {
    background-color: color-mix(in srgb, var(--text-primary) 3%, transparent);
}

/* The option chain is deliberately NOT striped. It already carries call/put
   tints, an ATM band and ITM shading - all of which mean something - and a
   stripe would both fight them visually and override them in the cascade. */

table.data tbody tr:hover td,
table.signals tbody tr:hover td {
    background-color: var(--bg-hover);
}

/* Honeypot: off-screen rather than display:none, because some bots skip
   display:none inputs. Real users never reach it (tabindex -1, aria-hidden). */
.hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ---------------------------------------------------------------------------
   Password visibility toggle
   --------------------------------------------------------------------------- */

.pw-field { position: relative; }

/* Room for the button so a long password never runs underneath it. */
.pw-field .input { padding-right: 44px; }

.pw-toggle {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    /* 36px square keeps the tap target usable on touch without overpowering
       a 38px-tall input. */
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 0;
    background: transparent;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    opacity: .55;
    transition: opacity 150ms cubic-bezier(.4, 0, .2, 1);
}

.pw-toggle:hover { opacity: 1; }
.pw-toggle[aria-pressed="true"] { opacity: 1; }
.pw-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; opacity: 1; }
