/* ============================================================
   NexTrade Platform — app.css
   Production stylesheet: variables, theme, layout, components
   ============================================================ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
button { cursor: pointer; border: none; outline: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; outline: none; }
a { text-decoration: none; color: inherit; }

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* ====================================================================
   THEME VARIABLES — LIGHT (default)
   ==================================================================== */
:root,
[data-theme="light"] {
  --bg:        #ffffff;
  --bg2:       #f4f5f9;
  --bg3:       #eceef5;
  --bg4:       #e2e5f0;
  --border:    #e0e3ef;
  --border2:   #ccd0e0;
  --text:      #111827;
  --sub:       #4b5473;
  --muted:     #7c84a3;
  --green:     #0da672;
  --red:       #dc3545;
  --blue:      #2563eb;
  --amber:     #d97706;
  --sell:      #dc3545;
  --buy:       #0da672;
  --shadow:    rgba(0,0,0,.08);
  --tv-theme:  light;
  --hdr-bg:    #ffffff;
  --wl-active: #eef2ff;
}

/* ====================================================================
   THEME VARIABLES — DARK
   ==================================================================== */
[data-theme="dark"] {
  --bg:        #1a2744;
  --bg2:       #1f3058;
  --bg3:       #253868;
  --bg4:       #2d4278;
  --border:    rgba(99,144,220,.25);
  --border2:   rgba(99,144,220,.40);
  --text:      #eef2ff;
  --sub:       #a0b8e0;
  --muted:     #6480aa;
  --green:     #00c896;
  --red:       #ff4b5c;
  --blue:      #5b8fe8;
  --amber:     #f59e0b;
  --sell:      #ff4b5c;
  --buy:       #00c896;
  --shadow:    rgba(0,10,30,.45);
  --tv-theme:  dark;
  --hdr-bg:    #152038;
  --wl-active: rgba(91,143,232,.22);
}

/* ── Font ── */
body {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  transition: background .2s, color .2s;
}

/* ====================================================================
   LAYOUT — Trading Room (flex full-height)
   ==================================================================== */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Header ── */
#hdr {
  height: 44px;
  background: var(--hdr-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  flex-shrink: 0;
  z-index: 200;
  box-shadow: 0 1px 0 var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  text-decoration: none;
}
.logo svg { width: 20px; height: 20px; }
.logo-dot { color: var(--green); }

.hdr-sep { width: 1px; height: 20px; background: var(--border); flex-shrink: 0; }
.hdr-badge {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--sub);
  padding: 2px 8px;
  background: var(--bg3);
  border-radius: 4px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.hdr-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* Header icon buttons */
.hdr-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sub);
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, color .15s;
  border: 1px solid transparent;
  position: relative;
}
.hdr-icon-btn:hover { background: var(--bg3); color: var(--text); border-color: var(--border); }
.hdr-icon-btn i { font-size: 13px; }

/* Theme toggle */
.theme-toggle { }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* Deposit button */
.deposit-btn {
  background: var(--text);
  color: var(--bg);
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .3px;
  cursor: pointer;
  transition: opacity .15s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}
.deposit-btn:hover { opacity: .85; }

/* Balance display */
.hdr-balance {
  font-size: 12px;
  font-weight: 600;
  color: var(--sub);
  white-space: nowrap;
  padding: 5px 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.hdr-balance span { color: var(--green); font-family: 'JetBrains Mono', monospace; }

/* Avatar */
.hdr-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  border: 2px solid var(--border);
}

/* Mobile buttons */
.mob-toggle { display: none; }

/* ── Ticker bar ── */
#ticker {
  height: 30px;
  background: var(--hdr-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  overflow: hidden;
  flex-shrink: 0;
}
.ticker-track {
  display: flex;
  animation: tickScroll 90s linear infinite;
  white-space: nowrap;
}
.ticker-track:hover,
#ticker:hover .ticker-track { animation-play-state: paused; }
.tick-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 14px;
  height: 30px;
  border-right: 1px solid var(--border);
  cursor: pointer;
  font-size: 11px;
  flex-shrink: 0;
  overflow: hidden;
  box-sizing: border-box;
  position: relative;
  white-space: nowrap;
}
.tick-item:hover { background: var(--bg2); }
.tick-sym { font-weight: 600; color: var(--text); }
.tick-chg { font-weight: 600; font-size: 10px; }
.up  { color: var(--green); }
.dn  { color: var(--red);   }
@keyframes tickScroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ── Main 3-column ── */
#main {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* ====================================================================
   LEFT: WATCHLIST
   ==================================================================== */
#watchlist {
  width: 190px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--hdr-bg);
  flex-shrink: 0;
  transition: transform .25s ease;
}
.wl-header {
  padding: 8px 10px 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.wl-title { font-weight: 600; font-size: 12.5px; }
.wl-close-mob { display: none; cursor: pointer; color: var(--muted); }

.wl-search {
  margin: 6px 8px;
  position: relative;
  flex-shrink: 0;
}
.wl-search i {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 11px;
  pointer-events: none;
}
.wl-search input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 8px 5px 26px;
  border-radius: 5px;
  font-size: 11px;
}
.wl-search input::placeholder { color: var(--muted); }

.wl-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
}
.wl-tabs::-webkit-scrollbar { height: 0; }
.wl-tab {
  padding: 5px 7px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  flex-shrink: 0;
  transition: color .15s;
}
.wl-tab.active { color: var(--text); border-bottom-color: var(--sell); font-weight: 600; }
.wl-tab:hover:not(.active) { color: var(--text); }

.wl-col-hdr {
  display: grid;
  grid-template-columns: 1fr 44px 44px 40px;
  padding: 4px 6px 3px 22px;
  font-size: 9.5px;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}
.wl-col-hdr span:not(:first-child) { text-align: right; }

.wl-list { overflow-y: auto; flex: 1; position: relative; }

.wl-row {
  display: grid;
  grid-template-columns: 1fr 44px 44px 40px;
  padding: 5px 6px 5px 4px;
  align-items: center;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.wl-row:hover  { background: var(--bg2); }
.wl-row.active { background: var(--wl-active); }

.wl-sym-wrap { display: flex; align-items: center; gap: 3px; min-width: 0; }
.wl-star {
  font-size: 11px;
  color: #fbbf24;
  flex-shrink: 0;
  line-height: 1;
  cursor: pointer;
  width: 14px;
}
.wl-star-off { color: var(--border2); }
.wl-sym-info { min-width: 0; }
.wl-sym {
  font-weight: 600;
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wl-name {
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wl-cat-icon { font-size: 10px; margin-right: 1px; flex-shrink: 0; }
.wl-price {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  text-align: right;
  font-weight: 500;
}
.wl-chg { font-size: 9.5px; text-align: right; font-weight: 600; }

/* ====================================================================
   CENTER: CHART + POSITIONS
   ==================================================================== */
#center { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

/* Chart header */
#chart-hdr {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  background: var(--hdr-bg);
  flex-wrap: wrap;
  min-height: 46px;
}
.ch-star { color: #fbbf24; font-size: 13px; cursor: pointer; }
.ch-sym-wrap { display: flex; flex-direction: column; }
.ch-sym { font-weight: 700; font-size: 14px; color: var(--text); }
.ch-name { font-size: 9.5px; color: var(--muted); }
.ch-price {
  font-family: 'JetBrains Mono', monospace;
  font-size: 17px;
  font-weight: 700;
  color: var(--green);
  transition: color .25s;
}
.ch-price.dn { color: var(--red); }
.ch-chg { font-size: 10.5px; font-weight: 600; }
.ch-stat { display: flex; flex-direction: column; gap: 0; }
.ch-stat-l { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.ch-stat-v { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--text); font-weight: 500; }
.ch-expand {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: .15s;
  flex-shrink: 0;
}
.ch-expand:hover { background: var(--bg2); color: var(--text); }

/* Chart tabs + timeframes */
#chart-tabs {
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
  background: var(--hdr-bg);
  height: 34px;
}
.ct-tab {
  padding: 0 12px;
  height: 34px;
  display: flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: .15s;
}
.ct-tab.active { color: var(--text); border-bottom-color: var(--sell); font-weight: 600; }
.ct-sep { width: 1px; height: 14px; background: var(--border); margin: 0 4px; }
.tf-btn {
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: .15s;
}
.tf-btn:hover, .tf-btn.active { background: var(--bg3); color: var(--text); }
.chart-tool {
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 3px;
  transition: .15s;
}
.chart-tool:hover { background: var(--bg3); color: var(--text); }

/* TradingView */
#tv-wrap { flex: 1; min-height: 0; position: relative; background: var(--bg); }
#tv-wrap .tradingview-widget-container,
#tv-wrap #tv_chart { width: 100% !important; height: 100% !important; }

/* Resize handle */
.resize-h {
  height: 4px;
  background: transparent;
  cursor: row-resize;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  transition: background .15s;
}
.resize-h:hover { background: var(--bg3); }

/* Positions panel */
#positions {
  height: 200px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  background: var(--bg);
}
.pos-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  align-items: center;
  padding: 0 10px;
  overflow-x: auto;
  background: var(--hdr-bg);
}
.pos-tabs::-webkit-scrollbar { height: 0; }
.pos-tab {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: .15s;
}
.pos-tab.active { color: var(--text); border-bottom-color: var(--sell); font-weight: 600; }
.pos-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.hide-others { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.close-all-btn {
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
.close-all-btn:hover { background: var(--sell); color: #fff; border-color: var(--sell); }

.pos-tbl-wrap { overflow: auto; flex: 1; }
.pos-tbl { width: 100%; border-collapse: collapse; font-size: 11px; }
.pos-tbl thead th {
  padding: 5px 8px;
  text-align: left;
  font-weight: 500;
  font-size: 10px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--bg2);
  position: sticky;
  top: 0;
  z-index: 1;
  cursor: pointer;
  user-select: none;
}
.pos-tbl thead th:hover { color: var(--text); }
.pos-tbl tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
.pos-tbl tbody tr:hover { background: var(--bg2); }
.pos-tbl td { padding: 5px 8px; white-space: nowrap; vertical-align: middle; }

.side-badge {
  width: 14px; height: 14px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 800;
  color: #fff;
  margin-right: 4px;
  flex-shrink: 0;
}
.side-s { background: var(--sell); }
.side-b { background: var(--buy); }
.pnl-pos { color: var(--green); font-weight: 600; }
.pnl-neg { color: var(--red);   font-weight: 600; }
.tpsl-cell { display: flex; align-items: center; gap: 4px; }
.tpsl-edit { color: var(--muted); cursor: pointer; transition: color .15s; }
.tpsl-edit:hover { color: var(--blue); }
.pos-btn {
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: .15s;
}
.pos-btn:hover { background: var(--bg4); }
.pos-btn-close:hover { background: var(--sell); color: #fff; border-color: var(--sell); }
.empty-pos { padding: 28px; text-align: center; color: var(--muted); font-size: 12px; }
.mono { font-family: 'JetBrains Mono', monospace; }

/* ====================================================================
   RIGHT: ORDER PANEL
   ==================================================================== */
#order-panel {
  width: 200px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--hdr-bg);
  flex-shrink: 0;
  overflow-y: auto;
  transition: transform .25s ease;
}
.op-mob-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}
.op-mob-title { font-size: 12px; font-weight: 600; }
.op-close-btn { cursor: pointer; color: var(--muted); font-size: 14px; }
.op-close-btn:hover { color: var(--text); }

/* Sell/Buy buttons */
.sb-row { display: flex; flex-shrink: 0; }
.sb-btn {
  flex: 1;
  padding: 10px 6px;
  text-align: center;
  cursor: pointer;
  transition: opacity .15s;
  border: none;
}
.sb-btn.sell-btn { background: var(--sell); color: #fff; }
.sb-btn.buy-btn  { background: var(--buy);  color: #fff; }
.sb-btn:hover { opacity: .88; }
.sb-label { font-size: 9.5px; font-weight: 600; letter-spacing: .5px; opacity: .85; display: block; }
.sb-price { font-family: 'JetBrains Mono', monospace; font-size: 16px; font-weight: 700; letter-spacing: -.5px; display: block; }

/* Spread bar */
.spread-bar { height: 3px; background: linear-gradient(90deg, var(--sell) 50%, var(--buy) 50%); flex-shrink: 0; }

/* Order type tabs */
.ot-tabs { display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0; background: var(--bg2); }
.ot-tab {
  flex: 1;
  padding: 6px 3px;
  text-align: center;
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: .15s;
}
.ot-tab.active { background: var(--bg); color: var(--text); font-weight: 600; border-bottom-color: var(--sell); }

/* Order form */
.order-form { padding: 9px 9px 6px; flex-shrink: 0; }
.of-field { margin-bottom: 8px; }
.of-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--sub);
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.of-inp-row {
  display: flex;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
  transition: border-color .2s;
}
.of-inp-row:focus-within { border-color: var(--blue); background: var(--bg); }
.of-inp {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 6px 8px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  min-width: 0;
}
.of-stepper { display: flex; flex-direction: column; border-left: 1px solid var(--border); }
.of-step {
  width: 22px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--sub);
  cursor: pointer;
  transition: .15s;
  user-select: none;
}
.of-step:hover { background: var(--bg3); color: var(--text); }
.of-step:first-child { border-bottom: 1px solid var(--border); }

/* Volume slider */
.vol-slider-wrap { margin-top: 6px; }
.vol-slider {
  width: 100%;
  -webkit-appearance: none;
  height: 3px;
  background: var(--border2);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--sell);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 1px 4px var(--shadow);
}
.vol-hint { display: flex; justify-content: space-between; font-size: 9.5px; color: var(--muted); margin-top: 3px; }

/* TP/SL */
.tpsl-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.tpsl-chk { width: 13px; height: 13px; accent-color: var(--sell); cursor: pointer; }
.tpsl-label { font-size: 11px; font-weight: 500; color: var(--text); cursor: pointer; }
.tpsl-fields { margin-bottom: 8px; }

/* Execute buttons */
.exec-btn {
  width: 100%;
  padding: 10px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  transition: .15s;
  letter-spacing: .3px;
  border: none;
}
.exec-sell { background: var(--sell); color: #fff; }
.exec-sell:hover { filter: brightness(.9); }
.exec-buy  { background: var(--buy);  color: #fff; margin-top: 6px; }
.exec-buy:hover  { filter: brightness(.9); }
.exec-btn:disabled { opacity: .4; cursor: not-allowed; filter: none !important; }
.order-err { color: var(--red); font-size: 10.5px; min-height: 14px; margin-top: 4px; text-align: center; }

/* Margin info */
.margin-section { padding: 7px 9px; border-top: 1px solid var(--border); flex-shrink: 0; }
.marg-row { display: flex; justify-content: space-between; align-items: center; padding: 2px 0; font-size: 10.5px; }
.marg-lbl { color: var(--muted); }
.marg-val { font-family: 'JetBrains Mono', monospace; font-weight: 500; font-size: 10.5px; }

/* Assets */
.assets-section { padding: 7px 9px; border-top: 1px solid var(--border); flex-shrink: 0; }
.assets-title { font-size: 11px; font-weight: 700; margin-bottom: 5px; }
.asset-row { display: flex; justify-content: space-between; padding: 2px 0; font-size: 10.5px; }
.asset-lbl { color: var(--muted); }
.asset-val { font-family: 'JetBrains Mono', monospace; font-weight: 500; font-size: 10.5px; }
.fpl-pos { color: var(--green); }
.fpl-neg { color: var(--red); }
.ml-warn { color: var(--red); font-weight: 700; }

.op-footer { padding: 7px 9px; border-top: 1px solid var(--border); flex-shrink: 0; }
.op-footer-btn {
  width: 100%;
  padding: 6px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.op-footer-btn:hover { background: var(--bg3); color: var(--text); }

/* ====================================================================
   MOBILE OVERLAY & DRAWERS
   ==================================================================== */
.mob-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 300;
  backdrop-filter: blur(2px);
}
.mob-overlay.show { display: block; }

/* ====================================================================
   TOAST NOTIFICATIONS
   ==================================================================== */
#toast-zone {
  position: fixed;
  top: 52px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 4px 16px var(--shadow);
  animation: toastIn .25s ease;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast i { font-size: 13px; }
.toast-success { background: var(--green); color: #fff; }
.toast-error   { background: var(--red);   color: #fff; }
.toast-info    { background: #1a1d2e;       color: #fff; }
[data-theme="dark"] .toast-info { background: #2d3150; }
@keyframes toastIn { from { opacity:0; transform:translateX(12px) } to { opacity:1; transform:translateX(0) } }

/* ====================================================================
   MODAL (for TP/SL edit, support)
   ==================================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px var(--shadow);
  overflow: hidden;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close { cursor: pointer; color: var(--muted); font-size: 18px; transition: color .15s; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ====================================================================
   FORM ELEMENTS (shared)
   ==================================================================== */
.form-field { margin-bottom: 16px; }
.form-label { display: block; font-size: 11.5px; font-weight: 600; color: var(--sub); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 7px; }
.form-input, .form-select {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color .2s;
}
.form-input:focus, .form-select:focus { border-color: var(--blue); background: var(--bg); }
.form-select option { background: var(--bg2); }
.form-input::placeholder { color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 7px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: .15s; }
.btn-primary { background: linear-gradient(135deg, var(--green), #0a8a5f); color: #fff; }
.btn-primary:hover { opacity: .9; }
.btn-danger  { background: linear-gradient(135deg, var(--red), #b52b2b); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-ghost { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg4); }

/* Alert */
.alert { padding: 11px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.alert-success { background: rgba(13,166,114,.1); border: 1px solid rgba(13,166,114,.3); color: var(--green); }
.alert-error   { background: rgba(220,53,69,.1);  border: 1px solid rgba(220,53,69,.3);  color: var(--red); }

/* ====================================================================
   ADMIN PAGES — general page layout
   ==================================================================== */
.page-wrap { max-width: 1100px; margin: 36px auto; padding: 0 20px; }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 5px; }
.breadcrumb { font-size: 12px; color: var(--muted); margin-bottom: 24px; }
.breadcrumb a { color: var(--green); text-decoration: none; }

.card { background: var(--hdr-bg); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 20px; }
.card-header { padding: 15px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 14px; font-weight: 700; }
.card-body { padding: 20px; }

/* Table */
.tbl-wrap { overflow-x: auto; }
.data-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-tbl thead th { padding: 9px 14px; text-align: left; font-weight: 600; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); background: var(--bg2); white-space: nowrap; }
.data-tbl tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-tbl tbody tr:hover { background: var(--bg2); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 20px; font-size: 10.5px; font-weight: 700; }
.badge-up      { background: rgba(13,166,114,.15); color: var(--green); }
.badge-dn      { background: rgba(220,53,69,.15);  color: var(--red); }
.badge-active  { background: rgba(13,166,114,.15); color: var(--green); }
.badge-off     { background: var(--bg3); color: var(--muted); }
.badge-amber   { background: rgba(217,119,6,.15);  color: var(--amber); }

/* Toggle switch */
.toggle-sw { position: relative; display: inline-block; width: 38px; height: 20px; }
.toggle-sw input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--border2);
  border-radius: 20px;
  cursor: pointer;
  transition: background .2s;
}
.toggle-track::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.toggle-sw input:checked + .toggle-track { background: var(--green); }
.toggle-sw input:checked + .toggle-track::before { transform: translateX(18px); }

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }


/* ====================================================================
   RESPONSIVE — Trading Room (breakpoints)
   ==================================================================== */
@media (max-width: 1024px) {
  #watchlist { width: 200px; }
  #order-panel { width: 185px; }
  .ch-stat:nth-child(n+6) { display: none; }
}

@media (max-width: 900px) {
  .mob-toggle { display: flex !important; }
  #watchlist {
    position: fixed; top: 0; left: 0;
    height: 100vh; width: 300px !important;
    z-index: 400; transform: translateX(-100%);
    box-shadow: 4px 0 24px var(--shadow);
  }
  #watchlist.open { transform: translateX(0); }
  .wl-close-mob { display: flex !important; }
  #order-panel {
    position: fixed; top: 0; right: 0;
    height: 100vh; width: 300px !important;
    z-index: 400; transform: translateX(100%);
    box-shadow: -4px 0 24px var(--shadow);
  }
  #order-panel.open { transform: translateX(0); }
  .op-mob-header { display: flex !important; }
  .ch-stat:nth-child(n+4) { display: none; }
  #positions { height: 160px; }
  .hide-others { display: none; }
  .hdr-balance { display: none; }
}

@media (max-width: 640px) {
  #hdr { padding: 0 8px; gap: 5px; }
  #ticker .tick-item:nth-child(n+8) { display: none; }
  #chart-hdr { padding: 5px 8px; gap: 6px; }
  .ch-stat { display: none; }
  .ch-sym { font-size: 13px; }
  .ch-price { font-size: 15px; }
  #positions { height: 130px; }
  .pos-tab:nth-child(n+3) { display: none; }
  .pos-tbl thead th:nth-child(n+6),
  .pos-tbl td:nth-child(n+6) { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ====================================================================
   PAGE-SPECIFIC: Auth pages (login / register)
   ==================================================================== */
body.auth-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px; overflow: auto; background: var(--bg2);
}
.auth-wrap {
  display: flex; width: 100%; max-width: 960px; min-height: 520px;
  border-radius: 18px; overflow: hidden; box-shadow: 0 24px 80px var(--shadow);
}
.auth-left {
  flex: 1; background: var(--bg); border: 1px solid var(--border);
  padding: 52px 44px; display: flex; flex-direction: column;
  justify-content: center; position: relative; overflow: hidden;
}
.auth-left::before {
  content: ''; position: absolute; top: -80px; right: -80px;
  width: 280px; height: 280px; border-radius: 50%;
  background: radial-gradient(circle, rgba(13,166,114,.07) 0%, transparent 70%);
}
.auth-right {
  width: 420px; background: var(--bg); border-left: 1px solid var(--border);
  padding: 52px 44px; display: flex; flex-direction: column; justify-content: center;
}
.auth-logo { font-weight: 700; font-size: 22px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.auth-logo svg { width: 22px; height: 22px; }
.auth-tagline { font-size: 14px; color: var(--muted); line-height: 1.8; max-width: 280px; margin-bottom: 32px; }
.auth-feature { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--sub); margin-bottom: 12px; }
.auth-feature-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.auth-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.auth-sub { font-size: 13px; color: var(--muted); margin-bottom: 28px; }
.auth-sub a { color: var(--green); font-weight: 600; }
.auth-btn {
  width: 100%; background: linear-gradient(135deg, var(--green), #0a8a5f);
  border: none; color: #fff; padding: 13px; border-radius: 9px;
  font-size: 14px; font-weight: 700; cursor: pointer; letter-spacing: .5px;
  margin-top: 6px; transition: opacity .2s;
}
.auth-btn:hover { opacity: .9; }
.auth-footer { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }
.auth-footer a { color: var(--green); font-weight: 600; text-decoration: none; }
.forgot-link { font-size: 12px; color: var(--green); text-decoration: none; }
@media (max-width: 700px) {
  .auth-left { display: none; }
  .auth-right { width: 100%; padding: 36px 24px; }
}

/* ====================================================================
   PAGE-SPECIFIC: Inner pages (deposit / withdraw / profile / dashboard)
   ==================================================================== */
body.inner-page { overflow: auto; min-height: 100vh; }
body.inner-page #hdr { position: sticky; top: 0; z-index: 200; }

/* Header nav */
.hdr-nav {
  display: flex; gap: 2px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; flex-shrink: 1; min-width: 0;
}
.hdr-nav::-webkit-scrollbar { display: none; }

.page-header { background: var(--hdr-bg); border-bottom: 1px solid var(--border); padding: 0 20px; height: 48px; display: flex; align-items: center; gap: 16px; position: sticky; top: 44px; z-index: 100; }
.page-nav-btn {
  padding: 6px 12px; border-radius: 6px; font-size: 12px;
  color: var(--sub); border: 1px solid transparent; cursor: pointer;
  transition: .15s; white-space: nowrap; display: inline-flex;
  align-items: center; gap: 5px; text-decoration: none;
}
.page-nav-btn:hover, .page-nav-btn.active { background: var(--bg2); color: var(--text); border-color: var(--border); }

.method-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin-bottom: 24px; }
.method-card {
  background: var(--bg); border: 2px solid var(--border);
  border-radius: 12px; padding: 20px; cursor: pointer;
  text-align: center; transition: .2s;
}
.method-card:hover, .method-card.selected { border-color: var(--green); background: rgba(13,166,114,.04); }
.method-icon { font-size: 24px; color: var(--green); margin-bottom: 8px; }
.method-name { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.method-desc { font-size: 11px; color: var(--muted); line-height: 1.5; }

.form-box { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 22px; margin-bottom: 22px; display: none; }
.form-box.show { display: block; }
.form-box-title { font-size: 14px; font-weight: 700; margin-bottom: 16px; }

.wallet-box {
  background: rgba(13,166,114,.07); border: 1px solid rgba(13,166,114,.25);
  border-radius: 7px; padding: 9px 13px; font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px; color: var(--green); word-break: break-all;
  cursor: pointer; transition: background .2s; margin-top: 6px;
}
.wallet-box:hover { background: rgba(13,166,114,.12); }

.bank-info { background: var(--bg2); border: 1px solid var(--border); border-radius: 9px; padding: 14px; margin-bottom: 16px; font-size: 12.5px; color: var(--sub); line-height: 1.9; }
.bank-info strong { color: var(--text); }

.bal-banner {
  background: linear-gradient(135deg, rgba(13,166,114,.08), rgba(13,166,114,.03));
  border: 1px solid rgba(13,166,114,.2); border-radius: 12px;
  padding: 18px 22px; display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 10px;
}
.bal-banner-lbl { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.bal-banner-amt { font-family: 'JetBrains Mono', monospace; font-size: 26px; font-weight: 700; color: var(--green); }

.profile-grid { display: grid; grid-template-columns: 200px 1fr; gap: 20px; }
.side-menu { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 8px; height: fit-content; }
.side-menu-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 8px; cursor: pointer; color: var(--sub); font-size: 13px;
  width: 100%; border: none; background: transparent; transition: .15s; text-align: left;
}
.side-menu-item:hover, .side-menu-item.active { background: var(--bg2); color: var(--text); }
.side-menu-item i { width: 16px; text-align: center; font-size: 12px; }
.side-menu-item.danger:hover { background: rgba(220,53,69,.1); color: var(--red); }

.avatar-circle {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.verify-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(13,166,114,.1); border: 1px solid rgba(13,166,114,.3);
  color: var(--green); padding: 2px 9px; border-radius: 20px;
  font-size: 10px; font-weight: 700; margin-top: 5px;
}

.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 9px; padding: 12px; }
.stat-card-label { font-size: 10.5px; color: var(--muted); margin-bottom: 4px; }
.stat-card-val { font-family: 'JetBrains Mono', monospace; font-size: 20px; font-weight: 700; }

/* ====================================================================
   MOBILE BOTTOM NAVIGATION — inner pages only
   ==================================================================== */
.mob-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: var(--hdr-bg);
  border-top: 1px solid var(--border2);
  z-index: 9000;
  box-shadow: 0 -4px 20px rgba(0,0,0,.35);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: transform;
  -webkit-backface-visibility: hidden;
}
.mob-bottom-nav-inner {
  display: flex; height: 60px; align-items: stretch;
}
.mob-nav-item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  color: var(--sub); text-decoration: none; font-size: 8px;
  font-weight: 600; transition: color .15s; border: none;
  background: none; cursor: pointer; padding: 2px 1px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
  min-width: 0;
}
.mob-nav-item i { font-size: 15px; }
.mob-nav-item.active { color: var(--green); }
.mob-nav-item:active { background: var(--bg2); }
[data-theme="dark"] .mob-nav-item { color: rgba(255,255,255,0.75); }

/* ====================================================================
   INNER PAGE RESPONSIVE
   ==================================================================== */
@media (max-width: 768px) {
  .mob-bottom-nav { display: block; }
  .logo-svg { display: none; }

  /* Prevent horizontal overflow on all pages */
  html, body { overflow-x: hidden; max-width: 100vw; }
  * { box-sizing: border-box; }

  /* Body padding so content never hides behind bottom nav */
  body { padding-bottom: calc(60px + env(safe-area-inset-bottom)) !important; }

  /* Header */
  .hdr-nav { display: none !important; }
  .hdr-sep-nav { display: none; }
  #hdr .deposit-btn { display: none; }
  .hdr-balance { display: flex !important; }
  #hdr { padding: 0 12px; gap: 6px; }
  .logo { font-size: 13px; font-weight: 700; }

  /* Page layout */
  .page-wrap { padding: 0 12px; margin: 12px auto 16px; max-width: 100%; }
  .page-title { font-size: 17px; margin-bottom: 4px; }
  .breadcrumb { font-size: 11px; margin-bottom: 14px; }

  /* Grids — all single column on mobile */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }

  /* Stat cards — 2 columns on mobile */
  .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .stat-card { padding: 10px 12px; }
  .stat-card-val { font-size: 18px; }

  /* Forms */
  .form-input, .form-select { font-size: 16px !important; min-height: 44px; }
  .form-box { padding: 16px 14px; margin-bottom: 16px; }
  .form-field { margin-bottom: 12px; }
  .form-label { font-size: 12px; }

  /* Buttons */
  .btn { min-height: 44px; font-size: 13px; }
  .btn-primary, .btn-danger, .btn-secondary { width: 100%; justify-content: center; }

  /* Method grid */
  .method-grid { gap: 8px; margin-bottom: 18px; }
  .method-card { padding: 14px 8px; border-radius: 10px; }
  .method-icon { font-size: 22px; margin-bottom: 6px; }
  .method-name { font-size: 11.5px; }
  .method-desc { font-size: 10px; }

  /* Balance banner */
  .bal-banner { padding: 14px 16px; flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 16px; }
  .bal-banner-amt { font-size: 24px; }

  /* Cards — full width, no overflow */
  .card { border-radius: 10px; overflow: hidden; }
  .card-header { padding: 12px 14px; flex-wrap: wrap; gap: 6px; }
  .card-title { font-size: 13px; }
  .card-body { padding: 14px; }

  /* Tables — horizontal scroll */
  .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }
  .data-tbl { font-size: 12px; min-width: 500px; }
  .data-tbl th, .data-tbl td { padding: 9px 10px; white-space: nowrap; }

  /* Profile page */
  .profile-grid { grid-template-columns: 1fr !important; }
  .side-menu { display: flex; flex-direction: row; overflow-x: auto; scrollbar-width: none; padding: 6px; gap: 4px; border-radius: 10px; margin-bottom: 12px; height: auto !important; }
  .side-menu::-webkit-scrollbar { display: none; }
  .side-menu-item { flex-shrink: 0; white-space: nowrap; font-size: 11px; padding: 7px 10px; width: auto !important; }
  .side-menu-item.danger { display: none; } /* hide signout from tab bar — in bottom nav */
  .stat-card-val { font-size: 16px; }
  .avatar-circle { width: 46px; height: 46px; font-size: 15px; }
  .page-wrap[style*="max-width"] { max-width: 100% !important; }
  .card-body { padding: 14px 12px !important; }

  /* Dashboard overview cards */
  .overview-grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .overview-card { padding: 12px !important; }
  .overview-card-val { font-size: 18px !important; }

  /* Recent deposits table */
  .data-tbl th:nth-child(3),
  .data-tbl td:nth-child(3) { display: none; } /* hide Method col on small screens */

  /* Misc */
  .secure-badge { flex-wrap: wrap; gap: 8px; font-size: 11px; }
  .alert { font-size: 13px; padding: 11px 13px; }

  /* KYC page */
  .kyc-steps { flex-direction: column !important; }

  /* Fix any flex rows that break on mobile */
  .flex-row-mobile { flex-direction: column !important; }
  .w-full-mobile { width: 100% !important; }
}

@media (max-width: 480px) {
  .page-wrap { padding: 0 10px; margin: 10px auto 12px; }
  .page-title { font-size: 15px; }
  .method-card { padding: 12px 6px; }
  .method-icon { font-size: 18px; }
  .method-name { font-size: 10.5px; }
  .method-desc { display: none; }
  .bal-banner-amt { font-size: 22px; }
  .form-box { padding: 14px 12px; }
  .btn { font-size: 13px; padding: 11px 16px; }
  .stat-card-val { font-size: 16px; }
  .logo { font-size: 12px; }

  /* On very small screens keep 2 stat cols */
  .stats-grid { grid-template-columns: 1fr 1fr !important; }

  /* Hide less important table columns */
  .data-tbl th:nth-child(n+5),
  .data-tbl td:nth-child(n+5) { display: none; }
}
