/* =====================================================================
   NovaTrade — user panel shell + components.
   Same navy look as the admin panel; loaded after app.css. Everything
   reads the theme variables, so Admin > Theme still recolours it.
   Mobile first: <992px the sidebar becomes a bottom bar.
   ===================================================================== */
:root {
  --font-body: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Plus Jakarta Sans', 'Inter', sans-serif;
  --radius-lg: 14px;
}
html, body { font-size: 14.5px; -webkit-text-size-adjust: 100%; }
/* Exactly ONE element owns page scrolling: html. Without this being explicit, the browser is
   free to treat BOTH html and body as separate scroll containers at once (body's overflow-y has
   no rule of its own here, so it falls back to an ambiguous default) -- each one then scrolls a
   few pixels independently of the other, which is what produced the glitchy, partial, can't-
   quite-reach-the-bottom scrolling and the sticky header/sidebar visibly jumping out of sync with
   the rest of the page. Pinning the scrollbar to html and keeping body a plain, non-scrolling
   block (it simply grows to fit its content) removes that whole class of bug. */
html { overflow-x: hidden; overflow-y: auto; }
body { overflow-x: hidden; overflow-y: visible; }
h1, h2, h3, h4, h5 { font-weight: 800; letter-spacing: -0.01em; }
h4 { font-size: 1.35rem; }
img, svg, video, canvas { max-width: 100%; }

/* ---------- shell ---------- */
.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.main-area { min-width: 0; }

.sidebar {
  /* app.css already pins this to position:sticky/top:0/height:100dvh -- that's correct. What was
     wrong is the overflow-y:auto inherited from here: it turned the sidebar into its own separate
     scroll container, so a wheel scroll anywhere near it (or scroll-chaining up through it) could
     get captured and scrolled INSIDE the sidebar instead of on the page -- the sidebar's own nav
     items would shift up/down out of sync with everything else, which is exactly the broken,
     independently-scrolling look. The sidebar's content (a handful of nav icons) comfortably fits
     its own 100dvh box without ever needing to scroll, so overflow is just visible here now. */
  width: auto; align-items: stretch; padding: 14px 12px; gap: 4px; overflow-y: visible;
  background: linear-gradient(180deg, var(--bg-surface), var(--bg-primary));
}
.sb-brand { display: flex; align-items: center; padding: 6px 8px 16px; }
.sb-nav { display: flex; flex-direction: column; gap: 3px; }
.sb-link {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
  color: var(--text-secondary); font-weight: 600; font-size: 13.5px; position: relative;
}
.sb-link i { font-size: 17px; flex: none; }
.sb-link:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.sb-link.active { background: var(--brand); color: #fff; }
.sb-link.active:hover { color: #fff; }
.sb-count { margin-left: auto; font-style: normal; background: var(--down-dim); color: var(--down-text); font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.sb-link.active .sb-count { background: rgba(255,255,255,.25); color: #fff; }
.sb-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding-top: 12px; border-top: 1px solid var(--border-subtle); }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; color: var(--text-primary); min-width: 0; }
.sb-user:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.sb-avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 800; background: rgba(var(--brand-rgb), .18); color: var(--brand-text); border: 1px solid var(--border-strong); }
.sb-user-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.sb-user-text b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-text small { color: var(--text-secondary); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-logout:hover { color: var(--down-text); }

/* ---------- top bar ---------- */
.topbar {
  height: auto; min-height: 60px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 10px 20px;
  background: color-mix(in srgb, var(--bg-surface) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.tb-logo { display: none; align-items: center; }
/* Admin-editable scrolling announcement line, right under the navbar/topbar (Admin > Platform
   Settings > "Navbar announcement ticker"). One copy of the text enters from off-screen right,
   scrolls fully across and off-screen left, then sits off-screen (invisible) for the rest of the
   cycle before jumping back to the start and re-entering — a visible pause between passes, not a
   back-to-back repeat. Hidden entirely (no empty bar) when the admin leaves the setting blank. */
.nt-ticker-bar {
  overflow: hidden; white-space: nowrap; background: var(--bg-surface-2); border-bottom: 1px solid var(--border-subtle);
  padding: 7px 0;
}
.nt-ticker-track { display: inline-block; white-space: nowrap; animation: nt-ticker-scroll 18s linear infinite; }
.nt-ticker-track span { padding: 0 48px; font-size: 13px; font-weight: 600; color: var(--text-secondary); letter-spacing: .01em; }
/* 0%: fully off-screen to the right (100vw is always wider than the bar itself, whatever the
   sidebar width). 0%-70% (first ~12.6s of the 18s cycle): scrolls left at a steady speed until
   fully off-screen to the left (-100% = shifted left by its own full rendered width). 70%-100%
   (the remaining ~5.4s): holds there, off-screen and invisible — the pause the admin asked for —
   before the next cycle silently teleports it back to the 0% start position (also invisible,
   since both ends of that jump are off-screen) and the pass begins again. */
@keyframes nt-ticker-scroll {
  0% { transform: translateX(100vw); }
  70% { transform: translateX(-100%); }
  100% { transform: translateX(-100%); }
}
@media (prefers-reduced-motion: reduce) { .nt-ticker-track { animation: none; } }
.tb-hello { font-weight: 700; font-size: 15px; order: 1; }
.wallet-toggle { order: 2; margin-left: auto; }
.tb-right { order: 3; display: flex; align-items: center; gap: 10px; }
.tb-icon, .theme-toggle {
  position: relative; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border-subtle);
  background: var(--bg-surface); color: var(--text-primary); display: inline-flex; align-items: center; justify-content: center; flex: none; padding: 0;
}
.tb-icon:hover, .theme-toggle:hover { border-color: var(--brand); color: var(--brand-text); }
.tb-logout-icon:hover { border-color: var(--down); color: var(--down); }
.tb-icon .badge-dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; background: var(--down); border-radius: 50%; border: 2px solid var(--bg-surface); }
.balance-figure {
  height: 38px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 10px; font-size: 14px; font-weight: 700;
  background: rgba(var(--brand-rgb), .12); border: 1px solid rgba(var(--brand-rgb), .35); color: var(--text-primary); white-space: nowrap;
}
/* Right next to the balance pill — the account's username/ID, visible on every page
   (including the trade page where the "Hi, Name" greeting is hidden on desktop). */
.tb-uid {
  display: inline-flex; align-items: center; height: 38px; padding: 0 10px; border-radius: 10px; font-size: 12px; font-weight: 600;
  background: var(--bg-surface); border: 1px solid var(--border-subtle); color: var(--text-secondary); white-space: nowrap;
}
/* One-click "add practice funds" button inline in the topbar balance pill —
   only shown while viewing the demo wallet and under the top-up cap. */
.balance-figure form.demo-topup-inline { display: contents; }
.demo-topup-btn {
  width: 20px; height: 20px; margin-left: 7px; border: 0; border-radius: 50%; flex: none;
  background: var(--brand); color: #111; font-size: 11px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.demo-topup-btn:hover { filter: brightness(1.08); }
.demo-topup-btn:active { transform: scale(0.92); }
.wallet-toggle { background: var(--bg-surface-2); }
.wallet-toggle button { min-height: 32px; }
.wallet-toggle button.active.demo { background: var(--bg-surface-3); color: var(--text-primary); }
.wallet-toggle button.active.demo2 { background: rgba(var(--brand-rgb), .2); color: var(--brand-text); }

.page-gutter { margin: 14px 20px 0; }
.imp-banner {
  margin: 14px 20px 0; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: rgba(255,163,26,.12); border: 1px solid rgba(255,163,26,.45); border-radius: 12px; font-size: 13px; color: var(--text-primary);
}

/* ---------- content ---------- */
.page-main > .p-4 { padding: 24px !important; }
.card-surface { border-radius: 14px; }
.stat-card { border-radius: 14px; background: var(--bg-surface); border: 1px solid var(--border-subtle); padding: 18px 20px; }
.stat-card .stat-value { font-family: var(--font-mono); font-size: 26px; font-weight: 700; }

/* buttons */
.btn-nova { min-height: 40px; border-radius: 10px; font-weight: 700; font-size: 13.5px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-nova.btn-sm { min-height: 34px; font-size: 12.5px; }
.btn-nova-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 18px rgba(var(--brand-rgb), .28); }
.btn-nova-outline { background: var(--bg-surface); }

/* forms */
.form-control-nova, select.form-control-nova, .form-select {
  width: 100%; min-height: 42px; border-radius: 10px; font-size: 14px; display: block;
  background-color: var(--bg-surface-2); border: 1px solid var(--border-subtle); color: var(--text-primary); padding: 9px 12px;
}
.form-control-nova::placeholder { color: var(--text-muted); }
.form-control-nova:focus { box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .2); }
select.form-control-nova, .form-select {
  appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%238da2cc' stroke-width='2' stroke-linecap='round' d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input[type="date"].form-control-nova { min-width: 0; }
label.form-label, .field-label, form > label, .card-surface label:not(.form-check-label):not(.pop-style-opt) {
  font-size: 12.5px; font-weight: 700; color: var(--text-secondary); margin-bottom: 6px; display: block;
}

/* Deposit/Withdraw payment-method cards (.row > .col-md-4 > .pm-option). The "instructions"
   text can be a long, unbroken crypto wallet address with no spaces/hyphens for the browser
   to wrap on naturally, which was pushing it straight off the right edge of the screen on
   mobile (clipped by body's overflow-x:hidden rather than scrolled, so it just looked cut
   off). min-width:0 is needed because these live inside Bootstrap's .row/.col flex grid,
   where a flex item's default min-width:auto lets its content's intrinsic (unwrapped) width
   force the column wider than the viewport before word-break ever gets a chance to apply. */
.pm-option { max-width: 100%; min-width: 0; }
.pm-option, .pm-option * { overflow-wrap: anywhere; word-break: break-word; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

/* tabs / pills (Bootstrap defaults were bright blue) */
.nav-pills, .nav-tabs { display: flex; flex-wrap: wrap; gap: 6px; border: 0; padding: 4px; background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 12px; width: fit-content; max-width: 100%; }
.nav-pills .nav-link, .nav-tabs .nav-link {
  border: 0; border-radius: 9px; padding: 8px 16px; font-weight: 700; font-size: 13px; color: var(--text-secondary); background: transparent; min-height: 36px;
}
.nav-pills .nav-link:hover, .nav-tabs .nav-link:hover { color: var(--text-primary); }
.nav-pills .nav-link.active, .nav-tabs .nav-link.active, .nav-pills .show > .nav-link { background: var(--brand); color: #fff; }

/* tables */
.table-nova { font-size: 13.5px; }
@media (max-width: 767px) { .table-nova { min-width: 0; } .table-nova:has(th:nth-child(6)) { min-width: 580px; } }
.table-nova th { background: var(--bg-surface-2); font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-secondary); font-weight: 700; padding: 11px 14px; white-space: nowrap; }
.table-nova td { padding: 12px 14px; }
.badge-status { border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 800; letter-spacing: .03em; }
.badge-active { background: rgba(var(--brand-rgb), .16); color: var(--brand-text); }

/* trade page polish */
.ticker-tape { background: var(--bg-surface); }
.demo-warning-banner { border-radius: 12px; }
.chart-header { background: var(--bg-surface); }
.trade-panel { background: var(--bg-surface); }
.panel-card { background: var(--bg-surface-2); }
.btn-direction { min-height: 46px; font-weight: 800; letter-spacing: .02em; }

/* more page / menu lists */
.more-list a { min-height: 54px; }

/* ---------- phones & tablets ---------- */
@media (max-width: 991px) {
  .app-shell { display: block; }
  .tb-logo { display: inline-flex; }
  .tb-hello { display: none; }
  .tb-right { margin-left: auto; order: 2; }
  .wallet-toggle { order: 3; width: 100%; margin: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
  .wallet-toggle button { padding: 8px 10px; font-size: 13px; text-align: center; }
  .topbar { padding: 10px 14px; gap: 8px; }
  .page-main > .p-4 { padding: 16px !important; }
  .page-gutter, .imp-banner { margin: 12px 14px 0; }

  /* bottom bar: flat, full width, thumb-friendly */
  .bottom-nav {
    left: 0; right: 0; bottom: 0; border-radius: 0; border-width: 1px 0 0; padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
    background: var(--glass-bg);
  }
  .bottom-nav-item { min-height: 54px; font-size: 11px; gap: 4px; }
  .bottom-nav-item i { font-size: 22px; }
  .nav-pill { top: 0; bottom: auto; height: 3px; border: 0; border-radius: 0 0 3px 3px; background: var(--brand); }
  .page-main { padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 575px) {
  html, body { font-size: 14px; }
  h4 { font-size: 1.2rem; }
  .stat-card { padding: 14px 16px; }
  .stat-card .stat-value { font-size: 23px; }
  .form-control-nova, select.form-control-nova, input, select, textarea { font-size: 16px; } /* stops iOS zooming on focus */
  .nav-pills, .nav-tabs { width: 100%; }
  .nav-pills .nav-item, .nav-tabs .nav-item { flex: 1 1 0; }
  .nav-pills .nav-link, .nav-tabs .nav-link { width: 100%; text-align: center; padding: 8px 6px; font-size: 12.5px; }
  .card-surface.p-4 { padding: 16px !important; }
  .row.g-4 { --bs-gutter-y: 1rem; }
}
@media (min-width: 992px) and (max-width: 1199px) { .app-shell { grid-template-columns: 212px minmax(0, 1fr); } }

/* ---------- light mode touches ---------- */
html[data-theme="light"] .sidebar { background: var(--bg-surface); }
html[data-theme="light"] .sb-link.active { color: #fff; }
html[data-theme="light"] .topbar { background: color-mix(in srgb, var(--bg-surface) 92%, transparent); }
html[data-theme="light"] .btn-nova-outline { background: var(--bg-surface); }
html[data-theme="light"] .table-nova th { background: var(--bg-surface-3); }

/* ---------- fixes found in review ---------- */
.theme-toggle-fixed { position: fixed; }
.page-main .card-surface:not([class*="mb-"]) + .card-surface { margin-top: 1rem; }
.hist-filter > * { min-width: 0; }
.hist-filter { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; }
.hist-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.hist-actions .btn-nova { flex: 0 0 auto; }
.hist-actions .ms-auto { margin-left: auto; }
@media (max-width: 575px) {
  .hist-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hist-filter > div:first-child { grid-column: 1 / -1; }
  .hist-actions .btn-nova { flex: 1 1 auto; }
  .hist-actions .ms-auto { margin-left: 0; flex-basis: 100%; }
  .table-nova th, .table-nova td { padding: 10px 9px; }
  .table-nova th { white-space: normal; font-size: 10.5px; }
}
.trade-panel .wallet-toggle { width: 100%; margin: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.trade-panel .wallet-toggle button { padding: 7px 6px; font-size: 12px; white-space: normal; line-height: 1.25; }

/* Open positions */
.text-up { color: var(--up-text) !important; }
.text-down { color: var(--down-text) !important; }
.pos-close { border: 1px solid var(--border-strong); background: var(--bg-surface-2); color: var(--text-primary); border-radius: 8px; padding: 2px 12px; font-size: 12px; font-weight: 600; }
.pos-close:hover { border-color: var(--brand); color: var(--brand-text); }
.pos-close:disabled { opacity: .5; }
.pos-row { gap: 12px; }
.pos-rate-line { line-height: 1.45; }
.pos-rate-line .pos-entry-rate, .pos-rate-line .pos-live-rate { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Stop-loss edit button on an open position — same look/text size as the Close button next
   to it (.pos-close above), just a different label, so the two read as one matched pair. */
.pos-sl-btn { border: 1px solid var(--border-strong); background: var(--bg-surface-2); color: var(--text-primary); border-radius: 8px; padding: 2px 12px; font-size: 12px; font-weight: 600; }
.pos-sl-btn:hover { border-color: var(--brand); color: var(--brand-text); }
.pos-sl-btn:disabled { opacity: .5; }

/* Trade-popup cautions/warnings — pulled out of plain grey text so they actually read as a
   warning instead of blending into the rest of the fine print. */
.trade-caution { color: var(--down-text); font-weight: 700; }
.trade-caution-note { background: var(--down-dim); color: var(--down-text); border-radius: 8px; padding: 6px 10px; font-weight: 600; }

/* =====================================================================
   Trading terminal look (trade page only): slim icon rail, big live
   chart, compact right-hand order panel, thumb-reach dock on phones.
   ===================================================================== */
.live-price { font-family: var(--font-mono); font-size: 16px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.live-price .up { color: var(--up-text); }
.live-price .down { color: var(--down-text); }
.amt-step { width: 38px; align-self: stretch; border: 0; background: var(--bg-surface-3); color: var(--text-primary); font-size: 20px; font-weight: 700; line-height: 1; }
.amt-step:active { background: var(--brand); color: #fff; }
.trade-dock { display: none; }

@media (min-width: 992px) {
  /* The trade page used to pin .app-shell to exactly one viewport tall with overflow:hidden, and
     every box inside it (chart, open-positions list, ...) had to be squeezed/clamped to fit
     whatever was left over. That's fragile by nature -- a manually-resized chart, a longer open
     -positions list, the navbar ticker, the OHLC strip -- any one of them changing height meant
     something else had to be measured and fought with to avoid pushing content out of a space
     that could never grow. It kept breaking in new ways instead of actually going away, so the
     page now works the normal, boring, reliable way a webpage does: .app-shell is free to be as
     tall as its content needs, the page itself scrolls, and only the top navbar (which already
     carries its own position:sticky) stays pinned in view while everything below it -- ticker,
     banners, chart, open positions -- scrolls like any other page content. The left icon sidebar
     keeps its own sticky positioning too so navigation stays reachable without scrolling back up.
  */
  .page-trade .app-shell { grid-template-columns: 68px minmax(0, 1fr); }
  .page-trade .main-area { display: flex; flex-direction: column; }
  .page-trade .sidebar { padding: 12px 8px; align-items: center; }
  .page-trade .sb-brand { display: none; }
  .page-trade .sb-nav { align-items: center; }
  /* Icons keep their name underneath (small caption) instead of being hidden entirely —
     a plain icon-only rail made it hard to tell Wallets from Settings from Support at a glance. */
  .page-trade .sb-link { width: 52px; height: auto; min-height: 48px; padding: 7px 2px 6px; flex-direction: column; justify-content: center; gap: 2px; border-radius: 12px; }
  .page-trade .sb-link i { font-size: 18px; }
  .page-trade .sb-link span { display: block; font-size: 8.5px; font-weight: 700; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 48px; }
  .page-trade .sb-user-text { display: none; }
  .page-trade .sb-count { position: absolute; top: 2px; right: 6px; margin: 0; padding: 0 5px; font-size: 9px; }
  .page-trade .sb-user { padding: 0; justify-content: center; }
  .page-trade .tb-logo { display: inline-flex; }
  .page-trade .tb-hello { display: none; }
  .page-trade .topbar { padding: 8px 16px; }
  .page-trade .ticker-tape { display: none; }

  .page-trade .trade-workspace { align-items: stretch; }
  .page-trade .demo-warning-banner { margin: 0; padding: 4px 12px; font-size: 11px; border-radius: 0; border-width: 0 0 1px; }
  .page-trade .chart-header { padding: 8px 14px; gap: 14px; }
  /* A fixed, viewport-relative height (not a flex-stretch that depended on exactly how much
     space happened to be left over) -- the chart gets a solid, predictable size on its own,
     and the open-positions list below it just takes whatever height its content needs, as part
     of the normal page flow. No more squeezing one against the other. */
  .page-trade .chart-canvas-wrap { min-height: 320px; height: min(620px, 62vh); flex: none; }
  .page-trade .chart-pane > .p-3 { padding: 8px 14px !important; flex: none; background: var(--bg-surface); }
  .page-trade .chart-pane > .p-3 h6 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); }
  .page-trade #activeTradesList { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
  .page-trade .trade-mini { margin: 0; padding: 8px 10px; }

  /* app.css gives .trade-panel its own overflow-y:auto for the mobile slide-up sheet, where it
     genuinely needs to scroll internally. On desktop it doesn't -- and leaving it on is exactly
     what made the mouse wheel appear to do nothing while it was hovering over this panel: the
     browser hands a wheel scroll to the nearest scrollable ancestor under the cursor first, and
     an overflow:auto box with nothing to scroll just swallows that scroll instead of the page
     ever seeing it. Turning it off here lets the wheel reach the actual page scroll however the
     cursor happens to be sitting over this side of the screen. */
  .page-trade .trade-panel { width: 278px; padding: 12px; gap: 9px; background: var(--bg-surface); overflow-y: visible; }
  .page-trade .panel-card { background: transparent; border: 0; padding: 0; }
  .page-trade .amount-input-wrap { border-radius: 10px; background: var(--bg-surface-2); }
  .page-trade .amount-input-wrap input { text-align: center; font-size: 15px; font-weight: 700; padding: 8px 0; }
  .page-trade .amount-input-wrap span { padding: 0 2px 0 10px; font-size: 13.5px; }
  .page-trade .amount-input-wrap input { min-width: 0; width: 100%; text-align: left; }
  .page-trade .amount-quick button { padding: 6px 0; font-weight: 600; }
  .page-trade .payout-preview { border: 1px solid var(--border-subtle); background: var(--bg-surface-2); }
  .page-trade .trade-panel .direction-row { gap: 8px !important; }
  .page-trade .btn-direction { min-height: 40px; font-size: 14px; padding: 9px 0; display: flex; align-items: center; justify-content: center; gap: 5px; }
  .page-trade .btn-direction i { font-size: 17px; }
  .page-trade .trade-panel > p { color: var(--text-muted); }
}
@media (min-width: 992px) and (max-height: 820px) {
  /* Shorter laptop screens (1366x768 and similar): give the chart a touch less height so it
     doesn't dominate a short window, leaving more of the visible area for what's below before
     the user has to scroll. The open-positions list itself no longer caps/scrolls on its own --
     see the min-width:992px block above -- the whole page scrolls instead. */
  .page-trade .chart-canvas-wrap { height: min(520px, 56vh); }
}

@media (max-width: 991px) {
  .page-trade .page-main { padding-bottom: calc(130px + env(safe-area-inset-bottom, 0px)); }
  .page-trade .ticker-tape { display: none; }
  .page-trade .demo-warning-banner { margin: 0; border-radius: 0; padding: 4px 10px; font-size: 11px; }
  /* Practice-mode strip eats chart space on the trade page specifically
     (it wraps to 2 lines at phone width) — keep it compact here only. */
  .page-trade .practice-strip { margin: 0; border-radius: 0; padding: 4px 10px; font-size: 9.5px; gap: 6px; flex-wrap: nowrap; }
  .page-trade .practice-strip span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page-trade .practice-strip .ps-btn { padding: 3px 7px; font-size: 9.5px; flex: none; }
  .page-trade .chart-header { padding: 8px 12px; gap: 10px; flex-wrap: nowrap; }
  .page-trade .live-price { margin-left: auto; font-size: 17px; }
  .trade-dock {
    display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: 8px; align-items: stretch;
    position: fixed; left: 0; right: 0; z-index: 60;
    bottom: calc(62px + env(safe-area-inset-bottom, 0px));
    padding: 8px 10px; background: var(--glass-bg); border-top: 1px solid var(--border-subtle);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  }
  .dock-amt { display: flex; align-items: stretch; background: var(--bg-surface-2); border: 1px solid var(--border-subtle); border-radius: 12px; overflow: hidden; cursor: pointer; }
  .dock-amt:active { background: var(--bg-surface-3); }
  .dock-amt-val { flex: 1; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-weight: 800; font-size: 15px; }
  .trade-dock .btn-direction { min-height: 52px; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 2px; }
  .trade-dock .btn-direction i { font-size: 24px; }
}
@media (max-width: 991px) { .sheet-backdrop.open ~ .trade-dock { z-index: 60; } }

/* Lot / Time mode switch, close-all, candle-time chips */
.mode-tabs { display: inline-flex; background: var(--bg-surface-2); border: 1px solid var(--border-subtle); border-radius: 10px; padding: 3px; gap: 2px; }
.mode-tabs button { border: 0; background: transparent; color: var(--text-secondary); font-weight: 700; font-size: 12.5px; padding: 6px 14px; border-radius: 8px; }
.mode-tabs button.active { background: var(--brand); color: #fff; }
.pos-closeall { border: 1px solid var(--down); background: rgba(var(--down-rgb), .1); color: var(--down-text); border-radius: 8px; padding: 3px 12px; font-size: 12px; font-weight: 700; text-transform: none; letter-spacing: 0; }
.pos-closeall:hover { background: var(--down); color: #fff; }
.dock-times { grid-column: 1 / -1; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.dock-times button { flex: 1 0 auto; border: 1px solid var(--border-subtle); background: var(--bg-surface-2); color: var(--text-secondary); border-radius: 9px; padding: 6px 12px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.dock-times button.active { border-color: var(--brand); color: var(--text-primary); background: rgba(var(--brand-rgb), .16); }
.pos-row .countdown { font-family: var(--font-mono); font-size: 12.5px; color: var(--warn-text); }
@media (max-width: 991px) {
  body.mode-binary.page-trade .page-main { padding-bottom: calc(176px + env(safe-area-inset-bottom, 0px)); }
  .page-trade .chart-header { flex-wrap: nowrap; }
  .page-trade .chart-header .asset-picker-btn { flex: 0 0 auto; }
}

/* Live chart (nt-chart.js) */
.nt-chart-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--border-subtle); background: var(--bg-surface); flex: none; overflow-x: auto; scrollbar-width: none; }
.nt-seg { display: inline-flex; flex: none; background: var(--bg-surface-2); border: 1px solid var(--border-subtle); border-radius: 9px; padding: 2px; gap: 1px; }
.nt-seg button { border: 0; background: transparent; color: var(--text-secondary); font-size: 12px; font-weight: 700; padding: 4px 11px; border-radius: 7px; white-space: nowrap; }
.nt-seg button:hover { color: var(--text-primary); }
.nt-seg button.active { background: var(--brand); color: #fff; }
.nt-draw-seg button { padding: 4px 8px; font-size: 14px; }
.nt-status { margin-left: auto; flex: none; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); white-space: nowrap; }
.nt-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.nt-status.ok { color: var(--up-text); }
.nt-status.ok::before { background: var(--up); box-shadow: 0 0 8px var(--up); }
.nt-stage { position: relative; flex: 1 1 auto; min-height: 0; }
.nt-stage canvas {
  position: absolute; inset: 0; display: block; touch-action: none; cursor: crosshair;
  /* A <canvas> is treated as a draggable image in some browsers by default, so a mouse-down
     drag can start the browser's native "drag a ghost image" gesture instead of ever firing
     pointermove on the canvas — this is what made the chart feel like it couldn't be freely
     panned with the mouse. Turning that native drag off is the fix. */
  -webkit-user-drag: none; user-drag: none; -webkit-user-select: none; user-select: none;
}
.nt-golive { position: absolute; right: 84px; bottom: 36px; display: none; background: var(--bg-surface-2); border: 1px solid var(--border-subtle); color: var(--text-primary); border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 700; }
.nt-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--text-secondary); font-size: 13px; background: linear-gradient(180deg, var(--bg-primary), var(--bg-surface)); }
.nt-loading i { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--brand); animation: ntspin .8s linear infinite; }
@keyframes ntspin { to { transform: rotate(360deg); } }
.chart-canvas-wrap #tv_chart_container { height: 100%; }
/* On a short laptop screen, .chart-canvas-wrap's height is a fixed calc()/min-height (see the
   media queries below) rather than something that can flex-shrink to fit — if the chart
   widget's own stacked rows (toolbar + HUD, which can wrap to 2 lines on a narrower window,
   + canvas + the OHLC strip) ever add up to a hair more than that box, the overflow used to
   render past the bottom of the box instead of being clipped, landing directly on top of the
   open-positions list that follows right after it in the page — looking like the open
   positions had "disappeared" under the chart. Clipping here is the fix: the canvas/HUD/strip
   stack is always sized to fit its own box's content-box height (see nt-chart.js's resize()),
   so nothing meaningful is ever actually cut off by this — it only ever discards the stray
   overflow that used to spill onto the section below. */
.chart-canvas-wrap { overflow: hidden; }

/* Drag handle under the chart (built by nt-chart.js's build(), inserted as .chart-canvas-wrap's
   next sibling) — lets the user manually resize the chart's height by hand, taller or shorter,
   independent of whatever the default auto/breakpoint-based height would be. The chosen height
   is remembered (localStorage) and re-applied on the next visit. Hidden entirely in fullscreen
   mode (see .nt-chart-max .nt-resize-handle above) since there's nothing left to resize there. */
.nt-resize-handle {
  flex: none; height: 14px; margin: -3px 0 -3px; position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: center; cursor: ns-resize; touch-action: none;
  color: var(--text-secondary); opacity: .5; transition: opacity .15s ease, color .15s ease;
}
.nt-resize-handle::before { content: ''; position: absolute; left: 16px; right: 16px; top: 50%; height: 1px; background: currentColor; opacity: .35; }
.nt-resize-handle i { position: relative; font-size: 13px; background: var(--bg-surface); padding: 0 6px; }
.nt-resize-handle:hover, .nt-resize-handle.active { opacity: 1; color: var(--brand); }


/* header row: asset + Lot/Time + price always stay on ONE line, price shrinks for big numbers */
.page-trade .chart-header { flex-wrap: nowrap; }
.page-trade .chart-header .mode-tabs { flex: 0 0 auto; }
@media (max-width: 400px) { .page-trade .live-price { font-size: 14px; } .page-trade .mode-tabs button { padding: 5px 9px; font-size: 12px; } }

/* Market-closed popup (auto-closes after 5s) */
.mkt-pop-wrap { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(3, 8, 20, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: mktFade .18s ease-out; }
.mkt-pop { position: relative; width: min(360px, 100%); padding: 24px 20px 18px; border-radius: 18px; text-align: center; overflow: hidden; background: linear-gradient(165deg, var(--bg-surface) 0%, var(--bg-surface-2) 100%); border: 1px solid var(--border-subtle); box-shadow: 0 24px 60px rgba(0, 0, 0, .45); animation: mktSlideUp .32s cubic-bezier(.16, .84, .32, 1.18); }
.mkt-pop::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, var(--warn-text, #f5b942), rgba(245, 185, 66, .15)); }
.mkt-pop h5 { margin: 10px 0 2px; font-weight: 800; color: var(--text-primary); font-size: 1.1rem; }
.mkt-ico { position: relative; width: 58px; height: 58px; margin: 4px auto 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 25px; color: var(--warn-text, #f5b942); background: rgba(245, 185, 66, .14); }
.mkt-ico::after { content: ''; position: absolute; inset: -7px; border-radius: 50%; border: 1px solid rgba(245, 185, 66, .3); animation: mktPulse 2.2s ease-out infinite; }
.mkt-name { font-weight: 700; color: var(--brand); margin-bottom: 14px; }
.mkt-rows { display: grid; gap: 7px; text-align: left; background: var(--bg-surface-2); border: 1px solid var(--border-subtle); border-radius: 12px; padding: 11px 13px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .02); }
.mkt-rows div { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; }
.mkt-rows span { color: var(--text-secondary); white-space: nowrap; }
.mkt-rows b { color: var(--text-primary); text-align: right; }
.mkt-rows div:last-child b { background: rgba(var(--brand-rgb), .15); color: var(--brand); padding: 3px 10px; border-radius: 999px; font-weight: 800; font-size: 12.5px; }
.mkt-note { margin-top: 11px; font-size: 12px; color: var(--text-muted); display: flex; align-items: center; justify-content: center; gap: 6px; }
.mkt-note::before { content: '\f431'; font-family: 'bootstrap-icons'; font-size: 13px; }
.mkt-x { position: absolute; top: 8px; right: 10px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: transparent; color: var(--text-secondary); font-size: 22px; line-height: 1; transition: background .15s, color .15s; }
.mkt-x:hover { background: var(--bg-surface-3); color: var(--text-primary); }
.mkt-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: transparent; }
.mkt-bar i { display: block; height: 100%; background: var(--brand); transform-origin: left; animation: mktBar 5s linear forwards; }
@keyframes mktPulse { 0% { transform: scale(.88); opacity: .55; } 100% { transform: scale(1.3); opacity: 0; } }

/* Close-all choice popup: all / profitable only / in loss only */
.ca-pop { text-align: left; }
.ca-pop h5 { text-align: center; }
.ca-pop .mkt-note { text-align: center; }
.ca-opts { display: grid; gap: 8px; margin-top: 14px; }
.ca-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--border-subtle); background: var(--bg-surface-2); color: var(--text-primary); font-weight: 700; font-size: 13.5px; text-align: left; }
.ca-opt i { font-size: 16px; color: var(--text-secondary); }
.ca-opt:hover { border-color: var(--brand); background: rgba(var(--brand-rgb), .1); }
.ca-opt-up i { color: var(--up-text); }
.ca-opt-up:hover { border-color: var(--up); background: rgba(var(--up-rgb), .1); }
.ca-opt-down i { color: var(--down-text); }
.ca-opt-down:hover { border-color: var(--down); background: rgba(var(--down-rgb), .1); }

/* Stop loss popup — same premium "mkt-pop" card language, with an input + an inline "Off"
   button instead of a plain browser prompt(). That clear control used to be a separate chip
   sitting below the input (the .amount-quick/.sl-pop-quick button) — on its own with nothing
   beside it, that just looked like a stray, undersized, oddly-centered box. Tucking it inside
   the price input itself, as a small labeled pill (same idea as a clearable search field, but
   with the word "Off" instead of a bare x so it stays self-explanatory) reads immediately as
   what it does and needs no extra row/vertical space. */
.sl-pop-ico { color: var(--brand); background: rgba(var(--brand-rgb), .14); }
.sl-pop-ico::after { border-color: rgba(var(--brand-rgb), .3); }
.sl-pop::before { background: linear-gradient(90deg, var(--brand), rgba(var(--brand-rgb), .15)); }
.sl-pop-input-wrap { position: relative; margin-top: 16px; }
.sl-pop-input { margin-top: 0; width: 100%; text-align: center; font-size: 17px; font-weight: 700; letter-spacing: .01em; padding-right: 54px; -moz-appearance: textfield; }
.sl-pop-input::-webkit-outer-spin-button, .sl-pop-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sl-pop-clear {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  height: 26px; padding: 0 12px; border-radius: 13px; display: flex; align-items: center; justify-content: center;
  background: var(--bg-surface-2); border: 1px solid var(--border-subtle); color: var(--text-secondary);
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
}
.sl-pop-clear:hover { color: var(--text-primary); border-color: var(--brand); }
.sl-pop-actions { display: flex; gap: 10px; margin-top: 16px; }
.sl-pop-actions .btn-nova { flex: 1 1 0; }

/* Order ticket popup (Buy/Sell Limit/Stop) — same "mkt-pop" card language as Stop Loss above. */
.order-pop-ico.order-pop-buy { color: var(--up-text, #19c98a); background: rgba(var(--up-rgb), .14); }
.order-pop-ico.order-pop-buy::after { border-color: rgba(var(--up-rgb), .3); }
.order-pop-ico.order-pop-sell { color: var(--down-text, #ff4d6a); background: rgba(var(--down-rgb), .14); }
.order-pop-ico.order-pop-sell::after { border-color: rgba(var(--down-rgb), .3); }
.order-pop .form-control-nova { margin-top: 4px; width: 100%; text-align: center; font-size: 16px; font-weight: 700; letter-spacing: .01em; }
.order-pop .field-label { font-size: 11.5px; color: var(--text-secondary); }
.order-pop-quick { justify-content: center; margin-top: 10px; }
.order-pop-quick button { flex: 0 0 auto; padding: 5px 16px; }

/* Right-click menu's Buy/Sell order rows — icon tint only, same row layout as the rest of the menu. */
.nt-ctx-buy i { color: var(--up-text, #19c98a); }
.nt-ctx-sell i { color: var(--down-text, #ff4d6a); }

/* PWA install prompt — same premium "mkt-pop" card language again. */
.pwa-pop-ico { color: var(--brand); background: rgba(var(--brand-rgb), .14); }
.pwa-pop-ico::after { border-color: rgba(var(--brand-rgb), .3); }
.pwa-pop::before { background: linear-gradient(90deg, var(--brand), rgba(var(--brand-rgb), .15)); }
.pwa-pop-steps { margin: 16px 0 0; padding-left: 22px; text-align: left; display: grid; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.pwa-pop-steps b { color: var(--text-primary); }
.pwa-pop-actions { display: flex; gap: 10px; margin-top: 16px; }
.pwa-pop-actions .btn-nova { flex: 1 1 0; }
.pwa-pop-check { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 13px; font-size: 12.5px; color: var(--text-muted); cursor: pointer; user-select: none; }
.pwa-pop-check input { accent-color: var(--brand); width: 15px; height: 15px; margin: 0; }
@keyframes mktBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes mktPop { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes mktFade { from { opacity: 0; } to { opacity: 1; } }
/* Entrance for dialog-style popups (Market Closed, close-all choice): rises up from below into
   place instead of the earlier center-scale pop-in. The buy/sell confirmation no longer uses a
   dialog popup at all — it now shares the exact same .trade-toast element/animation (app.css)
   that closing a position already used, on every screen size including mobile. */
@keyframes mktSlideUp { from { transform: translateY(46px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

/* Desktop: the asset list is a plain dropdown (outside-click closes it) - the dimming backdrop must not sit on top of it */
@media (min-width: 992px) { .sheet-backdrop, .sheet-backdrop.open { display: none !important; } .page-trade .asset-sheet { z-index: 80; } }

/* =====================================================================
   Compact / professional density (user panel). One calm scale everywhere:
   smaller type, tighter spacing, slimmer chrome. Bootstrap spacing is
   rem-based, so lowering the root size shrinks it all proportionally.
   ===================================================================== */
html, body { font-size: 13px; }
body { line-height: 1.45; -webkit-font-smoothing: antialiased; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.4rem; } h3 { font-size: 1.2rem; }
h4 { font-size: 1.3rem; } h5 { font-size: 1.05rem; } h6 { font-size: .95rem; }
h4.font-display, .page-main h4 { font-size: 17px; font-weight: 800; }
.text-secondary.small, .small { font-size: 12px; }

/* shell */
.app-shell { grid-template-columns: 208px minmax(0, 1fr); }
.sidebar { padding: 12px 10px; gap: 2px; }
.sb-brand { padding: 4px 8px 12px; }
.sb-brand img, .sb-brand svg { height: 24px; width: auto; }
.sb-link { gap: 10px; padding: 8px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 600; }
.sb-link i { font-size: 15px; }
.sb-count { font-size: 10px; padding: 0 6px; }
.sb-avatar { width: 30px; height: 30px; font-size: 12px; }
.sb-user { padding: 6px; }
.sb-user-text b { font-size: 12px; } .sb-user-text small { font-size: 11px; }

.topbar { min-height: 50px; padding: 7px 18px; gap: 8px 10px; }
.tb-hello { font-size: 13.5px; font-weight: 700; }
.tb-icon, .theme-toggle { width: 32px; height: 32px; border-radius: 8px; font-size: 14px; }
.tb-icon .badge-dot { top: 5px; right: 6px; width: 7px; height: 7px; }
.balance-figure { height: 32px; padding: 0 12px; border-radius: 8px; font-size: 12.5px; }
.tb-uid { height: 32px; padding: 0 8px; border-radius: 8px; font-size: 10.5px; }
.demo-topup-btn { width: 18px; height: 18px; margin-left: 5px; font-size: 10px; }
.wallet-toggle button { min-height: 28px; padding: 5px 11px; font-size: 11.5px; }

.page-main > .p-4 { padding: 18px 20px !important; }
.page-gutter { margin: 10px 18px 0; }
.imp-banner { margin: 10px 18px 0; padding: 8px 12px; font-size: 12px; border-radius: 10px; }

/* cards, stats */
.card-surface { border-radius: 12px; }
.card-surface.p-4, .p-4.card-surface { padding: 16px !important; }
.stat-card { border-radius: 12px; padding: 13px 16px; }
.stat-card .stat-label { font-size: 10.5px; letter-spacing: .06em; }
.stat-card .stat-value { font-size: 21px; margin-top: 3px; }
.kv, .kv span { font-size: 12.5px; }

/* controls */
.btn-nova { min-height: 34px; padding: 6px 14px; border-radius: 8px; font-size: 12.5px; gap: 5px; }
.btn-nova.btn-sm { min-height: 28px; padding: 4px 11px; font-size: 11.5px; }
.btn-nova-primary { box-shadow: 0 3px 10px rgba(var(--brand-rgb), .22); }
.form-control-nova, select.form-control-nova, .form-select { min-height: 34px; padding: 6px 10px; border-radius: 8px; font-size: 12.5px; }
select.form-control-nova, .form-select { padding-right: 30px; background-position: right 10px center; }
label.form-label, .field-label, form > label, .card-surface label:not(.form-check-label):not(.pop-style-opt) { font-size: 11.5px; margin-bottom: 4px; letter-spacing: .01em; }
.nav-pills, .nav-tabs { padding: 3px; border-radius: 10px; gap: 3px; }
.nav-pills .nav-link, .nav-tabs .nav-link { padding: 5px 12px; min-height: 30px; font-size: 12px; border-radius: 7px; }

/* tables */
.table-nova { font-size: 12.5px; }
.table-nova th { padding: 8px 12px; font-size: 10.5px; letter-spacing: .06em; }
.table-nova td { padding: 9px 12px; }
.table-nova td.num, .table-nova td .mono { font-size: 12px; }
.badge-status { padding: 2px 8px; font-size: 10px; border-radius: 999px; }

/* history page */
.hist-stat, .stats-row .stat { padding: 8px 12px; }

@media (max-width: 991px) {
  html, body { font-size: 13px; }
  .topbar { padding: 7px 12px; min-height: 46px; }
  .tb-hello { display: none; }
  .page-main > .p-4 { padding: 14px 12px !important; }
  .page-gutter { margin: 8px 12px 0; }
  .imp-banner { margin: 8px 12px 0; }
  h4.font-display, .page-main h4 { font-size: 16px; margin-bottom: 12px !important; }
  /* tables: one tidy row each, side-scroll instead of a tall wrapped mess */
  .card-surface:has(> .table-nova), .card-surface:has(> table), .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-nova th, .table-nova td { white-space: nowrap; padding: 8px 10px; font-size: 12px; }
  .table-nova td.text-secondary:last-child, .table-nova td.note { white-space: normal; min-width: 170px; }
  .table-nova { min-width: 520px !important; }
  /* bottom bar: slimmer */
  .bottom-nav-item { padding: 5px 2px; font-size: 10px; gap: 2px; }
  .bottom-nav-item i { font-size: 18px; }
}

/* trade terminal: compact scale (buttons/fields smaller on desktop/laptop —
   this block is the one that wins since it's declared after the earlier
   min-width:992px block above, so these are the real, final sizes). */
@media (min-width: 992px) {
  .page-trade .btn-direction { min-height: 36px; font-size: 13px; padding: 7px 0; }
  .page-trade .btn-direction i { font-size: 15px; }
  .page-trade .trade-panel .direction-row { gap: 7px !important; }
  .page-trade .trade-panel { padding: 10px 12px; gap: 8px; width: 260px; }
  .page-trade .amt-step { width: 26px; font-size: 15px; }
  .page-trade .payout-preview { padding: 6px 10px; }
  .page-trade .payout-preview .amt { font-size: 13px; }
  .page-trade .chart-header { padding: 6px 12px; gap: 10px; }
  .page-trade .live-price { font-size: 16px; }
  .page-trade .trade-panel > p { font-size: 10.5px; }

  /* Open-position cards: same idea as the phone-only shrink further down,
     just for desktop/laptop instead — smaller text/padding. Width (not
     height) is what the card should flex on: 205px was narrow enough that
     the Stop Loss / Close row had no room and wrapped "Stop Loss" onto two
     lines, which is what made the card taller than it should be. Widening
     the grid cell to 240px gives that row enough room to stay one line
     (plus white-space:nowrap + flex-shrink:0 below as a hard guarantee),
     so the card's height stays fixed and compact. */
  .page-trade #activeTradesList { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px; }
  .page-trade .trade-mini { padding: 6px 9px; margin: 0; }
  .page-trade .trade-mini.pos-row { gap: 6px; }
  .page-trade .trade-mini .fw-semibold { font-size: 12px; }
  .page-trade .trade-mini .badge-status { padding: 1px 7px; font-size: 9.5px; }
  .page-trade .trade-mini .pos-pnl { font-size: 12px !important; }
  .page-trade .trade-mini .pos-fees, .page-trade .trade-mini .pos-sl { font-size: 9.5px !important; }
  .page-trade .trade-mini .pos-close, .page-trade .trade-mini .pos-sl-btn {
    padding: 2px 9px; font-size: 10px; white-space: nowrap; flex-shrink: 0;
  }
  .page-trade .trade-mini .countdown { font-size: 11px; }
}
@media (max-width: 991px) {
  .table-nova td.text-secondary:last-child, .table-nova td.note { white-space: nowrap; min-width: 0; }
  .trade-dock .btn-direction { min-height: 44px; font-size: 14px; }
  .dock-amt-val { font-size: 14px; }
}
@media (min-width: 992px) {
  /* "Lot" label and the number next to it ("1") now match in size — the
     number used to be noticeably bigger/bolder (a leftover from the old
     app.css base: font-size 14.5px, font-weight 700) while "Lot" stayed at
     the label's own small size, which read as mismatched. */
  .page-trade .amount-input-wrap input { font-size: 12.5px; font-weight: 600; padding: 5px 0; }
  .page-trade .amount-input-wrap span { font-size: 12.5px; }
}
@media (max-width: 991px) {
  /* --nt-ohlc-h is set (and cleared) by nt-chart.js's applyOhlcVisibility() to the OHLC strip's
     own measured height whenever it's hidden, so turning that strip off shrinks this whole fixed
     box by exactly the room it was taking, instead of just letting the canvas inside grow to fill
     the same box — the latter left the open-positions list below no better off. */
  .page-trade .chart-canvas-wrap { flex: none; height: calc(100dvh - 350px - var(--nt-ohlc-h, 0px) - var(--nt-ticker-h, 0px)); min-height: 330px; max-height: 670px; }
}

/* phone dock: slim and quiet */
@media (max-width: 991px) {
  .trade-dock { gap: 6px; padding: 6px 8px; bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  .dock-amt { border-radius: 8px; min-height: 34px; }
  .dock-amt .amt-step { width: 26px; font-size: 14px; }
  .dock-amt-val { font-size: 12.5px; }
  .trade-dock .btn-direction { min-height: 30px; padding: 0 9px; font-size: 12px; border-radius: 8px; letter-spacing: .02em; gap: 3px; box-shadow: none; }
  .trade-dock .btn-direction i { font-size: 14px; }
  .dock-times { gap: 5px; }
  .dock-times button { padding: 4px 9px; font-size: 11px; border-radius: 7px; }
  .page-trade .page-main { padding-bottom: calc(128px + env(safe-area-inset-bottom, 0px)); }
  body.mode-binary.page-trade .page-main { padding-bottom: calc(164px + env(safe-area-inset-bottom, 0px)); }
  .bottom-nav { padding-bottom: env(safe-area-inset-bottom, 0px); }
  .bottom-nav-item { padding: 4px 2px; }
  /* Leave enough room below the chart for the fixed thumb-reach dock (amount
     + BUY/SELL) so it never sits on top of the chart's bottom edge — this
     used to be too tall and the dock would cover the last ~50-80px of the
     chart. Binary mode's dock is taller (extra duration-chip row), so it
     needs more room subtracted. */
  .page-trade .chart-canvas-wrap { height: calc(100dvh - 312px - var(--nt-ohlc-h, 0px) - var(--nt-ticker-h, 0px)); }
  body.mode-binary.page-trade .chart-canvas-wrap { height: calc(100dvh - 342px - var(--nt-ohlc-h, 0px) - var(--nt-ticker-h, 0px)); }

  /* Open-position cards below the chart: smaller on phones so they take
     less room and more of the chart stays visible while a trade is open. */
  .page-trade .trade-mini { padding: 7px 10px; margin-bottom: 6px; }
  .page-trade .trade-mini.pos-row { gap: 8px; }
  .page-trade .trade-mini .fw-semibold { font-size: 12px; }
  .page-trade .trade-mini .badge-status { padding: 1px 7px; font-size: 9.5px; }
  .page-trade .trade-mini .text-secondary { font-size: 10.5px !important; }
  .page-trade .trade-mini .pos-pnl { font-size: 12px !important; }
  .page-trade .trade-mini .pos-fees, .page-trade .trade-mini .pos-sl { font-size: 9.5px !important; }
  .page-trade .trade-mini .pos-close, .page-trade .trade-mini .pos-sl-btn { padding: 1px 10px; font-size: 10.5px; }
  .page-trade .trade-mini .countdown { font-size: 11px; }
  .page-trade .trade-mini .countdown-bar { height: 3px; }

  /* Trade panel sheet (the "Buy/Sell" popup): tighter spacing and smaller
     controls so the whole thing fits within its max-height on a normal
     phone without needing to scroll internally. */
  .page-trade .trade-panel { padding: 7px 12px 5px; gap: 5px; }
  .page-trade .trade-panel-header { padding: 0 2px; font-size: 12.5px; }
  .page-trade .panel-card { padding: 5px 8px; }
  .page-trade .trade-panel label.field-label { margin-bottom: 2px; font-size: 9.5px; line-height: 1.2; }
  .page-trade .amount-input-wrap input { padding: 5px 8px 5px 0; }
  .page-trade .amount-quick { margin-top: 3px; }
  .page-trade .amount-quick button { padding: 3px 0; }
  .page-trade .duration-grid { gap: 4px; }
  .page-trade .duration-grid button { padding: 5px 0; }
  .page-trade .payout-preview { padding: 5px 10px; }
  .page-trade .payout-preview .amt { font-size: 13.5px; }
  .page-trade .fee-line { font-size: 10px; line-height: 1.25; }
  .page-trade .trade-panel .direction-row { gap: 8px; }
  .page-trade .trade-panel .btn-direction { min-height: 36px; padding: 6px 0; font-size: 13px; }
  .page-trade .trade-panel > p { font-size: 9px; margin-top: 2px; line-height: 1.25; }
}

/* commission line under the order preview */
.fee-line { font-size: 11.5px; padding: 0 2px; line-height: 1.4; }
.fee-line b { color: var(--text-primary); font-weight: 700; }
.pos-fees { line-height: 1.3; }

/* Chart readout: full O/H/L/C line above the chart and a detail strip below it */
.nt-hud { flex: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; padding: 7px 12px; border-bottom: 1px solid var(--border-subtle); background: var(--bg-surface); font: 600 12px ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; min-height: 34px; }
.nt-hud .nm { font: 800 12.5px Inter, system-ui, sans-serif; color: var(--text-primary); margin-right: 4px; }
.nt-hud b { color: var(--text-secondary); font-weight: 500; margin-right: 3px; }
.nt-hud i { font-style: normal; font-weight: 700; }
.nt-hud i.up, .nt-strip .up { color: var(--up); }
.nt-hud i.down, .nt-strip .down { color: var(--down); }
.nt-hud em { margin-left: auto; font: 700 10.5px Inter, system-ui, sans-serif; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); font-style: normal; }
.nt-hud em.lv { color: var(--up); display: inline-flex; align-items: center; gap: 5px; }
.nt-hud em.lv u { width: 6px; height: 6px; border-radius: 50%; background: var(--up); animation: ntLive 1s infinite; }
.nt-hud em.sel { color: var(--brand); cursor: default; }
@keyframes ntLive { 50% { opacity: .25; } }
.nt-strip { flex: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); border-top: 1px solid var(--border-subtle); background: var(--bg-surface); }
.nt-strip > div { padding: 6px 10px; border-right: 1px solid var(--border-subtle); min-width: 0; }
.nt-strip > div:last-child { border-right: 0; }
.nt-strip small { display: block; font-size: 9.5px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 1px; }
.nt-strip span { font: 700 12px ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 560px) { .nt-hud { font-size: 9.5px; gap: 1px 6px; padding: 3px 7px; min-height: 22px; } .nt-hud .nm { font-size: 10px; } .nt-strip { grid-template-columns: repeat(4, 1fr); } .nt-strip > div { padding: 3px 5px; } .nt-strip > div:nth-child(4n) { border-right: 0; } .nt-strip > div:nth-child(n+5) { border-top: 1px solid var(--border-subtle); } .nt-strip small { font-size: 8px; margin-bottom: 0; } .nt-strip span { font-size: 10px; } }
@media (prefers-reduced-motion: reduce) { .nt-hud em.lv u { animation: none; } }

/* Practice-mode strip: always a clear way back */
.practice-strip { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 10px 18px 0; padding: 8px 12px; font-size: 12.5px; border-radius: 10px; background: rgba(245,165,36,.12); border: 1px solid rgba(245,165,36,.35); color: var(--text-primary); }
.practice-strip .ps-btn { border: 0; cursor: pointer; text-decoration: none; background: var(--brand, #f5a524); color: #111; font-weight: 600; font-size: 12.5px; padding: 6px 12px; border-radius: 8px; display: inline-flex; align-items: center; }
@media (max-width: 768px) { .practice-strip { margin: 10px 14px 0; } }

/* Timeframe dropdown */
.nt-frames { display: inline-flex; align-items: center; }
.nt-frame-sel { appearance: none; -webkit-appearance: none; background: var(--bg-surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%238a94a6' stroke-width='1.6'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 9px center; color: var(--text-primary); border: 1px solid var(--border, rgba(128,128,128,.25)); border-radius: 8px; padding: 6px 26px 6px 10px; font-size: 12.5px; font-weight: 600; min-height: 30px; cursor: pointer; }
.nt-frame-sel:focus { outline: 2px solid rgba(var(--brand-rgb, 47,107,255), .45); outline-offset: 1px; }
.nt-frame-sel option, .nt-frame-sel optgroup { background: var(--bg-surface, #fff); color: var(--text-primary, #111); }

/* chart: indicators dropdown */
.nt-ind-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; background: var(--bg-surface-2); color: var(--text-primary); border: 1px solid var(--border, rgba(128,128,128,.25)); border-radius: 8px; padding: 6px 11px; font-size: 12.5px; font-weight: 600; min-height: 30px; cursor: pointer; white-space: nowrap; }
.nt-ind-btn span { color: var(--brand); font-style: italic; font-weight: 800; }
.nt-ind-btn b { display: none; background: var(--brand); color: #fff; border-radius: 9px; font-size: 10.5px; padding: 0 6px; line-height: 16px; }
.nt-ind-btn:hover { border-color: var(--brand); }
.nt-max-btn { flex: none; display: inline-flex; align-items: center; justify-content: center; background: var(--bg-surface-2); color: var(--text-primary); border: 1px solid var(--border, rgba(128,128,128,.25)); border-radius: 8px; width: 30px; height: 30px; font-size: 14px; cursor: pointer; margin-left: auto; }
.nt-max-btn:hover { border-color: var(--brand); color: var(--brand-text); }
.nt-shot-btn { flex: none; display: inline-flex; align-items: center; justify-content: center; background: var(--bg-surface-2); color: var(--text-primary); border: 1px solid var(--border, rgba(128,128,128,.25)); border-radius: 8px; width: 30px; height: 30px; font-size: 14px; cursor: pointer; margin-left: auto; }
.nt-shot-btn:hover { border-color: var(--brand); color: var(--brand-text); }
/* Maximize-chart overlay — nt-chart.js's toggleMax() now puts this class on .trade-workspace
   (chart + open positions + the buy/sell panel together), not just the bare chart host, so a
   trade can still be opened/closed while maximized instead of the panel being left behind under
   the overlay. .trade-workspace already lays its children out correctly at every width (desktop:
   chart-pane + trade-panel side by side; phone: chart-pane stacked, trade-panel a slide-up sheet)
   — fullscreen just gives that same layout the whole viewport instead of the page's normal share
   of it, so nothing here needs to re-implement that layout, only neutralize the chart-canvas-wrap
   height formulas below (which were sized for the page's normal chrome, not a bare full screen)
   and make sure phone-only fixed UI (the quick-trade dock, bottom nav, trade-panel sheet) still
   renders above the z-index:2000 overlay instead of being hidden behind it. */
.nt-chart-max { position: fixed !important; inset: 0 !important; width: 100vw !important; height: 100vh !important; height: 100dvh !important; z-index: 2000 !important; background: var(--bg-surface, #0a0d13); }
body.nt-chart-max-open { overflow: hidden; }
.nt-chart-max .chart-pane { flex: 1 1 auto !important; min-height: 0 !important; display: flex !important; flex-direction: column !important; }
.nt-chart-max .chart-canvas-wrap { height: auto !important; flex: 1 1 auto !important; min-height: 0 !important; max-height: none !important; }
.nt-chart-max .nt-resize-handle { display: none !important; } /* resizing the chart box makes no sense once it already fills the screen */
/* Phone-only fixed chrome (quick-trade dock, bottom nav, the trade-panel/asset sheets' own
   backdrop) sits well below the overlay's z-index:2000 normally — bump it above while maximized
   so Buy/Sell, the Trade sheet and navigation all stay reachable instead of being covered. */
body.nt-chart-max-open .trade-dock,
body.nt-chart-max-open .bottom-nav,
body.nt-chart-max-open .sheet-backdrop,
body.nt-chart-max-open .trade-panel,
body.nt-chart-max-open .asset-sheet { z-index: 2001; }
.nt-ind-pop { position: absolute; z-index: 30; width: 270px; max-width: calc(100% - 12px); background: var(--bg-surface, #fff); color: var(--text-primary, #111); border: 1px solid var(--border, rgba(128,128,128,.3)); border-radius: 12px; box-shadow: 0 14px 40px rgba(0,0,0,.35); overflow: hidden; }
.nt-ind-head { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--border-subtle, rgba(128,128,128,.2)); }
.nt-ind-q { flex: 1; min-width: 0; background: var(--bg-surface-2); color: inherit; border: 1px solid var(--border-subtle, rgba(128,128,128,.25)); border-radius: 8px; padding: 5px 9px; font-size: 12.5px; }
.nt-ind-clr { background: transparent; border: 0; color: var(--brand); font-size: 12px; font-weight: 700; white-space: nowrap; }
.nt-ind-list { max-height: 330px; overflow-y: auto; padding: 4px 0 8px; }
.nt-ind-g { padding: 8px 12px 3px; font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary, #8a94a6); }
.nt-ind-row { display: flex; align-items: center; gap: 9px; padding: 6px 12px; font-size: 13px; cursor: pointer; margin: 0; }
.nt-ind-row:hover { background: var(--bg-surface-2); }
.nt-ind-row input { accent-color: var(--brand); width: 15px; height: 15px; }

/* More drawing tools popup (Fibonacci, rectangle, ellipse, channel, pitchfork, measure, text) */
.nt-more-row { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 12px; font-size: 13px; text-align: left; background: transparent; border: 0; color: inherit; cursor: pointer; }
.nt-more-row:hover { background: var(--bg-surface-2); }
.nt-more-row i { width: 16px; text-align: center; color: var(--text-secondary, #8a94a6); }

/* Right-click context menu — same look as the other chart popups above, but sized to its
   short row list instead of their fixed 270px list width. */
.nt-ctx-menu { width: auto; min-width: 200px; padding: 4px 0; }
.nt-ctx-menu .nt-more-row { white-space: nowrap; }
.nt-ctx-sep { border: 0; border-top: 1px solid var(--border-subtle, rgba(128,128,128,.2)); margin: 4px 0; }

/* "Table view" — plain OHLCV table of the candles currently on screen (right-click menu). */
.nt-table-ov { position: absolute; inset: 0; z-index: 40; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; padding: 16px; }
.nt-table-card { width: min(760px, 100%); max-height: 100%; background: var(--bg-surface, #fff); color: var(--text-primary, #111); border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.4); display: flex; flex-direction: column; overflow: hidden; }
.nt-table-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border-subtle, rgba(128,128,128,.2)); }
.nt-table-head b { font-size: 13.5px; font-weight: 700; }
.nt-table-close { background: transparent; border: 0; color: var(--text-secondary, #8a94a6); font-size: 15px; padding: 4px 6px; cursor: pointer; }
.nt-table-close:hover { color: var(--text-primary, #111); }
.nt-table-wrap { overflow: auto; max-height: min(70vh, 480px); }
.nt-table-wrap table { width: 100%; border-collapse: collapse; font-size: 12px; font-family: ui-monospace, Menlo, monospace; white-space: nowrap; }
.nt-table-wrap thead th { position: sticky; top: 0; background: var(--bg-surface-2); text-align: right; font-family: inherit; font-weight: 700; padding: 7px 10px; border-bottom: 1px solid var(--border-subtle, rgba(128,128,128,.2)); }
.nt-table-wrap thead th:first-child, .nt-table-wrap tbody td:first-child { text-align: left; }
.nt-table-wrap tbody td { text-align: right; padding: 5px 10px; border-bottom: 1px solid var(--border-subtle, rgba(128,128,128,.12)); }
.nt-table-wrap tbody tr:hover { background: var(--bg-surface-2); }
.nt-table-empty { text-align: center !important; padding: 20px !important; color: var(--text-secondary, #8a94a6); }

/* Price alerts popup */
.nt-alert-list { max-height: 220px; }
.nt-alert-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 12px; font-size: 13px; }
.nt-alert-row:hover { background: var(--bg-surface-2); }
.nt-alert-row button { background: transparent; border: 0; color: var(--text-secondary, #8a94a6); cursor: pointer; padding: 2px 4px; }
.nt-alert-row button:hover { color: var(--down-text, #e5484d); }
.nt-alert-empty { padding: 14px 12px; font-size: 12.5px; color: var(--text-secondary, #8a94a6); text-align: center; }

/* Compare-symbol popup */
.nt-compare-sel { flex: 1; min-width: 0; background: var(--bg-surface-2); color: inherit; border: 1px solid var(--border-subtle, rgba(128,128,128,.25)); border-radius: 8px; padding: 6px 9px; font-size: 12.5px; }

/* In-chart toast (price-alert notifications) */
.nt-chart-toast { position: absolute; left: 50%; bottom: 54px; transform: translate(-50%, 8px); z-index: 40; max-width: calc(100% - 24px); background: var(--bg-surface, #10131c); color: var(--text-primary, #fff); border: 1px solid var(--border, rgba(128,128,128,.3)); border-radius: 10px; padding: 8px 14px; font-size: 12.5px; font-weight: 600; box-shadow: 0 10px 28px rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.nt-chart-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Replay-mode bar */
.nt-replay-bar { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 35; display: flex; align-items: center; gap: 8px; background: var(--bg-surface, #10131c); border: 1px solid var(--border, rgba(128,128,128,.3)); border-radius: 999px; padding: 6px 12px; box-shadow: 0 10px 28px rgba(0,0,0,.35); max-width: calc(100% - 16px); }
.nt-replay-badge { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; color: var(--brand); padding: 2px 8px; border: 1px solid var(--brand); border-radius: 999px; white-space: nowrap; }
.nt-replay-bar button { background: transparent; border: 0; color: var(--text-primary, inherit); font-size: 15px; padding: 3px 5px; cursor: pointer; }
.nt-replay-bar button:hover { color: var(--brand); }
.nt-replay-speed { background: var(--bg-surface-2); color: inherit; border: 1px solid var(--border-subtle, rgba(128,128,128,.25)); border-radius: 6px; font-size: 11.5px; padding: 2px 4px; }
.nt-replay-slider { width: 120px; accent-color: var(--brand); }
@media (max-width: 480px) { .nt-replay-bar { gap: 5px; padding: 5px 8px; } .nt-replay-slider { width: 70px; } }
