/* ═══════════════════════════════════════════════════════════
   APEX PRO TERMINAL — Swiss-grade institutional UI
   Matches high-end broker terminal reference
   ═══════════════════════════════════════════════════════════ */

:root {
  --t-bg: #0b0b0b;
  --t-panel: #141414;
  --t-panel2: #1a1a1a;
  --t-line: #252525;
  --t-line2: #2e2e2e;
  --t-ink: #e4e4e4;
  --t-mute: #7a7a7a;
  --t-teal: #26a69a;
  --t-teal-dim: #1e8a80;
  --t-teal-bg: rgba(38, 166, 154, 0.12);
  --t-red: #ef5350;
  --t-green: #26a69a;
  --t-yellow: #ffc107;
  --t-nav: 46px;
  --t-acct: 42px;
  --t-order: 130px;
  --t-pos: 160px;
}

body.terminal-body {
  background: var(--t-bg) !important;
  overflow: hidden;
  font-size: 12px;
}

.pro-terminal {
  display: grid;
  grid-template-rows: var(--t-nav) var(--t-acct) 1fr var(--t-order) var(--t-pos);
  height: 100vh;
  background: var(--t-bg);
  color: var(--t-ink);
}

/* ── TOP NAV ── */
.pro-nav {
  display: flex;
  align-items: center;
  height: var(--t-nav);
  padding: 0 12px;
  background: #0e0e0e;
  border-bottom: 1px solid var(--t-line);
  gap: 4px;
  z-index: 50;
}
.pro-logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 14px; color: #fff;
  margin-right: 16px; white-space: nowrap; min-width: 100px;
}
.pro-logo svg { width: 22px; height: 22px; flex-shrink: 0; }
.pro-cats {
  display: flex; align-items: center; gap: 0; flex: 1; overflow-x: auto; scrollbar-width: none;
}
.pro-cats::-webkit-scrollbar { display: none; }
.pro-cat {
  padding: 12px 14px; font-size: 12px; font-weight: 500; color: var(--t-mute);
  border-bottom: 2px solid transparent; white-space: nowrap; transition: color .15s, border-color .15s;
  cursor: pointer; background: none; border-top: none; border-left: none; border-right: none;
}
.pro-cat:hover { color: var(--t-ink); }
.pro-cat.active { color: var(--t-yellow); border-bottom-color: var(--t-yellow); }
.pro-nav-end {
  display: flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0;
}
.pro-icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: 4px; color: var(--t-mute); font-size: 14px; transition: background .15s, color .15s;
  background: none; border: none; cursor: pointer;
}
.pro-icon-btn:hover { background: var(--t-panel2); color: var(--t-ink); }
.pro-lang {
  display: flex; align-items: center; gap: 4px; padding: 4px 8px;
  font-size: 11px; color: var(--t-ink); border-radius: 4px;
}
.pro-deposit {
  background: var(--t-teal); color: #fff; font-weight: 700; font-size: 11px;
  letter-spacing: 0.04em; padding: 8px 16px; border-radius: 3px; text-decoration: none;
  transition: background .15s; white-space: nowrap;
}
.pro-deposit:hover { background: var(--t-teal-dim); color: #fff; }
.pro-user-btn {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px;
  border-radius: 4px; cursor: pointer; background: none; border: none; color: var(--t-ink);
}
.pro-user-btn:hover { background: var(--t-panel2); }
.pro-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, #374151, #1f2937);
  display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff;
  border: 1px solid var(--t-line2);
}
.pro-user-name { font-size: 12px; font-weight: 500; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── ACCOUNT BAR ── */
.pro-acct-bar {
  display: flex; align-items: center; height: var(--t-acct);
  padding: 0 12px; gap: 0;
  background: #111; border-bottom: 1px solid var(--t-line);
  overflow-x: auto; scrollbar-width: none;
}
.pro-acct-bar::-webkit-scrollbar { display: none; }
.pro-acct-select-wrap {
  display: flex; align-items: center; gap: 6px; padding-right: 16px;
  border-right: 1px solid var(--t-line); margin-right: 4px; flex-shrink: 0;
}
.pro-acct-select-wrap label { font-size: 10px; color: var(--t-mute); text-transform: uppercase; letter-spacing: 0.05em; }
.pro-acct-select {
  background: transparent; border: none; color: var(--t-ink); font-size: 12px;
  font-weight: 600; outline: none; cursor: pointer; padding: 4px 0;
}
.pro-acct-select option { background: #1a1a1a; }
.pro-metric {
  display: flex; flex-direction: column; padding: 0 14px;
  border-right: 1px solid var(--t-line); min-width: 80px; flex-shrink: 0;
}
.pro-metric:last-of-type { border-right: none; }
.pro-metric .m-lbl { font-size: 9px; color: var(--t-mute); text-transform: uppercase; letter-spacing: 0.04em; line-height: 1; margin-bottom: 3px; }
.pro-metric .m-val { font-size: 12px; font-weight: 600; color: var(--t-ink); font-family: var(--mono, monospace); line-height: 1; }
.pro-metric .m-val.pos { color: var(--t-green); }
.pro-metric .m-val.neg { color: var(--t-red); }
.pro-roi-gauge {
  margin-left: auto; display: flex; align-items: center; gap: 8px; padding-left: 16px; flex-shrink: 0;
}
.pro-gauge-ring {
  width: 36px; height: 36px; border-radius: 50%;
  background: conic-gradient(var(--t-teal) 0deg, var(--t-teal) var(--roi-deg, 0deg), var(--t-line2) var(--roi-deg, 0deg));
  display: grid; place-items: center; position: relative;
}
.pro-gauge-ring::after {
  content: ''; width: 26px; height: 26px; border-radius: 50%; background: #111;
}

/* ── MAIN GRID ── */
.pro-main {
  display: grid; grid-template-columns: 200px 1fr 240px;
  overflow: hidden; min-height: 0;
}

/* ── WATCHLIST ── */
.pro-watchlist {
  background: var(--t-panel); border-right: 1px solid var(--t-line);
  display: flex; flex-direction: column; overflow: hidden;
}
.pro-wl-search {
  padding: 8px; border-bottom: 1px solid var(--t-line);
}
.pro-wl-search input {
  width: 100%; background: #0e0e0e; border: 1px solid var(--t-line);
  color: var(--t-ink); padding: 7px 10px; border-radius: 3px; font-size: 11px; outline: none;
}
.pro-wl-search input:focus { border-color: var(--t-teal); }
.pro-wl-search input::placeholder { color: #555; }
.pro-wl-list { flex: 1; overflow-y: auto; }
.pro-wl-item {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 8px;
  padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--t-line);
  align-items: center; transition: background .1s;
}
.pro-wl-logo {
  width: 22px; height: 22px; border-radius: 50%; object-fit: cover;
  background: var(--t-panel2); border: 1px solid var(--t-line);
}
.pro-wl-logo-fallback {
  width: 22px; height: 22px; border-radius: 50%; background: var(--t-panel2);
  border: 1px solid var(--t-line); display: grid; place-items: center;
  font-size: 9px; font-weight: 700; color: var(--t-mute);
}
.pro-cat-count {
  font-size: 9px; opacity: 0.5; margin-left: 2px;
}
.pro-wl-header {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 8px;
  padding: 6px 10px; font-size: 9px; color: var(--t-mute); text-transform: uppercase;
  letter-spacing: 0.05em; border-bottom: 1px solid var(--t-line); background: #0e0e0e;
}
.pro-tcard .tc-logo {
  width: 20px; height: 20px; border-radius: 50%; margin: 0 auto 4px; object-fit: cover;
  background: var(--t-panel2);
}
.pro-rate-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0; border-bottom: 1px solid var(--t-line); font-size: 11px;
}
.pro-rate-row:last-child { border-bottom: none; }
.pro-rate-row .rr-logo {
  width: 18px; height: 18px; border-radius: 50%; object-fit: cover; margin-right: 6px; flex-shrink: 0;
}
.pro-rate-row .rr-sym { font-weight: 600; flex: 1; }
.pro-rate-row .rr-price { font-family: var(--mono, monospace); }
  font-size: 9px; color: var(--t-teal); padding: 2px 8px; background: var(--t-teal-bg);
  border-radius: 3px; margin-left: 8px;
}
.pro-wl-item:hover { background: rgba(255,255,255,0.03); }
.pro-wl-item.active { background: var(--t-teal-bg); border-left: 2px solid var(--t-teal); padding-left: 8px; }
.pro-wl-icon { font-size: 14px; text-align: center; }
.pro-wl-sym { font-size: 11px; font-weight: 600; color: var(--t-ink); line-height: 1.2; }
.pro-wl-name { font-size: 9px; color: var(--t-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
.pro-wl-right { text-align: right; }
.pro-wl-price { font-size: 11px; font-family: var(--mono, monospace); color: var(--t-ink); }
.pro-wl-status { font-size: 9px; color: var(--t-mute); margin-top: 1px; }
.pro-wl-status.open { color: var(--t-green); }

/* ── CENTER ── */
.pro-center { display: flex; flex-direction: column; overflow: hidden; min-height: 0; background: var(--t-bg); }

.pro-chart-top {
  display: flex; align-items: center; gap: 0; height: 36px;
  padding: 0 10px; background: var(--t-panel); border-bottom: 1px solid var(--t-line);
  flex-shrink: 0;
}
.pro-ctab {
  padding: 8px 14px; font-size: 12px; font-weight: 500; color: var(--t-mute);
  cursor: pointer; border-bottom: 2px solid transparent; transition: all .15s;
}
.pro-ctab.active { color: var(--t-teal); border-bottom-color: var(--t-teal); }
.pro-chart-top-sep { width: 1px; height: 20px; background: var(--t-line); margin: 0 8px; }
.pro-chart-toggle {
  display: flex; align-items: center; gap: 6px; padding: 0 12px;
  font-size: 11px; color: var(--t-mute); cursor: pointer; user-select: none;
}
.pro-switch {
  width: 32px; height: 16px; background: var(--t-line2); border-radius: 8px;
  position: relative; transition: background .2s; flex-shrink: 0;
}
.pro-switch.on { background: var(--t-teal); }
.pro-switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; background: #fff; border-radius: 50%; transition: left .2s;
}
.pro-switch.on::after { left: 18px; }

.pro-chart-wrap {
  flex: 1; display: flex; overflow: hidden; min-height: 0; position: relative;
}
.pro-chart-tools {
  width: 36px; background: var(--t-panel); border-right: 1px solid var(--t-line);
  display: flex; flex-direction: column; align-items: center; padding: 6px 0; gap: 2px;
  flex-shrink: 0; overflow-y: auto;
}
.pro-tool {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 3px; color: var(--t-mute); font-size: 13px; cursor: pointer;
  transition: background .1s, color .1s;
}
.pro-tool:hover, .pro-tool.active { background: var(--t-panel2); color: var(--t-teal); }

.pro-chart-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pro-chart-meta {
  display: flex; align-items: center; gap: 10px; padding: 4px 10px;
  background: var(--t-bg); border-bottom: 1px solid var(--t-line); font-size: 11px; flex-shrink: 0;
}
.pro-chart-meta .sym-title { font-weight: 600; color: var(--t-ink); }
.pro-chart-meta .ohlc { color: var(--t-mute); font-family: var(--mono, monospace); font-size: 10px; }
.pro-chart-meta .ohlc span.up { color: var(--t-green); }
.pro-chart-meta .ohlc span.down { color: var(--t-red); }
.pro-chart-meta-right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.pro-meta-btn {
  padding: 3px 8px; font-size: 10px; color: var(--t-mute); background: var(--t-panel);
  border: 1px solid var(--t-line); border-radius: 3px; cursor: pointer;
}
.pro-meta-btn:hover, .pro-meta-btn.active { color: var(--t-teal); border-color: var(--t-teal); }
.pro-tf-select {
  background: var(--t-panel); border: 1px solid var(--t-line); color: var(--t-ink);
  padding: 3px 6px; border-radius: 3px; font-size: 10px; cursor: pointer; outline: none;
}

.pro-chart-canvas { flex: 1; position: relative; min-height: 0; }
.pro-chart-canvas #chartContainer { width: 100% !important; height: 100% !important; }

.pro-chart-range {
  display: flex; align-items: center; gap: 0; height: 28px;
  padding: 0 10px; background: var(--t-panel); border-top: 1px solid var(--t-line);
  flex-shrink: 0;
}
.pro-range-btn {
  padding: 4px 10px; font-size: 10px; color: var(--t-mute); cursor: pointer;
  border-radius: 2px; transition: color .1s, background .1s;
}
.pro-range-btn:hover { color: var(--t-ink); background: var(--t-panel2); }
.pro-range-btn.active { color: var(--t-teal); }
.pro-range-time { margin-left: auto; font-size: 10px; color: var(--t-mute); font-family: var(--mono, monospace); }

.pro-info-panel {
  flex: 1; padding: 16px; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px;
}
.pro-info-cell {
  background: var(--t-panel); border: 1px solid var(--t-line); border-radius: 4px; padding: 12px;
}
.pro-info-cell .ic-lbl { font-size: 9px; color: var(--t-mute); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.pro-info-cell .ic-val { font-size: 13px; font-weight: 600; font-family: var(--mono, monospace); }

/* ── ORDER PANEL ── */
.pro-order {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 0; height: var(--t-order);
  background: var(--t-panel); border-top: 1px solid var(--t-line);
  align-items: stretch;
}
.pro-order-sides {
  display: flex; flex-direction: column; width: 100px; flex-shrink: 0;
  border-right: 1px solid var(--t-line);
}
.pro-oside {
  flex: 1; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  cursor: pointer; transition: all .15s; letter-spacing: 0.02em;
}
.pro-oside.buy { background: transparent; color: var(--t-mute); }
.pro-oside.buy.active { background: var(--t-teal); color: #fff; }
.pro-oside.sell { background: transparent; color: var(--t-mute); border-top: 1px solid var(--t-line); }
.pro-oside.sell.active { background: var(--t-red); color: #fff; }

.pro-order-fields {
  display: flex; align-items: center; gap: 16px; padding: 10px 16px; flex-wrap: wrap;
}
.pro-ofield { display: flex; flex-direction: column; gap: 4px; }
.pro-ofield label { font-size: 9px; color: var(--t-mute); text-transform: uppercase; letter-spacing: 0.04em; }
.pro-qty-row { display: flex; align-items: center; gap: 0; }
.pro-qty-btn {
  width: 28px; height: 28px; background: var(--t-panel2); border: 1px solid var(--t-line);
  color: var(--t-ink); font-size: 14px; cursor: pointer; display: grid; place-items: center;
}
.pro-qty-btn:first-child { border-radius: 3px 0 0 3px; }
.pro-qty-btn:last-child { border-radius: 0 3px 3px 0; }
.pro-qty-input {
  width: 60px; height: 28px; background: #0e0e0e; border: 1px solid var(--t-line);
  border-left: none; border-right: none; color: var(--t-ink); text-align: center;
  font-family: var(--mono, monospace); font-size: 12px; outline: none;
}
.pro-otoggle-row { display: flex; align-items: center; gap: 8px; }
.pro-otoggle-row label { font-size: 11px; color: var(--t-mute); font-weight: 600; min-width: 32px; }
.pro-otoggle-input {
  width: 80px; height: 28px; background: #0e0e0e; border: 1px solid var(--t-line);
  color: var(--t-ink); padding: 0 8px; font-size: 11px; font-family: var(--mono, monospace);
  border-radius: 3px; outline: none;
}
.pro-otoggle-input:disabled { opacity: 0.35; }
.pro-order-meta { font-size: 10px; color: var(--t-mute); margin-top: auto; padding-top: 4px; }
.pro-order-meta strong { color: var(--t-ink); font-family: var(--mono, monospace); }

.pro-exec-btn {
  width: 160px; flex-shrink: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  font-weight: 700; font-size: 13px; cursor: pointer; border: none;
  transition: opacity .15s; padding: 0 12px; text-align: center; line-height: 1.3;
}
.pro-exec-btn.buy-side { background: var(--t-teal); color: #fff; }
.pro-exec-btn.sell-side { background: var(--t-red); color: #fff; }
.pro-exec-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.pro-exec-btn .exec-price { font-size: 11px; font-weight: 400; opacity: 0.85; font-family: var(--mono, monospace); }

/* ── RIGHT SIDEBAR ── */
.pro-sidebar {
  background: var(--t-panel); border-left: 1px solid var(--t-line);
  overflow-y: auto; display: flex; flex-direction: column;
}
.pro-sb-section { border-bottom: 1px solid var(--t-line); }
.pro-sb-head {
  padding: 10px 12px 8px; font-size: 10px; font-weight: 700;
  color: var(--t-mute); text-transform: uppercase; letter-spacing: 0.06em;
  display: flex; align-items: center; justify-content: space-between; cursor: pointer;
}
.pro-sb-head .arrow { font-size: 8px; transition: transform .2s; }
.pro-sb-head.collapsed .arrow { transform: rotate(-90deg); }
.pro-sb-body { padding: 0 12px 12px; }

.pro-ticker-cards { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.pro-ticker-cards::-webkit-scrollbar { display: none; }
.pro-tcard {
  flex: 0 0 72px; background: var(--t-panel2); border: 1px solid var(--t-line);
  border-radius: 4px; padding: 8px 6px; text-align: center;
}
.pro-tcard .tc-sym { font-size: 10px; font-weight: 700; color: var(--t-ink); }
.pro-tcard .tc-price { font-size: 10px; font-family: var(--mono, monospace); margin: 2px 0; }
.pro-tcard .tc-chg { font-size: 9px; }
.pro-tcard .tc-spark { height: 24px; margin-top: 4px; }

.pro-sync-badge { { padding: 8px 0; border-bottom: 1px solid var(--t-line); }
.pro-news-item:last-child { border-bottom: none; }
.pro-news-item a { color: var(--t-ink); font-size: 11px; line-height: 1.4; text-decoration: none; display: block; }
.pro-news-item a:hover { color: var(--t-teal); }
.pro-news-item .ni-src { font-size: 9px; color: var(--t-mute); margin-top: 3px; }

.pro-social-card {
  display: flex; align-items: center; gap: 8px; padding: 10px 0;
  border-bottom: 1px solid var(--t-line);
}
.pro-social-card:last-child { border-bottom: none; }
.pro-sc-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: #374151;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.pro-sc-info { flex: 1; min-width: 0; }
.pro-sc-name { font-size: 11px; font-weight: 600; }
.pro-sc-roi { font-size: 10px; color: var(--t-green); font-family: var(--mono, monospace); }
.pro-sc-bar { height: 3px; background: var(--t-line2); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.pro-sc-bar-fill { height: 100%; background: var(--t-teal); border-radius: 2px; }
.pro-sc-equity { font-size: 10px; color: var(--t-mute); font-family: var(--mono, monospace); text-align: right; }
.pro-follow-btn {
  background: var(--t-teal); color: #fff; font-size: 10px; font-weight: 700;
  padding: 5px 10px; border-radius: 3px; border: none; cursor: pointer; white-space: nowrap;
}
.pro-follow-btn:hover { background: var(--t-teal-dim); }

/* ── POSITIONS ── */
.pro-positions {
  background: var(--t-panel); border-top: 1px solid var(--t-line);
  display: flex; flex-direction: column; overflow: hidden;
}
.pro-pos-tabs { display: flex; border-bottom: 1px solid var(--t-line); flex-shrink: 0; }
.pro-ptab {
  padding: 10px 18px; font-size: 11px; font-weight: 600; color: var(--t-mute);
  cursor: pointer; border-bottom: 2px solid transparent; transition: all .15s;
  background: none; border-top: none; border-left: none; border-right: none;
}
.pro-ptab.active { color: var(--t-teal); border-bottom-color: var(--t-teal); }
.pro-pos-body { flex: 1; overflow: auto; }
.pro-pos-body .table th { background: #111; font-size: 9px; padding: 7px 12px; }
.pro-pos-body .table td { padding: 7px 12px; font-size: 11px; }

/* ── DROPDOWN (terminal) ── */
.pro-dropdown { position: relative; }
.pro-dropdown-menu {
  position: absolute; top: calc(100% + 4px); right: 0; min-width: 210px;
  background: #1a1a1a; border: 1px solid var(--t-line2); border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6); z-index: 200; display: none;
}
.pro-dropdown.open .pro-dropdown-menu { display: block; }
.pro-dropdown-menu a, .pro-dropdown-menu button {
  display: block; width: 100%; text-align: left; padding: 10px 14px;
  font-size: 12px; color: var(--t-ink); border-bottom: 1px solid var(--t-line);
  text-decoration: none; background: none; border-left: none; border-right: none; border-top: none; cursor: pointer;
}
.pro-dropdown-menu a:hover { background: rgba(38,166,154,0.08); color: var(--t-teal); }
.pro-dropdown-menu button:last-child { color: var(--t-red); border-bottom: none; }

/* ── CHAT FAB ── */
.pro-chat-fab {
  position: fixed; bottom: calc(var(--t-pos) + 16px); right: 16px;
  width: 48px; height: 48px; border-radius: 50%; background: #1565c0;
  color: #fff; display: grid; place-items: center; font-size: 20px;
  box-shadow: 0 4px 20px rgba(21,101,192,0.4); cursor: pointer; z-index: 100;
  border: none; transition: transform .15s;
}
.pro-chat-fab:hover { transform: scale(1.05); }

/* ── NOTIF BADGE ── */
.pro-notif-badge {
  position: absolute; top: 4px; right: 4px; min-width: 14px; height: 14px;
  background: var(--t-red); color: #fff; font-size: 8px; font-weight: 700;
  border-radius: 7px; display: grid; place-items: center; padding: 0 3px;
}

@media (max-width: 1100px) {
  .pro-main { grid-template-columns: 180px 1fr; }
  .pro-sidebar { display: none; }
}
@media (max-width: 768px) {
  .pro-main { grid-template-columns: 1fr; }
  .pro-watchlist { max-height: 140px; border-right: none; border-bottom: 1px solid var(--t-line); }
  .pro-order { grid-template-columns: 1fr; height: auto; }
  .pro-exec-btn { width: 100%; height: 48px; flex-direction: row; gap: 8px; }
  .pro-cats { display: none; }
}
