@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&family=JetBrains+Mono:wght@400;500;700&display=swap');
/* ── Design System Variables (Retro Pixel Terminal) ─────────── */
:root {
  --font-pixel: 'Press Start 2P', monospace;
  --font-term: 'VT323', monospace;
  --font-mono: 'JetBrains Mono', monospace;
  --font-sans: 'Press Start 2P', monospace;
  --font: 'Press Start 2P', monospace;
  --font-family: 'Press Start 2P', monospace;

  --bg-primary: #0a0c0e;
  --bg-secondary: #12151a;
  --bg-card: #12151a;
  --bg-card-hover: #181d24;
  --bg-elevated: #1e242d;
  --backdrop: rgba(10, 12, 14, 0.9);

  --term-bg: #0a0c0e;
  --term-text: #e8ecf0;
  --term-gray: #7d8794;
  --term-border: #222933;
  --term-green: #00e676;
  --term-red: #ff5252;
  --term-cyan: #00d2ff;
  --term-yellow: #feca57;

  --primary: #00d2ff;
  --primary-dim: rgba(0, 210, 255, 0.15);
  --primary-glow: rgba(0, 210, 255, 0.3);
  --secondary: #a371f7;
  --secondary-dim: rgba(163, 113, 247, 0.15);

  --positive: #00e676;
  --positive-dim: rgba(0, 230, 118, 0.15);
  --negative: #ff5252;
  --negative-dim: rgba(255, 82, 82, 0.15);
  --warning: #feca57;
  --warning-dim: rgba(254, 202, 87, 0.15);
  --info: #00d2ff;

  --text-primary: #e8ecf0;
  --text-secondary: #7d8794;
  --text-muted: #556070;

  --border: #222933;
  --border-hover: #343e4d;
  --radius: 4px;
  --radius-sm: 3px;
  --radius-xs: 2px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.7);

  --sidebar-width: 260px;
  --header-height: 64px;

  /* Exchange colors */
  --ex-binance: #F0B90B;
  --ex-bybit: #FFAD00;
  --ex-bitget: #00CEA8;
  --ex-gate: #2354E6;
  --ex-mexc: #00C693;
  --ex-bingx: #2563EB;
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
  font-family: 'Press Start 2P', monospace;
}

html, body {
  width: 100%;
  margin: 0;
  padding: 0;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  background: var(--bg-primary) !important;
  background-color: #0a0c0e !important;
  color: var(--text-primary);
  font-family: 'Press Start 2P', monospace;
}

body {
  padding-top: max(env(safe-area-inset-top, 0px), 0px);
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 68px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  overflow-x: hidden;
}

/* ── Fluid & Adaptive Mobile Typography ───────────────────── */
.card-spread-title {
  font-size: clamp(14px, 4.2vw, 20px) !important;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-spread-net {
  font-size: clamp(17px, 5.2vw, 25px) !important;
  line-height: 1.05;
  white-space: nowrap;
  font-weight: bold;
}

.card-spread-sub {
  font-size: clamp(9px, 2.5vw, 12px) !important;
  line-height: 1.2;
}

.spread-card, .retro-trade-card {
  width: 100% !important;
  box-sizing: border-box !important;
  margin: 8px 0 !important;
  padding: 10px 12px !important;
}

.spread-badges-row {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 6px !important;
  align-items: center !important;
  font-size: 11px !important;
  width: 100% !important;
}

.spread-badge {
  font-size: 11px !important;
  padding: 2px 6px !important;
  border-radius: 3px !important;
  white-space: nowrap !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 3px !important;
}

@media (min-width: 769px) {
  html, body {
    position: static !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    height: auto !important;
    min-height: 100vh !important;
  }
  .main-content {
    position: static !important;
    margin-left: 0 !important;
    width: 100% !important;
    min-height: 100vh !important;
    overflow: visible !important;
    background: var(--term-bg) !important;
  }
  .content-area {
    padding: 2.5rem 3rem 6.5rem 3rem !important;
    max-width: 1280px !important;
    width: 92% !important;
    margin: 0 auto !important;
    overflow: visible !important;
    box-sizing: border-box !important;
  }
}

@media (max-width: 768px) {
  html, body {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100dvh;
    overflow: hidden !important;
    overscroll-behavior: none !important;
    overscroll-behavior-y: none !important;
  }
  .main-content {
    position: absolute !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw !important;
    height: 100% !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain !important;
    touch-action: pan-y !important;
    background-color: #121212 !important;
  }
}

/* Background gradient effect disabled for clean monochrome gray */
body::before {
  display: none !important;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-card);
  backdrop-filter: var(--backdrop);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  margin-bottom: 2rem;
}

.brand-icon {
  font-size: 1.75rem;
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

.brand-text {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}

.nav-item:hover {
  background: var(--primary-dim);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--primary-dim);
  color: var(--primary);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.nav-icon { font-size: 1.1rem; width: 24px; text-align: center; }
.nav-label { white-space: nowrap; }

.sidebar-footer {
  padding: 1rem 0.5rem 0;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

.sidebar-version {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

header {
  height: var(--header-height);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2rem;
  background: var(--bg-card);
  backdrop-filter: var(--backdrop);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 1rem; }
.header-right { display: flex; align-items: center; gap: 1.5rem; }

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
}

.page-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.last-update {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 0.375rem 0.75rem;
  background: rgba(255,255,255,0.03);
  border-radius: 20px;
  border: 1px solid var(--border);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--negative);
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.dot.online {
  background: var(--positive);
  box-shadow: 0 0 8px var(--positive);
  animation: pulse 2s infinite;
}

.dot.warning {
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
}

.content-area {
  flex: 1;
  padding: 1.5rem 2rem 2rem;
  overflow-y: auto;
}

.section { display: none; animation: fadeIn 0.35s ease; }
.section.active { display: block; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  backdrop-filter: var(--backdrop);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover { border-color: var(--border-hover); }

.card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

/* Stat Cards */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  filter: blur(30px);
  opacity: 0.15;
  pointer-events: none;
}

.stat-card:nth-child(1)::after { background: var(--primary); }
.stat-card:nth-child(2)::after { background: var(--positive); }
.stat-card:nth-child(3)::after { background: var(--secondary); }
.stat-card:nth-child(4)::after { background: var(--warning); }

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.625rem;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-card .stat-change {
  font-size: 0.8rem;
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

/* ── Tables ───────────────────────────────────────────────── */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

thead { background: rgba(255, 255, 255, 0.02); }

th {
  padding: 0.875rem 1rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 10;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  user-select: none;
  transition: color 0.2s;
}

th:hover { color: var(--text-secondary); }
th.sorted { color: var(--primary); }

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}

tr { transition: background 0.15s ease; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-xs);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-strategy {
  background: var(--secondary-dim);
  color: var(--secondary);
}

.badge-risk-low { background: var(--positive-dim); color: var(--positive); }
.badge-risk-medium { background: var(--warning-dim); color: var(--warning); }
.badge-risk-high { background: var(--negative-dim); color: var(--negative); }

/* ── Heatmap ──────────────────────────────────────────────── */
.heatmap-wrapper { overflow-x: auto; padding: 0.5rem; }

.heatmap-grid {
  display: grid;
  gap: 2px;
  min-width: fit-content;
}

.heatmap-cell {
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 4px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: default;
  position: relative;
  min-width: 80px;
}

.heatmap-cell:hover {
  transform: scale(1.08);
  z-index: 10;
  box-shadow: var(--shadow-lg);
}

.heatmap-header {
  background: rgba(255,255,255,0.03) !important;
  color: var(--text-secondary) !important;
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.heatmap-symbol {
  background: rgba(255,255,255,0.02) !important;
  color: var(--text-primary) !important;
  justify-content: flex-start !important;
  font-weight: 600;
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}

.form-control::placeholder { color: var(--text-muted); }

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row > * { flex: 1; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 600;
  font-family: var(--font);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #00b89c);
  color: #000;
  box-shadow: 0 2px 8px rgba(0, 212, 170, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 212, 170, 0.35);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.1);
  border-color: var(--border-hover);
}

.btn-sm { padding: 0.5rem 1rem; font-size: 0.8rem; }

/* ── Calculator Result Card ───────────────────────────────── */
.result-card {
  background: linear-gradient(135deg, var(--primary-dim) 0%, var(--secondary-dim) 100%);
  border: 1px solid rgba(0, 212, 170, 0.2);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.result-row:last-child { border-bottom: none; }

.result-row.total {
  font-size: 1.25rem;
  font-weight: 700;
  border-bottom: none;
  padding-top: 1rem;
}

/* ── Filter Bar ───────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar .form-control { max-width: 200px; }

/* ── Virtual Scroll ───────────────────────────────────────── */
.vs-container {
  position: relative;
  overflow-y: auto;
  height: 65vh;
  min-height: 400px;
}

/* ── Loading States ───────────────────────────────────────── */
.loading-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
  gap: 1rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

/* ── Toast Notifications ──────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-elevated);
  backdrop-filter: var(--backdrop);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1.25rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 400px;
}

.toast-positive { border-left: 3px solid var(--positive); }
.toast-negative { border-left: 3px solid var(--negative); }
.toast-warning { border-left: 3px solid var(--warning); }

/* ── Utilities ────────────────────────────────────────────── */
.positive { color: var(--positive) !important; }
.negative { color: var(--negative) !important; }
.warning { color: var(--warning) !important; }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-primary-c { color: var(--primary); }
.text-sm { font-size: 0.8rem; }
.text-xs { font-size: 0.7rem; }
.text-lg { font-size: 1.125rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.p-0 { padding: 0 !important; }
.gap-2 { gap: 0.5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

.flash-positive { animation: flashGreen 0.6s ease; }
.flash-negative { animation: flashRed 0.6s ease; }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

/* ── Custom Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ── Animations ───────────────────────────────────────────── */
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes flashGreen {
  0%, 100% { background-color: transparent; }
  30% { background-color: rgba(16, 185, 129, 0.15); }
}

@keyframes flashRed {
  0%, 100% { background-color: transparent; }
  30% { background-color: rgba(239, 68, 68, 0.15); }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .sidebar-toggle {
    display: block;
  }
  .content-area {
    padding: 1rem;
  }
}

/* ── Compact App Header (PC / Desktop) ────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--term-bg) !important;
  background-color: #121212 !important;
  border-bottom: 1px solid var(--term-border) !important;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.header-logo {
  font-size: 1.25rem;
}

.header-title {
  font-size: 0.95rem;
  font-family: 'Press Start 2P', monospace !important;
  font-weight: normal;
  color: var(--term-text) !important;
  letter-spacing: 0.5px;
}

.header-action-btn {
  background: var(--term-bg) !important;
  border: 1px solid var(--term-border) !important;
  color: var(--term-text) !important;
  padding: 6px 12px;
  border-radius: 0;
  font-size: 0.75rem;
  font-family: 'Press Start 2P', monospace !important;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.1s ease;
}

.header-action-btn:hover {
  background: #181818 !important;
  border-color: var(--term-text) !important;
  color: var(--term-green) !important;
}

/* ── Modal Switcher ───────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1rem;
}

.modal-card {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.6);
  overflow: hidden;
  animation: modalPop 0.25s ease-out;
}

@keyframes modalPop {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0,0,0,0.2);
}

.module-toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  margin-bottom: 0.75rem;
}

.module-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.module-icon {
  font-size: 1.3rem;
}

.module-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: #f8fafc;
}

.module-desc {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 2px;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: #10b981;
}

input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* ── Mobile Responsive Rules ──────────────────────────────── */
@media (max-width: 768px) {
  body {
    min-height: 100dvh;
    padding-bottom: calc(48px + env(safe-area-inset-bottom, 34px));
  }
  .app-header { display: none !important; }
  .sidebar-toggle { display: none !important; }
  .hide-mobile { display: none !important; }
  .sidebar { display: none !important; }
  .main-content { margin-left: 0; width: 100%; max-width: 100vw; }
  .content-area { 
    padding: 12px 14px;
    padding-top: calc(max(var(--tg-content-safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px), env(safe-area-inset-top, 0px), 12px) + 44px);
  }

  .mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(44px + env(safe-area-inset-bottom, 34px));
    padding-bottom: env(safe-area-inset-bottom, 34px);
    box-sizing: border-box;
    background: rgba(10, 14, 23, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 9999;
    justify-content: space-around;
    align-items: flex-start;
    padding-top: 3px;
  }
  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #64748b;
    text-decoration: none;
    font-size: 0.58rem;
    font-weight: 600;
    gap: 1px;
    flex: 1;
    height: 38px;
    cursor: pointer;
    transition: color 0.15s ease;
  }
  .mobile-nav-item.active {
    color: #38bdf8;
  }
  .mobile-nav-icon {
    font-size: 0.85rem;
    line-height: 1;
  }
}

.mobile-bottom-nav {
  display: none;
}

/* ── TradingView Button Style ────────────────────────────── */
.btn-tv {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(37, 99, 235, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(37, 99, 235, 0.35);
  padding: 3px 9px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 4px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-tv:hover {
  background: rgba(37, 99, 235, 0.35);
  color: #ffffff;
  border-color: #3b82f6;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

/* v2.0 – Expanded row styling */
.row-expanded {
  background: rgba(139, 92, 246, 0.08) !important;
}

.row-expanded td {
  border-bottom: none;
}

tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.expand-toggle:hover {
  color: #a78bfa !important;
}

/* Sort Header Hover Effects */
.sort-header {
  transition: color 0.2s ease, background-color 0.2s ease;
}
.sort-header:hover {
  color: #a78bfa !important;
  background-color: rgba(139, 92, 246, 0.1);
}

/* Pattern scanner styles */
.p-sort-header {
  transition: color 0.2s ease, background-color 0.2s ease;
}
.p-sort-header:hover {
  color: #f59e0b !important;
  background-color: rgba(245, 158, 11, 0.1);
}
.pattern-type-btn:hover {
  border-color: rgba(245, 158, 11, 0.5) !important;
  background: rgba(245, 158, 11, 0.1) !important;
  color: #f59e0b !important;
}

/* ── TERMINAL MUTED UI (AENAFOUND) ──────────────────────────────── */
:root {
  --term-bg: #121212;
  --term-card-bg: #121212;
  --term-border: #333333;
  --term-text: #b0b0b0;
  --term-gray: #666666;
  --term-green: #799d7a;
  --term-red: #b87575;
  --term-cyan: #6c999e;
  --term-yellow: #a89f74;
}

/* Global Font & Color Overrides */
*, *::before, *::after, body, button, input, select, textarea, span, div, p, a, h1, h2, h3, h4, h5, h6, table, tr, th, td, label {
  font-family: 'Press Start 2P', 'Tiny5', 'VT323', monospace !important;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: unset;
  text-rendering: pixelated;
}

html, body, .main-content, .content-area, .content-body, #p2p-container, .section {
  background-color: var(--term-bg) !important;
  color: var(--term-text) !important;
}

/* Base Terminal Card (2D Flat) */
.retro-card {
  background: var(--term-bg) !important;
  border-radius: 4px !important;
  border: 1px solid var(--term-border) !important;
  box-shadow: none !important;
  transition: transform 0.1s ease;
}
.retro-card:active {
  transform: scale(0.99);
}

/* KPI Labels (Cyrillic Pixel Font) */
.retro-kpi-title {
  font-family: 'Press Start 2P', monospace !important;
  font-size: 0.52rem !important;
  letter-spacing: 0.5px;
  color: var(--term-gray) !important;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.retro-kpi-val {
  font-family: 'VT323', monospace !important;
  font-size: 2.1rem !important;
  margin-top: 2px;
  line-height: 1.1;
  letter-spacing: 1px;
}

/* Terminal Buttons */
.retro-btn {
  background: var(--term-bg) !important;
  border: 1px solid var(--term-border) !important;
  border-radius: 2px !important;
  color: var(--term-text) !important;
  padding: 4px 8px !important;
  font-family: 'Press Start 2P', monospace !important;
  font-size: 0.50rem !important;
  box-shadow: none !important;
  cursor: pointer;
  transition: all 0.1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.retro-btn:active {
  background: var(--term-border) !important;
  color: var(--term-text) !important;
}

/* Trade Card (Matches Tab УЧЕТ rectangular layout) */
.retro-trade-card {
  border-radius: 4px !important;
  background: var(--term-bg) !important;
  border: 1px solid var(--term-border) !important;
  box-shadow: none !important;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.retro-trade-card:hover {
  background: #14171c !important;
  border-color: var(--term-border) !important;
}

/* Modal styling matching modern terminal */
.modal-overlay {
  background: rgba(0, 0, 0, 0.75) !important;
  backdrop-filter: blur(8px) !important;
}
.modal-card {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  color: var(--text-primary) !important;
  box-shadow: var(--shadow-lg) !important;
}
.modal-header {
  border-bottom: 1px solid var(--border) !important;
  padding: 1rem 1.25rem;
}
.modal-footer {
  border-top: 1px solid var(--border) !important;
  background: var(--bg-card) !important;
  padding: 1rem 1.25rem;
}
.module-toggle-item {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
}
.module-title {
  color: var(--text-primary) !important;
  font-size: 0.82rem !important;
  font-weight: 600 !important;
  font-family: var(--font-sans) !important;
}
.module-desc {
  color: var(--text-secondary) !important;
  font-size: 0.75rem !important;
  font-family: var(--font-sans) !important;
}
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #21262d !important;
  border: 1px solid #30363d !important;
  border-radius: 20px !important;
  transition: 0.2s ease;
}
.toggle-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: #8b949e !important;
  border-radius: 50% !important;
  transition: 0.2s ease;
}
input:checked + .toggle-slider {
  background-color: rgba(0, 230, 118, 0.2) !important;
  border-color: #00e676 !important;
}
input:checked + .toggle-slider:before {
  transform: translateX(20px) !important;
  background-color: #00e676 !important;
}
.module-section {
  width: 100%;
  box-sizing: border-box;
}
.toast-container {
  pointer-events: none !important;
}
.retro-toast {
  pointer-events: auto !important;
  border-radius: 6px !important;
  font-family: var(--font-sans) !important;
  font-size: 0.8rem !important;
  animation: modalPop 0.2s ease-out;
}

.retro-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10, 12, 14, 0.98) !important;
  backdrop-filter: blur(14px) !important;
  border-top: 1px solid var(--term-border) !important;
  z-index: 100000 !important;
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 6px);
  box-shadow: 0 -4px 25px rgba(0, 0, 0, 0.7);
  pointer-events: auto !important;
}

.retro-nav-container {
  display: flex;
  justify-content: space-around;
  align-items: center;
  max-width: 600px;
  margin: 0 auto;
  height: 52px;
  padding: 0 4px;
  gap: 2px;
  pointer-events: auto !important;
}

.retro-nav-tab {
  flex: 1 1 0;
  min-width: 0;
  max-width: 20%;
  height: 44px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--term-gray);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer !important;
  padding: 3px 1px;
  white-space: nowrap;
  overflow: hidden;
  transition: all 0.15s ease;
  touch-action: manipulation !important;
  -webkit-tap-highlight-color: transparent !important;
  user-select: none !important;
  pointer-events: auto !important;
}

.retro-nav-tab:hover {
  color: var(--term-text);
  background: rgba(255, 255, 255, 0.05);
}

.retro-nav-tab.active {
  color: var(--term-green) !important;
  background: rgba(0, 230, 118, 0.12) !important;
  border: 1px solid rgba(0, 230, 118, 0.35) !important;
}

.retro-tab-icon {
  font-size: 1.05rem !important;
  line-height: 1 !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  pointer-events: none;
}
.retro-tab-text {
  pointer-events: none;
  font-family: 'Press Start 2P', monospace !important;
  font-size: 0.38rem !important;
  line-height: 1 !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  letter-spacing: 0px !important;
  white-space: nowrap !important;
}

/* ════════════════════════════════════════════════════════════════
   VERSION 1: iOS iPhone & Mobile Mini App Viewport
   ════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  body {
    background-color: var(--bg-primary) !important;
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
  }
  .main-content {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }
  .content-area {
    padding: 6px 10px calc(max(env(safe-area-inset-bottom, 0px), 12px) + 60px) 10px !important;
    padding-top: calc(max(var(--tg-content-safe-area-inset-top, 0px), var(--tg-viewport-safe-area-inset-top, 0px), env(safe-area-inset-top, 0px), 0px) + 54px) !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }
  /* Force all cards to stay within bounds */
  .retro-card, .retro-trade-card, .kpi-card {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    border-radius: 4px !important;
  }
  .kpi-grid-responsive {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
    margin-bottom: 0.75rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .kpi-grid-responsive .kpi-profit-main {
    grid-column: span 2 !important;
  }
  .kpi-card {
    padding: 0.55rem 0.65rem !important;
    min-width: 0 !important;
  }
  .kpi-card .retro-kpi-title {
    font-size: 0.44rem !important;
    font-family: 'Press Start 2P', monospace !important;
    font-weight: normal !important;
    color: var(--term-gray) !important;
    white-space: normal !important;
    line-height: 1.25 !important;
  }
  .kpi-card .retro-kpi-val {
    font-size: 1.25rem !important;
    font-family: 'VT323', monospace !important;
    font-weight: bold !important;
    white-space: nowrap;
    letter-spacing: 0.5px !important;
  }
  .kpi-profit-main .retro-kpi-val {
    font-size: 1.45rem !important;
    font-family: 'VT323', monospace !important;
  }
  .retro-btn {
    padding: 4px 8px !important;
    font-size: 0.50rem !important;
    border-radius: 2px !important;
    font-family: 'Press Start 2P', monospace !important;
  }
  .trade-details {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }
  .desktop-only {
    display: none !important;
  }
  .mobile-only {
    display: block !important;
  }
}

/* ════════════════════════════════════════════════════════════════
   VERSION 2: PC / Desktop Workstation (Wide Screen Viewport)
   ════════════════════════════════════════════════════════════════ */
@media (min-width: 769px) {
  html, body {
    position: relative !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    height: auto !important;
    min-height: 100vh !important;
  }
  .sidebar {
    display: none !important;
  }
  .app-header {
    display: none !important;
  }
  .main-content {
    position: relative !important;
    margin-left: 0 !important;
    width: 100% !important;
    min-height: 100vh !important;
    overflow-y: visible !important;
    overflow-x: hidden !important;
    background: var(--bg-primary) !important;
  }
  .content-area {
    padding: 1.5rem 2rem 5.5rem 2rem !important;
    max-width: 1200px !important;
    width: 95% !important;
    margin: 0 auto !important;
    overflow: visible !important;
    box-sizing: border-box !important;
  }
  .retro-card {
    padding: 0.85rem 1.1rem !important;
    margin-bottom: 0.9rem !important;
    border-radius: 4px !important;
  }
  .kpi-grid-responsive {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 0.55rem !important;
    margin-bottom: 0.9rem !important;
  }
  .kpi-grid-responsive .kpi-profit-main {
    grid-column: span 1 !important;
  }
  .kpi-card {
    padding: 0.55rem 0.65rem !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
  }
  .kpi-card .retro-kpi-title {
    font-size: 0.44rem !important;
    font-family: 'Press Start 2P', monospace !important;
    font-weight: normal !important;
    color: var(--term-gray) !important;
    margin-bottom: 0.25rem !important;
    white-space: normal !important;
    line-height: 1.25 !important;
    min-height: 1.8em !important;
    display: flex !important;
    align-items: center !important;
  }
  .kpi-card .retro-kpi-val {
    font-size: 1.25rem !important;
    font-family: 'VT323', monospace !important;
    font-weight: bold !important;
    white-space: nowrap !important;
    letter-spacing: 0.5px !important;
  }
  .kpi-profit-main .retro-kpi-val {
    font-size: 1.45rem !important;
    font-family: 'VT323', monospace !important;
  }
  .retro-trade-card {
    padding: 6px 8px !important;
    margin-bottom: 4px !important;
    border-radius: 3px !important;
  }
  .retro-nav-container {
    max-width: 650px !important;
    height: 52px !important;
    gap: 8px !important;
  }
  .retro-nav-tab {
    height: 40px !important;
    font-size: 0.52rem !important;
    font-family: 'Press Start 2P', monospace !important;
    padding: 0 10px !important;
  }
  .desktop-only {
    display: inline-block !important;
  }
  .mobile-only {
    display: none !important;
  }
  #chartModal .retro-card {
    width: 95vw !important;
    max-width: 1300px !important;
    height: 88vh !important;
    max-height: 800px !important;
    padding: 0.85rem 1.15rem !important;
  }
}

/* ── Smooth, Jitter-Free Chart Modal Styling (Mobile & Desktop) ── */
#chartModal {
  position: fixed !important;
  inset: 0 !important;
  display: none;
  align-items: center !important;
  justify-content: center !important;
  background: rgba(0, 0, 0, 0.85) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  z-index: 100005 !important;
  padding: 0.5rem !important;
}

#chartModal .modal-card {
  width: 96vw !important;
  max-width: 1200px !important;
  height: 88vh !important;
  max-height: 760px !important;
  display: flex !important;
  flex-direction: column !important;
  box-sizing: border-box !important;
  padding: 0.75rem 0.9rem !important;
  margin: auto !important;
  border-radius: 8px !important;
  box-shadow: 0 12px 45px rgba(0, 0, 0, 0.95) !important;
  animation: chartFadeIn 0.15s ease-out !important;
  transform: none !important;
  overflow: hidden !important;
}

@keyframes chartFadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.chart-header-row {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  border-bottom: 1px solid var(--border) !important;
  padding-bottom: 0.5rem !important;
  margin-bottom: 0.5rem !important;
  flex-wrap: wrap !important;
  gap: 6px !important;
  flex-shrink: 0 !important;
}

.chart-stats-ribbon {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  font-family: var(--font-mono) !important;
  font-size: 0.70rem !important;
  color: var(--text-secondary) !important;
  margin-bottom: 0.4rem !important;
  background: rgba(0, 0, 0, 0.35) !important;
  padding: 5px 8px !important;
  border-radius: 4px !important;
  border: 1px solid var(--border) !important;
  flex-wrap: nowrap !important;
  gap: 8px !important;
  overflow-x: auto !important;
  flex-shrink: 0 !important;
}

.chart-pos-banner {
  flex-shrink: 0 !important;
  margin-bottom: 0.4rem !important;
  background: rgba(255, 170, 0, 0.12) !important;
  border: 1px solid #d97706 !important;
  padding: 6px 10px !important;
  font-family: var(--font-mono) !important;
  font-size: 0.70rem !important;
  color: var(--term-yellow) !important;
  border-radius: 4px !important;
  display: none;
  flex-wrap: wrap !important;
  gap: 6px !important;
  align-items: center !important;
  justify-content: space-between !important;
}

#tvChartContainer {
  flex: 1 1 0% !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 240px !important;
  position: relative !important;
  background: #0b0e14 !important;
  border-radius: 4px !important;
  border: 1px solid var(--border) !important;
  overflow: hidden !important;
}

/* ══════════════════════════════════════════════════════════════════
   ULTRA-MINIMALIST PASSWORD PROMPT
   ══════════════════════════════════════════════════════════════════ */
.minimal-auth-overlay {
  position: fixed;
  inset: 0;
  background: #080a0f;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 999999;
}

.minimal-auth-box {
  width: 100%;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.minimal-input-line {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.22);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.minimal-input-line:focus-within {
  border-bottom-color: var(--term-cyan, #00e5ff);
  box-shadow: 0 1px 0 var(--term-cyan, #00e5ff);
}

.minimal-input {
  width: 100%;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  color: #f1f5f9 !important;
  font-family: var(--font-mono, 'JetBrains Mono', monospace) !important;
  font-size: 1.05rem !important;
  padding: 8px 32px 8px 4px !important;
  letter-spacing: 1px;
}

.minimal-input::placeholder {
  color: rgba(148, 163, 184, 0.4);
  font-size: 0.95rem;
}

.minimal-submit-btn {
  position: absolute;
  right: 0;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  color: rgba(255, 255, 255, 0.4);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 6px;
  transition: color 0.15s ease, transform 0.15s ease;
}

.minimal-submit-btn:hover {
  color: var(--term-cyan, #00e5ff);
  transform: translateX(2px);
}

.minimal-auth-error {
  margin-top: 12px;
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  color: #f87171;
  text-align: center;
  animation: minimalShake 0.35s ease-in-out;
}

@keyframes minimalShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

/* Logout button in settings / header */
.btn-auth-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  border-radius: 6px;
  font-family: var(--font-mono, monospace);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-auth-logout:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  color: #ffffff;
}

/* ═══════════════════════════════════════════════════════════════
   PRO TRADING COCKPIT & RACECAR HUD STYLES
═══════════════════════════════════════════════════════════════ */
.cockpit-instruments-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.cockpit-gauge-box {
  padding: 1.25rem;
  background: #0e1218 !important;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
}

.cockpit-gauge-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--term-cyan), transparent);
}

.gauge-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.gauge-icon {
  font-size: 1.15rem;
}

.gauge-label {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

.gauge-badge {
  margin-left: auto;
  font-size: 0.70rem;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid transparent;
}

.tachometer-svg-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 140px;
  margin: -10px auto 0;
}

.tachometer-svg {
  width: 100%;
  max-width: 260px;
  height: 140px;
}

.gauge-digital-readout {
  text-align: center;
  margin-top: -10px;
}

.strike-pill {
  padding: 4px 10px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.strike-pill.active {
  background: rgba(0, 230, 118, 0.12);
  border-color: rgba(0, 230, 118, 0.35);
  color: var(--term-green);
}

.strike-pill.dead {
  background: rgba(255, 59, 48, 0.15);
  border-color: rgba(255, 59, 48, 0.4);
  color: var(--term-red);
  text-decoration: line-through;
}

/* ── Telemetry Grid ────────────────────────────────────────── */
.cockpit-telemetry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.telemetry-card {
  padding: 0.85rem 1rem;
  background: #0e1218 !important;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.telemetry-card:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 210, 255, 0.35);
}

.tel-label {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}

.tel-val {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 4px;
}

.tel-sub {
  font-size: 0.65rem;
  color: var(--text-secondary);
}

/* ── Active Position Cockpit Card ─────────────────────────── */
.active-position-cockpit-card {
  padding: 1.25rem;
  background: #0e1218 !important;
  border: 1px solid rgba(0, 230, 118, 0.35);
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 230, 118, 0.08);
}

.cockpit-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.cockpit-badge-ex {
  padding: 3px 8px;
  background: rgba(255, 173, 0, 0.15);
  border: 1px solid rgba(255, 173, 0, 0.35);
  color: #ffad00;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 4px;
}

.cockpit-symbol-title {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--term-cyan);
}

.cockpit-badge-side {
  padding: 3px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid transparent;
}

/* ── Key Levels Banner ─────────────────────────────────────── */
.key-levels-banner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.level-box {
  padding: 0.6rem 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.level-tag {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-secondary);
}

.level-val {
  font-size: 0.95rem;
  font-family: var(--font-mono);
  font-weight: 800;
  color: var(--text-primary);
}

.level-box.be-box.be-ready {
  border-color: rgba(0, 240, 255, 0.5);
  background: rgba(0, 240, 255, 0.08);
}

.level-box.be-box.be-ready .level-val {
  color: #00f0ff;
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
}

.chart-active-tag {
  font-family: var(--font-mono);
  font-size: 0.70rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(0, 230, 118, 0.12);
  border: 1px solid rgba(0, 230, 118, 0.35);
  color: var(--term-green);
}

.chart-levels-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  background: rgba(8, 12, 16, 0.95);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.legend-line {
  display: inline-block;
  width: 14px;
  height: 3px;
  border-radius: 2px;
}


