/* ========================================
   Arcus Terminal – Design System
   ======================================== */
:root {
  --bg-primary: #0a0f0d;
  --bg-secondary: #0f1613;
  --bg-card: #111a16;
  --bg-card-hover: #162019;
  --bg-elevated: #1a2520;
  --bg-input: #0d1510;
  --bg-panel: #0e1411;
  --border-subtle: rgba(7, 201, 131, 0.08);
  --border-default: rgba(7, 201, 131, 0.12);
  --border-hover: rgba(7, 201, 131, 0.2);
  --border-input: rgba(255, 255, 255, 0.08);
  --border-input-focus: rgba(7, 201, 131, 0.5);
  --text-primary: #e8f0ec;
  --text-secondary: #8a9e92;
  --text-tertiary: #5a6e62;
  --text-accent: #07C983;
  --accent: #07C983;
  --accent-dim: rgba(7, 201, 131, 0.15);
  --accent-dark: #16A34A;
  --long: #07C983;
  --long-bg: rgba(7, 201, 131, 0.1);
  --long-hover: rgba(7, 201, 131, 0.2);
  --short: #ef4444;
  --short-bg: rgba(239, 68, 68, 0.1);
  --short-hover: rgba(239, 68, 68, 0.2);
  --positive: #07C983;
  --negative: #ef4444;
  --warning: #fbbf24;
  --space-xs: 4px; --space-sm: 8px; --space-md: 16px; --space-lg: 24px; --space-xl: 32px; --space-2xl: 48px; --space-3xl: 64px;
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-xl: 20px; --radius-full: 9999px;
  --shadow-card: 0 2px 8px rgba(0,0,0,0.3), 0 0 0 1px var(--border-subtle);
  --shadow-elevated: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px var(--border-default);
  --shadow-glow: 0 0 20px rgba(7,201,131,0.15);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { font-family: var(--font-sans); background: var(--bg-primary); color: var(--text-primary); min-height: 100vh; overflow-x: hidden; position: relative; }

/* Animated BG */
.bg-grid { position: fixed; inset: 0; background-image: linear-gradient(rgba(7,201,131,0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(7,201,131,0.03) 1px, transparent 1px); background-size: 60px 60px; pointer-events: none; z-index: 0; }
.bg-glow { position: fixed; border-radius: 50%; filter: blur(120px); pointer-events: none; z-index: 0; animation: glow-drift 20s ease-in-out infinite alternate; }
.bg-glow-1 { width: 600px; height: 600px; background: radial-gradient(circle, rgba(7,201,131,0.08), transparent 70%); top: -200px; right: -100px; }
.bg-glow-2 { width: 500px; height: 500px; background: radial-gradient(circle, rgba(22,163,74,0.06), transparent 70%); bottom: -200px; left: -100px; animation-delay: -10s; }
@keyframes glow-drift { 0% { transform: translate(0,0) scale(1); } 100% { transform: translate(30px,20px) scale(1.1); } }

/* App */
.app { position: relative; z-index: 1; max-width: 1600px; margin: 0 auto; padding: 0 var(--space-lg); min-height: 100vh; display: flex; flex-direction: column; }

/* Header */
.header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-md) 0; border-bottom: 1px solid var(--border-subtle); gap: var(--space-md); flex-wrap: wrap; }
.header-left { display: flex; align-items: center; gap: var(--space-lg); }
.header-right { display: flex; align-items: center; gap: var(--space-sm); }
.logo { display: flex; align-items: center; gap: var(--space-sm); }
.logo-icon { display: flex; align-items: center; }
.logo-text { display: flex; flex-direction: column; line-height: 1; }
.logo-name { font-weight: 700; font-size: 1.125rem; color: var(--text-primary); letter-spacing: -0.02em; }
.logo-sub { font-size: 0.625rem; color: var(--text-tertiary); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; margin-top: 2px; }

/* Nav Tabs */
.nav-tabs { display: flex; gap: 2px; background: var(--bg-elevated); border-radius: var(--radius-sm); padding: 2px; }
.nav-tab { display: flex; align-items: center; gap: 6px; padding: 7px 14px; border: none; border-radius: 6px; background: transparent; color: var(--text-tertiary); font-family: var(--font-sans); font-size: 0.8125rem; font-weight: 500; cursor: pointer; transition: all 0.2s var(--ease-out); white-space: nowrap; }
.nav-tab:hover { color: var(--text-secondary); }
.nav-tab.active { background: var(--bg-card); color: var(--text-primary); box-shadow: 0 1px 3px rgba(0,0,0,0.3); }

/* Network */
.network-badge { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--radius-full); background: var(--accent-dim); border: 1px solid var(--border-default); font-size: 0.75rem; font-weight: 600; color: var(--text-accent); letter-spacing: 0.02em; }
.network-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px var(--accent); animation: pulse-dot 2s ease-in-out infinite; }
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Buttons */
.btn-icon { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 1px solid var(--border-default); border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); cursor: pointer; transition: all 0.2s var(--ease-out); }
.btn-icon:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border-hover); }
.btn-primary { flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: var(--space-sm); padding: 12px 24px; border: none; border-radius: var(--radius-md); background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff; font-family: var(--font-sans); font-size: 0.875rem; font-weight: 600; cursor: pointer; transition: all 0.2s var(--ease-out); position: relative; overflow: hidden; }
.btn-primary::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent); opacity: 0; transition: opacity 0.2s; }
.btn-primary:hover::before { opacity: 1; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(7,201,131,0.3); }
.btn-primary:active { transform: translateY(0); }
.btn-primary.full { width: 100%; }
.btn-primary.loading .btn-text { opacity: 0; }
.btn-primary.loading .btn-loader { display: block; }
.btn-loader { display: none; position: absolute; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-secondary { display: flex; align-items: center; gap: 6px; padding: 8px 16px; border: 1px solid var(--border-default); border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); font-family: var(--font-sans); font-size: 0.8125rem; font-weight: 500; cursor: pointer; transition: all 0.2s var(--ease-out); }
.btn-secondary:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border-hover); }

/* Tab content */
.tab-content { display: none; animation: fade-in 0.3s var(--ease-out); }
.tab-content.active { display: block; }

/* Sections */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-lg); flex-wrap: wrap; gap: var(--space-md); }
.section-title { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }
.account-address { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-tertiary); background: var(--bg-elevated); padding: 6px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-subtle); cursor: pointer; transition: all 0.2s; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-address:hover { border-color: var(--border-hover); color: var(--text-secondary); }

/* Stats */
.account-section { padding-bottom: var(--space-xl); animation: slide-up 0.5s var(--ease-out); }
.stats-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--space-md); }
.stat-card { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: var(--space-lg); transition: all 0.3s var(--ease-out); position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--accent), transparent); opacity: 0; transition: opacity 0.3s; }
.stat-card:hover { border-color: var(--border-hover); background: var(--bg-card-hover); transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.stat-card:hover::before { opacity: 1; }
.stat-label { font-size: 0.75rem; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; margin-bottom: var(--space-sm); }
.stat-value { font-size: 1.5rem; font-weight: 700; font-family: var(--font-mono); letter-spacing: -0.02em; }
.stat-value.accent { color: var(--text-accent); }

/* Long/Short ratio bar inside stat card */
.ls-bar-track { display: flex; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.05); margin-top: 8px; overflow: hidden; }
.ls-bar-long { height: 100%; background: var(--long); transition: width 0.3s var(--ease-out); }
.ls-bar-short { height: 100%; background: var(--short); transition: width 0.3s var(--ease-out); }

/* Dashboard Charts Grid */
.dashboard-charts-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: var(--space-md); margin-top: var(--space-lg); }
.chart-card { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: var(--space-lg); display: flex; flex-direction: column; }
.chart-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-md); flex-wrap: wrap; gap: var(--space-sm); }
.chart-card-title { display: flex; align-items: center; gap: 8px; font-size: 0.8125rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); }

.chart-card-header-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.equity-mode-selector { display: inline-flex; align-items: center; gap: 2px; background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: 6px; padding: 2px; }
.equity-mode-btn { padding: 4px 10px; border: none; border-radius: 4px; background: transparent; color: var(--text-tertiary); font-family: var(--font-sans); font-size: 0.75rem; font-weight: 600; cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.equity-mode-btn:hover { color: var(--text-secondary); }
.equity-mode-btn.active { background: var(--bg-card); color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,0.3); border: 1px solid rgba(7, 201, 131, 0.25); }

.equity-tf-group { display: flex; gap: 2px; background: var(--bg-elevated); border-radius: 6px; padding: 2px; }
.equity-tf-btn { padding: 4px 10px; border: none; border-radius: 4px; background: transparent; color: var(--text-tertiary); font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.equity-tf-btn:hover { color: var(--text-secondary); }
.equity-tf-btn.active { background: var(--bg-card); color: var(--text-primary); box-shadow: 0 1px 3px rgba(0,0,0,0.3); }

.dashboard-canvas-wrapper { position: relative; flex: 1; min-height: 220px; width: 100%; }
.equity-history-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--text-tertiary); font-size: 0.8125rem; }

.pies-wrapper { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); flex: 1; }
.pie-box { display: flex; flex-direction: column; align-items: center; background: var(--bg-elevated); border-radius: var(--radius-sm); padding: var(--space-md); position: relative; }
.pie-title { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.pie-title.long { color: var(--long); }
.pie-title.short { color: var(--short); }
.pie-canvas-container { position: relative; width: 100%; height: 160px; display: flex; align-items: center; justify-content: center; }
.pie-empty-text { font-size: 0.75rem; color: var(--text-tertiary); text-align: center; }
.pie-total-notional { margin-top: var(--space-sm); text-align: center; font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 600; padding: 5px 10px; background: var(--bg-elevated); border-radius: var(--radius-sm); border: 1px solid var(--border-subtle); }
.pie-total-notional.long { color: var(--long); }
.pie-total-notional.short { color: var(--short); }

/* Table */
.positions-section { padding-bottom: var(--space-2xl); animation: slide-up 0.5s var(--ease-out) 0.1s both; }
.empty-state { text-align: center; padding: var(--space-3xl) var(--space-lg); animation: fade-in 0.5s var(--ease-out); }
.empty-icon { color: var(--text-tertiary); margin-bottom: var(--space-lg); opacity: 0.5; }
.empty-text { font-size: 1.125rem; font-weight: 600; color: var(--text-secondary); margin-bottom: var(--space-sm); }
.empty-sub { font-size: 0.875rem; color: var(--text-tertiary); }
.table-container { overflow-x: auto; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--bg-card); box-shadow: var(--shadow-card); animation: slide-up 0.5s var(--ease-out); }
.positions-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.positions-table th { padding: 14px 16px; text-align: left; font-weight: 600; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-tertiary); background: var(--bg-elevated); border-bottom: 1px solid var(--border-default); white-space: nowrap; }
.positions-table th.sortable { cursor: pointer; user-select: none; transition: color 0.15s; }
.positions-table th.sortable:hover { color: var(--text-primary); }
.positions-table th.active-sort { color: var(--text-accent); }
.sort-icon { display: inline-block; margin-left: 4px; font-size: 0.6875rem; color: var(--text-tertiary); }
.positions-table th.active-sort .sort-icon { color: var(--text-accent); }
.positions-table th:first-child { border-radius: var(--radius-lg) 0 0 0; }
.positions-table th:last-child { border-radius: 0 var(--radius-lg) 0 0; }
.positions-table td { padding: 16px 16px; border-bottom: 1px solid var(--border-subtle); white-space: nowrap; vertical-align: middle; }
.positions-table tbody tr { transition: background 0.15s; }
.positions-table tbody tr:hover { background: rgba(7,201,131,0.03); }
.positions-table tbody tr:last-child td { border-bottom: none; }
.r { text-align: right !important; }
.market-cell { display: flex; align-items: center; gap: var(--space-sm); }
.market-name { font-weight: 600; color: var(--text-primary); font-size: 0.875rem; }
.market-id { font-size: 0.6875rem; color: var(--text-tertiary); font-family: var(--font-mono); }
.side-badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: var(--radius-full); font-size: 0.6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.side-badge.long { background: var(--long-bg); color: var(--long); border: 1px solid rgba(7,201,131,0.2); }
.side-badge.short { background: var(--short-bg); color: var(--short); border: 1px solid rgba(239,68,68,0.2); }
.mono { font-family: var(--font-mono); font-size: 0.8125rem; }
.positive { color: var(--positive); }
.negative { color: var(--negative); }
.leverage-badge { display: inline-flex; padding: 3px 8px; border-radius: var(--radius-sm); font-size: 0.75rem; font-weight: 600; font-family: var(--font-mono); background: rgba(255,255,255,0.05); border: 1px solid var(--border-subtle); color: var(--text-secondary); }
.mode-badge { font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-tertiary); }

/* ==================== TRADE TAB ==================== */
.trade-layout { display: grid; grid-template-columns: 1fr 380px; gap: 0; min-height: calc(100vh - 140px); margin: 0 calc(-1 * var(--space-lg)); }
.trade-main { display: flex; flex-direction: column; border-right: 1px solid var(--border-subtle); overflow: hidden; }

/* Market bar */
.market-bar { display: flex; align-items: center; gap: var(--space-lg); padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--border-subtle); flex-wrap: wrap; }
.market-selector { position: relative; }
.market-select-btn { display: flex; align-items: center; gap: var(--space-sm); padding: 8px 14px; border: 1px solid var(--border-default); border-radius: var(--radius-sm); background: var(--bg-elevated); color: var(--text-primary); font-family: var(--font-sans); font-size: 1rem; font-weight: 700; cursor: pointer; transition: all 0.2s; }
.market-select-btn:hover { border-color: var(--border-hover); background: var(--bg-card-hover); }
.market-dropdown { position: absolute; top: calc(100% + 4px); left: 0; width: 280px; max-height: 400px; background: var(--bg-card); border: 1px solid var(--border-default); border-radius: var(--radius-md); box-shadow: var(--shadow-elevated); z-index: 100; overflow: hidden; display: flex; flex-direction: column; }
.market-search { width: 100%; padding: 12px 16px; background: var(--bg-input); border: none; border-bottom: 1px solid var(--border-subtle); color: var(--text-primary); font-family: var(--font-sans); font-size: 0.875rem; outline: none; }
.market-search::placeholder { color: var(--text-tertiary); }
.market-list { overflow-y: auto; max-height: 340px; }
.market-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; cursor: pointer; transition: background 0.15s; border-bottom: 1px solid var(--border-subtle); }
.market-item:hover { background: var(--bg-card-hover); }
.market-item.active { background: var(--accent-dim); }
.market-item-name { font-weight: 600; font-size: 0.875rem; }
.market-item-id { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--text-tertiary); }

/* Market info */
.market-info { display: flex; align-items: center; gap: var(--space-xl); flex: 1; }
.market-price-display { display: flex; align-items: baseline; gap: var(--space-sm); }
.market-price { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 700; color: var(--text-primary); }
.market-stat { display: flex; flex-direction: column; gap: 2px; }
.market-stat-label { font-size: 0.625rem; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.market-stat-value { font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 500; color: var(--text-secondary); }

/* Timeframe bar */
.tf-bar { display: flex; align-items: center; padding: var(--space-sm) var(--space-lg); border-bottom: 1px solid var(--border-subtle); gap: var(--space-md); }
.tf-group { display: flex; gap: 2px; background: var(--bg-elevated); border-radius: 6px; padding: 2px; }
.tf-btn { padding: 5px 12px; border: none; border-radius: 4px; background: transparent; color: var(--text-tertiary); font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.tf-btn:hover { color: var(--text-secondary); }
.tf-btn.active { background: var(--bg-card); color: var(--text-primary); box-shadow: 0 1px 3px rgba(0,0,0,0.3); }

/* Chart */
.chart-container {
  flex: 0 0 auto;
  width: 100%;
  height: clamp(400px, 52vh, 620px);
  min-height: 400px;
  position: relative;
  background: var(--bg-primary);
  contain: layout paint;
}
.chart-container.order-line-hover { cursor: ns-resize; }
.chart-container.dragging-order-line {
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
}
.order-line-labels { position: absolute; inset: 0; z-index: 4; overflow: hidden; pointer-events: none; }
.order-line-label { position: absolute; top: 0; left: 0; display: inline-flex; align-items: center; min-height: 25px; padding: 2px 9px; border-radius: 3px; background: var(--order-line-color); color: #fff; font: 500 0.8125rem var(--font-mono); letter-spacing: .01em; white-space: nowrap; box-shadow: 0 1px 5px rgba(0,0,0,.26); }
.chart-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: var(--space-md); color: var(--text-tertiary); font-size: 0.875rem; }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border-default); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }

/* Trade panel */
.trade-panel { background: var(--bg-panel); overflow-y: auto; max-height: calc(100vh - 140px); }
.trade-panel-inner { padding: var(--space-lg); display: flex; flex-direction: column; gap: var(--space-lg); }
.panel-section { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: var(--space-lg); }
.panel-section-title { display: flex; align-items: center; gap: var(--space-sm); font-size: 0.8125rem; font-weight: 600; color: var(--text-secondary); margin-bottom: var(--space-lg); text-transform: uppercase; letter-spacing: 0.04em; }

/* Auth */
.auth-status { display: flex; align-items: center; gap: var(--space-sm); font-size: 0.8125rem; color: var(--text-tertiary); margin-bottom: var(--space-md); padding: 8px 12px; background: var(--bg-elevated); border-radius: var(--radius-sm); }
.auth-dot { width: 6px; height: 6px; border-radius: 50%; }
.auth-dot.disconnected { background: var(--negative); }
.auth-dot.connected { background: var(--positive); box-shadow: 0 0 6px var(--positive); animation: pulse-dot 2s ease-in-out infinite; }
.auth-error { margin-top: var(--space-md); font-size: 0.8125rem; color: var(--negative); min-height: 16px; }

/* Forms */
.form-group { margin-bottom: var(--space-md); }
.form-group.row { display: flex; align-items: center; justify-content: space-between; }
.form-label { display: block; font-size: 0.6875rem; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.form-input { width: 100%; padding: 10px 12px; background: var(--bg-input); border: 1px solid var(--border-input); border-radius: var(--radius-sm); color: var(--text-primary); font-family: var(--font-sans); font-size: 0.875rem; outline: none; transition: border-color 0.2s; }
.form-input:focus { border-color: var(--border-input-focus); }
.form-input::placeholder { color: var(--text-tertiary); }
.form-input.mono { font-family: var(--font-mono); font-size: 0.8125rem; }
.form-hint { display: flex; align-items: flex-start; gap: 6px; margin-top: 6px; font-size: 0.6875rem; color: var(--text-tertiary); line-height: 1.4; }
.form-hint svg { flex-shrink: 0; margin-top: 1px; }
.input-with-suffix { position: relative; display: flex; align-items: center; }
.input-with-suffix .form-input { padding-right: 50px; }
.input-suffix { position: absolute; right: 12px; font-size: 0.75rem; font-weight: 600; color: var(--text-tertiary); pointer-events: none; }

/* Side tabs */
.side-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: var(--space-lg); background: var(--bg-elevated); border-radius: var(--radius-sm); padding: 3px; }
.side-tab { padding: 10px; border: none; border-radius: 6px; font-family: var(--font-sans); font-size: 0.8125rem; font-weight: 700; cursor: pointer; transition: all 0.2s; text-transform: uppercase; letter-spacing: 0.04em; }
.side-tab.buy { background: transparent; color: var(--text-tertiary); }
.side-tab.buy.active { background: var(--long-bg); color: var(--long); border: 1px solid rgba(7,201,131,0.2); }
.side-tab.buy:not(.active):hover { color: var(--long); }
.side-tab.sell { background: transparent; color: var(--text-tertiary); }
.side-tab.sell.active { background: var(--short-bg); color: var(--short); border: 1px solid rgba(239,68,68,0.2); }
.side-tab.sell:not(.active):hover { color: var(--short); }

/* Select group */
.select-group { display: flex; gap: 4px; background: var(--bg-elevated); border-radius: var(--radius-sm); padding: 3px; }
.select-btn { flex: 1; padding: 7px 10px; border: none; border-radius: 5px; background: transparent; color: var(--text-tertiary); font-family: var(--font-sans); font-size: 0.75rem; font-weight: 600; cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.select-btn:hover { color: var(--text-secondary); }
.select-btn.active { background: var(--bg-card); color: var(--text-primary); box-shadow: 0 1px 3px rgba(0,0,0,0.3); }

/* Toggle */
.toggle { position: relative; display: inline-block; width: 36px; height: 20px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--bg-elevated); border: 1px solid var(--border-default); border-radius: 20px; transition: all 0.2s; }
.toggle-slider::before { content: ''; position: absolute; width: 14px; height: 14px; left: 2px; bottom: 2px; background: var(--text-tertiary); border-radius: 50%; transition: all 0.2s; }
.toggle input:checked + .toggle-slider { background: var(--accent-dim); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); background: var(--accent); }

/* Order summary */
.order-summary { padding: var(--space-md); background: var(--bg-elevated); border-radius: var(--radius-sm); margin-bottom: var(--space-md); }
.summary-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 0.75rem; color: var(--text-tertiary); }
.summary-row .mono { color: var(--text-secondary); }

/* Order button */
.btn-order { width: 100%; padding: 14px; border: none; border-radius: var(--radius-md); font-family: var(--font-sans); font-size: 0.875rem; font-weight: 700; cursor: pointer; transition: all 0.2s; text-transform: uppercase; letter-spacing: 0.04em; position: relative; overflow: hidden; }
.btn-order.buy { background: linear-gradient(135deg, var(--long), #0ea85e); color: #fff; }
.btn-order.buy:hover { box-shadow: 0 4px 20px rgba(7,201,131,0.3); transform: translateY(-1px); }
.btn-order.sell { background: linear-gradient(135deg, var(--short), #dc2626); color: #fff; }
.btn-order.sell:hover { box-shadow: 0 4px 20px rgba(239,68,68,0.3); transform: translateY(-1px); }
.btn-order:active { transform: translateY(0); }
.btn-order.loading .btn-text { opacity: 0; }
.btn-order.loading .btn-loader { display: block; }
.btn-order .btn-loader { display: none; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; }
.order-result { margin-top: var(--space-md); font-size: 0.8125rem; min-height: 16px; line-height: 1.4; }
.order-result.success { color: var(--positive); }
.order-result.error { color: var(--negative); }

/* Open Orders */
.orders-list { max-height: 300px; overflow-y: auto; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 6px; border-radius: 9px; background: var(--accent-dim); color: var(--text-accent); font-size: 0.625rem; font-weight: 700; margin-left: auto; }
.order-item { padding: 10px 0; border-bottom: 1px solid var(--border-subtle); }
.order-item:last-child { border-bottom: none; }
.order-item-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.order-item-market { font-weight: 600; font-size: 0.8125rem; }
.order-item-details { display: flex; gap: var(--space-md); font-size: 0.75rem; color: var(--text-tertiary); font-family: var(--font-mono); }
.order-cancel-btn { padding: 4px 10px; border: 1px solid rgba(239,68,68,0.3); border-radius: 4px; background: transparent; color: var(--negative); font-size: 0.6875rem; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.order-cancel-btn:hover { background: var(--short-bg); border-color: var(--short); }
.empty-mini { padding: var(--space-lg); text-align: center; font-size: 0.8125rem; color: var(--text-tertiary); }

/* Mobile cards */
.positions-cards { display: none; }

/* Footer */
.footer { display: flex; align-items: center; justify-content: space-between; padding: var(--space-lg) 0; border-top: 1px solid var(--border-subtle); margin-top: auto; font-size: 0.75rem; color: var(--text-tertiary); flex-wrap: wrap; gap: var(--space-sm); }
.footer-left { display: flex; align-items: center; gap: var(--space-sm); }
.footer a { color: var(--text-secondary); text-decoration: none; transition: color 0.2s; }
.footer a:hover { color: var(--text-accent); }
.footer-sep { opacity: 0.3; }

/* Animations */
@keyframes slide-up { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Utility */
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 1500px) {
  .trade-layout { grid-template-columns: 1fr; }
  .trade-main { border-right: none; border-bottom: 1px solid var(--border-subtle); }
  .trade-panel { max-height: none; }
}
@media (max-width: 1200px) {
  .trade-layout { grid-template-columns: 1fr; }
  .trade-main { border-right: none; border-bottom: 1px solid var(--border-subtle); }
  .trade-panel { max-height: none; }
  .chart-container { height: clamp(350px, 48vh, 520px); min-height: 350px; }
}
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .app { padding: 0 var(--space-md); }
  .btn-primary:not(.full) { width: 100%; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 1.125rem; }
  .table-container { display: none !important; }
  .positions-cards { display: grid !important; grid-template-columns: 1fr; gap: var(--space-md); padding-bottom: var(--space-2xl); }
  .position-card { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: var(--space-lg); animation: slide-up 0.4s var(--ease-out) both; }
  .position-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-md); padding-bottom: var(--space-md); border-bottom: 1px solid var(--border-subtle); }
  .position-card-market { font-size: 1rem; font-weight: 700; }
  .position-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
  .position-card-item { display: flex; flex-direction: column; gap: 4px; }
  .position-card-label { font-size: 0.6875rem; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
  .position-card-value { font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 500; }
  .section-header { flex-direction: column; align-items: flex-start; }
  .market-bar { padding: var(--space-sm) var(--space-md); }
  .market-info { gap: var(--space-md); }
  .market-price { font-size: 1.125rem; }
  .nav-tabs { gap: 0; }
  .nav-tab { padding: 6px 10px; font-size: 0.75rem; }
  .trade-layout { margin: 0 calc(-1 * var(--space-md)); }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .header { gap: var(--space-sm); }
  .market-info { flex-wrap: wrap; gap: var(--space-md); }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }
::selection { background: rgba(7,201,131,0.3); color: var(--text-primary); }

/* Open Positions panel inside Trade tab */
.trade-positions-container {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-panel);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.trade-positions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--space-xs);
}
.trade-positions-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.trade-positions-summary {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
}
.trade-positions-table-wrap {
  overflow-x: auto;
  max-height: 260px;
}

.trade-positions-cards { display: none; }

/* The live positions table is part of the page, not a nested scroll area. */
#trade-positions-table-wrap {
  width: 100%;
  max-height: none;
  overflow-x: auto;
}

#trade-positions-table-wrap .positions-table {
  width: 100%;
  table-layout: fixed;
  min-width: 840px;
}

#trade-positions-table-wrap .positions-table th,
#trade-positions-table-wrap .positions-table td {
  padding-left: clamp(5px, 0.45vw, 10px);
  padding-right: clamp(5px, 0.45vw, 10px);
}

#trade-positions-table-wrap .positions-table td {
  font-size: clamp(0.6875rem, 0.62vw, 0.8125rem);
}

#trade-positions-table-wrap .positions-table th:nth-child(1) { width: 14%; min-width: 110px; }
#trade-positions-table-wrap .positions-table th:nth-child(2) { width: 9.5%; }
#trade-positions-table-wrap .positions-table th:nth-child(3) { width: 9%; }
#trade-positions-table-wrap .positions-table th:nth-child(4) { width: 8.5%; }
#trade-positions-table-wrap .positions-table th:nth-child(5) { width: 8.5%; }
#trade-positions-table-wrap .positions-table th:nth-child(6) { width: 9%; }
#trade-positions-table-wrap .positions-table th:nth-child(7) { width: 9%; }
#trade-positions-table-wrap .positions-table th:nth-child(8) { width: 7.5%; }
#trade-positions-table-wrap .positions-table th:nth-child(9) { width: 7.5%; }
#trade-positions-table-wrap .positions-table th:nth-child(10) { width: 9.5%; min-width: 80px; }
#trade-positions-table-wrap .positions-table th:nth-child(11) { width: 8%; min-width: 76px; }

#trade-positions-table-wrap .market-name {
  font-size: inherit;
}

#trade-positions-table-wrap .market-cell {
  gap: 4px;
}

#trade-positions-table-wrap .action-buttons-cell {
  gap: 4px;
  justify-content: center;
  width: 100%;
}

#trade-positions-table-wrap .side-badge.compact {
  margin-left: 3px;
  padding: 2px 5px;
}

#trade-positions-table-wrap .tpsl-cell-content {
  max-width: 100%;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 4px;
  line-height: 1.25;
  white-space: normal;
}

@media (max-width: 768px) {
  .trade-main { overflow: visible; }
  .chart-container { height: clamp(280px, 50vh, 390px); min-height: 280px; }
  .trade-panel { overflow: visible; }
  .trade-panel-inner { padding: var(--space-md); gap: var(--space-md); }
  .trade-bottom-panel { padding: var(--space-md); gap: var(--space-sm); }
  .trade-bottom-nav { align-items: flex-start; flex-direction: column; gap: var(--space-sm); }
  .trade-bottom-tabs { width: 100%; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .trade-bottom-tabs::-webkit-scrollbar { display: none; }
  .trade-bottom-tab { flex: 0 0 auto; padding: 7px 10px; font-size: 0.75rem; }
  #trade-positions-table-wrap { display: none !important; }
  .trade-positions-cards { display: grid !important; grid-template-columns: 1fr; gap: 10px; width: 100%; }
  .trade-position-card { width: 100%; display: flex; flex-direction: column; gap: 12px; padding: 14px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-card); color: var(--text-primary); font-family: var(--font-sans); text-align: left; cursor: pointer; }
  .trade-position-card:active { background: var(--bg-card-hover); }
  .trade-position-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .trade-position-card-top strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 0.9375rem; white-space: nowrap; }
  .trade-position-card-pnl { font: 700 1.125rem var(--font-mono); }
  .trade-position-card-pnl small { font-size: 0.6875rem; font-weight: 600; }
  .trade-position-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
  .trade-position-card-grid > span { display: flex; flex-direction: column; gap: 3px; font: 600 0.75rem var(--font-mono); color: var(--text-secondary); }
  .trade-position-card-grid i { color: var(--text-tertiary); font: 700 0.625rem var(--font-sans); letter-spacing: .06em; text-transform: uppercase; }
}
.clickable-row {
  cursor: pointer;
  transition: background 0.15s;
}
.clickable-row:hover {
  background: var(--bg-card-hover);
}

/* Unit Toggle (Coin/USD) */
.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.form-label-row .form-label {
  margin-bottom: 0;
}
.unit-toggle {
  display: inline-flex;
  gap: 2px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.unit-btn {
  padding: 2px 8px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.unit-btn:hover {
  color: var(--text-secondary);
}
.unit-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.size-converted-hint {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--accent);
  margin-top: 4px;
  min-height: 14px;
}

/* Minimal Web3 Header Account Widget & Modal */
.nav-account-widget {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-left: var(--space-sm);
}

.btn-connect-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #04140d;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 0 12px rgba(7, 201, 131, 0.25);
}

.btn-connect-nav:hover {
  background: #09e897;
  box-shadow: 0 0 16px rgba(7, 201, 131, 0.4);
  transform: translateY(-1px);
}

.nav-connected-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  transition: border-color 0.2s;
}

.nav-connected-pill:hover {
  border-color: var(--border-hover);
}

.btn-icon-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-icon-sm:hover {
  color: var(--negative);
  background: rgba(239, 68, 68, 0.15);
}

/* Unauthenticated Notice inside Place Order panel */
.order-unauth-notice {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
}

.unauth-desc {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  line-height: 1.4;
}

/* Modal Dialog */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  animation: fade-in 0.2s var(--ease-out);
}

.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-elevated);
  overflow: hidden;
  animation: slide-up 0.25s var(--ease-out);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
}

.modal-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modal-body {
  padding: var(--space-lg);
}

/* Trade Bottom Panel Navigation Subtabs */
.trade-bottom-panel {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-panel);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.trade-bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 8px;
}

.trade-bottom-tabs {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.trade-bottom-tab {
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.trade-bottom-tab:hover {
  color: var(--text-secondary);
  background: var(--bg-card-hover);
}

.trade-bottom-tab.active {
  color: var(--accent);
  background: var(--bg-elevated);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--bg-card);
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.trade-bottom-tab.active .tab-badge {
  background: rgba(7, 201, 131, 0.15);
  color: var(--accent);
}

.side-badge.compact {
  padding: 2px 6px;
  font-size: 0.625rem;
  margin-left: 6px;
}

.pnl-pct {
  font-size: 0.6875rem;
  opacity: 0.85;
}

.warning-color {
  color: #f59e0b;
}

.c {
  text-align: center !important;
}

/* Action Buttons & TP/SL Cell */
.tpsl-cell-content {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.btn-icon-xs {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.75rem;
}

.btn-icon-xs:hover {
  color: var(--accent);
  background: var(--bg-card-hover);
}

.action-buttons-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.75rem;
}

.btn-icon-action:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.btn-icon-action.close-btn:hover {
  color: var(--negative);
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
}

/* PnL Share Card */
.pnl-card-modal {
  max-width: 580px;
  width: 100%;
}

.pnl-theme-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
  scrollbar-width: none;
}
.pnl-theme-selector::-webkit-scrollbar { display: none; }

.pnl-preview-controls {
  display: flex;
  justify-content: flex-end;
  margin: -2px 0 10px;
}

.pnl-upnl-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.pnl-upnl-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.pnl-toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.pnl-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-tertiary);
  transition: transform 0.18s var(--ease-out), background 0.18s ease;
}

.pnl-upnl-toggle input:checked + .pnl-toggle-track {
  border-color: rgba(7, 201, 131, 0.55);
  background: rgba(7, 201, 131, 0.2);
  box-shadow: 0 0 12px rgba(7, 201, 131, 0.12);
}

.pnl-upnl-toggle input:checked + .pnl-toggle-track .pnl-toggle-thumb {
  transform: translateX(16px);
  background: var(--accent);
}

.pnl-upnl-toggle input:focus-visible + .pnl-toggle-track {
  outline: 2px solid rgba(59, 130, 246, 0.9);
  outline-offset: 2px;
}

.pnl-share-upnl.is-hidden {
  display: none;
}

.theme-chip {
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.theme-chip:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}
.theme-chip.active {
  background: var(--accent-dim);
  border-color: rgba(7, 201, 131, 0.4);
  color: var(--accent);
}

.pnl-share-card.split-layout {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 280px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-default);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 30px rgba(7, 201, 131, 0.1);
  display: flex;
  margin-bottom: var(--space-lg);
  background: #080d0a;
}

.pnl-share-card.split-layout.red-theme {
  border-color: rgba(239, 68, 68, 0.3);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 30px rgba(239, 68, 68, 0.12);
  background: #0d0808;
}

.pnl-card-bg-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: left center;
  background-repeat: no-repeat;
  z-index: 1;
}

.pnl-card-overlay-right {
  position: relative;
  z-index: 2;
  margin-left: auto;
  width: 52%;
  height: 100%;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  text-align: right;
  background: linear-gradient(90deg, transparent 0%, rgba(8, 14, 11, 0.6) 20%, rgba(8, 14, 11, 0.95) 100%);
  backdrop-filter: blur(2px);
}

.red-theme .pnl-card-overlay-right {
  background: linear-gradient(90deg, transparent 0%, rgba(15, 8, 8, 0.6) 20%, rgba(15, 8, 8, 0.95) 100%);
}

.pnl-share-brand {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}
.pnl-share-brand .logo-name {
  color: var(--text-primary);
}
.pnl-share-brand .logo-sub {
  color: var(--accent);
}
.red-theme .pnl-share-brand .logo-sub {
  color: var(--negative);
}

.pnl-share-market-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pnl-share-market {
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--text-primary);
}

.pnl-position-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.pnl-position-pill.long {
  background: rgba(7, 201, 131, 0.15);
  border: 1px solid rgba(7, 201, 131, 0.4);
  color: #07c983;
}

.pnl-position-pill.short {
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #f87171;
}

/* TP / SL Setup Modal Upgrades */
.tpsl-position-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.8125rem;
  text-align: center;
}
.tpsl-summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tpsl-summary-label {
  color: var(--text-tertiary);
  font-size: 0.6875rem;
  text-transform: uppercase;
}
.tpsl-summary-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-primary);
}

.tpsl-size-section .form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.tpsl-size-section .form-label {
  white-space: nowrap;
}
.tpsl-size-section .form-sub-hint {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  text-align: right;
}

.tpsl-section {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
}

.tpsl-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.tpsl-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tpsl-section-title.positive { color: var(--positive); }
.tpsl-section-title.negative { color: var(--negative); }
.tpsl-section-title .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.tpsl-section-title .dot.green { background: var(--positive); box-shadow: 0 0 6px var(--positive); }
.tpsl-section-title .dot.red { background: var(--negative); box-shadow: 0 0 6px var(--negative); }

.tpsl-mode-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 2px;
}
.tpsl-mode-btn {
  padding: 3px 8px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-tertiary);
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tpsl-mode-btn:hover { color: var(--text-secondary); }
.tpsl-mode-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.tpsl-presets-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.tpsl-preset-btn {
  flex: 1;
  padding: 4px 0;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tpsl-preset-btn:hover {
  border-color: var(--text-tertiary);
  color: var(--text-primary);
}
.tpsl-preset-btn.positive:hover, .tpsl-preset-btn.positive.active {
  background: rgba(7, 201, 131, 0.15);
  border-color: rgba(7, 201, 131, 0.4);
  color: var(--positive);
}
.tpsl-preset-btn.negative:hover, .tpsl-preset-btn.negative.active {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--negative);
}

.tpsl-est-box {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  font-size: 0.75rem;
}
.tpsl-est-box.positive { border-left: 3px solid var(--positive); }
.tpsl-est-box.negative { border-left: 3px solid var(--negative); }
.tpsl-est-box .est-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
  color: var(--text-tertiary);
}
.tpsl-est-box .est-row:last-child { margin-bottom: 0; }
.tpsl-est-box .est-row strong {
  font-family: var(--font-mono);
  font-weight: 700;
}
.tpsl-est-box.positive strong { color: var(--positive); }
.tpsl-est-box.negative strong { color: var(--negative); }

/* Place Order TP / SL Panel */
.tpsl-order-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 4px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tpsl-mini-presets {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.tpsl-mini-chip {
  flex: 1;
  padding: 3px 0;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tpsl-mini-chip:hover {
  border-color: var(--text-tertiary);
  color: var(--text-primary);
}

.tpsl-mini-chip.positive:hover, .tpsl-mini-chip.positive.active {
  background: rgba(7, 201, 131, 0.15);
  border-color: rgba(7, 201, 131, 0.4);
  color: var(--positive);
}

.tpsl-mini-chip.negative:hover, .tpsl-mini-chip.negative.active {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--negative);
}

.pnl-share-roi {
  font-family: var(--font-mono);
  font-size: clamp(1.8rem, 3.2vw, 2.5rem);
  font-weight: 900;
  color: var(--positive);
  line-height: 1;
  text-shadow: 0 0 20px rgba(7, 201, 131, 0.3);
}

.red-theme .pnl-share-roi {
  color: var(--negative);
  text-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
}

.pnl-share-upnl {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.pnl-share-footer {
  display: flex;
  gap: 12px;
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.pnl-card-domain {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.red-theme .pnl-card-domain {
  color: var(--negative);
}

.pnl-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
}

.pnl-action-btn {
  width: 100%;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out), border-color 0.2s;
}

.pnl-action-btn:disabled {
  cursor: wait;
  opacity: 0.72;
}

.btn-share-x {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: #050706;
  color: #fff;
  text-decoration: none;
}

.btn-share-x:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

@media (max-width: 560px) {
  .pnl-card-actions { grid-template-columns: 1fr; }
}

/* Custom Web3 Dialog Modal */
.dialog-card {
  max-width: 440px;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 30px rgba(7, 201, 131, 0.05);
}

.dialog-body {
  padding: var(--space-lg);
}

.dialog-text {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-primary);
  white-space: pre-line;
  word-break: break-word;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border-subtle);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Account & authorization */
.account-page { width: min(1120px, 100%); margin: 0 auto; padding: var(--space-2xl) 0 var(--space-3xl); }
.account-page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-xl); margin-bottom: var(--space-xl); }
.account-page-heading h1 { margin: 6px 0 8px; font-size: clamp(1.8rem, 4vw, 2.5rem); line-height: 1.05; letter-spacing: -0.045em; }
.account-page-heading p, .account-card-head p, .security-card p, .advanced-card p { color: var(--text-secondary); line-height: 1.55; }
.account-page-heading p { max-width: 680px; }
.eyebrow { color: var(--accent); font-size: 0.6875rem; font-weight: 800; letter-spacing: 0.11em; text-transform: uppercase; }
.security-badge { display: inline-flex; align-items: center; gap: 8px; flex: none; padding: 9px 12px; border: 1px solid var(--border-default); border-radius: var(--radius-full); background: rgba(7,201,131,.07); color: var(--text-secondary); font-size: .75rem; font-weight: 600; }
.account-page-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-md); }
.account-card { min-width: 0; padding: clamp(20px, 3vw, 28px); border: 1px solid var(--border-default); border-radius: var(--radius-lg); background: linear-gradient(145deg, rgba(255,255,255,.018), transparent 42%), var(--bg-card); box-shadow: var(--shadow-card); }
.account-card-wide { grid-column: 1 / -1; }
.account-card-head { display: flex; gap: 14px; margin-bottom: var(--space-lg); }
.account-card h2 { margin-bottom: 5px; font-size: 1.05rem; letter-spacing: -.02em; }
.account-card-head p { font-size: .8125rem; }
.account-step { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border: 1px solid rgba(7,201,131,.28); border-radius: 9px; background: var(--accent-dim); color: var(--accent); font: 800 .75rem var(--font-mono); }
.identity-disconnected { display: grid; gap: 10px; }
.auth-choice { width: 100%; min-height: 48px; display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 10px; padding: 0 14px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-input); color: var(--text-primary); font: 700 .875rem var(--font-sans); text-align: left; cursor: pointer; transition: border-color .15s, background .15s, transform .15s; }
.auth-choice:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--border-hover); background: var(--bg-elevated); }
.auth-choice:disabled { opacity: .48; cursor: not-allowed; }
.google-mark { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #fff; color: #4285f4; font: 800 .75rem Arial,sans-serif; }
.auth-choice-tag { padding: 3px 7px; border-radius: var(--radius-full); background: var(--bg-elevated); color: var(--text-tertiary); font-size: .625rem; letter-spacing: .05em; text-transform: uppercase; }
.account-help { color: var(--text-tertiary); font-size: .72rem; line-height: 1.45; }
.connection-summary { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid rgba(7,201,131,.18); border-radius: var(--radius-md); background: rgba(7,201,131,.055); }
.connection-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--accent-dim); color: var(--accent); font-weight: 900; }
.connection-copy { min-width: 0; display: flex; flex: 1; flex-direction: column; gap: 3px; }
.connection-copy .mono { overflow: hidden; text-overflow: ellipsis; font-size: .75rem; }
.connection-label { color: var(--text-secondary); font-size: .6875rem; }
.status-pill, .network-chip { display: inline-flex; align-items: center; gap: 6px; width: fit-content; padding: 5px 8px; border-radius: var(--radius-full); font-size: .6875rem; font-weight: 700; }
.status-pill.success { background: var(--accent-dim); color: var(--accent); }
.network-chip { background: var(--bg-elevated); color: var(--text-secondary); }
.account-select { appearance: auto; }
.account-action-result { min-height: 18px; margin-top: 9px; color: var(--text-secondary); font-size: .75rem; line-height: 1.4; }
.account-action-result.error { color: var(--negative); }
.account-action-result.success { color: var(--positive); }
.access-status-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); margin-bottom: var(--space-md); }
.account-details { display: grid; margin-bottom: var(--space-lg); }
.account-details > div { display: grid; grid-template-columns: minmax(120px,.8fr) minmax(0,1.2fr); gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border-subtle); }
.account-details dt { color: var(--text-tertiary); font-size: .75rem; }
.account-details dd { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--text-secondary); font-size: .75rem; text-align: right; }
.btn-secondary.full { justify-content: center; width: 100%; }
.btn-secondary.danger { border-color: rgba(239,68,68,.18); color: #f87171; }
.btn-secondary.danger:hover { background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.35); }
.security-card, .advanced-card { display: flex; align-items: center; justify-content: space-between; gap: var(--space-xl); }
.security-card > div:first-child { max-width: 570px; }
.security-card h2, .advanced-card h2 { margin: 5px 0; }
.security-card p, .advanced-card p { font-size: .8125rem; }
.security-flow { display: flex; align-items: center; gap: 9px; color: var(--text-tertiary); font-size: .6875rem; font-weight: 650; white-space: nowrap; }
.security-flow span { padding: 8px 10px; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--bg-input); }
.security-flow i { color: var(--accent); font-style: normal; }

@media (max-width: 768px) {
  .account-page { padding: var(--space-xl) 0; }
  .account-page-heading, .security-card, .advanced-card { align-items: flex-start; flex-direction: column; }
  .account-page-grid { grid-template-columns: 1fr; }
  .account-card-wide { grid-column: auto; }
  .security-flow { width: 100%; flex-wrap: wrap; white-space: normal; }
}

@media (max-width: 480px) {
  .security-badge { display: none; }
  .account-details > div { grid-template-columns: 1fr; gap: 4px; }
  .account-details dd { text-align: left; }
}

/* Spectator / Address Positions Navbar Widget */
.nav-spectate-widget {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.btn-spectate-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 9px;
  background: transparent;
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

.btn-spectate-nav:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(7, 201, 131, 0.15);
  transform: translateY(-1px);
}

.btn-spectate-nav .ghost-icon {
  color: currentColor;
  transition: transform 0.2s ease;
}

.btn-spectate-nav:hover .ghost-icon {
  transform: scale(1.1);
}

.nav-spectating-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: rgba(7, 201, 131, 0.08);
  border: 1px solid rgba(7, 201, 131, 0.3);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  transition: all 0.2s ease;
}

.nav-spectating-pill:hover {
  background: rgba(7, 201, 131, 0.14);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(7, 201, 131, 0.2);
}

.nav-spectating-pill .ghost-icon-active {
  color: var(--accent);
  animation: pulse-ghost 2s infinite ease-in-out;
}

@keyframes pulse-ghost {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.75; transform: scale(0.95); }
}

.btn-icon-xs {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  margin-left: 2px;
}

.btn-icon-xs:hover {
  background: rgba(239, 68, 68, 0.25);
  color: var(--negative);
}

/* Spectator Active Banner on top of Portfolio */
.spectator-active-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 10px 16px;
  margin-bottom: var(--space-lg);
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, rgba(7, 201, 131, 0.12), rgba(7, 201, 131, 0.04));
  border: 1px solid rgba(7, 201, 131, 0.25);
}

.spectator-banner-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.spectator-banner-content svg {
  color: var(--accent);
  flex-shrink: 0;
}

.spectator-banner-content strong {
  font-family: var(--font-mono);
  color: var(--accent);
}

.btn-xs {
  padding: 4px 10px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

/* Portfolio Empty Hero (shown when no wallet connected & not spectating) */
.portfolio-empty-hero {
  padding: var(--space-3xl) var(--space-md);
  display: flex;
  justify-content: center;
  align-items: center;
}

.portfolio-empty-card {
  max-width: 520px;
  width: 100%;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl) var(--space-xl);
  box-shadow: var(--shadow-card);
}

.empty-ghost-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto var(--space-lg);
  border-radius: 50%;
  background: rgba(7, 201, 131, 0.08);
  border: 1px solid rgba(7, 201, 131, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.portfolio-empty-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.portfolio-empty-desc {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: var(--space-xl);
}

.portfolio-empty-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
}

/* Spectate Modal Styling */
.spectate-modal-card {
  max-width: 480px;
  width: 100%;
}

.spectate-modal-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
  line-height: 1.4;
}

.spectate-input-row {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.spectate-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  padding: 0 12px;
  transition: border-color 0.2s;
}

.spectate-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(7, 201, 131, 0.15);
}

.search-input-icon {
  color: var(--text-tertiary);
  flex-shrink: 0;
  margin-right: 8px;
}

.spectate-input {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  padding: 10px 0;
}

.spectate-error {
  margin-top: 8px;
  font-size: 0.8125rem;
  color: var(--negative);
  min-height: 18px;
}

.spectate-modal-footer {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-subtle);
}
