/* ==========================================================================
   APEXQUANT TERMINAL - MODERN FINANCIAL DASHBOARD STYLESHEET
   Aesthetics: Deep Obsidian Dark Mode, Glassmorphism, Micro-Glow Accents
   ========================================================================== */

:root {
  /* Color Tokens */
  --bg-black: #06080c;
  --bg-panel: #0d1118;
  --bg-card: rgba(17, 23, 34, 0.75);
  --bg-card-hover: rgba(22, 31, 46, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(16, 185, 129, 0.4);

  /* Financial Accents */
  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.25);
  --rose: #f43f5e;
  --rose-glow: rgba(244, 63, 94, 0.25);
  --amber: #f59e0b;
  --amber-glow: rgba(245, 158, 11, 0.25);
  --cyan: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.25);
  --indigo: #6366f1;
  --purple: #8b5cf6;

  /* Typography Colors */
  --text-main: #f3f4f6;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* Typography Families */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Elevation */
  --shadow-panel: 0 10px 30px -5px rgba(0, 0, 0, 0.6), 0 0 1px 1px rgba(255, 255, 255, 0.05);
  --shadow-glow-emerald: 0 0 25px rgba(16, 185, 129, 0.15);
  --shadow-glow-amber: 0 0 25px rgba(245, 158, 11, 0.15);
}

/* Reset & Box Sizing */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  background-color: var(--bg-black);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(99, 102, 241, 0.04) 0%, transparent 40%);
}

.mono {
  font-family: var(--font-mono);
}

/* Utilities */
.profit-text {
  color: var(--emerald) !important;
}

.loss-text {
  color: var(--rose) !important;
}

.text-emerald {
  color: var(--emerald);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-panel);
}
::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* ==========================================================================
   HEADER NAVIGATION
   ========================================================================== */

.terminal-header {
  background: rgba(13, 17, 24, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}

.header-left, .header-center, .header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 22px;
  filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.6));
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1.5px;
  background: linear-gradient(135deg, #ffffff 40%, var(--emerald) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 9px;
  display: block;
  color: var(--text-dim);
  letter-spacing: 1px;
  font-weight: 600;
  margin-top: -2px;
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--emerald);
  letter-spacing: 0.5px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background: var(--emerald);
  border-radius: 50%;
  animation: pulseGlow 1.8s infinite;
}

@keyframes pulseGlow {
  0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.account-badge {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  display: flex;
  gap: 6px;
}

.badge-label {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 11px;
}

.badge-val {
  color: var(--text-main);
  font-weight: 600;
}

/* Header Buttons */
.btn-terminal {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-terminal:hover {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.4);
  color: #fda4af;
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.3);
  border-color: var(--rose);
}

/* ==========================================================================
   HERO STATS STRIP
   ========================================================================== */

.terminal-main {
  padding: 24px;
  max-width: 1700px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hero-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 16px 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: var(--shadow-panel);
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-dim);
}

.stat-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.stat-tag.tag-live {
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald);
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-main);
  margin-bottom: 4px;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   4 BOTS FLEET GRID
   ========================================================================== */

.section-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 4px;
}

.title-with-icon {
  display: flex;
  align-items: center;
  gap: 8px;
}

.title-with-icon h2 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-main);
}

.legend-pills {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-dim);
}

.pill-legend {
  display: flex;
  align-items: center;
  gap: 5px;
}

.dot-legend {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.dot-green { background: var(--emerald); }
.dot-red { background: var(--rose); }
.dot-yellow { background: var(--amber); }
.dot-blue { background: var(--cyan); }

.bot-fleet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 16px;
}

.bot-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 18px;
  position: relative;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bot-card:hover {
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-2px);
  box-shadow: var(--shadow-panel);
}

.bot-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.bot-identity {
  display: flex;
  flex-direction: column;
}

.bot-symbol-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bot-symbol {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-main);
}

.bot-tf-badge {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
}

.bot-name {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 500;
}

.bot-signal-pill {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sig-buy {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: var(--emerald);
}

.sig-sell {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: var(--rose);
}

.sig-wait {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--amber);
}

.sig-pyramid {
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.35);
  color: var(--cyan);
}

/* Price Strip */
.bot-price-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: rgba(0, 0, 0, 0.25);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.bot-live-price {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-main);
}

.bot-spread-tag {
  font-size: 11px;
  color: var(--text-muted);
}

.bot-meta-tags {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bot-atr-badge {
  font-size: 10px;
  background: rgba(6, 182, 212, 0.1);
  color: var(--cyan);
  border: 1px solid rgba(6, 182, 212, 0.25);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

/* Indicators Matrix in Card */
.bot-indicators-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  text-align: center;
}

.indicator-box {
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 4px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.ind-lbl {
  display: block;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.ind-val {
  font-size: 11px;
  font-weight: 700;
}

/* Pyramiding Layer Status Bar inside Card */
.bot-pyramid-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pyramid-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
}

.pyramid-pills-row {
  display: flex;
  gap: 6px;
}

.layer-step-pill {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  transition: all 0.3s ease;
}

.layer-step-pill.active {
  background: var(--emerald);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.layer-step-pill.locked {
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.6);
}

/* Card Bottom */
.bot-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
  font-size: 12px;
}

.bot-pnl-val {
  font-weight: 700;
}

/* ==========================================================================
   MIDDLE SPLIT LAYOUT
   ========================================================================== */

.terminal-split-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 20px;
  width: 100%;
  min-width: 0;
}

.layout-column-left, .layout-column-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  width: 100%;
}

.panel-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
  width: 100%;
}

.panel-header {
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-subtle);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-title h3 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-main);
}

.panel-icon {
  font-size: 16px;
}

.chart-timer-pill {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 8px;
  border-radius: 4px;
  color: var(--text-muted);
}

.badge-mini {
  font-size: 10px;
  font-weight: 700;
  color: var(--cyan);
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.3);
  padding: 3px 8px;
  border-radius: 4px;
}

/* Canvas Wrapper */
.chart-canvas-wrapper {
  padding: 18px 20px 10px 20px;
  height: 240px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

#equityChart {
  width: 100% !important;
  max-width: 100%;
  height: 100% !important;
  display: block;
}

/* Terminal Tabs & Trade History */
.tabbed-header {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
}

.terminal-tabs {
  display: flex;
  gap: 8px;
  align-items: center;
}

.term-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  user-select: none;
}

.term-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.term-tab.active {
  color: #ffffff;
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.15);
}

.term-tab .lucide {
  width: 15px;
  height: 15px;
}

.tab-badge {
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 7px;
  border-radius: 10px;
  color: inherit;
}

.term-tab.active .tab-badge {
  background: var(--emerald);
  color: #06080c;
}

/* History Toolbar & Filter Pills */
.history-toolbar {
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.15);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.history-filter-pills {
  display: flex;
  gap: 6px;
}

.filter-pill {
  font-size: 11px;
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-pill:hover {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.filter-pill.active {
  background: rgba(6, 182, 212, 0.15);
  border-color: rgba(6, 182, 212, 0.4);
  color: var(--cyan);
  font-weight: 700;
}

.history-metrics {
  display: flex;
  gap: 14px;
  font-size: 11px;
}

.history-metric-item {
  display: flex;
  gap: 5px;
  align-items: center;
}

.metric-lbl {
  color: var(--text-dim);
  font-size: 10px;
  letter-spacing: 0.5px;
}

.reason-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.reason-tp {
  background: rgba(16, 185, 129, 0.12);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.reason-be {
  background: rgba(6, 182, 212, 0.12);
  color: var(--cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.reason-sl {
  background: rgba(244, 63, 94, 0.12);
  color: var(--rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

/* ==========================================================================
   ACTIVE ORDERS & TRADE HISTORY TABLES (MAX 10 ROWS + INFINITE SCROLL)
   ========================================================================== */

.table-responsive {
  width: 100%;
  max-height: 480px; /* Max height for approx 10 rows */
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  border-radius: 0 0 8px 8px;
  scrollbar-width: thin;
}

.terminal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
  min-width: 640px;
}

.terminal-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #0d121c; /* Solid dark background to prevent bleed-through on scroll */
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
}

.terminal-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  vertical-align: middle;
}

.terminal-table tbody tr {
  transition: background 0.15s ease;
}

.terminal-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* Skeleton Loading Shimmer Effect for Tables */
@keyframes skeletonShimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton-row td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  background: transparent !important;
}

.skeleton-bar {
  display: inline-block;
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04) 25%, rgba(255, 255, 255, 0.10) 50%, rgba(255, 255, 255, 0.04) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.4s infinite ease-in-out;
  vertical-align: middle;
}

.skeleton-bar.w-ticket { width: 58px; }
.skeleton-bar.w-sym { width: 68px; font-weight: bold; }
.skeleton-bar.w-type { width: 46px; height: 18px; border-radius: 4px; }
.skeleton-bar.w-layer { width: 85px; height: 18px; border-radius: 4px; }
.skeleton-bar.w-lot { width: 40px; }
.skeleton-bar.w-price { width: 65px; }
.skeleton-bar.w-sltp { width: 70px; height: 22px; }
.skeleton-bar.w-pnl { width: 62px; height: 16px; }
.skeleton-bar.w-time { width: 55px; }
.skeleton-bar.w-reason { width: 80px; height: 18px; border-radius: 4px; }

/* Table Footer Status / Count Indicator */
.table-footer-status {
  padding: 9px 16px;
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-subtle);
  background: rgba(10, 14, 20, 0.6);
  font-family: var(--font-mono);
}

.table-footer-status .count-badge {
  color: var(--cyan);
  font-weight: 600;
}

.table-scroll-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(6, 182, 212, 0.04);
  border-top: 1px dashed rgba(6, 182, 212, 0.2);
}

.table-scroll-loader .spin-icon {
  animation: spin 1s linear infinite;
  color: var(--cyan);
}

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

.badge-order-type {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
}

.order-buy {
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.order-sell {
  background: rgba(244, 63, 94, 0.15);
  color: var(--rose);
  border: 1px solid rgba(244, 63, 94, 0.4);
}

.layer-badge {
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ==========================================================================
   PYRAMIDING MATRIX & LOG STREAM
   ========================================================================== */

.pyramid-rules-box {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rule-step-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.25);
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.rule-step-item.active {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.04);
}

.step-num {
  width: 28px;
  height: 28px;
  background: #1e293b;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  color: var(--text-muted);
}

.rule-step-item.active .step-num {
  background: var(--emerald);
  color: #06080c;
}

.step-desc {
  flex: 1;
}

.step-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.step-meta {
  font-size: 10px;
  color: var(--text-dim);
}

.step-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 4px;
}

.badge-active { background: rgba(16, 185, 129, 0.2); color: var(--emerald); }
.badge-locked { background: rgba(6, 182, 212, 0.2); color: var(--cyan); }
.badge-waiting { background: rgba(255, 255, 255, 0.05); color: var(--text-dim); }

.rule-footer-note {
  padding: 0 20px 16px 20px;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
}

/* Log Stream */
.log-stream-box {
  padding: 12px;
  height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 11px;
}

.log-entry {
  background: rgba(0, 0, 0, 0.25);
  border-left: 3px solid rgba(255, 255, 255, 0.1);
  padding: 7px 10px;
  border-radius: 0 6px 6px 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.log-entry.buy { border-left-color: var(--emerald); }
.log-entry.sell { border-left-color: var(--rose); }
.log-entry.pyramid { border-left-color: var(--cyan); }
.log-entry.telegram { border-left-color: #38bdf8; background: rgba(56, 189, 248, 0.05); }
.log-entry.profit { border-left-color: var(--emerald); background: rgba(16, 185, 129, 0.05); }
.log-entry.loss { border-left-color: var(--rose); background: rgba(244, 63, 94, 0.05); }
.log-entry.alert { border-left-color: var(--amber); background: rgba(245, 158, 11, 0.05); }
.log-entry.system { border-left-color: var(--purple); }

.log-time {
  color: var(--text-dim);
  font-size: 10px;
  white-space: nowrap;
}

.log-tag {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
}

.tg-tag { background: rgba(56, 189, 248, 0.15); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.3); }
.buy-tag { background: rgba(16, 185, 129, 0.15); color: var(--emerald); border: 1px solid rgba(16, 185, 129, 0.3); }
.sell-tag { background: rgba(244, 63, 94, 0.15); color: var(--rose); border: 1px solid rgba(244, 63, 94, 0.3); }
.pyramid-tag { background: rgba(6, 182, 212, 0.15); color: var(--cyan); border: 1px solid rgba(6, 182, 212, 0.3); }
.profit-tag { background: rgba(16, 185, 129, 0.15); color: var(--emerald); border: 1px solid rgba(16, 185, 129, 0.3); }
.loss-tag { background: rgba(244, 63, 94, 0.15); color: var(--rose); border: 1px solid rgba(244, 63, 94, 0.3); }
.alert-tag { background: rgba(245, 158, 11, 0.15); color: var(--amber); border: 1px solid rgba(245, 158, 11, 0.3); }
.system-tag { background: rgba(168, 85, 247, 0.15); color: var(--purple); border: 1px solid rgba(168, 85, 247, 0.3); }

.log-msg {
  color: var(--text-main);
  flex: 1;
  word-break: break-word;
  line-height: 1.4;
}

.log-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 10px;
  color: var(--text-dim);
  text-align: center;
  font-size: 11px;
  padding: 20px;
}

.log-empty-icon {
  width: 24px;
  height: 24px;
  color: var(--cyan);
  opacity: 0.7;
}

@keyframes pulseRadio {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 1; color: var(--emerald); }
}

.log-empty-icon.pulse {
  animation: pulseRadio 2.5s infinite ease-in-out;
}

.btn-mini {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
}

.btn-mini:hover {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

.terminal-footer {
  border-top: 1px solid var(--border-subtle);
  background: rgba(13, 17, 24, 0.95);
  padding: 10px 24px;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
}

.footer-left, .footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sep {
  color: rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   RESPONSIVE DESIGN & SAFARI iOS MOBILE ENGINE
   ========================================================================== */

/* Tables Container Touch-Friendly Scrollability */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  scrollbar-width: thin;
}

.terminal-table {
  min-width: 640px;
}

/* Tablets & Small Laptops (<= 1024px) */
@media (max-width: 1024px) {
  .terminal-main {
    padding: 20px 16px;
    gap: 20px;
  }

  .terminal-split-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    width: 100%;
    min-width: 0;
  }

  .hero-stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  .bot-fleet-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
}

/* Mobile Phones (<= 768px) */
@media (max-width: 768px) {
  /* Mobile Header */
  .terminal-header {
    padding: 12px 14px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .header-left {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .header-center {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    padding-bottom: 4px;
    width: 100%;
    scrollbar-width: none;
  }
  .header-center::-webkit-scrollbar {
    display: none;
  }

  .account-badge {
    flex-shrink: 0;
    padding: 4px 10px;
    font-size: 11px;
  }

  .header-right {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 8px;
    width: 100%;
    align-items: center;
  }

  .btn-terminal {
    min-height: 44px;
    padding: 8px 12px;
    font-size: 11px;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
  }

  .btn-terminal:active {
    transform: scale(0.98);
  }

  .btn-icon-only {
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Main Container */
  .terminal-main {
    padding: 14px 12px;
    gap: 16px;
  }

  /* Hero Stats Grid (Mobile 2-column) */
  .hero-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .winrate-card {
    grid-column: span 2;
  }

  .stat-card {
    padding: 12px 14px;
    border-radius: 10px;
  }

  .stat-value {
    font-size: 20px;
  }

  .stat-label {
    font-size: 10px;
  }

  .stat-sub {
    font-size: 11px;
  }

  /* Section Title Bar */
  .section-title-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .legend-pills {
    flex-wrap: wrap;
    gap: 8px;
    font-size: 10px;
  }

  /* Bot Fleet Grid (1 Column) */
  .bot-fleet-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .bot-card {
    padding: 14px 16px;
    border-radius: 12px;
  }

  .bot-live-price {
    font-size: 20px;
  }

  /* Chart Canvas Wrapper */
  .chart-canvas-wrapper {
    height: 200px;
    padding: 12px 10px 6px 10px;
  }

  /* Tabbed Header */
  .tabbed-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }

  .terminal-tabs {
    width: 100%;
    display: flex;
  }

  .term-tab {
    flex: 1;
    min-height: 44px;
    justify-content: center;
    font-size: 12px;
    padding: 8px 12px;
    -webkit-tap-highlight-color: transparent;
  }

  .panel-actions {
    display: flex;
    justify-content: flex-end;
  }

  /* History Toolbar */
  .history-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }

  .history-filter-pills {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .history-filter-pills::-webkit-scrollbar {
    display: none;
  }

  .filter-pill {
    flex-shrink: 0;
    min-height: 40px;
    padding: 6px 14px;
    font-size: 11px;
    -webkit-tap-highlight-color: transparent;
  }

  .history-metrics {
    display: flex;
    justify-content: space-between;
    width: 100%;
    background: rgba(0, 0, 0, 0.25);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 11px;
  }

  /* Pyramiding Matrix Box */
  .pyramid-rules-box {
    padding: 14px;
    gap: 10px;
  }

  .rule-step-item {
    padding: 10px 12px;
  }

  /* Log Stream Box */
  .log-stream-box {
    height: 220px;
  }

  /* Footer */
  .terminal-footer {
    flex-direction: column;
    gap: 8px;
    text-align: center;
    padding: 14px 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .footer-left, .footer-right {
    flex-wrap: wrap;
    justify-content: center;
  }

  /* Login Modal Mobile */
  .login-modal {
    width: 100%;
    max-width: 380px;
    padding: 28px 18px 24px;
    border-radius: 16px;
  }

  .login-title {
    font-size: 18px;
  }

  .btn-login-submit {
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
  }
}

/* Extra Small Phones (<= 380px, e.g. iPhone SE, iPhone 12/13 Mini) */
@media (max-width: 380px) {
  .hero-stats-grid {
    grid-template-columns: 1fr;
  }
  .winrate-card {
    grid-column: span 1;
  }
  .header-right {
    grid-template-columns: 1fr 1fr;
  }
  #emergencyCloseBtn {
    grid-column: span 2;
  }
  .btn-terminal {
    font-size: 10px;
    padding: 6px 8px;
  }
}

/* ==========================================================================
   PASSWORD AUTHENTICATION LOCK SCREEN OVERLAY & FORM STYLES
   ========================================================================== */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(5, 7, 12, 0.90);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity 0.35s ease, visibility 0.35s ease;
  visibility: visible;
  opacity: 1;
}

.login-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.login-modal {
  position: relative;
  background: rgba(13, 17, 24, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 38px 32px 30px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 
    0 25px 60px -15px rgba(0, 0, 0, 0.85),
    0 0 1px 1px rgba(255, 255, 255, 0.08),
    0 0 45px rgba(16, 185, 129, 0.1);
  overflow: hidden;
  animation: modalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.login-glow-orb {
  position: absolute;
  top: -90px;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.22) 0%, transparent 70%);
  filter: blur(45px);
  pointer-events: none;
}

.login-brand {
  text-align: center;
  margin-bottom: 24px;
}

.login-shield-wrapper {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--emerald);
  box-shadow: 0 0 24px rgba(16, 185, 129, 0.22);
  transition: all 0.3s ease;
}

.login-shield-svg {
  width: 28px;
  height: 28px;
}

.login-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text-main);
}

.login-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Form Styles */
.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.form-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.password-input-group {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 4px 12px;
  transition: all 0.2s ease;
}

.password-input-group:focus-within {
  border-color: var(--emerald);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2), 0 0 16px rgba(16, 185, 129, 0.1);
}

.password-input-group.shake {
  border-color: var(--rose) !important;
  animation: inputShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes inputShake {
  10%, 90% { transform: translate3d(-3px, 0, 0); }
  20%, 80% { transform: translate3d(5px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

.input-icon-left {
  font-size: 15px;
  margin-right: 8px;
  opacity: 0.7;
}

.terminal-password-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 16px; /* iOS Safari: >=16px avoids auto-zoom on input focus */
  padding: 10px 4px;
}

.terminal-password-input::placeholder {
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 13px;
}

.btn-toggle-eye {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  font-size: 15px;
  border-radius: 6px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-toggle-eye:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.login-status-msg {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
  min-height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.login-status-msg.error-text {
  color: var(--rose);
}

.login-status-msg.success-text {
  color: var(--emerald);
}

.btn-login-submit {
  width: 100%;
  height: 48px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 18px rgba(16, 185, 129, 0.35);
  transition: all 0.2s ease;
}

.btn-login-submit:hover {
  box-shadow: 0 6px 24px rgba(16, 185, 129, 0.5);
  transform: translateY(-1px);
}

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

.btn-login-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-arrow {
  transition: transform 0.2s ease;
}

.btn-login-submit:hover .btn-arrow {
  transform: translateX(3px);
}

.login-footer-info {
  margin-top: 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.login-hint-tag {
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.login-hint-tag strong {
  color: var(--cyan);
  letter-spacing: 0.08em;
}

.login-device-hint {
  font-size: 11px;
  color: var(--text-dim);
}

.btn-lock {
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--amber);
}

.btn-lock:hover {
  border-color: var(--amber);
  background: rgba(245, 158, 11, 0.12);
  color: #ffffff;
}

@media (max-width: 480px) {
  .login-modal {
    padding: 28px 20px 24px;
    border-radius: 16px;
  }
}

/* ==========================================================================
   LUCIDE ICONS INTEGRATION
   ========================================================================== */

.lucide {
  width: 1.15em;
  height: 1.15em;
  stroke-width: 2;
  display: inline-block;
  vertical-align: middle;
}

.brand-icon .lucide {
  width: 22px;
  height: 22px;
  color: var(--emerald);
}

.section-icon .lucide {
  width: 20px;
  height: 20px;
  color: var(--cyan);
}

.panel-icon .lucide {
  width: 17px;
  height: 17px;
  color: var(--cyan);
}

.btn-icon .lucide,
.btn-terminal .lucide {
  width: 15px;
  height: 15px;
  vertical-align: -2px;
}

.input-icon-left .lucide {
  width: 16px;
  height: 16px;
  color: var(--text-dim);
}

.btn-toggle-eye .lucide {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.btn-arrow .lucide {
  width: 15px;
  height: 15px;
  vertical-align: -2px;
}

.icon-inline {
  width: 15px;
  height: 15px;
  color: var(--amber);
  vertical-align: -2px;
  margin-right: 4px;
}

.icon-sl-lock {
  width: 13px;
  height: 13px;
  color: var(--emerald);
  vertical-align: -2px;
  margin-right: 3px;
}

.icon-layer-zap {
  width: 13px;
  height: 13px;
  color: var(--cyan);
  vertical-align: -2px;
  margin-right: 3px;
}

.log-icon {
  width: 14px;
  height: 14px;
  margin-right: 6px;
  vertical-align: -2px;
}

.log-entry.buy .log-icon {
  color: var(--emerald);
}

.log-entry.sell .log-icon {
  color: var(--rose);
}

.log-entry.pyramid .log-icon {
  color: var(--cyan);
}

.log-entry.system .log-icon {
  color: var(--amber);
}

.spin {
  animation: lucideSpin 1s linear infinite;
}

@keyframes lucideSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}


