/* ==========================================================================
   Finance House — trading terminal shell theme
   --------------------------------------------------------------------------
   Dark terminal palette kept in lockstep with the chart engine theme
   (_docs/chart-engine.md):
     page #131722 · panels #1E222D · borders #2A2E39 · accent #2962FF
     up #089981 · down #F23645 · text #D1D4DC · muted #787B86
     MA20 #F5C842 · EMA50 #4DB8FF

   Loaded AFTER css/style.css (shared base: resets, preloader, custom
   cursor). All overrides are terminal-scoped; landing pages are not
   affected by this file. No external URLs, no webfonts beyond
   css/fonts.css.

   Layout (desktop >= 1024px):
     #appShell (100vh, column)
       ├─ #termHeader          48px bar
       ├─ #termBody (row, min-height:0)
       │   ├─ #watchlist       260px
       │   ├─ #chartColumn     flex:1 → toolbar + #chartWrap(flex:1)
       │   └─ #orderPanel      300px
       └─ #bottomPanel         220px full-width tabs (Positions/History/
                               Deposit)
   Mobile (<= 820px): everything stacks in one column — watchlist strip,
   chart (50vh), order panel, tabs.
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. Base + palette
   -------------------------------------------------------------------------- */

:root {
  --tv-bg: #131722;
  --tv-panel: #1E222D;
  --tv-border: #2A2E39;
  --tv-accent: #2962FF;
  --tv-up: #089981;
  --tv-down: #F23645;
  --tv-text: #D1D4DC;
  --tv-muted: #787B86;
  --tv-ma: #F5C842;
  --tv-ema: #4DB8FF;
  --tv-hover: #232735;
}

html,
body {
  background: var(--tv-bg);
}

body {
  color: var(--tv-text);
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

/* The landing film-grain overlay (css/style.css body::after, z-index 9998)
   would sit on top of the terminal and disturb pixel-level QA checks —
   keep terminal surfaces clean. The landing keeps its grain. */
body::after {
  content: none;
}

/* --------------------------------------------------------------------------
   1. App shell
   -------------------------------------------------------------------------- */

#appShell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 480px;
  background: var(--tv-bg);
}

#appShell button:focus-visible,
#appShell a:focus-visible,
#appShell input:focus-visible {
  outline: 1px solid var(--tv-accent);
  outline-offset: 1px;
}

/* --------------------------------------------------------------------------
   2. Header
   -------------------------------------------------------------------------- */

#termHeader {
  flex: 0 0 auto;
  min-height: 48px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 6px 14px;
  background: var(--tv-panel);
  border-bottom: 1px solid var(--tv-border);
}

.th-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--tv-text);
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.th-brand svg { display: block; }

.th-back {
  color: var(--tv-muted);
  text-decoration: none;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  transition: color 0.15s, background-color 0.15s;
}
.th-back:hover { color: var(--tv-text); background: var(--tv-border); }

.th-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tv-muted);
  border: 1px solid var(--tv-border);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.th-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tv-accent);
}

.th-stats {
  display: flex;
  gap: 18px;
  margin-left: auto;
}
.th-stat { display: flex; flex-direction: column; align-items: flex-end; }
.th-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tv-muted);
}
.th-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.th-user { display: flex; align-items: center; gap: 10px; }
.th-username { font-weight: 500; white-space: nowrap; }
.th-logout {
  font: inherit;
  font-size: 12px;
  color: var(--tv-muted);
  background: transparent;
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  padding: 4px 10px;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.th-logout:hover { color: var(--tv-text); border-color: var(--tv-muted); }

/* --------------------------------------------------------------------------
   3. Body row + watchlist
   -------------------------------------------------------------------------- */

#termBody {
  flex: 1 1 auto;
  display: flex;
  min-height: 0; /* let the chart column shrink — height chain to canvas */
}

#watchlist {
  flex: 0 0 260px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--tv-panel);
  border-right: 1px solid var(--tv-border);
}

.wl-head {
  flex: 0 0 auto;
  padding: 10px 14px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tv-muted);
}

#wlList {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.wl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 9px 14px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--tv-border);
  color: var(--tv-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s;
}
.wl-row:hover { background: var(--tv-hover); }
.wl-row.active {
  background: var(--tv-hover);
  box-shadow: inset 2px 0 0 var(--tv-accent);
}

.wl-sym {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}
.wl-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.wl-price {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.wl-pct {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.wl-pct.up   { color: var(--tv-up); }
.wl-pct.down { color: var(--tv-down); }
.wl-pct.flat { color: var(--tv-muted); }

/* --------------------------------------------------------------------------
   4. Chart column + toolbar
   -------------------------------------------------------------------------- */

#chartColumn {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--tv-bg);
}

#chartToolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: var(--tv-panel);
  border-bottom: 1px solid var(--tv-border);
  overflow-x: auto;
  scrollbar-width: thin;
}

.tb-btn {
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--tv-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 10px;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}
.tb-btn:hover { color: var(--tv-text); background: var(--tv-border); }
.tb-btn.active { color: #FFFFFF; background: var(--tv-accent); }

.tb-sep {
  flex: 0 0 1px;
  width: 1px;
  height: 18px;
  margin: 0 6px;
  background: var(--tv-border);
}

.tb-info {
  margin-left: auto;
  font-size: 11px;
  color: var(--tv-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-left: 8px;
}

/* CRITICAL (chart-engine §6): the engine measures #tvChart exactly once
   at init and re-measures only on window 'resize' (no ResizeObserver).
   The flex chain below (100vh shell → #termBody min-height:0 →
   #chartColumn min-height:0 → #chartWrap flex:1 + min-height:0) gives the
   canvas its real, non-zero CSS size at DOMContentLoaded. */
#chartWrap {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  background: var(--tv-bg);
}

#tvChart {
  display: block;
  width: 100%;
  height: 100%;
}

/* --------------------------------------------------------------------------
   5. Order panel (skeleton — logic arrives with trading.js)
   -------------------------------------------------------------------------- */

#orderPanel {
  flex: 0 0 300px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  background: var(--tv-panel);
  border-left: 1px solid var(--tv-border);
}

.op-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tv-muted);
}

.op-symbol {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 20px;
  font-weight: 700;
  white-space: nowrap;
}

.op-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.op-label { color: var(--tv-muted); font-size: 13px; }
.op-value { font-weight: 500; font-variant-numeric: tabular-nums; }

.op-field { display: flex; flex-direction: column; gap: 6px; }

#orderQty {
  font: inherit;
  font-size: 15px;
  color: var(--tv-text);
  background: var(--tv-bg);
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  padding: 8px 10px;
  width: 100%;
}
#orderQty:focus {
  outline: none;
  border-color: var(--tv-accent);
}

.op-actions { display: flex; gap: 10px; margin-top: 6px; }
.op-actions button {
  flex: 1 1 0;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #FFFFFF;
  background: #10b981;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 12px 0;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
  transition: all 0.2s ease;
}
#btnBuy {
  background: linear-gradient(135deg, #0ecb81 0%, #2ebd85 100%);
  box-shadow: 0 4px 12px rgba(14, 203, 129, 0.25);
}
#btnSell {
  background: linear-gradient(135deg, #f6465d 0%, #cf304a 100%);
  box-shadow: 0 4px 12px rgba(246, 70, 93, 0.3);
}
.op-actions button:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}
.op-actions button:active {
  transform: translateY(0);
}

.op-note {
  font-size: 11px;
  color: var(--tv-muted);
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   6. Bottom panel — Positions / History / Deposit tabs
   -------------------------------------------------------------------------- */

#bottomPanel {
  flex: 0 0 160px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--tv-panel);
  border-top: 1px solid var(--tv-border);
}

.bp-tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 4px;
  padding: 0 8px;
  border-bottom: 1px solid var(--tv-border);
}

.bp-tab {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--tv-muted);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 9px 14px;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.bp-tab:hover { color: var(--tv-text); }
.bp-tab.active { color: var(--tv-text); border-bottom-color: var(--tv-accent); }

.bp-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 10px 14px;
}
.bp-panel[hidden] { display: none; }

.bp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.bp-table th {
  text-align: left;
  font-weight: 500;
  color: var(--tv-muted);
  padding: 6px 10px;
  border-bottom: 1px solid var(--tv-border);
  white-space: nowrap;
}
.bp-table td {
  padding: 6px 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bp-empty {
  padding: 34px 12px;
  text-align: center;
  color: var(--tv-muted);
  font-size: 13px;
}

/* Deposit skeleton */
.dep-row { display: flex; flex-direction: column; gap: 8px; max-width: 340px; }
#depositAmount {
  font: inherit;
  color: var(--tv-text);
  background: var(--tv-bg);
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  padding: 8px 10px;
  width: 100%;
}
#depositAmount:focus {
  outline: none;
  border-color: var(--tv-accent);
}
.dep-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #FFFFFF;
  background: var(--tv-accent);
  border: 0;
  border-radius: 4px;
  padding: 9px 18px;
  width: max-content;
  cursor: pointer;
  transition: filter 0.15s;
}
.dep-btn:hover { filter: brightness(1.12); }
.dep-note {
  font-size: 11px;
  color: var(--tv-muted);
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   7. QA report (only exists in the DOM with ?qareport=1)
   -------------------------------------------------------------------------- */

#qaReport {
  max-width: 100%;
  overflow-x: auto; /* long JSON lines scroll inside, never widen the page */
  margin: 0;
  padding: 10px 12px;
  background: var(--tv-panel);
  color: var(--tv-muted);
  font-size: 11px;
  line-height: 1.4;
  white-space: pre;
  border-top: 1px solid var(--tv-border);
}

/* --------------------------------------------------------------------------
   8. Responsive — single column below 820px (matches the mobile flag in
      the QA report: matchMedia('(max-width: 820px)'))
   -------------------------------------------------------------------------- */

@media (max-width: 820px) {
  #appShell { height: auto; min-height: 100vh; }

  #termHeader { padding: 8px 10px; }
  /* The brand already links home — the explicit "Back to site" link is
     redundant on a 390px bar and would force a third header row. */
  .th-back { display: none; }
  .th-stats { gap: 12px; }
  .th-username {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #termBody { flex-direction: column; }

  /* Watchlist → compact horizontal strip above the chart */
  #watchlist {
    flex: none;
    border-right: 0;
    border-bottom: 1px solid var(--tv-border);
  }
  .wl-head { display: none; }
  #wlList {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .wl-row {
    flex: 0 0 auto;
    width: auto;
    min-width: 116px;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    border-bottom: 0;
    border-right: 1px solid var(--tv-border);
    padding: 8px 12px;
  }
  .wl-row.active { box-shadow: inset 0 2px 0 var(--tv-accent); }
  .wl-right {
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
  }

  /* Chart keeps a meaningful height; single-finger pan is native to the
     chart engine. */
  #chartColumn { flex: none; }
  #chartWrap { flex: none; height: 50vh; min-height: 260px; }

  /* Order panel stacks below the chart, compact so Buy/Sell stay above
     the fold on a 390x844 viewport. */
  #orderPanel {
    flex: none;
    border-left: 0;
    border-top: 1px solid var(--tv-border);
    padding: 12px;
    gap: 10px;
  }
  .op-symbol { font-size: 16px; }
  .op-note { display: none; }

  #bottomPanel { flex: none; }
  .bp-panel { max-height: 300px; }
}

/* --------------------------------------------------------------------------
   9. Reduced motion — the chart engine suppresses its own blink/breath
      effects; this covers the shell chrome only.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  #appShell,
  #appShell *,
  #qaReport {
    transition: none !important;
    animation: none !important;
  }
}

/* ------------------------------------------------------------------ */
/* Scrollbars — thin and dark, consistent with the terminal theme.     */
/* Covers the page scrollbar (visible in the stacked mobile layout)    */
/* and every internal scroller (watchlist strip, toolbar, panels).     */
/* ------------------------------------------------------------------ */
html,
body,
#appShell,
#appShell *,
#qaReport {
  scrollbar-width: thin;
  scrollbar-color: var(--tv-border) var(--tv-bg);
}

/* ------------------------------------------------------------------ */
/* QA report overlay. The <pre id="qaReport"> node only exists when    */
/* the ?qareport=1 flag creates it, so this rule is inert for normal   */
/* visitors. Fixed to the viewport bottom so headless screenshots can  */
/* capture the JSON even though the app shell fills 100vh; fixed       */
/* positioning keeps it out of flow, so it never influences layout     */
/* metrics (canvas size, scrollWidth) that the report itself measures. */
/* ------------------------------------------------------------------ */
#qaReport {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  max-height: 46vh;
  margin: 0;
  padding: 8px 12px;
  overflow: auto;
  background: rgba(19, 23, 34, 0.96);
  border-top: 1px solid var(--tv-border);
  color: var(--tv-text);
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  line-height: 1.3;
  white-space: pre;
}

/* --------------------------------------------------------------------------
   10. Paper-trading UI (js/trading.js) — order panel live rows, symbol
       <select>, inline messages, pending state, positions/history rows,
       deposit presets. Palette locked to the terminal tokens.
   -------------------------------------------------------------------------- */

/* Order symbol is a <select> since trading.js landed — keep the big bold
   look of the old text block, add a dropdown affordance (pure glyph caret,
   no image assets). */
.op-symbol-wrap { position: relative; }
.op-symbol {
  display: block;
  width: 100%;
  font: inherit;
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--tv-text);
  background: var(--tv-bg);
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  padding: 7px 26px 7px 10px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.op-symbol:focus { outline: none; border-color: var(--tv-accent); }
.op-symbol:disabled { opacity: 0.6; cursor: not-allowed; }
.op-symbol option { background: var(--tv-panel); color: var(--tv-text); }
.op-symbol-wrap::after {
  content: '\25BE';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--tv-muted);
  font-size: 12px;
  pointer-events: none;
}

/* Live rows (market price / est. value / free funds). */
.op-em { font-weight: 600; color: var(--tv-text); }

/* Inline message strip under the Buy/Sell buttons.
   Variants: .is-error (red), .is-ok (green), .is-info (muted). */
.op-error {
  font-size: 12px;
  line-height: 1.5;
  border-radius: 4px;
  padding: 8px 10px;
  margin: 0;
}
.op-error[hidden] { display: none; }
.op-error.is-error { color: var(--tv-down); background: rgba(242, 54, 69, 0.08); }
.op-error.is-ok { color: var(--tv-up); background: rgba(8, 153, 129, 0.08); }
.op-error.is-info { color: var(--tv-muted); background: rgba(120, 123, 134, 0.08); }

/* Pending order state — the acting button shows "Awaiting market price…"
   and pulses while the fill waits for the next tick. */
#orderPanel.is-pending .op-actions button { cursor: wait; }
#orderPanel.is-pending .op-actions button:disabled {
  animation: fh-pulse 1.2s ease-in-out infinite;
}
@keyframes fh-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* Positions rows: side badge, live P&L, Close button (7th column). */
.pos-row:hover { background: rgba(41, 98, 255, 0.04); }
.pos-sym { font-weight: 600; color: var(--tv-text); white-space: nowrap; }
.side-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 3px;
  padding: 2px 7px;
  white-space: nowrap;
}
.side-long { color: var(--tv-up); background: rgba(8, 153, 129, 0.12); }
.side-short { color: var(--tv-down); background: rgba(242, 54, 69, 0.12); }

/* Signed P&L / price coloring inside the bottom tables (JS toggles
   .pos / .neg on the cell itself). */
.bp-table .pos { color: var(--tv-up); }
.bp-table .neg { color: var(--tv-down); }
.bp-table td.pos-pnl,
.bp-table td.hist-pnl { font-weight: 600; }

.pos-close {
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--tv-text);
  background: transparent;
  border: 1px solid var(--tv-border);
  border-radius: 3px;
  padding: 4px 10px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.pos-close:hover { border-color: var(--tv-accent); color: var(--tv-accent); }
.pos-close:disabled { opacity: 0.5; cursor: wait; }
.pos-actions { text-align: right; }

/* History rows: bonus lines carry a subtle accent tint. */
.hist-bonus { color: var(--tv-accent); font-weight: 600; }

/* Deposit presets + inline messages. */
.dep-presets { display: flex; gap: 8px; flex-wrap: wrap; }
.dep-preset {
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--tv-muted);
  background: transparent;
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.dep-preset:hover { color: var(--tv-text); border-color: var(--tv-muted); }
.dep-preset.active { color: var(--tv-accent); border-color: var(--tv-accent); }
.dep-msg {
  font-size: 12px;
  line-height: 1.5;
  color: var(--tv-up);
  border-radius: 4px;
  padding: 8px 10px;
  background: rgba(8, 153, 129, 0.08);
}
.dep-msg[hidden] { display: none; }
.dep-msg.dep-msg-error {
  color: var(--tv-down);
  background: rgba(242, 54, 69, 0.08);
}

/* Pending pulse is suppressed for reduced-motion users (the generic
   section 9 block already covers #appShell *; this makes the intent
   explicit for the trading chrome). */
@media (prefers-reduced-motion: reduce) {
  #orderPanel.is-pending .op-actions button:disabled { animation: none; }
}

/* Floating Draggable AI Analysis Panel Card — v8 styles live in terminal.html
   (.ai-float + .ai-panel-header etc.). Kept here as anchor only. */

/* ===================== v9: binary deals engine UI ===================== */

/* Stake field ($ prefix, transparent input) */
.op-field .op-stake-wrap { display: flex; align-items: center; gap: 8px; background: #131722; border: 1px solid #2a2e39; border-radius: 9px; padding: 9px 12px; }
.op-field .op-stake-wrap:focus-within { border-color: rgba(240,185,11,.55); }
.op-stake-cur { color: #f0b90b; font-weight: 800; font-size: 15px; }
.op-field .op-stake-wrap input { border: none; background: transparent; color: #fff; font-size: 16px; font-weight: 700; width: 100%; min-width: 0; outline: none; padding: 0; box-shadow: none; }
.op-field .op-stake-wrap input::-webkit-outer-spin-button,
.op-field .op-stake-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.op-field .op-stake-wrap input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* Amber Binance-style expiry pills */
#orderDurations .op-dur-btn { background: #131722; border: 1px solid #2a2e39; color: #d1d5db; border-radius: 8px; padding: 7px 10px; font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit; height: 34px; transition: border-color .12s, color .12s, background .12s; }
#orderDurations .op-dur-btn:hover { border-color: rgba(240,185,11,.6); color: #f0b90b; }
#orderDurations .op-dur-btn.active { background: linear-gradient(135deg, #f0b90b, #f8d33a); color: #17181c; border: 2px solid #ffffff; box-shadow: 0 0 16px rgba(240,185,11,.45); height: 40px; transform: scale(1.08); animation: dur-pop .18s ease-out; }
@keyframes dur-pop { 0% { transform: scale(.92); } 60% { transform: scale(1.14); } 100% { transform: scale(1.08); } }
.op-dur-badge { display: inline-flex; align-items: center; margin-left: 6px; padding: 1px 8px; border-radius: 7px; background: linear-gradient(135deg, #f0b90b, #f8d33a); color: #17181c; font-size: 11px; font-weight: 800; }

/* TRADING IN PROGRESS bar */
.trading-status { display: flex; align-items: center; gap: 10px; width: fit-content; padding: 8px 16px; border-radius: 10px; background: rgba(16,185,129,.07); border: 1px solid rgba(16,185,129,.35); margin-bottom: 10px; }
.trading-status[hidden] { display: none !important; }
.ts-pulse { width: 9px; height: 9px; border-radius: 50%; background: #10b981; animation: ts-pulse 1.2s infinite; flex: 0 0 auto; }
@keyframes ts-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,.55); } 50% { box-shadow: 0 0 0 6px rgba(16,185,129,0); } }
.ts-text { color: #34d399; font-size: 12.5px; font-weight: 800; letter-spacing: .5px; white-space: nowrap; }

/* Open-deals tab badge */
.tab-badge { display: inline-flex; align-items: center; justify-content: center; margin-left: 7px; min-width: 19px; height: 19px; border-radius: 10px; background: linear-gradient(135deg, #f0b90b, #f8d33a); color: #17181c; font-size: 11px; font-weight: 800; padding: 0 6px; vertical-align: middle; }
.tab-badge[hidden] { display: none !important; }

/* Countdown timer + progress bar in the deals table */
.pos-timer { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; color: #e5e7eb; white-space: nowrap; }
.pos-progress { position: relative; width: 110px; height: 8px; border-radius: 5px; background: #232733; overflow: hidden; }
.pos-progress > i { position: absolute; top: 0; left: 0; bottom: 0; border-radius: 5px; transition: width 1s linear; }
.pos-progress.pri-green > i { background: linear-gradient(90deg, #059669, #10b981); }
.pos-progress.pri-amber > i { background: linear-gradient(90deg, #d99e0b, #f0b90b); }
.pos-progress.pri-red > i { background: linear-gradient(90deg, #dc2626, #ef4444); }

/* Bottom-panel result flash (3.5 s) */
#bottomPanel.flash-win { animation: flash-win 3.5s ease-out; }
#bottomPanel.flash-loss { animation: flash-loss 3.5s ease-out; }
@keyframes flash-win { 0%, 22% { box-shadow: 0 0 0 2px #10b981, 0 0 44px rgba(16,185,129,.55); } 100% { box-shadow: none; } }
@keyframes flash-loss { 0%, 22% { box-shadow: 0 0 0 2px #ef4444, 0 0 44px rgba(239,68,68,.55); } 100% { box-shadow: none; } }

/* Deal result window (glowing frame) */
.deal-result-dialog { width: min(430px, 94vw) !important; display: flex; flex-direction: column; align-items: center; gap: 13px; padding: 30px 26px 24px; text-align: center; animation: dr-pop .28s ease-out; }
.deal-result-dialog.win { border: 1px solid rgba(16,185,129,.65); box-shadow: 0 0 40px rgba(16,185,129,.35), inset 0 0 26px rgba(16,185,129,.07); }
.deal-result-dialog.loss { border: 1px solid rgba(239,68,68,.65); box-shadow: 0 0 40px rgba(239,68,68,.32), inset 0 0 26px rgba(239,68,68,.06); }
.deal-result-dialog.tie { border: 1px solid rgba(240,185,11,.6); box-shadow: 0 0 40px rgba(240,185,11,.3); }
@keyframes dr-pop { 0% { transform: scale(.9); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.dr-amount { font-size: 46px; font-weight: 800; line-height: 1.05; letter-spacing: -1px; }
.win .dr-amount { color: #10b981; text-shadow: 0 0 26px rgba(16,185,129,.5); }
.loss .dr-amount { color: #ef4444; text-shadow: 0 0 26px rgba(239,68,68,.45); }
.tie .dr-amount { color: #f0b90b; font-size: 36px; }
.dr-label { color: #9ca3af; font-size: 13px; font-weight: 600; letter-spacing: .4px; }
.dr-balance { color: #e5e7eb; font-size: 14.5px; font-weight: 700; }
.dr-strategic { width: 100%; background: linear-gradient(135deg, rgba(240,185,11,.13), rgba(240,185,11,.04)); border: 1px solid rgba(240,185,11,.42); border-radius: 12px; padding: 14px 16px; }
.dr-s-title { color: #f0b90b; font-weight: 800; font-size: 13px; margin-bottom: 10px; letter-spacing: .3px; }
.dr-s-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.dr-s-cell { display: flex; flex-direction: column; gap: 3px; align-items: center; }
.dr-s-cell span { color: #9ca3af; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.dr-s-cell b { color: #fff; font-size: 14.5px; font-weight: 700; }

/* Deposit window polish (v9) */
.dep-head { display: flex; align-items: center; gap: 14px; padding: 4px 2px 2px; }
.dep-coin { width: 52px; height: 52px; flex: 0 0 auto; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 800; color: #17181c; background: linear-gradient(135deg, #f7931a, #f0b90b); box-shadow: 0 6px 18px rgba(240,185,11,.35); }
.dep-head-txt b { display: block; color: #fff; font-size: 16px; font-weight: 800; }
.dep-head-txt span { display: block; color: #9ca3af; font-size: 12px; margin-top: 2px; }
.dep-security { display: flex; align-items: center; gap: 8px; color: #6b7280; font-size: 12px; padding: 2px 4px; }
#depositModal .acc-modal-dialog { border-top: 3px solid #f0b90b; }

/* Buy/Sell colors: defined at #btnBuy/#btnSell (Binance green/red) */


/* ==== v10: order panel + tables polish ==== */
.op-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.op-head-title { font-size: 13px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; color: #e7ecf3; }
.op-live { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 800; letter-spacing: .8px; color: #2ebd85; background: rgba(46,189,133,.1); border: 1px solid rgba(46,189,133,.35); padding: 3px 8px; border-radius: 999px; }
.op-live i { width: 6px; height: 6px; border-radius: 50%; background: #2ebd85; animation: oplive 1.6s infinite; }
@keyframes oplive { 0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(46,189,133,.5); } 50% { opacity: .6; box-shadow: 0 0 0 4px rgba(46,189,133,0); } }

.op-actions button { height: 46px; font-size: 14px; border-radius: 10px; }
.op-btn-arrow { font-size: 11px; margin-right: 6px; vertical-align: 1px; }
.op-payout-chip { display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .5px; color: #17181c; background: linear-gradient(135deg, #f0b90b, #f8d33a); border-radius: 999px; padding: 2px 8px; margin-right: 8px; }
.op-value-wrap { display: inline-flex; align-items: center; }

/* lower tabs polish */
.bp-tab { position: relative; }
.bp-tab.active { font-weight: 700; }
.bp-tab.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, #f0b90b, #f8d33a); }

/* tables polish */
#bottomPanel thead th { font-size: 10.5px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: #7a8699 !important; border-bottom: 1px solid #2a3245 !important; padding: 8px 12px; white-space: nowrap; }
#bottomPanel tbody td { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,.035); }
#bottomPanel tbody tr:hover td { background: rgba(240,185,11,.03); }
.side-badge { border-radius: 999px !important; padding: 3px 9px !important; font-size: 10px !important; font-weight: 800 !important; letter-spacing: .06em !important; }
.side-long { color: #2ebd85 !important; background: rgba(46,189,133,.14) !important; border: 1px solid rgba(46,189,133,.3); }
.side-short { color: #f6465d !important; background: rgba(246,70,93,.12) !important; border: 1px solid rgba(246,70,93,.3); }
.pos-pnl { color: #2ebd85; font-weight: 700; }


/* ==== v10.1: bottom panel drag-resize + collapse + live highlights ==== */
#bottomPanel { position: relative; flex: 0 0 210px; }
.bp-resize { position: absolute; top: -4px; left: 0; right: 0; height: 9px; cursor: row-resize; z-index: 6; display: flex; align-items: center; justify-content: center; }
.bp-resize span { width: 46px; height: 4px; border-radius: 3px; background: #2a3245; transition: background .15s, width .15s; }
.bp-resize:hover span, .bp-resize.active span { background: linear-gradient(90deg, #f0b90b, #f8d33a); width: 76px; }
.bp-tabs { align-items: center; }
.bp-tabs-right { margin-left: auto; display: flex; gap: 6px; padding-right: 8px; }
.bp-icon-btn { background: #131a29; border: 1px solid #2a3245; color: #8fa0b8; width: 26px; height: 26px; border-radius: 7px; cursor: pointer; font-size: 13px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; transition: all .15s; font-family: inherit; }
.bp-icon-btn:hover { color: #f0b90b; border-color: rgba(240,185,11,.5); background: rgba(240,185,11,.08); }
#bottomPanel.collapsed { flex: 0 0 44px !important; height: 44px !important; overflow: hidden; }
#bottomPanel.collapsed .bp-panel, #bottomPanel.collapsed .trading-status { display: none !important; }
#bottomPanel.collapsed .bp-tabs { border-bottom: none; }
.mark-flash { animation: markflash .7s ease-out; }
@keyframes markflash { 0% { color: #f0b90b; text-shadow: 0 0 10px rgba(240,185,11,.7); } 100% { color: inherit; text-shadow: none; } }
.row-new td { animation: rownew 2s ease-out; }
@keyframes rownew { 0% { background: rgba(240,185,11,.16); } 100% { background: transparent; } }
@media (max-width: 820px) { .bp-resize { display: none; } }

/* ==== v11.4 DESIGN POLISH (terminal) ==== */
.chart-column, #orderPanel, #watchlistPanel, #bottomPanel, .ot-card, .trade-head {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
#orderPanel, #watchlistPanel, #bottomPanel, .ot-card {
  border-color: #262b33;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.028), 0 12px 32px rgba(0,0,0,.35);
}
#btnBuy, #btnSell { border-radius: 8px; letter-spacing: .01em; }
#btnBuy { box-shadow: inset 0 -2px 0 rgba(0,0,0,.22), 0 1px 2px rgba(0,0,0,.3); }
#btnSell { box-shadow: inset 0 -2px 0 rgba(0,0,0,.22), 0 1px 2px rgba(0,0,0,.3); }
#btnBuy:active, #btnSell:active { transform: translateY(1px) scale(.99); }
.ot-input:focus { outline: none; border-color: rgba(240,185,11,.6); box-shadow: 0 0 0 3px rgba(240,185,11,.13); }
#watchlistPanel .wl-row:hover { background: rgba(255,255,255,.03); }
.deals-table td, .deals-table th { font-variant-numeric: tabular-nums; }
mark-flash { animation-duration: .5s; }
