/* ==========================================================================
   CYBERPULSE QUANT TERMINAL v2.6.4 — MASTER FINTECH PRO 2026 STYLESHEET
   Comprehensive, Self-Contained, Zero-Breakage Design System (OKLCH + Hex)
   ========================================================================== */

/* --- IMPORT MODULAR STYLES --- */
@import url('tokens.css');
@import url('components.css');
@import url('panels.css');
@import url('intelligence.css');
@import url('autotrade.css');
@import url('auth.css');
@import url('modals.css');

/* --- ROOT VARIABLES & TOKENS FALLBACK --- */
:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  --font-display: "Space Grotesk", var(--font-sans);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 150ms;
  --duration-normal: 220ms;
}

/* --- DARK THEME TOKENS (DEFAULT) --- */
[data-theme="dark"], body.theme-dark, :root {
  color-scheme: dark;
  --surface-base: #0a0d14;
  --surface-card: #101522;
  --surface-card-sub: #161c2d;
  --surface-card-hover: #1d253b;
  --surface-inset: #07090e;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: #1e2638;
  --border-strong: #2f3b54;
  --border-specular: rgba(255, 255, 255, 0.12);

  --text-primary: #f0f4fc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-muted: #475569;

  --color-brand: #00f2fe;
  --color-brand-glow: rgba(0, 242, 254, 0.25);
  --color-success: #10b981;
  --color-success-bg: rgba(16, 185, 129, 0.15);
  --color-danger: #ef4444;
  --color-danger-bg: rgba(239, 68, 68, 0.15);
  --color-warning: #f59e0b;
  --color-warning-bg: rgba(245, 158, 11, 0.15);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
}

/* --- LIGHT THEME TOKENS --- */
[data-theme="light"], body.theme-light {
  color-scheme: light;
  --surface-base: #f8fafc;
  --surface-card: #ffffff;
  --surface-card-sub: #f1f5f9;
  --surface-card-hover: #e2e8f0;
  --surface-inset: #e2e8f0;

  --border-subtle: rgba(0, 0, 0, 0.05);
  --border-default: #cbd5e1;
  --border-strong: #94a3b8;
  --border-specular: rgba(255, 255, 255, 0.8);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --text-muted: #94a3b8;

  --color-brand: #0284c7;
  --color-brand-glow: rgba(2, 132, 199, 0.2);
  --color-success: #059669;
  --color-success-bg: rgba(5, 150, 105, 0.1);
  --color-danger: #dc2626;
  --color-danger-bg: rgba(220, 38, 38, 0.1);
  --color-warning: #d97706;
  --color-warning-bg: rgba(217, 119, 6, 0.1);
}

/* --- GLOBAL RESET & BASE --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  min-height: 100vh;
  background-color: var(--surface-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- MASTER LAYOUT WRAPPER --- */
.app-container, .app-layout {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0 var(--space-4);
  max-width: 1820px;
  margin: 0 auto;
  width: 100%;
}

/* --- TYPOGRAPHY & TABULAR NUMS --- */
.tabular, .font-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* --- TOP HUD HEADER BAR --- */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-default);
  margin-bottom: var(--space-4);
  gap: var(--space-3);
  flex-wrap: wrap;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.header-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--color-brand-glow);
  color: var(--color-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-brand);
}

.brand-title {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  line-height: 1.1;
}

.brand-sub {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.badge-v {
  font-size: 0.625rem;
  padding: 1px 4px;
  background: var(--surface-card-sub);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xs);
  color: var(--color-brand);
}

.divider-v {
  width: 1px;
  height: 24px;
  background: var(--border-default);
}

.divider-v-sm {
  width: 1px;
  height: 14px;
  background: var(--border-default);
  display: inline-block;
  vertical-align: middle;
}

/* Swarm Health Cluster */
.health-cluster {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 10px;
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
}

.health-label {
  font-weight: 600;
  color: var(--text-primary);
}

.health-metric {
  font-size: 0.6875rem;
  padding-left: var(--space-2);
  border-left: 1px solid var(--border-subtle);
}

.pulse-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-healthy, .pulse-green {
  background: var(--color-success);
  box-shadow: 0 0 8px var(--color-success);
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.7; }
}

/* Trading Mode Selector */
.trading-mode-selector {
  display: flex;
  background: var(--surface-inset);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-xs);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.mode-btn.active {
  background: var(--surface-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

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

.sim-dot {
  background: var(--color-success);
  box-shadow: 0 0 6px var(--color-success);
}

.live-dot {
  background: var(--color-danger);
}

.mode-btn.active .live-dot {
  box-shadow: 0 0 8px var(--color-danger);
}

/* Balance Card */
.balance-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 6px 14px;
}

.balance-item {
  display: flex;
  flex-direction: column;
}

.balance-label {
  font-size: 0.5625rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.balance-val {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
}

.balance-val-sol {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-brand);
}

.balance-pnl {
  font-size: 0.75rem;
  font-weight: 600;
}

.balance-pnl.positive {
  color: var(--color-success);
}

.balance-pnl.negative {
  color: var(--color-danger);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Kill Switch Button */
.btn-killswitch {
  background: var(--color-danger);
  color: #ffffff;
  border: none;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.4);
  transition: all var(--duration-fast);
}

.btn-killswitch:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

/* --- SECTION HEADERS --- */
.section-container {
  margin-bottom: var(--space-4);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.section-title-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.section-title {
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-primary);
}

.badge-cluster {
  font-size: 0.625rem;
  font-family: var(--font-mono);
  padding: 2px 6px;
  background: var(--surface-card-sub);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xs);
  color: var(--color-brand);
}

/* --- DUAL COLUMN TRADING LAYOUT --- */
.main-trading-layout, .dashboard-split-layout {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

@media (max-width: 1100px) {
  .main-trading-layout, .dashboard-split-layout {
    grid-template-columns: 1fr;
  }
}

.col-main, .col-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* --- CARDS & PANELS --- */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-top: 1px solid var(--border-specular);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  gap: var(--space-2);
}

.card-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.icon-indicator {
  font-size: 1.1rem;
  line-height: 1;
}

.card-title {
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

/* --- CHART WRAPPER & TIMEFRAMES --- */
.chart-wrapper {
  position: relative;
  width: 100%;
  min-height: 220px;
  background: var(--surface-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-wrapper canvas {
  width: 100% !important;
  height: 220px !important;
}

.chart-timeframes {
  display: flex;
  background: var(--surface-inset);
  padding: 2px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-default);
  gap: 2px;
}

.tf-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 2px;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.tf-btn.active {
  background: var(--surface-card);
  color: var(--text-primary);
}

/* --- AUTONOMOUS STRATEGY & POSITION GOVERNOR HUD --- */
.autonomous-strategy-hud {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  padding: 10px 14px;
  background: var(--surface-inset);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
}

.strategy-status-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.75rem;
}

.strategy-label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-muted);
}

.strategy-metrics-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
}

@media (max-width: 900px) {
  .strategy-metrics-group {
    grid-template-columns: 1fr 1fr;
  }
}

.strategy-metric-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface-card-sub);
  padding: 6px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
}

.metric-lbl {
  font-size: 0.5625rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.metric-val {
  font-size: 0.6875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
  color: #ffffff;
}

.btn-buy:hover, .btn-sell:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}

/* --- POSITIONS TABLE --- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.positions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.positions-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-default);
  background: var(--surface-card-sub);
}

.positions-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.positions-table tr:hover td {
  background: var(--surface-card-hover);
  color: var(--text-primary);
}

/* On-Chain Links & Live Token Cells */
.pos-token-wrap, .trade-token-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pos-sym, .token-symbol {
  font-size: 0.8125rem;
  color: var(--text-primary);
}

.trade-uid {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid rgba(56, 189, 248, 0.2);
  margin-right: 4px;
}

.badge-action.win-badge {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.2);
}

.badge-action.loss-badge {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.4);
}

.pos-links-row, .trade-links-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
}

.onchain-link {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 600;
  text-decoration: none;
  padding: 1px 5px;
  border-radius: 3px;
  transition: all var(--duration-fast);
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.dexscreener-link {
  background: rgba(14, 165, 233, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(14, 165, 233, 0.3);
}

.dexscreener-link:hover {
  background: rgba(14, 165, 233, 0.25);
  color: #7dd3fc;
}

.solscan-link {
  background: rgba(168, 85, 247, 0.12);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.solscan-link:hover {
  background: rgba(168, 85, 247, 0.25);
  color: #e9d5ff;
}

.target-ladder-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fee-breakdown-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.reason-badge-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 280px;
}

.subagent-tag {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  padding: 1px 5px;
  border-radius: 3px;
  display: inline-block;
  width: fit-content;
}

.reason-text {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  line-height: 1.25;
}

/* --- CONSOLE LOG WINDOW --- */
.console-header {
  margin-bottom: var(--space-2);
}

.console-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.log-filter-group {
  display: flex;
  background: var(--surface-inset);
  padding: 2px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-default);
  gap: 2px;
}

.filter-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 2px;
  cursor: pointer;
}

.filter-tab.active {
  background: var(--surface-card);
  color: var(--text-primary);
}

.auto-scroll-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.6875rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.terminal-log-window {
  background: var(--surface-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px;
  height: 220px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.log-line {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.log-time {
  color: var(--text-muted);
}

.log-badge {
  font-size: 0.5625rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 2px;
}

.badge-info { background: rgba(0, 242, 254, 0.15); color: var(--color-brand); }
.badge-trade { background: var(--color-success-bg); color: var(--color-success); }
.badge-signal { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-warn { background: rgba(245, 158, 11, 0.2); color: var(--color-warning); }
.badge-error { background: var(--color-danger-bg); color: var(--color-danger); }

/* --- FOOTER BAR --- */
.footer-bar, .app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border-default);
  margin-top: auto;
  font-size: 0.6875rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: var(--space-2);
}

.footer-left, .footer-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.footer-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.text-right { text-align: right; }
.text-center { text-align: center; }
.live-stream-badge {
  font-size: 0.625rem;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: var(--color-success-bg);
  color: var(--color-success);
}
.bg-cyan { background: var(--color-brand-glow); color: var(--color-brand); }
.bg-emerald { background: var(--color-success-bg); color: var(--color-success); }

/* --- TRADE AUDIT MODAL & PIPELINE STEPPER --- */
.btn-audit-pipeline {
  background: rgba(14, 165, 233, 0.1);
  border: 1px solid rgba(14, 165, 233, 0.3);
  color: #38bdf8;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  margin-top: 4px;
  width: fit-content;
  transition: all var(--duration-fast);
}

.btn-audit-pipeline:hover {
  background: rgba(14, 165, 233, 0.25);
  color: #e0f2fe;
}

.audit-status-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
}

.audit-status-banner.rejected-banner {
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: #fecdd3;
}

.audit-status-banner.approved-banner {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #a7f3d0;
}

.banner-icon { font-size: 1.5rem; }

.audit-token-metabar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface-inset);
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  margin-bottom: var(--space-3);
}

.analysis-pipeline-stepper {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stage-card {
  background: var(--surface-card-sub);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  transition: all var(--duration-fast);
}

.stage-card.stage-failed {
  border-color: rgba(244, 63, 94, 0.5);
  background: rgba(244, 63, 94, 0.05);
}

.stage-card.stage-passed {
  border-color: rgba(16, 185, 129, 0.3);
}

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

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

.stage-num {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-default);
}

.stage-badge {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}

.stage-badge.badge-pass {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.stage-badge.badge-fail {
  background: rgba(244, 63, 94, 0.2);
  color: #fb7185;
}

.stage-checks-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  font-size: 0.6875rem;
}

.check-item.check-pass { color: #34d399; }
.check-item.check-fail { color: #fb7185; font-weight: 600; }

