/* ============================================================
   MIRAE DASHBOARD - app.css
   Premium Dark Glassmorphism UI
   ============================================================ */

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

/* ── CSS Custom Properties ────────────────────────────────── */
:root {
  /* Colors */
  --bg-primary:        #080d1a;
  --bg-secondary:      #0d1526;
  --bg-tertiary:       #111d35;
  --card-bg:           rgba(255, 255, 255, 0.04);
  --card-border:       rgba(255, 255, 255, 0.08);
  --card-hover-bg:     rgba(255, 255, 255, 0.07);
  --card-hover-border: rgba(59, 130, 246, 0.3);

  /* Brand */
  --blue:    #3b82f6;
  --blue-dark: #2563eb;
  --blue-glow: rgba(59, 130, 246, 0.25);
  --blue-light: rgba(59, 130, 246, 0.12);

  /* Semantic */
  --green:   #10b981;
  --green-glow: rgba(16, 185, 129, 0.2);
  --red:     #ef4444;
  --red-dark: #dc2626;
  --red-glow: rgba(239, 68, 68, 0.25);
  --amber:   #f59e0b;
  --amber-glow: rgba(245, 158, 11, 0.2);
  --purple:  #8b5cf6;

  /* Text */
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --text-inverse:   #080d1a;

  /* 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;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* Borders */
  --radius-sm:  0.375rem;
  --radius-md:  0.625rem;
  --radius-lg:  0.875rem;
  --radius-xl:  1.25rem;
  --radius-2xl: 1.75rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.6);
  --shadow-blue: 0 4px 24px rgba(59, 130, 246, 0.3);
  --shadow-green: 0 4px 24px rgba(16, 185, 129, 0.3);
  --shadow-red: 0 4px 24px rgba(239, 68, 68, 0.4);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --transition-slow: 0.4s ease;

  /* Layout */
  --sidebar-width: 240px;
  --header-height: 60px;
  --bottom-nav-height: 64px;
  --content-max: 1400px;
}

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

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

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

a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
img, svg { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: rgba(59,130,246,0.5); }
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.12) var(--bg-secondary); }

/* ── Background Mesh ──────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 10%, rgba(59,130,246,0.07) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(139,92,246,0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Layout Shell ─────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: rgba(8, 13, 26, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-base);
  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(--card-border);
  min-height: var(--header-height);
}

.brand-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: #fff;
  flex-shrink: 0;
  box-shadow: var(--shadow-blue);
}

.brand-text {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: var(--space-4) var(--space-3);
  flex: 1;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--space-4) var(--space-3) var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.625rem var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
  position: relative;
  margin-bottom: 2px;
}

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

.nav-item.active {
  background: var(--blue-light);
  color: var(--blue);
  font-weight: 600;
}

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

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 2; }

.sidebar-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--card-border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.user-role {
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* ── Header ───────────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  height: var(--header-height);
  background: rgba(8, 13, 26, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5);
  z-index: 90;
  gap: var(--space-4);
}

@media (min-width: 768px) {
  .app-header { left: var(--sidebar-width); }
}

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

.header-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

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

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

.broker-status-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  border: 1px solid;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.broker-status-chip.valid {
  background: rgba(16,185,129,0.1);
  border-color: rgba(16,185,129,0.3);
  color: var(--green);
}

.broker-status-chip.expired {
  background: rgba(239,68,68,0.1);
  border-color: rgba(239,68,68,0.3);
  color: var(--red);
  animation: chipPulse 2s infinite;
}

@keyframes chipPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.3); }
  50% { box-shadow: 0 0 0 4px rgba(239,68,68,0); }
}

.header-logout {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  transition: all var(--transition-fast);
}

.header-logout:hover {
  border-color: var(--red);
  color: var(--red);
  background: rgba(239,68,68,0.08);
}

.header-logout svg { width: 14px; height: 14px; }

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-top: var(--header-height);
  padding: var(--space-5) var(--space-4);
  padding-bottom: calc(var(--bottom-nav-height) + var(--space-4));
  position: relative;
  z-index: 1;
  min-height: calc(100vh - var(--header-height));
}

@media (min-width: 768px) {
  .main-content {
    margin-left: var(--sidebar-width);
    padding-bottom: var(--space-8);
    padding: var(--space-6);
    padding-top: calc(var(--header-height) + var(--space-6));
  }
}

/* ── Bottom Navigation (Mobile) ───────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: rgba(8, 13, 26, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 200;
  padding: 0 var(--space-2);
}

@media (min-width: 768px) { .bottom-nav { display: none; } }

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
  min-width: 52px;
  min-height: 48px;
  position: relative;
  border: none;
  background: transparent;
  text-decoration: none;
}

.bottom-nav-item svg { width: 22px; height: 22px; stroke-width: 1.8; }

.bottom-nav-item.active {
  color: var(--blue);
}

.bottom-nav-item.active::after {
  content: '';
  position: absolute;
  top: -1px;
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--blue);
  border-radius: 0 0 var(--radius-full) var(--radius-full);
}

/* More dropdown */
.more-menu {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 8px);
  right: var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  padding: var(--space-3);
  display: none;
  flex-direction: column;
  gap: var(--space-1);
  z-index: 300;
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  animation: slideUp 0.2s ease;
}

.more-menu.open { display: flex; }

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

.more-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
  text-decoration: none;
}

.more-menu-item:hover, .more-menu-item.active {
  background: var(--blue-light);
  color: var(--blue);
}

.more-menu-item svg { width: 18px; height: 18px; }

/* ── Desktop: hide sidebar on mobile ──────────────────────── */
@media (max-width: 767px) {
  .sidebar { display: none; }
  .mobile-brand { display: flex; }
}
@media (min-width: 768px) {
  .mobile-brand { display: none !important; }
}

/* ── Glass Card ───────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 60%);
  pointer-events: none;
}

.card:hover {
  border-color: var(--card-hover-border);
  background: var(--card-hover-bg);
  transform: translateY(-1px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

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

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.card-title svg { width: 16px; height: 16px; color: var(--blue); }

/* ── Stat Card ────────────────────────────────────────────── */
.stat-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--blue), var(--purple));
  opacity: 0;
  transition: opacity var(--transition-base);
}

.stat-card:hover::after { opacity: 1; }
.stat-card:hover {
  border-color: var(--card-hover-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-blue);
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
}

.stat-icon svg { width: 20px; height: 20px; }

.stat-icon.blue { background: var(--blue-light); color: var(--blue); }
.stat-icon.green { background: rgba(16,185,129,0.12); color: var(--green); }
.stat-icon.red { background: rgba(239,68,68,0.12); color: var(--red); }
.stat-icon.amber { background: rgba(245,158,11,0.12); color: var(--amber); }
.stat-icon.purple { background: rgba(139,92,246,0.12); color: var(--purple); }

.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-2);
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: var(--space-2);
}

.stat-value.profit { color: var(--green); }
.stat-value.loss   { color: var(--red); }

.stat-change {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Grid Layouts ─────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }

@media (min-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.badge-profit  { background: rgba(16,185,129,0.15); color: var(--green); border: 1px solid rgba(16,185,129,0.25); }
.badge-loss    { background: rgba(239,68,68,0.15);  color: var(--red);   border: 1px solid rgba(239,68,68,0.25); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--amber); border: 1px solid rgba(245,158,11,0.25); }
.badge-neutral { background: rgba(148,163,184,0.1); color: var(--text-secondary); border: 1px solid rgba(148,163,184,0.2); }
.badge-blue    { background: var(--blue-light);     color: var(--blue);  border: 1px solid rgba(59,130,246,0.25); }
.badge-purple  { background: rgba(139,92,246,0.12); color: var(--purple); border: 1px solid rgba(139,92,246,0.25); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.625rem var(--space-5);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-sans);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 42px;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background var(--transition-fast);
}

.btn:active { transform: scale(0.97); }
.btn:active::after { background: rgba(0,0,0,0.1); }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; stroke-width: 2.5; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 2px 12px rgba(59,130,246,0.35);
}
.btn-primary:hover {
  background: var(--blue-dark);
  box-shadow: var(--shadow-blue);
  transform: translateY(-1px);
}

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

.btn-danger {
  background: var(--red);
  color: #fff;
  box-shadow: 0 2px 12px rgba(239,68,68,0.3);
}
.btn-danger:hover {
  background: var(--red-dark);
  box-shadow: var(--shadow-red);
  transform: translateY(-1px);
}

.btn-warning {
  background: var(--amber);
  color: #000;
  box-shadow: 0 2px 12px rgba(245,158,11,0.3);
}
.btn-warning:hover {
  background: #d97706;
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--card-border);
}
.btn-ghost:hover {
  background: var(--card-bg);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.15);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  min-height: 36px;
  border-radius: var(--radius-md);
}

.btn-sm {
  padding: 0.375rem var(--space-4);
  font-size: 0.78rem;
  min-height: 34px;
}

.btn-lg {
  padding: 0.875rem var(--space-8);
  font-size: 1rem;
  min-height: 52px;
}

.btn-block { width: 100%; }

/* ── Emergency Kill Button ────────────────────────────────── */
.btn-kill {
  background: linear-gradient(135deg, #7f1d1d, #991b1b);
  color: #fca5a5;
  border: 2px solid rgba(239,68,68,0.4);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  position: relative;
  overflow: visible;
}

.btn-kill::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: calc(var(--radius-md) + 4px);
  border: 2px solid rgba(239,68,68,0);
  transition: all 0.3s ease;
}

.btn-kill:hover {
  background: linear-gradient(135deg, #991b1b, #dc2626);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(239,68,68,0.2), 0 8px 32px rgba(239,68,68,0.5);
  transform: translateY(-1px);
  border-color: rgba(239,68,68,0.7);
  animation: killPulse 1s infinite;
}

@keyframes killPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(239,68,68,0.2), 0 8px 32px rgba(239,68,68,0.5); }
  50% { box-shadow: 0 0 0 8px rgba(239,68,68,0.1), 0 8px 32px rgba(239,68,68,0.6); }
}

.btn-kill.armed {
  animation: killArmed 0.5s ease infinite alternate;
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

@keyframes killArmed {
  from { box-shadow: 0 0 0 0 rgba(239,68,68,0.5); }
  to { box-shadow: 0 0 0 12px rgba(239,68,68,0); }
}

/* ── Status Dot ───────────────────────────────────────────── */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.running {
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(16,185,129,0.4);
  animation: greenPulse 2s infinite;
}

@keyframes greenPulse {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
  70%  { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

.status-dot.stopped { background: var(--red); }
.status-dot.paused  { background: var(--amber); }
.status-dot.idle    { background: var(--text-muted); }

/* ── Strategy Status Banner ───────────────────────────────── */
.strategy-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
}

.strategy-banner.running { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.2); }
.strategy-banner.stopped { background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.15); }
.strategy-banner.paused  { background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.15); }

.strategy-banner-text { font-weight: 600; font-size: 0.9rem; }
.strategy-banner-sub  { font-size: 0.75rem; color: var(--text-secondary); }

/* ── Forms ────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.form-label svg { width: 14px; height: 14px; }

.form-control {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  padding: 0.625rem var(--space-4);
  transition: all var(--transition-fast);
  width: 100%;
  min-height: 44px;
  outline: none;
  -webkit-appearance: none;
}

.form-control:focus {
  border-color: var(--blue);
  background: rgba(59,130,246,0.06);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

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

.form-control::-webkit-calendar-picker-indicator {
  filter: invert(0.5);
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
  cursor: pointer;
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 640px) {
  .form-row { grid-template-columns: 1fr 1fr; }
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group .form-control {
  padding-left: 2.5rem;
}

.input-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  pointer-events: none;
}

.input-icon svg { width: 16px; height: 16px; }

.input-action {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: color var(--transition-fast);
}

.input-action:hover { color: var(--text-primary); }
.input-action svg { width: 16px; height: 16px; }

/* Toggle Switch */
.toggle-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
}

.toggle-info { flex: 1; }
.toggle-label { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.toggle-desc  { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

.toggle {
  position: relative;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

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

.toggle-track {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.toggle-track::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition-fast);
}

.toggle input:checked + .toggle-track {
  background: var(--blue);
  border-color: var(--blue);
}

.toggle input:checked + .toggle-track::before {
  transform: translateX(22px);
  background: #fff;
}

.toggle-danger input:checked + .toggle-track {
  background: var(--red);
  border-color: var(--red);
  box-shadow: 0 0 12px rgba(239,68,68,0.4);
}

/* ── Table ────────────────────────────────────────────────── */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-lg);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.825rem;
  min-width: 600px;
}

thead tr {
  border-bottom: 1px solid var(--card-border);
}

th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

td {
  padding: 0.875rem var(--space-4);
  color: var(--text-primary);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  white-space: nowrap;
}

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

tbody tr:hover { background: rgba(255,255,255,0.03); }
tbody tr:last-child td { border-bottom: none; }

.td-profit { color: var(--green); font-weight: 600; }
.td-loss   { color: var(--red);   font-weight: 600; }
.td-muted  { color: var(--text-secondary); }
.td-symbol { font-weight: 700; font-family: var(--font-mono); letter-spacing: 0.03em; }
.td-mono   { font-family: var(--font-mono); font-size: 0.8rem; }

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 4px;
  margin-bottom: var(--space-5);
  overflow-x: auto;
}

.tab-btn {
  flex: 1;
  min-width: 80px;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 36px;
}

.tab-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.tab-btn.active {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,0.4);
}

.tab-count {
  background: rgba(255,255,255,0.15);
  color: inherit;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

.tab-btn.active .tab-count { background: rgba(255,255,255,0.25); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Toast Notifications ──────────────────────────────────── */
.toast-container {
  position: fixed;
  top: calc(var(--header-height) + var(--space-4));
  right: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  z-index: 9999;
  pointer-events: none;
  max-width: calc(100vw - 2rem);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid;
  min-width: 280px;
  max-width: 380px;
  pointer-events: all;
  animation: toastSlideIn 0.3s ease forwards;
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}

.toast-success {
  background: rgba(16,185,129,0.12);
  border-color: rgba(16,185,129,0.25);
}
.toast-success::before { background: var(--green); }

.toast-error {
  background: rgba(239,68,68,0.12);
  border-color: rgba(239,68,68,0.25);
}
.toast-error::before { background: var(--red); }

.toast-warning {
  background: rgba(245,158,11,0.12);
  border-color: rgba(245,158,11,0.25);
}
.toast-warning::before { background: var(--amber); }

.toast-info {
  background: rgba(59,130,246,0.12);
  border-color: rgba(59,130,246,0.25);
}
.toast-info::before { background: var(--blue); }

.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-icon svg { width: 18px; height: 18px; }
.toast-success .toast-icon { color: var(--green); }
.toast-error   .toast-icon { color: var(--red); }
.toast-warning .toast-icon { color: var(--amber); }
.toast-info    .toast-icon { color: var(--blue); }

.toast-body { flex: 1; }
.toast-title { font-size: 0.825rem; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; }
.toast-message { font-size: 0.775rem; color: var(--text-secondary); line-height: 1.4; }

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  flex-shrink: 0;
  transition: color var(--transition-fast);
  display: flex;
  align-items: center;
}

.toast-close:hover { color: var(--text-primary); }
.toast-close svg { width: 14px; height: 14px; }

.toast.exiting { animation: toastSlideOut 0.25s ease forwards; }

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0); max-height: 100px; }
  to   { opacity: 0; transform: translateX(100%); max-height: 0; padding: 0; margin: 0; }
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden { display: none; }

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

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  width: 100%;
  max-width: 440px;
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-lg);
  position: relative;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.modal-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-icon.danger  { background: rgba(239,68,68,0.12); color: var(--red); }
.modal-icon.warning { background: rgba(245,158,11,0.12); color: var(--amber); }
.modal-icon.info    { background: var(--blue-light); color: var(--blue); }
.modal-icon svg     { width: 22px; height: 22px; }

.modal-title { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.modal-subtitle { font-size: 0.78rem; color: var(--text-muted); }

.modal-body {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
  margin-bottom: var(--space-6);
}

.modal-footer {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

/* ── Loading Spinner ──────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

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

.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-12);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ── 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: skeleton 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

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

.skeleton-text  { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 24px; margin-bottom: 12px; width: 60%; }
.skeleton-card  { height: 120px; border-radius: var(--radius-xl); }
.skeleton-row   { height: 48px; margin-bottom: 4px; }

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

.empty-state-icon {
  width: 64px;
  height: 64px;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.empty-state-icon svg { width: 28px; height: 28px; }

.empty-state-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 280px;
}

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

.page-info {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 0 var(--space-3);
}

/* ── Filter Bar ───────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
  margin-bottom: var(--space-5);
  padding: var(--space-4);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 140px;
  flex: 1;
}

.filter-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.page-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Log Terminal ─────────────────────────────────────────── */
.log-terminal {
  background: #05080f;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.8;
  max-height: 560px;
  overflow-y: auto;
}

.log-line {
  display: flex;
  gap: var(--space-3);
  padding: 1px 0;
  border-radius: 3px;
}

.log-line:hover { background: rgba(255,255,255,0.03); }

.log-ts   { color: #4b5563; flex-shrink: 0; font-size: 0.72rem; }
.log-src  { color: #6366f1; flex-shrink: 0; min-width: 80px; }
.log-msg  { color: #9ca3af; word-break: break-word; }

.log-INFO     .log-msg { color: #9ca3af; }
.log-WARNING  .log-msg { color: var(--amber); }
.log-ERROR    .log-msg { color: var(--red); }
.log-CRITICAL { background: rgba(239,68,68,0.08); border-radius: 4px; padding: 0 4px; }
.log-CRITICAL .log-msg { color: #fca5a5; font-weight: 600; }
.log-level-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  flex-shrink: 0;
  min-width: 64px;
  text-align: center;
}
.log-INFO .log-level-badge    { background: rgba(148,163,184,0.1); color: #94a3b8; }
.log-WARNING .log-level-badge { background: rgba(245,158,11,0.1);  color: var(--amber); }
.log-ERROR .log-level-badge   { background: rgba(239,68,68,0.15);  color: var(--red); }
.log-CRITICAL .log-level-badge{ background: rgba(239,68,68,0.25);  color: #fca5a5; }

/* ── Section Divider ──────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--card-border);
  margin: var(--space-5) 0;
}

/* ── Risk Status Banner ───────────────────────────────────── */
.risk-banner {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  font-weight: 600;
  font-size: 0.875rem;
}

.risk-banner.safe   { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.2); color: var(--green); }
.risk-banner.danger { background: rgba(239,68,68,0.1);  border: 1px solid rgba(239,68,68,0.2);  color: var(--red);   animation: riskPulse 2s infinite; }

@keyframes riskPulse {
  0%,100% { box-shadow: none; }
  50% { box-shadow: 0 0 16px rgba(239,68,68,0.2); }
}

.risk-banner svg { width: 20px; height: 20px; }

/* ── Summary Footer Row ───────────────────────────────────── */
.summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  margin-top: var(--space-4);
}

.summary-item { flex: 1; min-width: 100px; }
.summary-item-label { font-size: 0.68rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.summary-item-value { font-size: 1rem; font-weight: 700; color: var(--text-primary); margin-top: 2px; }
.summary-item-value.profit { color: var(--green); }
.summary-item-value.loss   { color: var(--red); }

/* ── OTP Modal specific ───────────────────────────────────── */
.otp-input {
  letter-spacing: 0.4em;
  font-size: 1.5rem;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 700;
}

/* ── Utility Classes ──────────────────────────────────────── */
.flex          { display: flex; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2         { gap: var(--space-2); }
.gap-3         { gap: var(--space-3); }
.gap-4         { gap: var(--space-4); }
.flex-wrap     { flex-wrap: wrap; }
.flex-1        { flex: 1; }
.text-right    { text-align: right; }
.text-center   { text-align: center; }
.text-sm       { font-size: 0.875rem; }
.text-xs       { font-size: 0.75rem; }
.text-muted    { color: var(--text-muted); }
.text-secondary{ color: var(--text-secondary); }
.text-profit   { color: var(--green); }
.text-loss     { color: var(--red); }
.text-blue     { color: var(--blue); }
.text-amber    { color: var(--amber); }
.font-mono     { font-family: var(--font-mono); }
.font-bold     { font-weight: 700; }
.font-semibold { font-weight: 600; }
.mb-0 { margin-bottom: 0; }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ── Page fade-in ─────────────────────────────────────────── */
.page-enter {
  animation: pageFadeIn 0.3s ease;
}

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

/* ── Watchlist table action btns ──────────────────────────── */
.icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.3); color: var(--red); }
.icon-btn svg { width: 14px; height: 14px; }

/* ── Responsive adjustments ───────────────────────────────── */
@media (max-width: 480px) {
  .stat-value { font-size: 1.3rem; }
  .card { padding: var(--space-4); }
  .btn { font-size: 0.825rem; }
  .page-title { font-size: 1.1rem; }
  .filter-bar { flex-direction: column; }
  .filter-group { min-width: 100%; }
}
