/* ══════════════════════════════════════════════════════════════
   AlphaForge — AI Trading Terminal Design System
   ══════════════════════════════════════════════════════════════ */

/* ─── DESIGN TOKENS ─── */
:root {
  /* Core palette — Professional White + Navy */
  --bg-deepest:    #0A1128;
  --bg-deep:       #0F1B44;
  --bg-base:       #F2F4F8;
  --bg-elevated:   #FFFFFF;
  --bg-surface:    #EDF0F7;
  --bg-card:       #FFFFFF;
  --bg-hover:      #E8ECF4;
  --bg-active:     #DCE2EF;

  /* Sidebar-specific dark palette */
  --sidebar-bg:         #0A1128;
  --sidebar-bg-hover:   rgba(255,255,255,0.06);
  --sidebar-bg-active:  rgba(59,130,246,0.15);
  --sidebar-text:       rgba(255,255,255,0.65);
  --sidebar-text-bright:#FFFFFF;
  --sidebar-text-muted: rgba(255,255,255,0.35);
  --sidebar-border:     rgba(255,255,255,0.06);

  /* Borders */
  --border-subtle:  rgba(15, 27, 68, 0.06);
  --border-default: rgba(15, 27, 68, 0.10);
  --border-strong:  rgba(15, 27, 68, 0.18);
  --border-glow:    rgba(37, 99, 235, 0.25);

  /* Text */
  --text-primary:    #111827;
  --text-secondary:  #4B5563;
  --text-tertiary:   #9CA3AF;
  --text-disabled:   #D1D5DB;
  --text-inverse:    #FFFFFF;

  /* Accent: Professional Navy Blue */
  --cyan-50:  #EFF6FF;
  --cyan-100: #DBEAFE;
  --cyan-200: #BFDBFE;
  --cyan-300: #60A5FA;
  --cyan-400: #2563EB;
  --cyan-500: #1D4ED8;
  --cyan-600: #1E40AF;
  --cyan-700: #1E3A8A;
  --cyan-glow: rgba(37, 99, 235, 0.08);
  --cyan-glow-strong: rgba(37, 99, 235, 0.20);

  /* Semantic colors */
  --color-profit:    #059669;
  --color-profit-bg: rgba(5, 150, 105, 0.06);
  --color-profit-glow: rgba(5, 150, 105, 0.15);
  --color-loss:      #DC2626;
  --color-loss-bg:   rgba(220, 38, 38, 0.06);
  --color-loss-glow: rgba(220, 38, 38, 0.15);
  --color-neutral:   #6B7280;
  --color-warning:   #D97706;
  --color-warning-bg:rgba(217, 119, 6, 0.06);
  --color-info:      #2563EB;
  --color-info-bg:   rgba(37, 99, 235, 0.06);

  /* Agent colors */
  --agent-fundamentalist: #6366F1;
  --agent-technical:      #2563EB;
  --agent-quant:          #DC2626;
  --agent-risk:           #D97706;
  --agent-contrarian:     #8B5CF6;
  --agent-sentiment:      #EC4899;
  --agent-macro:          #059669;
  --agent-momentum:       #EA580C;

  /* Spacing */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  12px;
  --space-lg:  16px;
  --space-xl:  24px;
  --space-2xl: 32px;
  --space-3xl: 48px;

  /* Typography */
  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:  'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --font-xs:    11px;
  --font-sm:    12px;
  --font-base:  13px;
  --font-md:    14px;
  --font-lg:    16px;
  --font-xl:    20px;
  --font-2xl:   24px;
  --font-3xl:   32px;
  --font-hero:  48px;

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

  /* Shadows — subtle, professional */
  --shadow-sm:   0 1px 2px rgba(0,0,0,0.04), 0 1px 4px rgba(0,0,0,0.03);
  --shadow-md:   0 2px 8px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  --shadow-lg:   0 4px 12px rgba(0,0,0,0.06), 0 8px 32px rgba(0,0,0,0.06);
  --shadow-glow: 0 0 0 3px var(--cyan-glow);

  /* Transitions */
  --transition-fast:   0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow:   0.4s cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --sidebar-width:     260px;
  --sidebar-collapsed: 68px;
  --header-height:     56px;
  --content-max:       1600px;
}

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

html {
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}

a { color: var(--cyan-400); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--cyan-300); }

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

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ─── APP LAYOUT ─── */
.app-wrapper {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--header-height) 1fr;
  grid-template-areas:
    "sidebar header"
    "sidebar main";
  height: 100vh;
  overflow: hidden;
}

.app-wrapper.sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed) 1fr;
}

/* ─── SIDEBAR ─── */
.sidebar {
  grid-area: sidebar;
  background: var(--sidebar-bg);
  border-right: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
  transition: width var(--transition-normal);
}

.sidebar-brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 var(--space-lg);
  gap: var(--space-md);
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #3B82F6, #6366F1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.brand-icon::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #3B82F6, #6366F1);
  opacity: 0.25;
  filter: blur(8px);
  z-index: -1;
}

.brand-icon svg { width: 20px; height: 20px; fill: white; }

.brand-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand-name {
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--sidebar-text-bright);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-tagline {
  font-size: var(--font-xs);
  color: var(--sidebar-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md) var(--space-sm);
}

.nav-section {
  margin-bottom: var(--space-lg);
}

.nav-section-title {
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--sidebar-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-xs);
}

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

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

.nav-item.active {
  background: var(--sidebar-bg-active);
  color: #60A5FA;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: #3B82F6;
  border-radius: 0 3px 3px 0;
  box-shadow: none;
}

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

.nav-item.active svg { opacity: 1; }

.nav-item .nav-badge {
  margin-left: auto;
  background: rgba(59,130,246,0.25);
  color: #93C5FD;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}

.nav-item .nav-badge.live {
  background: var(--color-profit);
  animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Sidebar footer */
.sidebar-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-sm);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.sidebar-user:hover { background: var(--sidebar-bg-hover); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #3B82F6, #6366F1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-sm);
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.user-info { overflow: hidden; }
.user-name { font-size: var(--font-sm); font-weight: 600; color: var(--sidebar-text-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: var(--font-xs); color: var(--sidebar-text-muted); }

/* ─── HEADER ─── */
.header {
  grid-area: header;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
  z-index: 90;
}

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

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

.header-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-sm);
  color: var(--text-tertiary);
}

.header-breadcrumb span { color: var(--text-secondary); }

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

/* Market ticker strip */
.market-ticker {
  display: flex;
  gap: var(--space-lg);
  font-family: var(--font-mono);
  font-size: var(--font-xs);
}

.ticker-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.ticker-symbol { color: var(--text-secondary); font-weight: 600; }
.ticker-price { color: var(--text-primary); }
.ticker-change { font-weight: 600; }

/* Header buttons */
.header-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.header-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.header-btn .notification-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  background: var(--color-loss);
  border-radius: 50%;
  border: 1.5px solid var(--bg-elevated);
}

.header-btn svg { width: 18px; height: 18px; }

/* Search */
.header-search {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 0 var(--space-md);
  height: 36px;
  min-width: 240px;
  transition: all var(--transition-fast);
}

.header-search:focus-within {
  border-color: var(--cyan-400);
  box-shadow: 0 0 0 3px var(--cyan-glow);
}

.header-search svg { width: 16px; height: 16px; color: var(--text-tertiary); flex-shrink: 0; }

.header-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: var(--font-sm);
  font-family: var(--font-sans);
  width: 100%;
}

.header-search input::placeholder { color: var(--text-disabled); }

.header-search kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
  background: var(--bg-elevated);
  padding: 2px 5px;
  border-radius: 3px;
  border: 1px solid var(--border-default);
}

/* ─── MAIN CONTENT ─── */
.main-content {
  grid-area: main;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-xl);
  background: var(--bg-base);
  position: relative;
}

.main-content::before {
  display: none;
}

.page-content {
  position: relative;
  z-index: 1;
  max-width: var(--content-max);
}

/* ─── CARD SYSTEM ─── */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-normal);
}

.card:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-md);
}

.card-glass {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.card-title .card-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.card-body { padding: var(--space-xl); }
.card-body.compact { padding: var(--space-lg); }

.card-footer {
  padding: var(--space-md) var(--space-xl);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.card-stat::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  opacity: 0.05;
  transform: translate(30%, -30%);
}

.card-stat.profit::before { background: var(--color-profit); }
.card-stat.loss::before { background: var(--color-loss); }
.card-stat.info::before { background: var(--cyan-400); }

.stat-label {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.stat-value {
  font-size: var(--font-2xl);
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--font-sm);
  font-weight: 600;
  font-family: var(--font-mono);
  margin-top: var(--space-sm);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.stat-change.up { color: var(--color-profit); background: var(--color-profit-bg); }
.stat-change.down { color: var(--color-loss); background: var(--color-loss-bg); }
.stat-change.neutral { color: var(--text-secondary); background: var(--bg-surface); }

.stat-sparkline {
  margin-top: var(--space-md);
  opacity: 0.7;
}

/* ─── GRID LAYOUTS ─── */
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-lg); }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-lg); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-lg); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-lg); }
.grid-dashboard { display: grid; grid-template-columns: 2fr 1fr; gap: var(--space-lg); }
.grid-trading { display: grid; grid-template-columns: 1fr 340px; gap: var(--space-lg); }

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

/* ─── TABLES ─── */
.table-wrapper {
  overflow-x: auto;
}

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

.data-table thead th {
  text-align: left;
  padding: var(--space-md) var(--space-lg);
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  z-index: 1;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child { border-bottom: none; }

.data-table td {
  padding: var(--space-md) var(--space-lg);
  vertical-align: middle;
  white-space: nowrap;
}

.data-table .mono { font-family: var(--font-mono); font-size: var(--font-xs); }
.data-table .symbol-cell { font-weight: 600; color: var(--text-primary); }
.data-table .price-cell { font-family: var(--font-mono); }

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.4;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--cyan-400);
  color: var(--text-inverse);
  border-color: var(--cyan-400);
}

.btn-primary:hover {
  background: var(--cyan-300);
  border-color: var(--cyan-300);
  box-shadow: 0 0 20px var(--cyan-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-default);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-success {
  background: var(--color-profit);
  color: var(--text-inverse);
}

.btn-success:hover {
  box-shadow: 0 0 20px var(--color-profit-glow);
}

.btn-danger {
  background: var(--color-loss);
  color: white;
}

.btn-danger:hover {
  box-shadow: 0 0 20px var(--color-loss-glow);
}

.btn-sm { padding: 4px var(--space-md); font-size: var(--font-xs); }
.btn-lg { padding: var(--space-md) var(--space-xl); font-size: var(--font-md); }
.btn-icon { padding: var(--space-sm); }

/* ─── BADGES & TAGS ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-profit { background: var(--color-profit-bg); color: var(--color-profit); border: 1px solid rgba(5, 150, 105, 0.15); }
.badge-loss { background: var(--color-loss-bg); color: var(--color-loss); border: 1px solid rgba(220, 38, 38, 0.15); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); border: 1px solid rgba(217, 119, 6, 0.15); }
.badge-info { background: var(--color-info-bg); color: var(--color-info); border: 1px solid rgba(37, 99, 235, 0.15); }
.badge-neutral { background: var(--bg-surface); color: var(--text-secondary); border: 1px solid var(--border-default); }

.badge-live {
  background: var(--color-profit-bg);
  color: var(--color-profit);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.badge-live::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--color-profit);
  border-radius: 50%;
  animation: pulse-live 2s ease-in-out infinite;
}

@keyframes pulse-live {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* ─── FORMS ─── */
.form-group { margin-bottom: var(--space-lg); }

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

.form-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-base);
  font-family: var(--font-sans);
  transition: all var(--transition-fast);
  outline: none;
}

.form-input:focus {
  border-color: var(--cyan-400);
  box-shadow: 0 0 0 3px var(--cyan-glow);
}

.form-input::placeholder { color: var(--text-disabled); }

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239CA3AF' d='M6 8L1.5 3.5h9L6 8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

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

/* ─── TABS ─── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 var(--space-xl);
}

.tab {
  padding: var(--space-md) var(--space-lg);
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tab:hover { color: var(--text-secondary); }
.tab.active { color: var(--cyan-400); border-bottom-color: var(--cyan-400); }

/* ─── TEXT UTILITIES ─── */
.text-profit { color: var(--color-profit) !important; }
.text-loss { color: var(--color-loss) !important; }
.text-neutral { color: var(--text-secondary) !important; }
.text-warning { color: var(--color-warning) !important; }
.text-info { color: var(--cyan-400) !important; }
.text-muted { color: var(--text-tertiary) !important; }
.text-xs { font-size: var(--font-xs) !important; }
.text-sm { font-size: var(--font-sm) !important; }
.text-mono { font-family: var(--font-mono) !important; }
.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.font-bold { font-weight: 700 !important; }
.whitespace-nowrap { white-space: nowrap; }

/* Spacing utilities */
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

/* ─── PROGRESS BARS ─── */
.progress-bar {
  height: 4px;
  background: var(--bg-surface);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width var(--transition-normal);
}

.progress-fill.profit { background: var(--color-profit); }
.progress-fill.loss { background: var(--color-loss); }
.progress-fill.info { background: var(--cyan-400); }
.progress-fill.warning { background: var(--color-warning); }

/* ─── CHART CONTAINER ─── */
.chart-container {
  position: relative;
  width: 100%;
  min-height: 300px;
}

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

/* ─── AI AGENT STYLES ─── */
.agent-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--font-md);
  color: white;
  flex-shrink: 0;
  position: relative;
}

.agent-avatar.fundamentalist { background: linear-gradient(135deg, #6c5ce7, #a29bfe); }
.agent-avatar.technical { background: linear-gradient(135deg, #0984e3, #74b9ff); }
.agent-avatar.quant { background: linear-gradient(135deg, #d63031, #ff7675); }
.agent-avatar.risk_manager { background: linear-gradient(135deg, #f39c12, #ffeaa7); color: #2d3436; }
.agent-avatar.contrarian { background: linear-gradient(135deg, #6c5ce7, #fd79a8); }
.agent-avatar.sentiment { background: linear-gradient(135deg, #e84393, #fd79a8); }

.agent-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-elevated);
}

.agent-status-dot.online { background: var(--color-profit); }
.agent-status-dot.thinking { background: var(--color-warning); animation: pulse-live 1s ease-in-out infinite; }
.agent-status-dot.offline { background: var(--text-tertiary); }

/* Agent debate */
.debate-thread {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  max-height: 500px;
  overflow-y: auto;
  padding: var(--space-lg);
}

.debate-message {
  display: flex;
  gap: var(--space-md);
  animation: fadeInUp 0.3s ease-out;
}

.debate-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  max-width: 80%;
}

.debate-bubble .agent-name {
  font-size: var(--font-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
}

.debate-bubble .agent-message {
  font-size: var(--font-base);
  color: var(--text-secondary);
  line-height: 1.6;
}

.debate-bubble .sentiment-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: var(--space-sm);
  font-size: var(--font-xs);
  font-weight: 600;
}

.debate-verdict {
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-card));
  border: 1px solid var(--cyan-400);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  box-shadow: var(--shadow-glow);
}

.debate-verdict h3 {
  font-size: var(--font-lg);
  color: var(--cyan-400);
  margin-bottom: var(--space-sm);
}

/* ─── STRATEGY CARDS ─── */
.strategy-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.strategy-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.strategy-card .strategy-status {
  position: absolute;
  top: 0;
  right: 0;
  padding: var(--space-xs) var(--space-lg);
  font-size: var(--font-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 0 var(--radius-lg) 0 var(--radius-md);
}

.strategy-status.live { background: var(--color-profit-bg); color: var(--color-profit); }
.strategy-status.paper { background: var(--color-info-bg); color: var(--color-info); }
.strategy-status.backtest { background: var(--color-warning-bg); color: var(--color-warning); }
.strategy-status.draft { background: var(--bg-surface); color: var(--text-tertiary); }

/* ─── LOADING & ANIMATIONS ─── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

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

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

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

.loading-pulse {
  animation: pulse-live 1.5s ease-in-out infinite;
}

.animate-in { animation: fadeInUp 0.4s ease-out forwards; }

/* Staggered animations */
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }
.stagger-5 { animation-delay: 0.25s; }

/* ─── NOTIFICATION PANEL ─── */
.notification-panel {
  position: fixed;
  top: var(--header-height);
  right: 0;
  width: 380px;
  max-height: calc(100vh - var(--header-height));
  background: var(--bg-elevated);
  border-left: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform var(--transition-normal);
}

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

.notification-item {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.notification-item:hover { background: var(--bg-hover); }

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

.notification-icon.success { background: var(--color-profit-bg); color: var(--color-profit); }
.notification-icon.warning { background: var(--color-warning-bg); color: var(--color-warning); }
.notification-icon.danger { background: var(--color-loss-bg); color: var(--color-loss); }
.notification-icon.info { background: var(--color-info-bg); color: var(--color-info); }

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all var(--transition-normal);
}

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

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform var(--transition-normal);
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title { font-size: var(--font-lg); font-weight: 700; }

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body { padding: var(--space-xl); }
.modal-footer { padding: var(--space-lg) var(--space-xl); border-top: 1px solid var(--border-subtle); display: flex; justify-content: flex-end; gap: var(--space-md); }

/* ─── TOGGLE SWITCH ─── */
.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  cursor: pointer;
}

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

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 11px;
  transition: all var(--transition-fast);
}

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

.toggle input:checked + .toggle-slider {
  background: var(--cyan-glow);
  border-color: var(--cyan-400);
}

.toggle input:checked + .toggle-slider::before {
  background: var(--cyan-400);
  transform: translateX(18px);
}

/* ─── TOOLTIP ─── */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: var(--font-xs);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  pointer-events: none;
  border: 1px solid var(--border-default);
  z-index: 1000;
}

[data-tooltip]:hover::after { opacity: 1; visibility: visible; }

/* ─── EMPTY STATE ─── */
.empty-state {
  text-align: center;
  padding: var(--space-3xl);
}

.empty-state svg { width: 64px; height: 64px; color: var(--text-disabled); margin: 0 auto var(--space-lg); }
.empty-state h3 { font-size: var(--font-lg); color: var(--text-secondary); margin-bottom: var(--space-sm); }
.empty-state p { font-size: var(--font-sm); color: var(--text-tertiary); max-width: 400px; margin: 0 auto; }

/* ─── PORTFOLIO PIE ─── */
.allocation-ring {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto;
}

.allocation-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }

.allocation-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.allocation-center .value { font-size: var(--font-xl); font-weight: 700; font-family: var(--font-mono); }
.allocation-center .label { font-size: var(--font-xs); color: var(--text-tertiary); }

/* ─── HAMBURGER MENU ─── */
.hamburger-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  margin-right: 8px;
  border-radius: 8px;
  transition: background 0.2s;
}
.hamburger-btn:hover { background: var(--bg-elevated); }
.hamburger-btn svg { width: 22px; height: 22px; display: block; }
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 998;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }
.sidebar-close {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
}
.sidebar-close:hover { background: var(--sidebar-bg-hover); }
.sidebar-close svg { width: 18px; height: 18px; }

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .app-wrapper {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main";
  }
  .hamburger-btn { display: flex; align-items: center; }
  .sidebar-close { display: block; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 270px;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .main-content { padding: var(--space-md); }
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
  .header-search { display: none; }
  .market-ticker { display: none; }
  .header-title { font-size: 14px; }
}
