:root {
  --bg: #0b0e14;
  --panel: #111622;
  --panel2: #161c2b;
  --panel3: #1d2538;
  --inp: #0d121c;
  --line: #222b3d;
  --line-light: #2c374d;
  --fg: #e2e8f0;
  --dim: #94a3b8;
  --axis: #64748b;
  --grid: #151b27;
  --acc: #3b82f6;
  --acc-hover: #2563eb;
  --up: #10b981;
  --up-bg: rgba(16, 185, 129, 0.12);
  --up-border: rgba(16, 185, 129, 0.3);
  --dn: #ef4444;
  --dn-bg: rgba(239, 68, 68, 0.12);
  --dn-border: rgba(239, 68, 68, 0.3);
  --warn: #f59e0b;
  --warn-bg: rgba(245, 158, 11, 0.12);
  --flow: #e056fd;
  --sharpe: #00d2d3;
  --header-h: 46px;
  --footer-h: 180px;
  --sidebar-w: 360px;
}

body.light {
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel2: #f1f5f9;
  --panel3: #e2e8f0;
  --inp: #ffffff;
  --line: #cbd5e1;
  --line-light: #94a3b8;
  --fg: #0f172a;
  --dim: #475569;
  --axis: #64748b;
  --grid: #e2e8f0;
  --acc: #2563eb;
  --acc-hover: #1d4ed8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  user-select: none;
}

/* Responsive Base Utility Defaults (Desktop >= 1200px) */
.mobile-only { display: none !important; }
.desktop-only { display: inherit; }
.positions-mobile-cards { display: none; }
.positions-desktop-table { display: block; }
.sidebar-backdrop { display: none; }
#mobile-bottom-bar { display: none; }

/* Header */
#header {
  height: var(--header-h);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
}

.brand .logo-badge {
  background: linear-gradient(135deg, var(--acc), #8b5cf6);
  color: #fff;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
}

.account-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.stat-item .stat-lbl { color: var(--dim); font-size: 11px; }
.stat-item .stat-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-item .stat-val.up { color: var(--up); }
.stat-item .stat-val.dn { color: var(--dn); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Layout Workspace */
#workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

#chart-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

#chart-toolbar {
  height: 38px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

#chart-viewport {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
  position: relative;
}

.chart-column {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--line);
  padding: 4px;
}
.chart-column:last-child { border-right: none; }

.col-head {
  height: 28px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 4px 4px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  font-size: 11px;
  margin-bottom: 2px;
}
.col-title { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.col-title.primary { color: var(--acc); }
.col-title.secondary { color: #a855f7; }

/* Panes */
.pane {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  overflow: hidden;
  margin-bottom: 2px;
}

.pane-title {
  position: absolute;
  top: 5px;
  left: 8px;
  z-index: 10;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--dim);
  background: rgba(11, 14, 20, 0.85);
  padding: 1px 6px;
  border-radius: 3px;
  pointer-events: none;
}
body.light .pane-title { background: rgba(255, 255, 255, 0.85); }

.pane-resizer {
  height: 6px;
  margin: -1px 0;
  cursor: row-resize;
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.pane-resizer::after {
  content: "";
  width: 36px;
  height: 2px;
  background: var(--line);
  border-radius: 1px;
  transition: width .15s, background .15s;
}
.pane-resizer:hover, .pane-resizer.dragging {
  background: rgba(59, 130, 246, 0.15);
}
.pane-resizer:hover::after, .pane-resizer.dragging::after {
  width: 64px;
  height: 3px;
  background: var(--acc);
}

/* Sidebar Terminal */
#sidebar {
  width: var(--sidebar-w);
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 40;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  border-left: none !important;
  padding: 0 !important;
  overflow: hidden !important;
}

/* Docked Reopen Tab for Collapsed Sidebar */
.sidebar-reopen-tab {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 55;
  background: var(--panel2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-right: none;
  border-radius: 6px 0 0 6px;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: -4px 0 14px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sidebar-reopen-tab:hover {
  background: var(--panel3);
  color: var(--acc);
  border-color: var(--acc);
}

.sidebar-reopen-tab.hidden {
  display: none !important;
}

.sidebar-tabs {
  display: flex;
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
}
.sidebar-tab {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  color: var(--dim);
  transition: all .15s;
}
.sidebar-tab:hover { color: var(--fg); }
.sidebar-tab.active {
  color: var(--acc);
  border-bottom-color: var(--acc);
  background: var(--panel);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

/* Order Panel & Risk Calculator */
.order-card {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
}

.order-dir-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.btn-dir {
  padding: 8px 0;
  font-size: 12px;
  font-weight: 700;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--inp);
  color: var(--dim);
  cursor: pointer;
  transition: all .15s;
}
.btn-dir.buy:hover, .btn-dir.buy.active {
  background: var(--up);
  color: #fff;
  border-color: var(--up);
}
.btn-dir.sell:hover, .btn-dir.sell.active {
  background: var(--dn);
  color: #fff;
  border-color: var(--dn);
}

.form-row {
  margin-bottom: 10px;
}
.form-row label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: var(--dim);
  margin-bottom: 4px;
}
.form-row label .hint { font-weight: 400; color: var(--axis); }

.input-group {
  display: flex;
  align-items: center;
  position: relative;
}

input[type=text], input[type=number], select {
  width: 100%;
  background: var(--inp);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 8px;
  color: var(--fg);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
input[type=text]:focus, input[type=number]:focus, select:focus {
  border-color: var(--acc);
}

.risk-summary {
  background: var(--inp);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px;
  margin-top: 10px;
  font-size: 11.5px;
}
.risk-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  color: var(--dim);
}
.risk-row:last-child { margin-bottom: 0; }
.risk-row b { color: var(--fg); font-variant-numeric: tabular-nums; }

.btn-execute {
  width: 100%;
  padding: 10px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  margin-top: 12px;
  color: #fff;
  transition: opacity .15s;
}
.btn-execute.buy { background: var(--up); }
.btn-execute.sell { background: var(--dn); }
.btn-execute:hover { opacity: 0.9; }
.btn-execute:active { transform: scale(0.99); }

/* Indicators list in sidebar */
.ind-item {
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel2);
  overflow: hidden;
}
.ind-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
}
.ind-item-header label { flex: 1; font-size: 12px; font-weight: 600; cursor: pointer; }

.ind-settings-panel {
  padding: 10px;
  background: var(--inp);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 8px;
  align-items: center;
  font-size: 11px;
}
.ind-grp-title {
  grid-column: span 2;
  font-size: 10px;
  font-weight: 700;
  color: var(--acc);
  text-transform: uppercase;
  margin-top: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}
.ind-grp-title:first-child { margin-top: 0; padding-top: 0; border-top: none; }

/* Positions Drawer */
#positions-drawer {
  height: var(--footer-h);
  background: var(--panel);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 45;
  transition: height 0.2s ease, min-height 0.2s ease;
}

#positions-drawer.collapsed {
  height: 32px !important;
  min-height: 32px !important;
  max-height: 32px !important;
}

#positions-drawer.collapsed .drawer-content {
  display: none !important;
}

#positions-drawer.collapsed .drawer-header {
  border-bottom: none;
}

.drawer-header {
  height: 32px;
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}

.drawer-header:hover {
  background: var(--panel3);
}

#btn-toggle-positions-drawer {
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

#positions-drawer.collapsed #btn-toggle-positions-drawer {
  background: var(--panel3);
  border-color: var(--line-light);
  color: var(--fg);
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  text-align: left;
}
table.data-table th {
  background: var(--panel);
  color: var(--dim);
  font-weight: 600;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
table.data-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
table.data-table tr:hover { background: var(--panel2); }

.badge {
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
}
.badge.buy { background: var(--up-bg); color: var(--up); border: 1px solid var(--up-border); }
.badge.sell { background: var(--dn-bg); color: var(--dn); border: 1px solid var(--dn-border); }

/* Buttons */
.btn {
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all .15s;
}
.btn:hover { background: var(--panel3); border-color: var(--line-light); }
.btn.on { background: var(--acc); color: #fff; border-color: var(--acc); }
.btn.sm { padding: 2px 6px; font-size: 10.5px; }
.btn.danger { background: var(--dn-bg); color: var(--dn); border-color: var(--dn-border); }
.btn.danger:hover { background: var(--dn); color: #fff; }

.hidden { display: none !important; }

/* On-Chart Dashboard HUD */
.chart-dashboard-hud {
  position: absolute;
  top: 10px;
  right: 75px;
  z-index: 25;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(51, 65, 85, 0.8);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11px;
  min-width: 220px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  user-select: none;
}

body.light .chart-dashboard-hud {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(203, 213, 225, 0.9);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.chart-dashboard-hud .hud-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin-bottom: 6px;
  font-weight: 700;
  font-size: 11px;
  color: #fff;
}

body.light .chart-dashboard-hud .hud-header {
  color: #0f172a;
}

.chart-dashboard-hud .hud-badge {
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.chart-dashboard-hud .hud-body {
  display: flex;
  flex-direction: column;
  gap: 3.5px;
}

.chart-dashboard-hud .hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10.5px;
}

.chart-dashboard-hud .hud-lbl {
  color: var(--dim);
}

.chart-dashboard-hud .hud-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}

.chart-dashboard-hud .hud-val.up { color: var(--up); }
.chart-dashboard-hud .hud-val.dn { color: var(--dn); }
.chart-dashboard-hud .hud-val.warn { color: var(--warn); }

.chart-dashboard-hud .hud-apply-btn {
  margin-top: 8px;
  width: 100%;
  justify-content: center;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(16, 185, 129, 0.2));
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #60a5fa;
  font-weight: 700;
  font-size: 10.5px;
  padding: 4px 6px;
}

.chart-dashboard-hud .hud-apply-btn:hover {
  background: linear-gradient(135deg, #3b82f6, #10b981);
  color: #fff;
}

/* Dual Timeframe Toolbar Groups */
.tf-selector-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.tf-selector-group.primary {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.tf-selector-group.secondary {
  background: rgba(168, 85, 247, 0.08);
  border: 1px solid rgba(168, 85, 247, 0.2);
}

.tf-selector-group .tf-lbl {
  font-size: 10.5px;
  font-weight: 700;
  margin-right: 2px;
}

.tf-selector-group.primary .tf-lbl { color: var(--acc); }
.tf-selector-group.secondary .tf-lbl { color: #c084fc; }

/* Column Header Timeframe Pills */
.col-tf-pills {
  display: flex;
  gap: 2px;
  margin-left: 6px;
}

.tf-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  color: var(--dim);
  font-size: 9.5px;
  font-weight: 600;
  padding: 1px 5px;
  cursor: pointer;
  transition: all .15s;
}

.tf-pill:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--fg);
}

.tf-pill.active {
  background: var(--acc);
  border-color: var(--acc);
  color: #fff;
  font-weight: 700;
}

/* Indicator Target Segmented Control */
.ind-target-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  background: var(--inp);
  padding: 3px;
  border-radius: 5px;
  border: 1px solid var(--line);
  margin-bottom: 10px;
}

.target-btn {
  background: transparent;
  border: none;
  border-radius: 3px;
  color: var(--dim);
  font-size: 10px;
  font-weight: 600;
  padding: 5px 2px;
  cursor: pointer;
  text-align: center;
  transition: all .15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.target-btn:hover {
  color: var(--fg);
}

.target-btn.active {
  background: var(--acc);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* Trade Canvas Overlay */
.pane-trade-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* Shift-drag price/percent/pip measurement overlay — sits above the trade
   overlay so the measurement box is visible on top of trade boxes. Purely
   visual: pointer-events stays off here, the actual drag is handled by a
   mousedown/mousemove/mouseup listener on the pane element itself (see
   setupMeasureTool in chart.js), not on this canvas. */
.pane-measure-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
}

/* Alerts panel */
.hint {
  font-size: 11px;
  color: var(--axis);
  line-height: 1.4;
}
.alert-section {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 12px;
}
.alert-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}
.alert-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.alert-card:last-child {
  margin-bottom: 0;
}

/* Dual HTF Confluence HUD Strip */
.htf-hud-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
  padding: 4px 14px;
  font-size: 11px;
  min-height: 30px;
  overflow-x: auto;
  white-space: nowrap;
}
.htf-badge-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.htf-mode-select {
  background: var(--inp);
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
}
.htf-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.htf-sub {
  color: var(--dim);
  font-weight: 700;
  font-size: 10.5px;
}
.htf-val {
  font-weight: 800;
  font-size: 11.5px;
}
.htf-grade-badge {
  margin-left: auto;
  padding: 3px 10px;
  border-radius: 4px;
  border: 1px solid transparent;
  font-size: 11px;
  letter-spacing: 0.3px;
}

/* 1M Confluence Scorecard inside Order Panel */
.confluence-scorecard {
  margin-bottom: 10px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
}
.btn-execute.caution {
  opacity: 0.85;
  filter: saturate(0.7);
  border: 1px dashed var(--warn);
}

/* High-Impact Economic News & Session Barometer Strip */
.news-hud-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 4px 14px;
  font-size: 11px;
  min-height: 28px;
  overflow-x: auto;
  white-space: nowrap;
}
.news-title-tag {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 800;
  color: #ef4444;
  letter-spacing: 0.3px;
}
.news-badge-red {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 10.5px;
}
.news-session-badge {
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--dim);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 10.5px;
}
.news-countdown {
  font-weight: 800;
  color: var(--fg);
  font-family: monospace;
  font-size: 11.5px;
}
.news-details {
  color: var(--dim);
  font-size: 10.5px;
}
.news-btn-schedule {
  margin-left: auto;
  background: var(--inp);
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 10.5px;
  font-weight: 600;
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
}
.news-btn-schedule:hover {
  background: var(--panel2);
  border-color: var(--accent);
}

/* Modal Overlay & News Schedule Table */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay.hidden {
  display: none !important;
}
.news-schedule-content {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 90%;
  max-width: 820px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-body {
  padding: 14px 16px;
  overflow-y: auto;
}
.news-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.news-table th {
  text-align: left;
  padding: 6px 8px;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
}
.news-table td {
  padding: 8px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.news-table tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Floating 10-minute Imminent News Alert Banner */
.news-alert-banner {
  position: fixed;
  top: 42px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26, 15, 15, 0.95);
  border: 1px solid #ef4444;
  border-radius: 6px;
  padding: 8px 16px;
  z-index: 10000;
  box-shadow: 0 4px 25px rgba(239, 68, 68, 0.45);
  color: var(--fg);
  font-size: 11.5px;
  display: flex;
  align-items: center;
  backdrop-filter: blur(6px);
  animation: newsSlideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes newsSlideDown {
  from { top: 10px; opacity: 0; }
  to { top: 42px; opacity: 1; }
}

/* Stale Data Floating Watchdog Banner */
.stale-data-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #dc2626;
  color: #fff;
  text-align: center;
  font-size: 11.5px;
  font-weight: 700;
  padding: 5px 12px;
  z-index: 99999;
  box-shadow: 0 2px 12px rgba(220, 38, 38, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.2px;
}
.stale-data-banner.hidden {
  display: none !important;
}

/* ==========================================================================
   Responsive Breakpoint Architecture & Mobile Experience
   - Desktop: >= 1200px (Default base styles, pixel-identical)
   - Tablet:  700px - 1199px (Middle layout)
   - Mobile:  <= 699px (Phone optimized layout)
   ========================================================================== */

/* --------------------------------------------------------------------------
   Tablet Breakpoint (700px - 1199px)
   -------------------------------------------------------------------------- */
@media (max-width: 1199px) and (min-width: 700px) {
  :root {
    --sidebar-w: 300px;
    --footer-h: 160px;
  }

  #header {
    padding: 0 10px;
  }

  .account-strip {
    gap: 8px;
    font-size: 11px;
  }

  .header-actions {
    gap: 4px;
  }

  .header-actions .btn.sm {
    padding: 3px 6px;
    font-size: 10.5px;
  }

  #chart-toolbar {
    padding: 0 8px;
  }

  .tf-selector-group {
    font-size: 10px;
  }
}

/* --------------------------------------------------------------------------
   Mobile Breakpoint (<= 699px)
   -------------------------------------------------------------------------- */
@media (max-width: 699px) {
  :root {
    --header-h: auto;
    --footer-h: 32px;
    --sidebar-w: min(340px, 86vw);
  }

  html, body {
    height: 100% !important;
    height: 100dvh !important;
    min-height: 100% !important;
    overflow: hidden !important;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }

  .desktop-only { display: none !important; }
  .mobile-only { display: inline-flex !important; }

  /* Header Layout */
  #header {
    height: auto !important;
    min-height: 48px;
    flex-direction: column;
    align-items: stretch;
    padding: 6px 10px 8px;
    gap: 6px;
    border-bottom: 1px solid var(--line);
    position: relative;
    z-index: 100;
  }

  #header .brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    font-size: 13px;
  }

  #header .brand-name {
    font-size: 11.5px;
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
  }

  #header .account-strip {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 4px 8px;
    background: var(--panel2);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 11px;
    width: 100%;
  }

  #header .stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  /* Overflow Menu Modal */
  .mobile-overflow-content {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    width: 90%;
    max-width: 380px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
  }

  .overflow-menu-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
  }

  .overflow-menu-actions .btn {
    min-height: 44px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 14px;
  }

  /* Workspace & Layout */
  #workspace {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain;
    contain: content;
    will-change: scroll-position;
    padding-bottom: 54px;
  }

  #chart-area {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    height: auto !important;
    min-height: min-content !important;
    overflow: visible !important;
  }

  /* Toolbar */
  #chart-toolbar {
    height: auto !important;
    min-height: 40px;
    padding: 4px 8px;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }

  #chart-toolbar .toolbar-group:not(.desktop-only) {
    width: 100%;
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 6px;
    overflow-x: auto !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }

  #chart-toolbar .toolbar-group.desktop-only {
    display: none !important;
  }

  /* Hide bulky dual date-range input on small mobile screens */
  #wrap-date-range {
    display: none !important;
  }

  /* Clean up horizontal scrollbars on mobile HUDs & toolbars */
  #chart-toolbar .toolbar-group::-webkit-scrollbar,
  .htf-hud-strip::-webkit-scrollbar,
  .news-hud-strip::-webkit-scrollbar,
  .col-tf-pills::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
  }

  #chart-toolbar .toolbar-group,
  .htf-hud-strip,
  .news-hud-strip,
  .col-tf-pills {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }

  .mobile-chart-segmented-control {
    display: flex !important;
    background: var(--panel2);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 2px;
    gap: 2px;
  }

  .mobile-chart-segmented-control .segment-btn {
    border: none;
    background: transparent;
    color: var(--dim);
    font-size: 11px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    min-height: 36px;
  }

  .mobile-chart-segmented-control .segment-btn.active {
    background: var(--acc);
    color: #fff;
  }

  .tf-selector-group {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
  }

  .tf-btn, .btn.sm, .tf-pill {
    min-height: 36px;
    min-width: 36px;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Single-Chart Mode on Mobile: Natural Height & Scroll */
  #chart-viewport {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    height: auto !important;
    min-height: min-content !important;
    max-height: none !important;
    overflow: visible !important;
    position: relative;
  }

  .chart-column {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    height: auto !important;
    min-height: min-content !important;
    max-height: none !important;
    border-right: none !important;
    padding: 4px;
    overflow: visible !important;
  }

  .chart-column.mobile-hidden,
  .mobile-hidden {
    display: none !important;
    pointer-events: none !important;
  }

  .col-head {
    height: 32px;
    padding: 0 6px;
  }

  .col-tf-pills {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    display: flex;
    gap: 2px;
  }

  /* Off-Canvas Sidebar Drawer */
  #sidebar {
    position: fixed !important;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--sidebar-w);
    max-width: 86vw;
    height: 100vh;
    height: 100dvh;
    z-index: 1050;
    background: var(--panel);
    border-left: 1px solid var(--line);
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
  }

  #sidebar.open {
    transform: translateX(0) !important;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(3px);
    z-index: 1040;
    display: none;
  }

  .sidebar-backdrop:not(.hidden) {
    display: block !important;
  }

  .sidebar-drawer-header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--panel2);
    border-bottom: 1px solid var(--line);
    font-size: 13px;
  }

  .sidebar-drawer-header .btn {
    min-height: 38px;
    min-width: 38px;
  }

  .sidebar-tabs {
    min-height: 42px;
  }

  .sidebar-tab {
    padding: 12px 0;
    font-size: 12.5px;
  }

  /* Indicator Subpanes (Accordion / Collapsible) */
  .pane {
    contain: layout paint;
    transition: height 0.2s ease;
    border-radius: 6px;
    margin-bottom: 6px !important;
  }

  .pane[data-pane-type="price"] {
    min-height: 350px !important;
  }

  .pane:not([data-pane-type="price"]) {
    min-height: 160px;
  }

  .pane.collapsed {
    height: 32px !important;
    min-height: 32px !important;
    cursor: pointer;
  }

  .pane.collapsed canvas {
    visibility: hidden !important;
    pointer-events: none !important;
  }

  .pane.collapsed .pane-resizer {
    display: none !important;
  }

  .pane:not([data-pane-type="price"]) .pane-title::before {
    content: "▼ ";
    font-size: 8.5px;
    color: var(--accent);
    margin-right: 4px;
    transition: transform 0.2s ease;
  }

  .pane.collapsed .pane-title::before {
    content: "▶ ";
    color: var(--dim);
  }

  .pane-title {
    pointer-events: auto !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 28px;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 4px;
    background: rgba(17, 22, 34, 0.9);
    border: 1px solid var(--line);
    user-select: none;
    -webkit-user-select: none;
  }

  /* Positions Drawer & Stacked Cards */
  #positions-drawer {
    transition: height 0.2s ease;
    z-index: 900;
  }

  #positions-drawer.collapsed {
    height: 32px !important;
  }

  #positions-drawer.collapsed .drawer-content {
    display: none !important;
  }

  #positions-drawer:not(.collapsed) {
    height: 240px !important;
  }

  .positions-desktop-table { display: none !important; }
  .positions-mobile-cards {
    display: flex !important;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
  }

  .position-card {
    background: var(--panel2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .pos-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .pos-card-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
    font-size: 11.5px;
    background: var(--inp);
    border: 1px solid var(--line);
    padding: 8px 10px;
    border-radius: 6px;
  }

  .pos-card-stat {
    display: flex;
    justify-content: space-between;
  }

  .pos-card-stat .lbl { color: var(--dim); font-size: 10.5px; }
  .pos-card-stat .val { font-weight: 700; font-variant-numeric: tabular-nums; }

  .pos-card-actions {
    display: flex;
    gap: 8px;
  }

  .pos-card-actions .btn {
    flex: 1;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
  }

  .pos-mobile-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 4px 6px;
    border-bottom: 1px solid var(--line);
    font-size: 12px;
    font-weight: 700;
  }

  /* Mobile Floating Bottom Bar */
  #mobile-bottom-bar {
    position: fixed !important;
    bottom: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: var(--panel);
    border-top: 1px solid var(--line);
    display: flex !important;
    align-items: center;
    justify-content: space-around;
    padding: 4px 8px;
    z-index: 950;
    gap: 6px;
  }

  .mobile-bar-btn {
    flex: 1;
    height: 38px;
    font-size: 11px;
    font-weight: 700;
    padding: 0 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--panel2);
    border: 1px solid var(--line);
    color: var(--fg);
  }

  .mobile-bar-btn:active {
    background: var(--acc);
    color: #fff;
  }

  /* Touch Targets & Inputs */
  input, select, button {
    touch-action: manipulation;
  }

  .ind-item-header {
    min-height: 42px;
  }

  .ind-item-header input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--acc);
  }

  /* Mobile Touch Gestures & Scroll Rules */
  .pane, .pane canvas {
    touch-action: pan-y pinch-zoom !important;
  }

  .sidebar-content,
  .drawer-content,
  .positions-mobile-cards,
  .overflow-menu-actions,
  .modal-body {
    touch-action: pan-y !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain;
  }

  #chart-toolbar .toolbar-group,
  .col-tf-pills {
    touch-action: pan-x !important;
    -webkit-overflow-scrolling: touch !important;
  }
}



