/* ---------------------------------------------------------------------------
   Analytics-specific surfaces: option chain, heatmap, buildup, payoff.
   --------------------------------------------------------------------------- */

/* ===========================================================================
   Option chain
   =========================================================================== */

.chain-wrap {
    overflow: auto;
    max-height: calc(100vh - 240px);
    border-radius: var(--radius);
    position: relative;
}

table.chain {
    width: 100%;
    min-width: 720px;
    border-collapse: separate;
    border-spacing: 0;
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
    font-size: var(--fs-sm);
}

table.chain thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--bg-sunken);
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    padding: 8px 10px;
    text-align: right;
    border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
}

/* Side headers (CALLS / PUTS) sit above the column row. */
table.chain thead tr.chain__sides th {
    top: 0;
    font-size: var(--fs-sm);
    letter-spacing: .12em;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
}
table.chain thead tr.chain__cols th { top: 29px; }

.chain__side-call { color: var(--bull); background: var(--call-tint); }
.chain__side-put { color: var(--bear); background: var(--put-tint); }

table.chain tbody td {
    padding: 6px 10px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: relative;
}

.chain__call { background: var(--call-tint); }
.chain__put { background: var(--put-tint); }

/* Strike stays visible while the table scrolls sideways. */
.chain__strike {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--bg-surface);
    text-align: center !important;
    font-weight: 700;
    color: var(--text-primary);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    box-shadow: 1px 0 0 var(--border), -1px 0 0 var(--border);
}

tr.is-atm td { background: var(--atm-tint) !important; }
tr.is-atm .chain__strike { background: var(--atm-tint) !important; color: var(--brand); }
tr.is-itm-call .chain__call { background: color-mix(in srgb, var(--warn) 6%, transparent); }
tr.is-itm-put .chain__put { background: color-mix(in srgb, var(--warn) 6%, transparent); }

table.chain tbody tr:hover td { filter: brightness(1.06); }

/* In-cell OI bar, scaled against the largest OI on screen. */
.oi-cell { position: relative; z-index: 1; }
.oi-cell__bar {
    position: absolute;
    top: 3px; bottom: 3px;
    right: 0;
    background: var(--bull-bar);
    border-radius: 2px;
    z-index: -1;
    transition: width var(--dur) var(--ease);
}
.chain__put .oi-cell__bar { left: 0; right: auto; background: var(--bear-bar); }

.chain__legend {
    display: flex; flex-wrap: wrap; gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
}
.chain__legend span { display: inline-flex; align-items: center; gap: 6px; }
.chain__legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* Mobile: one side at a time, strike pinned. */
.chain-side-toggle { display: flex; }
@media (max-width: 767px) {
    table.chain { min-width: 0; }
    .chain-wrap { max-height: calc(100vh - 300px); }
    body[data-chain-side="call"] .chain__put,
    body[data-chain-side="call"] .chain__side-put { display: none; }
    body[data-chain-side="put"] .chain__call,
    body[data-chain-side="put"] .chain__side-call { display: none; }
}
@media (min-width: 768px) {
    .chain-side-toggle { display: none; }
}

/* ===========================================================================
   Buildup quadrants
   =========================================================================== */

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

.quadrant {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-3);
    background: var(--bg-surface);
    transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.quadrant:hover { border-color: var(--border-strong); }
.quadrant.is-active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.quadrant--bullish { border-left: 3px solid var(--bull); }
.quadrant--bearish { border-left: 3px solid var(--bear); }
.quadrant--neutral { border-left: 3px solid var(--flat); }

.quadrant__label { font-size: var(--fs-sm); font-weight: 650; margin-bottom: 2px; }
.quadrant__count { font-family: var(--font-num); font-size: var(--fs-2xl); font-weight: 700; line-height: 1.1; }
.quadrant__hint { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 4px; }
.quadrant__top { margin-top: var(--space-2); font-size: var(--fs-xs); color: var(--text-secondary); display: grid; gap: 2px; }

@media (min-width: 1024px) {
    .quadrants { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Sentiment meter: bullish vs bearish share of signals. */
.meter { height: 8px; border-radius: var(--radius-full); background: var(--bg-hover); overflow: hidden; display: flex; }
.meter__bull { background: var(--bull); }
.meter__bear { background: var(--bear); }
.meter__labels { display: flex; justify-content: space-between; font-size: var(--fs-xs); margin-top: 6px; }

/* ===========================================================================
   Heatmap
   =========================================================================== */

.heat-sector { margin-bottom: var(--space-4); }
.heat-sector__head {
    display: flex; align-items: baseline; gap: var(--space-2);
    margin-bottom: var(--space-2);
    font-size: var(--fs-sm);
    font-weight: 650;
}

.heat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 6px;
}

.heat-tile {
    border-radius: var(--radius-sm);
    padding: 9px 8px;
    min-height: 66px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
    cursor: default;
}
.heat-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); z-index: 1; }

.heat-tile__symbol {
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: -.01em;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.heat-tile__value {
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
    font-size: var(--fs-md);
    font-weight: 700;
}
/* Price on the left, ATM IV on the right. Two facts in one 10px line is the
   most a 96px tile can carry without the text wrapping into the next tile. */
.heat-tile__meta {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
    display: flex;
    justify-content: space-between;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
}
.heat-tile__meta span { overflow: hidden; text-overflow: ellipsis; }

/* Larger tiles for the heavier-weighted symbols. */
.heat-tile[data-size="5"], .heat-tile[data-size="6"] { grid-column: span 2; min-height: 80px; }
.heat-tile[data-size="6"] .heat-tile__value { font-size: var(--fs-lg); }

/* Category tabs above the heatmap: index universes on one row, sectors on the
   next. Two dropdowns said the same thing, but a dropdown hides its options -
   and "which universes exist" is information the reader wants without clicking.
   Scrolls sideways inside itself so the page body never does. */
.cat-tabs {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
}
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tabs + .cat-tabs { margin-top: var(--space-2); }

.cat-tabs__label {
    flex: 0 0 auto;
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 62px;
}

.cat-tab {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    /* 44px tall so it is a real tap target on a phone. */
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease),
                background var(--dur) var(--ease);
}
.cat-tab:hover { border-color: var(--border-strong); color: var(--text-primary); }
.cat-tab.is-active {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--text-primary);
}

.cat-tab__count {
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
    font-size: var(--fs-xs);
    color: var(--text-muted);
}
.cat-tab.is-active .cat-tab__count { color: var(--brand); }

@media (max-width: 767px) {
    .cat-tabs__label { display: none; }
    .cat-tab { min-height: 40px; }
}

.heat-legend { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-xs); color: var(--text-secondary); }
.heat-legend__scale {
    height: 10px; width: 160px; border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--bear), var(--bg-hover), var(--bull));
    border: 1px solid var(--border);
}

/* ===========================================================================
   Charts
   =========================================================================== */

.chart { width: 100%; min-height: 260px; }
.chart--tall { min-height: 340px; }
.chart--short { min-height: 180px; }

/* ===========================================================================
   Strategy builder
   =========================================================================== */

.legs { display: grid; gap: var(--space-2); }
.leg {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    align-items: end;
    padding: var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-inset);
}
.leg--buy { border-left: 3px solid var(--bull); }
.leg--sell { border-left: 3px solid var(--bear); }
.leg .label { font-size: 10px; margin-bottom: 3px; }
.leg .input, .leg .select { min-height: 34px; font-size: var(--fs-sm); }

@media (min-width: 768px) {
    .leg { grid-template-columns: 90px 90px 1fr 1fr 80px 40px; }
}

.payoff-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
@media (min-width: 768px) { .payoff-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ===========================================================================
   Index cards (dashboard)
   =========================================================================== */

.index-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    padding: var(--space-4);
    display: grid;
    gap: var(--space-3);
    transition: border-color var(--dur) var(--ease);
}
.index-card:hover { border-color: var(--border-strong); }
.index-card__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.index-card__symbol { font-weight: 700; letter-spacing: -.01em; }
.index-card__spot { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: var(--fs-xl); font-weight: 650; }
.index-card__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2) var(--space-3); }
.index-card__item { font-size: var(--fs-xs); }
.index-card__item b { display: block; font-family: var(--font-num); font-size: var(--fs-base); font-weight: 650; color: var(--text-primary); margin-top: 2px; }

/* ===========================================================================
   Pricing (public + billing)
   =========================================================================== */

.plans { display: grid; gap: var(--space-4); }
@media (min-width: 768px) { .plans { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .plans { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.plan {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    position: relative;
}
.plan--featured { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.plan__ribbon {
    position: absolute; top: -11px; left: var(--space-5);
    background: var(--brand); color: #fff;
    padding: 3px 10px; border-radius: var(--radius-full);
    font-size: var(--fs-xs); font-weight: 700;
}
.plan__name { font-size: var(--fs-lg); font-weight: 700; }
.plan__price { font-family: var(--font-num); font-size: var(--fs-3xl); font-weight: 700; letter-spacing: -.03em; }
.plan__price small { font-family: var(--font-ui); font-size: var(--fs-sm); font-weight: 500; color: var(--text-muted); }
.plan__mrp { text-decoration: line-through; color: var(--text-muted); font-size: var(--fs-sm); }
.plan__features { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: var(--fs-base); flex: 1; }
.plan__features li { display: flex; gap: 8px; align-items: flex-start; color: var(--text-secondary); }
.plan__features li::before { content: '✓'; color: var(--bull); font-weight: 700; flex: none; }
.plan__features li.is-off { color: var(--text-muted); }
.plan__features li.is-off::before { content: '×'; color: var(--text-muted); }

/* ===========================================================================
   Auth & marketing
   =========================================================================== */

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: var(--space-4);
    background:
        radial-gradient(900px 500px at 15% -10%, var(--brand-soft), transparent 60%),
        radial-gradient(700px 400px at 110% 110%, color-mix(in srgb, #8B5CF6 12%, transparent), transparent 60%),
        var(--bg-base);
}
.auth-card { width: 100%; max-width: 420px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: var(--space-5); font-size: var(--fs-xl); font-weight: 700; letter-spacing: -.02em; }

.hero {
    padding: var(--space-8) var(--space-4);
    text-align: center;
    background:
        radial-gradient(800px 420px at 50% -20%, var(--brand-soft), transparent 65%),
        var(--bg-base);
}
.hero h1 { font-size: clamp(30px, 6vw, 54px); letter-spacing: -.035em; margin-bottom: var(--space-3); }
.hero p { color: var(--text-secondary); font-size: var(--fs-lg); max-width: 620px; margin: 0 auto var(--space-5); }

.feature-grid { display: grid; gap: var(--space-3); }
@media (min-width: 640px) { .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .feature-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.feature {
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
}
.feature__icon { font-size: 20px; margin-bottom: var(--space-2); }
.feature__title { font-weight: 650; margin-bottom: 4px; }
.feature__text { font-size: var(--fs-base); color: var(--text-secondary); margin: 0; }

.site-footer {
    border-top: 1px solid var(--border);
    padding: var(--space-5) var(--space-4);
    color: var(--text-muted);
    font-size: var(--fs-sm);
    text-align: center;
}
.site-footer a { color: var(--text-secondary); margin: 0 8px; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 var(--space-4); }
.container--narrow { max-width: 820px; }

/* ===========================================================================
   Signals
   Colour always rides along with a word and a sign - never colour alone.
   =========================================================================== */

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

@media (min-width: 768px) {
    .signal-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.signal-stat {
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
}

.signal-stat__label {
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.signal-stat__value {
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
    font-size: var(--fs-xl);
    font-weight: 700;
    line-height: 1.2;
}

.signal-stat--buy           { border-left: 3px solid var(--bull); }
.signal-stat--sell          { border-left: 3px solid var(--bear); }
.signal-stat--cautious_buy  { border-left: 3px solid var(--bull); opacity: .85; }
.signal-stat--cautious_sell { border-left: 3px solid var(--bear); opacity: .85; }

.signal-stat--buy .signal-stat__value,
.signal-stat--cautious_buy .signal-stat__value  { color: var(--bull); }
.signal-stat--sell .signal-stat__value,
.signal-stat--cautious_sell .signal-stat__value { color: var(--bear); }

/* Action + strength pills ------------------------------------------------- */

.sig { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
       border-radius: var(--radius-xs); font-size: var(--fs-xs); font-weight: 600; }

.sig--buy            { background: var(--bull-soft); color: var(--bull); }
.sig--sell           { background: var(--bear-soft); color: var(--bear); }
/* Cautious calls are deliberately quieter than the outright ones. */
.sig--cautious_buy   { background: transparent; color: var(--bull); border: 1px solid var(--bull); }
.sig--cautious_sell  { background: transparent; color: var(--bear); border: 1px solid var(--bear); }

.strength { display: inline-flex; align-items: center; gap: 5px;
            font-size: var(--fs-xs); font-weight: 600; color: var(--text-secondary); }

.strength__dots { display: inline-flex; gap: 2px; }
.strength__dot  { width: 5px; height: 5px; border-radius: 50%; background: var(--border-strong); }

.strength--strong   { color: var(--text-primary); }
.strength--strong   .strength__dot { background: var(--brand); }
.strength--moderate .strength__dot:nth-child(-n+2) { background: var(--brand); }
.strength--weak     .strength__dot:nth-child(1)    { background: var(--text-muted); }

/* Tabs + pager ------------------------------------------------------------ */

.tabs {
    display: flex;
    gap: var(--space-1);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-4);
    overflow-x: auto;
}

.tabs__item {
    padding: var(--space-2) var(--space-4);
    /* Tap target stays at 44px on touch, per the mobile rules. */
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    text-decoration: none;
    transition: color 150ms cubic-bezier(.4, 0, .2, 1),
                border-color 150ms cubic-bezier(.4, 0, .2, 1);
}

.tabs__item:hover     { color: var(--text-primary); }
.tabs__item.is-active { color: var(--brand); border-bottom-color: var(--brand); }

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.pager__links { display: flex; gap: var(--space-2); }

/* Signal table ------------------------------------------------------------ */

table.signals { width: 100%; min-width: 780px; border-collapse: collapse; }

table.signals th,
table.signals td {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border);
    text-align: right;
    white-space: nowrap;
}

table.signals th:first-child,
table.signals td:first-child,
table.signals .t-left { text-align: left; }

table.signals td.num,
table.signals td:not(.t-left):not(.t-center) {
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
}

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

/* Under 768px the leg column stays put and the numbers scroll under it. */
@media (max-width: 767px) {
    table.signals th:first-child,
    table.signals td:first-child {
        position: sticky;
        left: 0;
        z-index: 1;
        background: var(--bg-surface);
    }

    table.signals tbody tr:hover td:first-child { background: var(--bg-hover); }
}

/* Filter bar - fields sit in a row on desktop, stack full width on phones. */
.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-3);
}

.filters .field {
    margin-bottom: 0;
    flex: 1 1 160px;
    min-width: 0;
}

.filters .btn {
    /* Line the button up with the inputs, not with their labels. */
    min-height: 38px;
    flex: 0 0 auto;
}

@media (max-width: 479px) {
    .filters .field,
    .filters .btn { flex: 1 1 100%; }
}

/* ===========================================================================
   Admin guide (How to Use)
   =========================================================================== */

/* Code is read as data, so it gets the numeric face and an inset ground. */
.card__body code {
    font-family: var(--font-num);
    font-size: var(--fs-xs);
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 1px 5px;
    color: var(--text-primary);
    word-break: break-word;
}

.card__body pre {
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-3);
    margin: var(--space-2) 0;
    /* Commands must not wrap - a broken command line is a wrong command line. */
    overflow-x: auto;
}

.card__body pre code {
    background: none;
    border: 0;
    padding: 0;
    white-space: pre;
    line-height: 1.6;
}

.guide-steps {
    margin: 0;
    padding-left: var(--space-5);
    display: grid;
    gap: var(--space-4);
    color: var(--text-secondary);
    line-height: 1.6;
}

.guide-steps li::marker {
    color: var(--brand);
    font-weight: 700;
}

.guide-steps strong { color: var(--text-primary); }

.guide-steps ul {
    margin: var(--space-2) 0 0;
    padding-left: var(--space-4);
    display: grid;
    gap: var(--space-2);
}

/* Troubleshooting accordion -------------------------------------------------- */

.faq {
    border-bottom: 1px solid var(--border);
    padding: var(--space-3) 0;
}

.faq:last-of-type { border-bottom: 0; }

.faq__q {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-primary);
    /* Comfortable tap target on touch. */
    min-height: 32px;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    list-style: none;
}

.faq__q::-webkit-details-marker { display: none; }

.faq__q::before {
    content: '+';
    color: var(--brand);
    font-family: var(--font-num);
    font-weight: 700;
    flex: 0 0 auto;
}

.faq[open] .faq__q::before { content: '−'; }

.faq__a {
    color: var(--text-secondary);
    line-height: 1.6;
    padding: var(--space-2) 0 0 var(--space-4);
}

/* ===========================================================================
   Live spot readout in the sticky toolbar
   The toolbar is already sticky under the topbar, so putting spot here keeps it
   on screen for the whole length of the chain instead of scrolling away.
   =========================================================================== */

.toolbar__spot {
    display: inline-flex;
    align-items: baseline;
    gap: var(--space-2);
    padding: 4px var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-inset);
    white-space: nowrap;
}

.toolbar__spot-label {
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.toolbar__spot-value {
    /* inline-block, not inline: min-width and padding are ignored on inline
       boxes, and the tick flash paints a background that needs the padding. */
    display: inline-block;
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--text-primary);
    /* Digits change on every tick; a fixed width stops the bar from jittering. */
    min-width: 7ch;
    text-align: right;
    padding: 0 4px;
    border-radius: var(--radius-xs);
}

.toolbar__spot-atm {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    padding-left: var(--space-2);
    border-left: 1px solid var(--border);
}

.toolbar__spot-atm .num { font-variant-numeric: tabular-nums; }

/* Phones: the spot block leads the toolbar on its own row, full width, so it is
   the first thing read and never squeezed out by the pickers. */
@media (max-width: 767px) {
    .toolbar__spot {
        order: -1;
        flex: 1 1 100%;
        justify-content: space-between;
    }

    .toolbar__spacer { display: none; }
}

/* ===========================================================================
   Greeks columns - hidden until the switch in the chain card head is on.
   The cells stay in the DOM and keep refreshing, so flipping the switch never
   shows a stale number and the toggle costs no network round trip.
   =========================================================================== */

table.chain .is-greek { display: none; }

table.chain.show-greeks .is-greek { display: table-cell; }

/* Greeks are small signed decimals - keep them narrow and quiet so they never
   out-shout OI and LTP, which are what the eye is actually scanning for. */
table.chain.show-greeks .is-greek {
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    white-space: nowrap;
}

table.chain thead .is-greek {
    font-weight: 700;
    color: var(--text-primary);
}

/* With four extra columns a side the table needs more room before scrolling. */
table.chain.show-greeks { min-width: 1080px; }

/* Mobile shows one side at a time. These need to out-specify the .show-greeks
   rule above, or the hidden side's Greek cells would reappear with the switch on. */
@media (max-width: 767px) {
    body[data-chain-side="call"] table.chain.show-greeks .chain__put,
    body[data-chain-side="put"] table.chain.show-greeks .chain__call { display: none; }

    /* Never widen past the viewport - the chain scrolls inside its wrapper,
       the page body itself must not scroll sideways. */
    table.chain.show-greeks { min-width: 0; }
}

/* OHOL has two outcomes, not four - keep the tiles side by side at every width
   rather than letting the four-column grid leave two empty cells. */
.quadrants--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 1024px) { .quadrants--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ===========================================================================
   Strategy builder - two pane
   Picker on the left, result on the right. Choosing a structure and reading its
   payoff used to mean scrolling back and forth; now both are on screen at once.
   =========================================================================== */

.builder {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: 1fr;          /* phones: stacked */
    align-items: start;
}

@media (min-width: 1024px) {
    .builder { grid-template-columns: 320px minmax(0, 1fr); }
}

@media (min-width: 1440px) {
    .builder { grid-template-columns: 360px minmax(0, 1fr); }
}

/* The rail follows the page, so a strategy can be swapped while the chart is
   still in view. Its own list scrolls inside, never the page. */
@media (min-width: 1024px) {
    .builder__rail {
        position: sticky;
        top: calc(var(--topbar-h) + var(--space-3));
    }

    .builder__list {
        max-height: calc(100vh - var(--topbar-h) - 140px);
        overflow-y: auto;
    }

    /* "Change" is a phone affordance; on desktop the list is always open. */
    .builder__toggle { display: none; }
}

@media (max-width: 1023px) {
    /* Collapsed by default so the payoff is what you land on. */
    .builder__list { display: none; }
    .builder__list.is-open { display: block; max-height: 60vh; overflow-y: auto; }
}

/* On a phone the split stacks, so the payoff chart sits directly above the
   summary and Legs lands about a screen and a half down. A payoff is two
   straight segments and a kink - it reads perfectly at 240px, and the 100px
   saved is most of the difference. */
@media (max-width: 767px) {
    .builder__split .chart--tall { min-height: 240px; }
}

/* Two cards on one row inside the builder's main column.
   Stacked below 1280px: the rail already takes 300px, so splitting the rest in
   two before then leaves a payoff chart too narrow to read. */
.builder__split { display: grid; gap: var(--space-4); grid-template-columns: 1fr; }

@media (min-width: 1280px) {
    /* The chart column is wider - its shape carries the meaning, while the
       numbers beside it read fine in a narrow two-up grid. */
    .builder__split { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); }
}

/* The summary now lives in a half-width column, so it stays two-up all the way
   up. The old rule took it to four across at 768px, which was right when it
   spanned the full width and is wrong now - four tabular numbers in half a
   column wrap mid-value. */
.builder__split .payoff-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.rail-search {
    padding: var(--space-3);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-surface);
}

.rail-group { padding: var(--space-2) 0; }

.rail-group__label {
    padding: var(--space-2) var(--space-4);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.rail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    text-align: left;
    padding: var(--space-3) var(--space-4);
    background: transparent;
    border: 0;
    /* A 3px bar marks the active row without shifting anything when it appears. */
    border-left: 3px solid transparent;
    cursor: pointer;
    font-family: inherit;
    min-height: 56px;
    transition: background 150ms cubic-bezier(.4, 0, .2, 1),
                border-color 150ms cubic-bezier(.4, 0, .2, 1);
}

.rail-item:hover { background: var(--bg-hover); }

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

.rail-item.is-active {
    background: var(--brand-soft);
    border-left-color: var(--brand);
}

.rail-item__name {
    font-size: var(--fs-sm);
    font-weight: 650;
    color: var(--text-primary);
}

.rail-item.is-active .rail-item__name { color: var(--brand); }

.rail-item__desc {
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Capped vs uncapped downside is the most important thing on the row, so it
   gets a word of its own rather than only a colour. */
.rail-item__risk {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    margin-top: 2px;
}

.rail-item__risk--defined   { color: var(--bull); }
.rail-item__risk--undefined { color: var(--warn); }

.rail-empty { padding: var(--space-5) var(--space-4); }

/* The summary strip carries eight tiles; two columns on a phone, four from
   tablet up, so a tile never gets too narrow to read. */
.payoff-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (min-width: 768px) {
    .payoff-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Grid children need min-width:0 or a wide table inside will stretch the column
   past its track and push the rail off screen. */
.builder__main { min-width: 0; }

.builder__picker { margin-bottom: 0; }

/* Inline PCR sparkline. Deliberately not a chart library: it only has to show
   direction at a glance, and the PCR page carries the real chart. */
.spark {
    display: inline-flex;
    align-items: flex-end;
    gap: 1px;
    height: 22px;
    min-width: 60px;
}

.spark i {
    width: 3px;
    background: var(--brand);
    border-radius: 1px;
    opacity: .75;
}

.spark i:last-child {
    background: var(--text-primary);
    opacity: 1;
}

/* Category tabs above the strategy list. Horizontal scroll rather than wrap, so
   the rail header keeps a fixed height whatever the category names are. */
.rail-tabs {
    display: flex;
    gap: 2px;
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-surface);
}

.rail-tabs::-webkit-scrollbar { display: none; }

.rail-tab {
    flex: 0 0 auto;
    padding: 6px 10px;
    border: 0;
    background: transparent;
    border-radius: var(--radius-xs);
    font-family: inherit;
    font-size: var(--fs-xs);
    font-weight: 650;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: background 150ms cubic-bezier(.4, 0, .2, 1),
                color      150ms cubic-bezier(.4, 0, .2, 1);
}

.rail-tab:hover { color: var(--text-primary); background: var(--bg-hover); }

.rail-tab.is-active { background: var(--brand-soft); color: var(--brand); }

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

/* The search box sits under the tabs, so only the tabs stay pinned. */
.rail-search { position: static; }
