:root {
  --bg: #12131c;
  --panel: #1b1d2a;
  --panel-2: #222536;
  --panel-3: #2a2e42;
  --line: #2c3045;
  --text: #e6e8f0;
  --muted: #8d92a8;
  --up: #7ac74f;
  --down: #f0625d;
  --accent: #6c7cff;
  --amber: #f0a43a;
  --blue: #4d8dff;
  --buy: #4caf50;
  --sell: #e5534b;
  --radius: 10px;
  --nav-h: 60px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.up { color: var(--up); }
.down { color: var(--down); }
.r { text-align: right; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 20px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }
.brand-logo { height: 34px; width: auto; display: block; }
.nav { display: flex; gap: 4px; }
.nav button {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; padding: 7px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap;
}
.nav button svg { width: 16px; height: 16px; display: none; }
.nav button.active { background: var(--panel-2); color: var(--text); }
.badge-count {
  min-width: 18px; height: 18px; border-radius: 9px; background: var(--amber); color: #111;
  font-size: 11px; line-height: 18px; text-align: center; padding: 0 5px;
}
.top-right { margin-left: auto; display: flex; align-items: center; gap: 18px; white-space: nowrap; }
.clock { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.countdown { font-size: 11px; font-variant-numeric: tabular-nums; }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px;
  background: var(--panel-2); font-size: 12px; color: var(--muted);
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-pill.live .dot { background: var(--up); box-shadow: 0 0 0 3px rgba(122, 199, 79, .2); }
.status-pill.warn .dot { background: var(--amber); }
.networth { text-align: right; font-variant-numeric: tabular-nums; }
.networth strong { font-size: 15px; }

/* ── layout ──────────────────────────────────────────────────────────────── */
.layout { padding: 14px 16px 32px; max-width: 1500px; margin: 0 auto; }
.view#view-stocks { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 14px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; color: var(--muted);
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { color: var(--text); }
.footer { text-align: center; padding: 0 16px 24px; }
.footer a { color: var(--muted); }

/* ── sidebar / watchlist ─────────────────────────────────────────────────── */
.sidebar { padding: 0; position: sticky; top: 72px; max-height: calc(100vh - 88px); display: flex; flex-direction: column; overflow: hidden; }
.search { padding: 12px; border-bottom: 1px solid var(--line); }
.search input { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; }
.indices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.indices button { background: var(--panel); border: 0; padding: 9px 12px; text-align: left; border-left: 3px solid transparent; }
.indices button:hover { background: var(--panel-2); }
.indices button.active { background: var(--panel-2); border-left-color: var(--accent); }
.indices .n { font-size: 12px; color: var(--muted); }
.indices b { font-variant-numeric: tabular-nums; }
.list-tabs { display: flex; align-items: center; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.list-tabs button { background: none; border: 0; border-radius: 6px; padding: 5px 10px; color: var(--muted); font-weight: 500; }
.list-tabs button.active { background: var(--panel-2); color: var(--text); }
.list-tabs select { margin-left: auto; }
.watchlist { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.watchlist li {
  display: grid; grid-template-columns: minmax(0, 1fr) 56px auto; align-items: center; gap: 10px;
  padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; border-left: 3px solid transparent; position: relative;
}
.watchlist li:hover { background: var(--panel-2); }
.watchlist li.active { background: var(--panel-2); border-left-color: var(--accent); }
.watchlist .nm { min-width: 0; }
.watchlist .nm div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.watchlist .spark { width: 56px; height: 22px; }
.watchlist .px { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.watchlist .ltp::after { content: ""; display: inline-block; width: 0; height: 0; margin-left: 5px; vertical-align: middle; border: 4px solid transparent; }
.watchlist .ltp.up::after { border-bottom-color: var(--up); margin-bottom: 4px; }
.watchlist .ltp.down::after { border-top-color: var(--down); margin-top: 4px; }
.watchlist .rm {
  position: absolute; right: 4px; top: 4px; width: 20px; height: 20px; border-radius: 50%; border: 0;
  background: var(--panel-3); color: var(--muted); font-size: 13px; line-height: 20px; display: none;
}
.watchlist li:hover .rm { display: block; }
@media (hover: none) { .watchlist .rm { display: block; } }
.list-empty { padding: 28px 20px; text-align: center; }
.list-empty svg { width: 28px; height: 28px; color: var(--muted); }
.list-empty p { margin: 6px 0; }

/* ── stock header ────────────────────────────────────────────────────────── */
.detail { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.stock-head { display: flex; flex-direction: column; gap: 10px; }
.head-row { display: flex; align-items: center; gap: 12px; }
.back-btn { display: none; }
.stock-id { flex: 1; min-width: 0; }
.stock-name { position: relative; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 18px; font-weight: 600; }
.badge { font-size: 11px; font-weight: 500; border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; color: var(--muted); }
.badge.view-only { color: var(--amber); border-color: rgba(240, 164, 58, .4); }
.bookmark { width: 28px; height: 28px; }
.bookmark.on { color: var(--amber); }
.bookmark.on svg { fill: var(--amber); }
.popover {
  position: absolute; top: 34px; left: 0; z-index: 15; min-width: 190px; padding: 6px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  font-size: 13px; font-weight: 400;
}
.popover label { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; cursor: pointer; }
.popover label:hover { background: var(--panel-3); }
.popover .muted { margin-left: auto; }
.stock-price { font-size: 28px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stock-price span:last-child { font-size: 16px; margin-left: 6px; }
.trade-btns { display: flex; gap: 8px; }
.btn { border: 0; border-radius: 8px; padding: 9px 24px; font-weight: 600; color: #fff; }
.btn.buy { background: var(--buy); } .btn.sell { background: var(--sell); }
.btn.ghost { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); padding: 7px 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.pos-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pos-chips:empty { display: none; }
.pos-chip { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px; font-variant-numeric: tabular-nums; }
.pos-chip b { font-weight: 600; }
.ranges { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; }
.range-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; font-size: 12px; font-variant-numeric: tabular-nums; }
.range-row .k { grid-column: 1 / -1; color: var(--muted); font-size: 11px; margin-bottom: -6px; }
.range-row .track { position: relative; height: 4px; border-radius: 2px; background: linear-gradient(90deg, rgba(240, 98, 93, .55), rgba(122, 199, 79, .55)); }
.range-row .track i { position: absolute; top: -4px; width: 2px; height: 12px; margin-left: -1px; background: var(--text); border-radius: 1px; }

/* ── tabs / charts ───────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; }
.tabs button { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; color: var(--muted); }
.tabs button.active { background: var(--panel-2); color: var(--text); border-color: var(--accent); }
.chart-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.seg { display: inline-flex; gap: 2px; background: var(--panel-2); border-radius: 8px; padding: 3px; }
.seg button { background: none; border: 0; border-radius: 6px; padding: 5px 11px; color: var(--muted); }
.seg button.active { background: var(--bg); color: var(--amber); }
.seg.full { display: flex; width: 100%; }
.seg.full button { flex: 1; }
.dmas, .overlays { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.overlays { gap: 6px; }
.c-dma50 { color: var(--amber); } .c-dma200 { color: var(--blue); }
.tog { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--text); }
.tog input { margin: 0; width: 15px; height: 15px; accent-color: var(--muted); }
.tog.t50 input { accent-color: var(--amber); } .tog.t200 input { accent-color: var(--blue); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 99px; padding: 4px 10px; font-size: 12px; color: var(--muted);
}
.chip i { width: 8px; height: 8px; border-radius: 50%; opacity: .45; }
.chip.on { color: var(--text); border-color: var(--panel-3); background: var(--panel-3); }
.chip.on i { opacity: 1; }
.chip:disabled { opacity: .4; cursor: not-allowed; }
.chart-wrap { position: relative; }
.chart { height: 380px; width: 100%; }
.chart.tall { height: 480px; }
.chart-note:empty { display: none; }
.chart-note { margin-top: 6px; }
.loader {
  position: absolute; inset: 0; z-index: 4; display: none; place-items: center;
  background: rgba(27, 29, 42, .55); border-radius: 8px;
}
.loader span { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--panel-3); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.is-loading > .loader { display: grid; }
@keyframes spin { to { transform: rotate(360deg); } }
.legend {
  position: absolute; top: 4px; left: 8px; z-index: 3; pointer-events: none;
  display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; font-variant-numeric: tabular-nums;
  background: rgba(27, 29, 42, .75); border-radius: 6px; padding: 3px 8px; max-width: calc(100% - 90px);
}
.legend b { font-weight: 600; margin-left: 3px; }
.returns {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 3; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
  background: rgba(27, 29, 42, .85); border: 1px solid var(--line); border-radius: 8px; padding: 6px 14px;
  font-size: 12px; font-variant-numeric: tabular-nums;
}
.returns b { font-size: 16px; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.stats div { background: var(--panel-2); border-radius: 8px; padding: 8px 10px; font-variant-numeric: tabular-nums; }
.stats span { display: block; font-size: 12px; color: var(--muted); }

/* full screen (a fixed overlay, so it also works where the Fullscreen API does not) */
.card.full { position: fixed; inset: 0; z-index: 60; border-radius: 0; border: 0; display: flex; flex-direction: column; }
.card.full .chart-wrap { flex: 1; min-height: 0; }
.card.full .chart, .card.full .chart.tall { height: 100%; }
.card.full .stats, .card.full .chart-note { display: none; }
body.has-full { overflow: hidden; }

/* ── technicals ──────────────────────────────────────────────────────────── */
.tech-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tech-grid .wide { grid-column: 1 / -1; }
#tab-technicals { position: relative; transition: opacity .15s; }
#tab-technicals.is-loading { opacity: .55; pointer-events: none; }
.pivots { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.pv { display: grid; grid-template-columns: 34px 70px 1fr 80px; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.pv .lbl { font-weight: 600; }
.pv.res .lbl, .pv.res .dist { color: var(--down); }
.pv.sup .lbl, .pv.sup .dist { color: var(--up); }
.pv.piv .lbl { color: var(--amber); }
.pv .track { position: relative; height: 6px; background: var(--panel-2); border-radius: 3px; }
.pv .fill { position: absolute; top: 0; height: 6px; border-radius: 3px; }
.pv.res .fill { background: var(--down); } .pv.sup .fill { background: var(--up); } .pv.piv .fill { background: var(--amber); }
.pv .val { text-align: right; }
.ltp-chip { align-self: center; background: #6a4fd1; color: #fff; border-radius: 6px; padding: 3px 12px; font-size: 13px; font-weight: 600; margin: 2px 0; }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th { font-weight: 500; color: var(--muted); font-size: 12px; text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }
.tbl th.r { text-align: right; }
.tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl-wrap { overflow-x: auto; }
/* OI build-up: a fixed-height box that scrolls inside itself, header pinned (a session is up to 75 rows). */
.bu-scroll { max-height: 440px; overflow-y: auto; scrollbar-width: thin; border-bottom: 1px solid var(--line); }
.bu-scroll thead th { position: sticky; top: 0; z-index: 1; background: var(--panel); }
.sig-Bullish { color: var(--up); } .sig-Bearish { color: var(--down); } .sig-Neutral { color: var(--amber); }
.tally { display: flex; justify-content: space-between; margin: 4px 0 8px; }
.tally b { display: inline-block; min-width: 22px; text-align: center; border-radius: 50%; background: var(--panel-2); margin-left: 6px; }
.tally-bar { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--down), var(--amber), var(--up)); position: relative; margin-bottom: 10px; }
.tally-bar i { position: absolute; top: -4px; left: 50%; width: 4px; height: 14px; background: var(--text); border-radius: 2px; transition: left .3s; }
.skel { display: block; height: 12px; border-radius: 4px; background: linear-gradient(90deg, var(--panel-2), var(--panel-3), var(--panel-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.mini-btn { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 10px; font-size: 12px; }

/* ── empty states ────────────────────────────────────────────────────────── */
.empty-cell { padding: 0 !important; border: 0 !important; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 36px 16px; text-align: center; white-space: normal; }
.empty svg { width: 34px; height: 34px; color: var(--muted); margin-bottom: 4px; }
.empty b { font-size: 15px; }
.empty p { margin: 0; color: var(--muted); max-width: 420px; }
.empty .btn { margin-top: 10px; background: var(--accent); }

/* ── funds ───────────────────────────────────────────────────────────────── */
/* The label is its own class: a bare `span` rule here once also caught the coloured P&L value
   inside <b>, turning it small and grey. */
.funds-hero { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.funds-hero > div { background: var(--panel-2); border-radius: 10px; padding: 14px 16px; border-top: 3px solid transparent; }
.funds-hero > div.pos { border-top-color: var(--up); }
.funds-hero > div.neg { border-top-color: var(--down); }
.funds-hero .k, .fund-grid .k { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.funds-hero b { display: block; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.funds-hero .main b { font-size: 28px; }
.funds-hero .sub { display: block; margin-top: 4px; font-size: 13px; font-variant-numeric: tabular-nums; }
.funds-hero .sub.up::before { content: "▲ "; font-size: 10px; }
.funds-hero .sub.down::before { content: "▼ "; font-size: 10px; }
.alloc { background: var(--panel-2); border-radius: 10px; padding: 12px 16px; margin-bottom: 12px; }
.alloc-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--panel-3); margin: 8px 0 10px; }
.alloc-bar i { display: block; height: 100%; min-width: 0; transition: width .3s; }
.alloc-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; font-variant-numeric: tabular-nums; }
.alloc-legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.alloc-legend span b { color: var(--text); font-weight: 600; }
.alloc-legend em { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.alloc-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.alloc-head b { color: var(--text); font-size: 14px; }
.fund-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 16px; }
.fund-grid > div { background: var(--panel-2); border-radius: 8px; padding: 10px 12px; }
.fund-grid b { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.equity-head { margin-top: 4px; }
/* stroke: none undoes the global icon rule (svg { stroke: currentColor }) for this chart. */
.equity-svg { display: block; font-family: inherit; overflow: visible; stroke: none; }
.equity-svg .eq-grid { stroke: #23263a; stroke-width: 1; }
.equity-svg .eq-grid.base { stroke: #4a4f6a; stroke-dasharray: 4 4; }
.equity-svg .eq-tick, .equity-svg .eq-x { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.equity-svg .eq-pt:hover circle { r: 5.5; }
.equity-svg .eq-tag rect { fill: var(--up); }
.equity-svg .eq-tag.down rect { fill: var(--down); }
.equity-svg .eq-tag text { fill: #12131c; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── ticket ──────────────────────────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 30; }
.ticket {
  position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 100%; z-index: 31;
  background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column;
}
.ticket-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; color: #fff; }
.ticket-head.buy { background: var(--buy); } .ticket-head.sell { background: var(--sell); }
.ticket-head #t-title { font-weight: 700; font-size: 16px; }
.close { background: none; border: 0; font-size: 24px; color: #fff; line-height: 1; }
.ticket-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.ticket-body label { color: var(--muted); font-size: 12px; margin-top: 6px; display: block; }
.ticket-body input { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; }
#t-side button.active[data-v="BUY"] { background: var(--buy); color: #fff; }
#t-side button.active[data-v="SELL"] { background: var(--sell); color: #fff; }
.field-head { display: flex; justify-content: space-between; align-items: flex-end; }
.link-btn { background: none; border: 0; color: var(--accent); font-size: 12px; padding: 0; }
.stepper { display: grid; grid-template-columns: 40px 1fr 40px; gap: 6px; }
.stepper button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; font-size: 18px; }
.stepper input { text-align: center; }
.ticket-info { background: var(--panel-2); border-radius: 8px; padding: 10px 12px; margin-top: 8px; display: flex; flex-direction: column; gap: 6px; font-variant-numeric: tabular-nums; }
.ticket-info > div:not(.meter) { display: flex; justify-content: space-between; }
.meter { height: 5px; border-radius: 3px; background: var(--panel-3); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--up); transition: width .2s; }
.meter.over i { background: var(--down); }
.error { background: rgba(240, 98, 93, .12); color: var(--down); border-radius: 8px; padding: 9px 12px; }
.submit { margin-top: 8px; padding: 12px; }

/* ── toasts ──────────────────────────────────────────────────────────────── */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 70; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100% - 32px)); }
.toast {
  background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px;
  padding: 10px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); cursor: pointer; animation: toast-in .2s ease-out;
}
.toast.ok { border-left-color: var(--up); } .toast.bad { border-left-color: var(--down); } .toast.warn { border-left-color: var(--amber); }
.toast b { display: block; margin-bottom: 2px; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ── responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .ranges { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .view#view-stocks { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; max-height: none; overflow: visible; }
  #view-stocks:not(.show-detail) .detail { display: none; }
  #view-stocks.show-detail .sidebar { display: none; }
  .back-btn { display: inline-grid; }
  .tech-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
  .topbar { gap: 10px; padding: 8px 12px; }
  .brand-text, .networth .label { display: none; }
  .brand-logo { height: 26px; }
  .clock { align-items: flex-start; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding: 4px 4px env(safe-area-inset-bottom); gap: 0; background: var(--panel); border-top: 1px solid var(--line);
  }
  .nav button { flex: 1; flex-direction: column; gap: 3px; padding: 6px 2px; font-size: 11px; border-radius: 8px; }
  .nav button svg { display: block; width: 20px; height: 20px; }
  .nav button.active { background: none; color: var(--accent); }
  .nav .badge-count { position: absolute; top: 2px; left: 50%; margin-left: 6px; }
  .layout { padding: 10px 10px 24px; }
  #view-stocks.show-detail { padding-bottom: 64px; }
  #view-stocks.show-detail .trade-btns {
    position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 24;
    padding: 8px 10px; background: var(--panel); border-top: 1px solid var(--line);
  }
  .trade-btns .btn { flex: 1; padding: 11px; }
  .stock-price { font-size: 24px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .chart { height: 300px; } .chart.tall { height: 360px; }
  .pv { grid-template-columns: 30px 60px 1fr 70px; }
  .ticket { width: 100%; }
  .toasts { left: 16px; right: 16px; bottom: calc(var(--nav-h) + 76px); max-width: none; }
  .footer { padding-bottom: 12px; }
}

/* ── accounts: auth screen, account menu, banner ─────────────────────────── */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(circle at 20% 10%, rgba(108, 124, 255, .16), transparent 45%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.auth-logo { display: block; width: 220px; max-width: 70%; height: auto; margin: 2px auto 4px; }
.auth-title { text-align: center; font-size: 18px; font-weight: 700; }
.auth-tag { margin: -6px 0 4px; text-align: center; }
.auth-form { display: flex; flex-direction: column; gap: 6px; }
.auth-form label, .adm-form label { color: var(--muted); font-size: 12px; margin-top: 6px; display: block; }
.auth-form input, .adm-form input, .modal input {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
.adm-form label input { margin-top: 4px; }
.pm-card { margin-bottom: 14px; }
.pm-note { margin: 2px 0 10px; }
.adm-form.pm-form { display: grid; grid-template-columns: minmax(150px, 1.4fr) minmax(130px, 1fr) minmax(90px, .7fr) minmax(130px, 1fr) auto; gap: 10px; align-items: end; padding-top: 0; border-top: 0; }
.pm-form select { display: block; width: 100%; margin-top: 4px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.pm-form .pm-field > span { color: var(--muted); font-size: 12px; display: block; margin-bottom: 4px; }
.pm-form .seg { padding: 4px; }
.pm-form .seg button { padding: 7px 8px; }
.pm-form .submit { width: auto; white-space: nowrap; padding: 10px 16px; margin: 0; }
#pm-error { margin-top: 8px; }
.pos-filter select { margin-left: 6px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; max-width: 190px; }
.modal.wide { width: min(780px, calc(100% - 32px)); max-height: 86vh; overflow-y: auto; }
.pf-funds { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 10px 0 4px; }
.pf-funds div { background: var(--panel-2); border-radius: 8px; padding: 8px 10px; font-weight: 600; }
.pf-funds span { display: block; color: var(--muted); font-size: 11px; font-weight: 400; margin-bottom: 3px; }
.modal h4.pf-head { margin: 14px 0 6px; font-size: 13px; }
.link-name { background: none; border: 0; padding: 0; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.link-name:hover { text-decoration-color: currentColor; }
.pos-row { cursor: pointer; }
.pos-row:hover { background: var(--panel-2); }
.pos-row .caret { display: inline-block; width: 14px; color: var(--muted); }
.pos-row small { display: block; color: var(--muted); font-weight: 400; }
.pos-detail td { background: var(--panel-2); font-size: 12.5px; }
.pos-detail td:first-child { padding-left: 28px; }
#pm-list { margin-top: 12px; }
@media (max-width: 860px) { .adm-form.pm-form { grid-template-columns: 1fr 1fr; } .pm-form .submit { grid-column: 1 / -1; width: 100%; } }
.btn.primary { background: var(--accent); }
.notice { background: rgba(108, 124, 255, .12); color: var(--text); border-radius: 8px; padding: 9px 12px; font-size: 13px; }
.acct-wrap { position: relative; }
.acct-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 99px; padding: 3px 10px 3px 3px; max-width: 220px; }
.acct-text { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.acct-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-text svg { width: 14px; height: 14px; flex: none; color: var(--muted); }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid;
  place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.menu { position: absolute; right: 0; top: 40px; z-index: 40; width: 290px; max-width: calc(100vw - 24px); padding: 8px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
  white-space: normal; }
.menu .who { padding: 6px 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu .who b { display: block; }
.menu h5 { margin: 8px 8px 4px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.menu button.item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0;
  border-radius: 8px; padding: 8px; }
.menu button.item:hover { background: var(--panel-3); }
.menu button.item.current { background: var(--panel-3); }
.menu .item .tick { margin-left: auto; color: var(--accent); }
.menu .join { display: flex; gap: 6px; padding: 6px 8px; }
.menu .join input { flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; }
.menu .join button { background: var(--accent); border: 0; border-radius: 8px; color: #fff; padding: 0 12px; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.menu button.mobile-only { display: none; }
.state { display: inline-block; font-size: 11px; border-radius: 99px; padding: 1px 8px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.state.live { color: var(--up); border-color: rgba(122, 199, 79, .4); }
.state.upcoming { color: var(--blue); border-color: rgba(77, 141, 255, .4); }
.state.paused { color: var(--amber); border-color: rgba(240, 164, 58, .4); }
.state.ended { color: var(--muted); }
.banner { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; padding: 8px 16px;
  background: var(--panel-2); border-bottom: 1px solid var(--line); font-size: 13px; text-align: center; }
.banner.warn { background: rgba(240, 164, 58, .12); }
.banner.info { background: rgba(77, 141, 255, .12); }
.banner a, .banner button.link-btn { font-size: 13px; }

/* ── leaderboard ─────────────────────────────────────────────────────────── */
.lb-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-bottom: 12px; }
.lb-head h2 { margin: 0; font-size: 20px; }
.lb-head .meta { color: var(--muted); font-size: 13px; }
.lb-me { margin-left: auto; display: flex; gap: 18px; }
.lb-me div { text-align: right; }
.lb-me span { display: block; color: var(--muted); font-size: 12px; }
.lb-me b { font-size: 20px; font-variant-numeric: tabular-nums; }
.lb tr.me td { background: rgba(108, 124, 255, .1); }
.rank { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 50%; background: var(--panel-2); font-weight: 600; font-size: 12px; }
.rank.r1 { background: #d4a53a; color: #1b1d2a; } .rank.r2 { background: #a9b1c2; color: #1b1d2a; } .rank.r3 { background: #b9774a; color: #1b1d2a; }

/* ── admin ───────────────────────────────────────────────────────────────── */
.admin-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 14px; align-items: start; }
.adm-events { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.adm-events button { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; }
.adm-events button.active { border-color: var(--accent); }
.adm-events .sub { display: block; color: var(--muted); font-size: 12px; }
.adm-form { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.adm-form h4 { margin: 0 0 4px; font-size: 14px; }
.small-btn { padding: 5px 10px !important; font-size: 12px; }
.adm-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 14px; }
.code-box { display: inline-flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px dashed var(--panel-3);
  border-radius: 8px; padding: 6px 10px; font-family: ui-monospace, Consolas, monospace; font-size: 15px; letter-spacing: .08em; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 10px 0; }
.kv div { background: var(--panel-2); border-radius: 8px; padding: 8px 10px; }
.kv span { display: block; font-size: 12px; color: var(--muted); }
.tbl tr.off td { opacity: .5; }

/* ── modal ───────────────────────────────────────────────────────────────── */
.modal { position: fixed; z-index: 81; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100% - 32px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
#modal-overlay { z-index: 80; }
.modal h3 { margin: 0 0 10px; }
.modal label { color: var(--muted); font-size: 12px; display: block; margin: 8px 0 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 17px; background: var(--panel-2); border-radius: 8px; padding: 10px 12px;
  margin: 8px 0; user-select: all; word-break: break-all; }
.chart.short { height: 220px; }
@media (max-width: 900px) {
  .funds-hero { grid-template-columns: 1fr 1fr; }
  .funds-hero .main { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .funds-hero > div { padding: 12px; }
  .funds-hero b { font-size: 17px; }
  .funds-hero .main b { font-size: 24px; }
  .funds-hero .sub { font-size: 12px; }
  .fund-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .fund-grid b { font-size: 14px; }
  .alloc-head { flex-direction: column; gap: 2px; }
}

@media (max-width: 980px) {
  .admin-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .nav [data-view="funds"], .nav [data-view="admin"] { display: none !important; }
  .acct-text { display: none; }
  .menu button.mobile-only { display: flex; }
  .menu { position: fixed; left: 10px; right: 10px; top: 54px; width: auto; max-width: none; }
  .lb .tbl td, .lb td, .lb th { padding: 9px 5px; }
  .acct-btn { padding: 3px; }
  .lb-me { margin-left: 0; width: 100%; justify-content: space-between; }
  .lb th:nth-child(5), .lb td:nth-child(5), .lb th:nth-child(6), .lb td:nth-child(6) { display: none; }
}

/* ── market depth ────────────────────────────────────────────────────────── */
.depth-tbl td { position: relative; padding: 8px 10px; }
.depth-tbl th:nth-child(4), .depth-tbl td:nth-child(4) { border-left: 1px solid var(--line); }
.depth-tbl td.bidp { color: var(--up); font-weight: 600; }
.depth-tbl td.askp { color: var(--down); font-weight: 600; }
.depth-tbl td .bar { position: absolute; top: 3px; bottom: 3px; border-radius: 3px; opacity: .16; pointer-events: none; }
.depth-tbl td.bq .bar { right: 0; background: var(--up); }
.depth-tbl td.aq .bar { left: 0; background: var(--down); }
.depth-tbl tr.best td { background: rgba(255, 255, 255, .03); }
.depth-totals { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.imb { margin-top: 12px; }
.imb-bar { height: 8px; border-radius: 4px; background: var(--down); overflow: hidden; }
.imb-bar i { display: block; height: 100%; background: var(--up); transition: width .3s; }
.imb-legend { display: flex; justify-content: space-between; font-size: 12px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.depth-note { margin: 12px 0 0; }
.badge.sim { color: var(--amber); border-color: rgba(240, 164, 58, .4); }
.badge.live { color: var(--up); border-color: rgba(122, 199, 79, .4); }
.est { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; margin-top: 8px;
  font-size: 13px; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; gap: 3px; }
.est b { font-weight: 600; }
@media (max-width: 640px) {
  .depth-tbl .o { display: none; }
  .depth-tbl td, .depth-tbl th { padding: 7px 6px; }
}

/* ── F&O ─────────────────────────────────────────────────────────────────── */
.fno-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.fno-bar input { flex: 1 1 260px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; }
.fno-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.fno-quick button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; color: var(--muted); font-size: 12px; font-weight: 600; }
.fno-quick button.active { color: var(--text); border-color: var(--accent); }
.fno-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; margin: 4px 0 12px; }
.fno-head .nm { font-size: 22px; font-weight: 700; }
.fno-head .px { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fno-futs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin-bottom: 14px; }
.fut { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.fut .px { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.fut .acts { grid-column: 1 / -1; display: flex; gap: 6px; }
.fut .acts button { flex: 1; }
.chain-head { margin-top: 4px; flex-wrap: wrap; row-gap: 8px; }
.chain-ctl { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.greeks-toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; white-space: nowrap; }
.greeks-toggle input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.greeks-toggle:has(input:checked) { color: var(--text); }
.chain .opt-g { display: none; color: var(--muted); }
.chain.greeks .opt-g { display: table-cell; }
.chain.greeks th.opt-g { color: inherit; }
/* A fixed box that scrolls inside itself (header pinned), opened centred on the spot. */
.chain-wrap { max-height: min(560px, 62vh); overflow: auto; scrollbar-width: thin; border: 1px solid var(--line); border-radius: 8px; }
.chain { font-variant-numeric: tabular-nums; }
.chain thead th { position: sticky; top: 0; background: var(--panel); z-index: 1; }
.chain thead tr + tr th { top: 26px; }
.chain .sides th { text-align: center; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.chain th.strike, .chain td.strike { text-align: center; font-weight: 700; background: var(--panel-2); }
.chain td.itm { background: rgba(108, 124, 255, .08); }
.chain tr.atm td.strike { color: var(--accent); }
.chain tr.spot-line td { padding: 0; height: 2px; background: var(--accent); }
.chain td.ltp b { font-weight: 600; }
.chain .bs { display: inline-flex; gap: 3px; margin: 0 6px; visibility: hidden; }
.chain tr:hover .bs, .chain .bs:focus-within { visibility: visible; }
@media (hover: none) { .chain .bs { visibility: visible; } }
.bs button, .fut .acts button { border: 0; border-radius: 6px; padding: 3px 8px; font-size: 11px; font-weight: 700; color: #fff; cursor: pointer; }
.bs button[data-t="BUY"], .fut .acts button[data-t="BUY"] { background: var(--up); color: #10140c; }
.bs button[data-t="SELL"], .fut .acts button[data-t="SELL"] { background: var(--down); }
@media (max-width: 640px) {
  .chain .opt-x { display: none; }
  .chain-wrap { max-height: 60vh; }
  .fut { grid-template-columns: 1fr auto auto; padding: 8px 10px; }
  .fut .muted.small { display: none; }
  .fut .acts { grid-column: auto; }
  .fut .acts button { padding: 6px 10px; }
  .chain .bs { margin: 0 3px; }
  .chain .bs button { padding: 3px 6px; }
  .fno-head .nm { font-size: 19px; }
}
@media (max-width: 520px) { .chain .opt-c { display: none; } }

/* ── MCX ─────────────────────────────────────────────────────────────────── */
.mcx-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.mcx-head h3 { margin: 0 0 4px; font-size: 18px; }
.mcx-head p { margin: 0; }
.mcx-status { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; color: var(--muted); }
.mcx-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.mcx-status.live .dot { background: var(--up); box-shadow: 0 0 0 3px rgba(122, 199, 79, .2); }
.mcx-status b { color: var(--text); font-weight: 600; }
.mcx-groups { margin-bottom: 12px; }
.mcx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.mcx-group-title { grid-column: 1 / -1; margin: 6px 0 -2px; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.cmd { display: grid; gap: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.cmd .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cmd .nm { font-weight: 700; font-size: 15px; }
.cmd .spec { font-size: 12px; color: var(--muted); }
.cmd .exp { display: flex; gap: 4px; flex-wrap: wrap; }
.cmd .exp button { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font-size: 11px; color: var(--muted); }
.cmd .exp button.active { color: var(--text); border-color: var(--accent); }
.cmd .px { display: flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; }
.cmd .px b { font-size: 20px; font-weight: 600; }
.cmd .meta { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cmd .acts { display: flex; gap: 6px; }
.cmd .acts button { flex: 1; border: 0; border-radius: 8px; padding: 7px 8px; font-weight: 700; font-size: 12px; cursor: pointer; }
.cmd .acts button[data-t="BUY"] { background: var(--up); color: #10140c; }
.cmd .acts button[data-t="SELL"] { background: var(--down); color: #fff; }
.cmd .acts button:disabled { opacity: .45; cursor: not-allowed; }
@media (max-width: 640px) { .mcx-grid { grid-template-columns: 1fr; } .cmd .px b { font-size: 18px; } }

/* Eight sections fit the top bar only on wide screens: shed the wordmark, then the account name and countdown,
   and as a last resort let the menu scroll inside the bar, so the page itself never gets wider than the screen. */
.nav { min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
@media (min-width: 641px) { .top-right { flex: none; } }
@media (max-width: 640px) {
  .topbar { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .top-right { gap: 8px; min-width: 0; }
  .nav button { min-width: 0; padding: 6px 0; font-size: 10px; letter-spacing: -.01em; }
}
@media (min-width: 641px) and (max-width: 1320px) {
  .brand-text { display: none; }
  .topbar { gap: 12px; }
  .nav button { padding: 7px 9px; }
}
@media (min-width: 641px) and (max-width: 1180px) {
  .acct-text { display: none; }
  .clock .countdown { display: none; }
  .top-right { gap: 12px; }
}
@media (min-width: 641px) and (max-width: 1080px) {
  .nav button { padding: 8px 10px; }
  .nav button svg { display: block; width: 18px; height: 18px; }
  .nav button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ── stock page: Futures and Options tabs ─────────────────────────────────── */
.fut-tbl { font-variant-numeric: tabular-nums; }
.bu-head { margin-top: 18px; }
.zone { display: inline-block; border: 1px solid currentColor; border-radius: 6px; padding: 1px 7px; font-size: 12px; white-space: nowrap; }
.zone.lb { color: var(--up); } .zone.sb { color: var(--down); } .zone.sc { color: #f0a43a; } .zone.lu { color: #6c9cff; } .zone.n { color: var(--muted); }


/* ── stock page: Options tab ──────────────────────────────────────────────── */
#tab-options { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }   /* columns may shrink below a canvas's pixel width */
#tab-options.hidden { display: none; }
.oi-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-bottom: 12px; }
.oi-stats div { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.oi-stats span { display: block; color: var(--muted); font-size: 12px; }
.oi-stats b { font-size: 16px; font-variant-numeric: tabular-nums; }
/* The Options tab chart is a canvas (static/oi/chart.js) sized here; the readout gives the hovered strike's numbers. */
.oi-chart { min-width: 0; }
.oi-chart .oi-canvas { display: block; width: 100%; max-width: 100%; height: 330px; touch-action: pan-y; }
.oi-readout { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; min-height: 30px; padding: 6px 4px 0;
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.oi-readout b { color: var(--text); font-weight: 600; }
.oi-readout i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.oi-readout i.ce { background: #ffaa00; } .oi-readout i.pe { background: #a754ff; }
@media (max-width: 640px) { .oi-chart .oi-canvas { height: 260px; } }
.oi-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; }
.oi-legend { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; font-size: 12px; color: var(--muted); }
.oi-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.oi-legend i.ce { background: #ffaa00; } .oi-legend i.pe { background: #a754ff; }
.oi-legend i.up { background: rgba(141, 146, 168, .38); }
.oi-legend i.down { border: 1.5px solid #8d92a8; }
.oi-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-bottom: 12px; }
.oi-tiles div { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.oi-tiles span { display: block; color: var(--muted); font-size: 12px; }
.oi-tiles b { font-size: 15px; font-variant-numeric: tabular-nums; }
#oi-contracts .bs { visibility: visible; }

/* ── option chain polish ──────────────────────────────────────────────────── */
.xp-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 2px 0 10px; }
.xp-row::-webkit-scrollbar { display: none; }
.xp-row button { flex: none; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; color: var(--muted); font-weight: 600; font-size: 13px; }
.xp-row button.active { color: #ffaa00; border-color: #ffaa00; }
.xp-row button i { font-style: normal; font-size: 11px; margin-left: 6px; padding: 1px 5px; border-radius: 5px; background: var(--line); color: var(--muted); }
.chain td.oi { position: relative; }
.chain td.oi .sub, .chain td.ltp .sub { display: block; font-size: 11px; margin-top: 1px; }
.chain .oibar { position: absolute; bottom: 3px; height: 3px; border-radius: 2px; opacity: .85; }
.chain td.oi.ce .oibar { right: 8px; background: #ffaa00; } .chain td.oi.pe .oibar { left: 8px; background: #a754ff; }
.chain .oi-rank { display: inline-block; font-size: 10px; font-weight: 700; padding: 0 4px; border-radius: 4px; margin-right: 5px; vertical-align: 1px; }
.chain td.ce .oi-rank { background: #ffaa00; color: #1a1205; } .chain td.pe .oi-rank { background: #a754ff; color: #fff; margin: 0 0 0 5px; }
.chain tr.spot-row td { padding: 0; height: 0; border: 0; position: relative; }
.chain tr.spot-row td::before { content: ""; position: absolute; left: 0; right: 0; top: -1px; border-top: 1px solid #7ac74f; }
.chain tr.spot-row .spot-pill { position: absolute; left: 50%; top: -11px; transform: translateX(-50%); background: #7ac74f; color: #0d1508;
  font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 6px; z-index: 2; white-space: nowrap; }

/* Positions: a closed position's buy and sell averages as two aligned rows (labels in the app's up/down colours). */
.avg-legs { display: inline-grid; grid-template-columns: auto auto; column-gap: 10px; row-gap: 3px; align-items: baseline;
  justify-items: end; font-variant-numeric: tabular-nums; }
.avg-legs span { justify-self: start; font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; opacity: .85; }
.avg-legs .b { color: var(--up); }
.avg-legs .s { color: var(--down); }
.avg-legs b { font-weight: 500; }
