/* ============================================================
   A&V Trading Bot — Design System
   Premium Dark Theme with Glassmorphism
   ============================================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
  /* Colors — Backgrounds */
  --bg-primary: #0b0d13;
  --bg-secondary: #12151e;
  --bg-tertiary: #161a25;
  --bg-card: rgba(22, 26, 37, 0.75);
  --bg-card-solid: #161a25;
  --bg-hover: rgba(59, 130, 246, 0.08);
  --bg-input: rgba(11, 13, 19, 0.7);
  --bg-sidebar: rgba(18, 21, 30, 0.96);

  /* Colors — Borders */
  --border-primary: #222634;
  --border-secondary: rgba(255, 255, 255, 0.08);
  --border-focus: #3B82F6;
  --border-card: rgba(255, 255, 255, 0.1);

  /* Colors — Accent */
  --accent: #3B82F6;
  --accent-hover: #2563EB;
  --accent-light: rgba(59, 130, 246, 0.12);
  --accent-glow: rgba(59, 130, 246, 0.25);

  /* Colors — Semantic */
  --profit: #10B981;
  --profit-light: rgba(16, 185, 129, 0.12);
  --profit-glow: rgba(16, 185, 129, 0.25);
  --loss: #F43F5E;
  --loss-light: rgba(244, 63, 94, 0.12);
  --loss-glow: rgba(244, 63, 94, 0.25);
  --warning: #F59E0B;
  --warning-light: rgba(245, 158, 11, 0.12);
  --info: #8B5CF6;
  --info-light: rgba(139, 92, 246, 0.12);

  /* Colors — Text */
  --text-primary: #e4e4e7;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --text-heading: #f4f4f5;
  --text-inverse: #0f1117;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;

  /* Font Sizes */
  --text-xs: 0.694rem;
  --text-sm: 0.833rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 24px 60px rgba(0, 0, 0, 0.5), 0 8px 20px rgba(0, 0, 0, 0.35);
  --shadow-glow-blue: 0 0 20px rgba(59, 130, 246, 0.2), 0 0 40px rgba(59, 130, 246, 0.08);
  --shadow-glow-green: 0 0 20px rgba(16, 185, 129, 0.2);
  --shadow-glow-red: 0 0 20px rgba(244, 63, 94, 0.2);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.04);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.35s ease;
  --transition-spring: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-collapsed: 68px;
  --header-height: 0px;
  --content-max-width: 1440px;

  /* Z-index layers */
  --z-sidebar: 100;
  --z-overlay: 200;
  --z-modal: 300;
  --z-toast: 400;
  --z-tooltip: 500;
}

/* ============================================================
   Reset / Normalize
   ============================================================ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover { color: var(--accent-hover); }

img, svg { display: block; max-width: 100%; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  outline: none;
  border: none;
  background: none;
}

button { cursor: pointer; }

ul, ol { list-style: none; }

table {
  border-collapse: collapse;
  width: 100%;
}

::selection {
  background: var(--accent);
  color: #fff;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

/* ============================================================
   Typography
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-heading);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h1 { font-size: var(--text-3xl); font-weight: 700; }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-base); }
h6 { font-size: var(--text-sm); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); }

.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-profit { color: var(--profit); }
.text-loss { color: var(--loss); }
.text-warning { color: var(--warning); }
.text-accent { color: var(--accent); }
.font-mono { font-family: var(--font-mono); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ============================================================
   Layout — Sidebar + Main
   ============================================================ */
.layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-primary);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: transform var(--transition-slow);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-5);
  border-bottom: 1px solid var(--border-primary);
}

.sidebar__logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--accent), #8B5CF6);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 18px rgba(59,130,246,0.25);
}

.sidebar__title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.2;
}

.sidebar__subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Bot Status Indicator */
.sidebar__status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-4) var(--space-5);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
}

.sidebar__status--running {
  background: var(--profit-light);
  color: var(--profit);
  border: 1px solid rgba(16,185,129,0.2);
}

.sidebar__status--stopped {
  background: var(--loss-light);
  color: var(--loss);
  border: 1px solid rgba(244,63,94,0.2);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot--live {
  background: var(--profit);
  box-shadow: 0 0 6px var(--profit);
  animation: pulse-dot 2s ease-in-out infinite;
}

.status-dot--off {
  background: var(--loss);
  box-shadow: 0 0 6px var(--loss);
}

/* Sidebar Navigation */
.sidebar__nav {
  flex: 1;
  padding: var(--space-4) var(--space-3);
}

.sidebar__section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-4) var(--space-3) var(--space-2);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  margin-bottom: 2px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition-base);
  position: relative;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-link--active {
  color: var(--accent) !important;
  background: var(--accent-light) !important;
}

.nav-link--active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}

.nav-icon {
  font-size: 1.15rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar__footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-primary);
}

.sidebar__footer .nav-link {
  color: var(--text-muted);
}
.sidebar__footer .nav-link:hover {
  color: var(--loss);
  background: var(--loss-light);
}

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

.main__header {
  position: sticky;
  top: 0;
  background: rgba(15, 17, 23, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-primary);
  padding: var(--space-4) var(--space-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 50;
}

.main__title {
  font-size: var(--text-xl);
  font-weight: 700;
}

.main__content {
  flex: 1;
  padding: var(--space-8);
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

/* Mobile hamburger */
.mobile-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  color: var(--text-primary);
  font-size: 1.3rem;
  cursor: pointer;
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: calc(var(--z-sidebar) - 1);
}

/* ============================================================
   Card Component
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-sm), var(--shadow-inset);
  transition: box-shadow var(--transition-base), transform var(--transition-base);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md), var(--shadow-inset);
}

.card--interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), var(--shadow-inset);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-secondary);
}

.card__title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-heading);
}

.card__body {
  padding: var(--space-5) var(--space-6);
}

.card__footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-secondary);
}

/* Stat Card */
.stat-card {
  padding: var(--space-5) var(--space-6);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.5;
}

.stat-card--profit::before {
  background: linear-gradient(90deg, transparent, var(--profit), transparent);
}

.stat-card--loss::before {
  background: linear-gradient(90deg, transparent, var(--loss), transparent);
}

.stat-card--warning::before {
  background: linear-gradient(90deg, transparent, var(--warning), transparent);
}

.stat-card__icon {
  font-size: 1.5rem;
  margin-bottom: var(--space-3);
}

.stat-card__label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: var(--space-1);
}

.stat-card__value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.2;
}

.stat-card__change {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  margin-top: var(--space-2);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.stat-card__change--up {
  color: var(--profit);
  background: var(--profit-light);
}

.stat-card__change--down {
  color: var(--loss);
  background: var(--loss-light);
}

/* ============================================================
   Grid System
   ============================================================ */
.grid { display: grid; gap: var(--space-6); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--auto-fit { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.flex { display: flex; }
.flex--center { align-items: center; justify-content: center; }
.flex--between { align-items: center; justify-content: space-between; }
.flex--wrap { flex-wrap: wrap; }
.flex--col { flex-direction: column; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-weight: 600;
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, transparent 100%);
  pointer-events: none;
}

.btn:active { transform: scale(0.97); }

.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,0.3);
}
.btn--primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-glow-blue);
}

.btn--success {
  background: var(--profit);
  color: #fff;
  box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}
.btn--success:hover {
  background: #059669;
  box-shadow: var(--shadow-glow-green);
}

.btn--danger {
  background: var(--loss);
  color: #fff;
  box-shadow: 0 2px 8px rgba(244,63,94,0.3);
}
.btn--danger:hover {
  background: #E11D48;
  box-shadow: var(--shadow-glow-red);
}

.btn--warning {
  background: var(--warning);
  color: var(--text-inverse);
}
.btn--warning:hover {
  background: #D97706;
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-primary);
}
.btn--ghost:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  border-color: var(--accent);
}

.btn--outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn--outline:hover {
  background: var(--accent-light);
}

.btn--sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.btn--lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-base);
  border-radius: var(--radius-lg);
}

.btn--block { width: 100%; }

.btn--loading {
  pointer-events: none;
  opacity: 0.7;
}
.btn--loading .btn__text { opacity: 0; }
.btn--loading .btn__spinner { display: block; }

.btn__spinner {
  display: none;
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Emergency Stop */
.btn--emergency {
  background: linear-gradient(135deg, #E11D48, #BE123C);
  color: #fff;
  font-size: var(--text-lg);
  font-weight: 700;
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(244,63,94,0.35);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  animation: emergency-glow 2s ease-in-out infinite;
}

.btn--emergency:hover {
  background: linear-gradient(135deg, #F43F5E, #E11D48);
  box-shadow: 0 4px 30px rgba(244,63,94,0.5);
  transform: scale(1.02);
}

/* ============================================================
   Form Elements
   ============================================================ */
.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.form-input,
.form-select,
.form-textarea,
.form-control {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-input);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  transition: all var(--transition-base);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover,
.form-control:hover {
  border-color: rgba(255,255,255,0.15);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  background: rgba(11, 13, 19, 0.9);
  outline: none;
}

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

.form-control--sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
  cursor: pointer;
}

.form-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

/* Inline Form */
.form-inline {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
}

.form-inline .form-group {
  margin-bottom: 0;
  flex: 1;
}

/* Form Row */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-5);
}

/* Toggle Switch */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
}

.toggle input { display: none; }

.toggle__track {
  width: 44px;
  height: 24px;
  background: var(--border-primary);
  border-radius: var(--radius-full);
  position: relative;
  transition: background var(--transition-base);
  flex-shrink: 0;
}

.toggle__track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition-base);
}

.toggle input:checked + .toggle__track {
  background: var(--accent);
}

.toggle input:checked + .toggle__track::after {
  transform: translateX(20px);
  background: #fff;
}

.toggle__label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

/* ============================================================
   Tables
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
}

.table {
  width: 100%;
  font-size: var(--text-sm);
}

.table thead {
  background: rgba(255,255,255,0.03);
}

.table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: 600;
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-primary);
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-secondary);
  vertical-align: middle;
  white-space: nowrap;
}

.table tbody tr {
  transition: background var(--transition-fast);
}

.table tbody tr:hover {
  background: rgba(59,130,246,0.04);
}

.table tbody tr:nth-child(even) {
  background: rgba(255,255,255,0.015);
}

.table tbody tr:nth-child(even):hover {
  background: rgba(59,130,246,0.04);
}

.table--striped tbody tr:nth-child(odd) {
  background: rgba(255,255,255,0.02);
}

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge--active, .badge--running {
  background: var(--profit-light);
  color: var(--profit);
  border: 1px solid rgba(16,185,129,0.2);
}

.badge--stopped, .badge--closed {
  background: var(--loss-light);
  color: var(--loss);
  border: 1px solid rgba(244,63,94,0.2);
}

.badge--paper {
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid rgba(245,158,11,0.2);
}

.badge--live {
  background: var(--profit-light);
  color: var(--profit);
  border: 1px solid rgba(16,185,129,0.2);
}

.badge--profit {
  background: var(--profit-light);
  color: var(--profit);
}

.badge--loss {
  background: var(--loss-light);
  color: var(--loss);
}

.badge--info {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid rgba(59,130,246,0.2);
}

.badge--warning {
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid rgba(245,158,11,0.2);
}

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

.badge--buy, .badge--long {
  background: var(--profit-light);
  color: var(--profit);
}

.badge--sell, .badge--short {
  background: var(--loss-light);
  color: var(--loss);
}

/* ============================================================
   Alerts / Notifications
   ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  border: 1px solid;
  margin-bottom: var(--space-4);
  animation: fadeIn 0.3s ease;
}

.alert__icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert__content { flex: 1; }
.alert__title {
  font-weight: 600;
  margin-bottom: 2px;
}

.alert--success {
  background: var(--profit-light);
  border-color: rgba(16,185,129,0.25);
  color: var(--profit);
}

.alert--error {
  background: var(--loss-light);
  border-color: rgba(244,63,94,0.25);
  color: var(--loss);
}

.alert--warning {
  background: var(--warning-light);
  border-color: rgba(245,158,11,0.25);
  color: var(--warning);
}

.alert--info {
  background: var(--accent-light);
  border-color: rgba(59,130,246,0.25);
  color: var(--accent);
}

/* Flash Messages */
.flash-messages {
  margin-bottom: var(--space-6);
}

/* ============================================================
   Toast Notifications
   ============================================================ */
.toast-container {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-card-solid);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  min-width: 300px;
  max-width: 420px;
  pointer-events: auto;
  animation: slideInRight 0.35s var(--transition-spring);
  backdrop-filter: blur(16px);
}

.toast--success { border-left: 3px solid var(--profit); }
.toast--error { border-left: 3px solid var(--loss); }
.toast--warning { border-left: 3px solid var(--warning); }
.toast--info { border-left: 3px solid var(--accent); }

.toast__icon { font-size: 1.2rem; flex-shrink: 0; }
.toast__content { flex: 1; }
.toast__close {
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all var(--transition-fast);
}
.toast__close:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.06);
}

.toast--exit {
  animation: slideOutRight 0.3s ease forwards;
}

/* ============================================================
   Chart Containers
   ============================================================ */
.chart-container {
  position: relative;
  width: 100%;
  padding: var(--space-4);
}

.chart-container canvas {
  width: 100% !important;
}

.chart-container--sm { height: 200px; }
.chart-container--md { height: 320px; }
.chart-container--lg { height: 440px; }

/* ============================================================
   Loading Spinner
   ============================================================ */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(59,130,246,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner--sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.spinner--lg {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15,17,23,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: inherit;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-12);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.modal-overlay--active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card-solid);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.92) translateY(20px);
  transition: transform var(--transition-slow);
}

.modal-overlay--active .modal {
  transform: scale(1) translateY(0);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6);
  border-bottom: 1px solid var(--border-primary);
}

.modal__title {
  font-size: var(--text-lg);
  font-weight: 700;
}

.modal__close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 1.2rem;
  transition: all var(--transition-fast);
}

.modal__close:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}

.modal__body {
  padding: var(--space-6);
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-primary);
}

/* ============================================================
   Tabs
   ============================================================ */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border-primary);
  margin-bottom: var(--space-6);
  overflow-x: auto;
}

.tab {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-base);
  white-space: nowrap;
}

.tab:hover {
  color: var(--text-secondary);
}

.tab--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-6);
}

.pagination__btn {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-base);
  min-width: 36px;
  text-align: center;
}

.pagination__btn:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--accent);
  background: var(--accent-light);
}

.pagination__btn--active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.pagination__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================================
   Connection / Status Indicators
   ============================================================ */
.connection-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
}

.connection-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.connection-dot--connected {
  background: var(--profit);
  box-shadow: 0 0 8px var(--profit);
  animation: pulse-dot 2s ease-in-out infinite;
}

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

/* ============================================================
   Log Viewer
   ============================================================ */
.log-entry {
  display: grid;
  grid-template-columns: 140px 70px 100px 1fr;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  border-bottom: 1px solid var(--border-secondary);
  transition: background var(--transition-fast);
}

.log-entry:hover {
  background: rgba(255,255,255,0.02);
}

.log-entry__time { color: var(--text-muted); }
.log-entry__category { color: var(--text-secondary); }

.log-entry__level { font-weight: 600; }
.log-entry__level--debug { color: var(--text-muted); }
.log-entry__level--info { color: var(--accent); }
.log-entry__level--warning { color: var(--warning); }
.log-entry__level--error { color: var(--loss); }
.log-entry__level--critical { color: var(--loss); font-weight: 800; }

.log-entry__message {
  color: var(--text-primary);
  word-break: break-word;
  white-space: pre-wrap;
}

/* ============================================================
   Login Page
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: var(--space-6);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(59,130,246,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(139,92,246,0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 60% 80%, rgba(16,185,129,0.04) 0%, transparent 50%);
  animation: bgShift 20s ease-in-out infinite;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: var(--space-10);
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: 1;
}

.login-logo {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--accent), #8B5CF6);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  margin: 0 auto var(--space-5);
  box-shadow: 0 0 30px rgba(59,130,246,0.3);
}

.login-title {
  text-align: center;
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-8);
}

/* ============================================================
   Empty States
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  text-align: center;
}

.empty-state__icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  opacity: 0.4;
}

.empty-state__title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.empty-state__text {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 360px;
}

/* ============================================================
   Utility Classes
   ============================================================ */
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.w-full { width: 100%; }

/* ============================================================
   Animations / Keyframes
   ============================================================ */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(60px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(60px);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.15); }
}

@keyframes emergency-glow {
  0%, 100% { box-shadow: 0 4px 20px rgba(244,63,94,0.35); }
  50% { box-shadow: 0 4px 35px rgba(244,63,94,0.55), 0 0 60px rgba(244,63,94,0.15); }
}

@keyframes bgShift {
  0%, 100% { transform: translate(0,0) rotate(0deg); }
  33% { transform: translate(2%,-1%) rotate(1deg); }
  66% { transform: translate(-1%,2%) rotate(-1deg); }
}

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

/* Staggered fade-in for cards */
.animate-in {
  animation: fadeInUp 0.5s ease backwards;
}

.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.2s; }
.animate-in:nth-child(5) { animation-delay: 0.25s; }
.animate-in:nth-child(6) { animation-delay: 0.3s; }

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.08) 50%,
    rgba(255,255,255,0.04) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ============================================================
   Responsive Breakpoints
   ============================================================ */

/* Tablet and below */
@media (max-width: 1024px) {
  .grid--4 { grid-template-columns: repeat(2, 1fr); }
  .grid--3 { grid-template-columns: repeat(2, 1fr); }

  .main__content {
    padding: var(--space-6);
  }
}

/* Mobile */
@media (max-width: 768px) {
  html { font-size: 14px; }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar--open {
    transform: translateX(0);
  }

  .sidebar-overlay--active {
    display: block;
  }

  .main {
    margin-left: 0;
  }

  .mobile-toggle {
    display: flex;
  }

  .main__content {
    padding: var(--space-4);
  }

  .main__header {
    padding: var(--space-3) var(--space-4);
  }

  .grid--4,
  .grid--3,
  .grid--2 {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .log-entry {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }

  .card__header {
    padding: var(--space-4);
  }

  .card__body {
    padding: var(--space-4);
  }

  .stat-card {
    padding: var(--space-4);
  }

  .toast {
    min-width: unset;
    max-width: calc(100vw - 2rem);
  }

  .toast-container {
    right: var(--space-4);
    left: var(--space-4);
  }
}

/* Small mobile */
@media (max-width: 480px) {
  .login-card {
    padding: var(--space-6);
  }

  .pagination {
    flex-wrap: wrap;
  }
}

/* Large screens */
@media (min-width: 1600px) {
  html { font-size: 16px; }
}

/* Top Status Bar Ribbon */
.top-nav__status-bar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: 0 var(--space-4);
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
}

.top-nav__status-bar::-webkit-scrollbar {
  display: none; /* Safari and Chrome */
}

.top-status-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
}

.top-status-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.top-status-item .badge {
  font-size: 11px;
  padding: 2px 6px;
  font-weight: 700;
  border-radius: var(--radius-sm);
}

@media (max-width: 1150px) {
  .top-nav__status-bar {
    display: none;
  }
}

/* Dashboard Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: var(--space-6);
  margin-top: var(--space-6);
  align-items: start;
}

.dashboard-grid__left {
  display: flex;
  flex-direction: column;
}

.dashboard-grid__right {
  display: flex;
  flex-direction: column;
}

@media (max-width: 1200px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}
