/* ============================================================
   InvestX — Design System & Stylesheet
   Theme: Volcanic Glass (Dark Mode)
   Palette: #1A1A1A, #2A2A2A, #FF6B2B, #FFB088
   Fonts: Space Grotesk (headings) + Outfit (body)
   ============================================================ */

/* ── 1. CSS CUSTOM PROPERTIES (Design Tokens) ─────────────── */
:root {
  /* Background layers */
  --bg-base:        #0E0E0E;   /* Deepest background */
  --bg-surface:     #161616;   /* Cards, panels */
  --bg-elevated:    #1E1E1E;   /* Hover states, inputs */
  --bg-overlay:     #252525;   /* Modals, dropdowns */
  --bg-border:      #2C2C2C;   /* Subtle borders */
  --bg-border-soft: #222222;   /* Very subtle dividers */

  /* Brand / Accent */
  --accent-primary:   #FF6B2B;   /* Orange — primary CTA */
  --accent-secondary: #FFB088;   /* Soft orange — secondary */
  --accent-glow:      rgba(255, 107, 43, 0.15);

  /* Semantic colors */
  --color-green:      #22C55E;
  --color-green-dim:  rgba(34, 197, 94, 0.12);
  --color-red:        #EF4444;
  --color-red-dim:    rgba(239, 68, 68, 0.12);
  --color-gold:       #F59E0B;
  --color-gold-dim:   rgba(245, 158, 11, 0.12);
  --color-blue:       #3B82F6;
  --color-blue-dim:   rgba(59, 130, 246, 0.12);
  --color-purple:     #A855F7;

  /* Asset class colors */
  --color-stocks:     #3B82F6;
  --color-mf:         #22C55E;
  --color-crypto:     #A855F7;
  --color-gold-asset: #F59E0B;

  /* Text hierarchy */
  --text-primary:   #F0EDE8;   /* Main content */
  --text-secondary: #9A9590;   /* Labels, meta */
  --text-muted:     #5A5550;   /* Disabled, placeholders */
  --text-inverse:   #0E0E0E;

  /* Typography */
  --font-display: 'Space Grotesk', sans-serif;
  --font-body:    'Outfit', sans-serif;

  /* Font scale */
  --text-xs:   0.70rem;   /* 11.2px */
  --text-sm:   0.80rem;   /* 12.8px */
  --text-base: 0.875rem;  /* 14px */
  --text-md:   1rem;      /* 16px */
  --text-lg:   1.125rem;  /* 18px */
  --text-xl:   1.375rem;  /* 22px */
  --text-2xl:  1.75rem;   /* 28px */
  --text-3xl:  2.25rem;   /* 36px */

  /* Spacing scale */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Layout */
  --sidebar-width:          220px;
  --sidebar-collapsed-width: 64px;
  --topbar-height:          60px;
  --border-radius-sm:       6px;
  --border-radius-md:       10px;
  --border-radius-lg:       14px;
  --border-radius-xl:       20px;

  /* 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-glow: 0 0 24px rgba(255, 107, 43, 0.2);

  /* Transitions */
  --transition-fast:   150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow:   400ms ease;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;           /* Electron desktop — no browser scroll */
  height: 100vh;
  width: 100vw;
  user-select: none;          /* Desktop app feel */
}

/* Allow text selection in inputs and content areas */
input, textarea, .selectable { user-select: text; }

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
canvas { display: block; }

/* Scrollbar styling */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── 3. APP SHELL LAYOUT ───────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--bg-base);
}

/* ── 4. SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--bg-border-soft);
  display: flex;
  flex-direction: column;
  padding: var(--space-4) 0;
  transition: width var(--transition-normal), min-width var(--transition-normal);
  overflow: hidden;
  position: relative;
  z-index: 10;
}

/* Collapsed state */
.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
  min-width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar__brand-name,
.sidebar.collapsed .sidebar__user-info,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .sidebar__nav-label {
  opacity: 0;
  pointer-events: none;
  width: 0;
  overflow: hidden;
}

.sidebar.collapsed .sidebar__collapse-btn svg {
  transform: rotate(180deg);
}

/* Brand */
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--bg-border-soft);
  margin-bottom: var(--space-4);
}

.sidebar__logo {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar__brand-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  white-space: nowrap;
  transition: opacity var(--transition-normal), width var(--transition-normal);
}

.sidebar__collapse-btn {
  margin-left: auto;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.sidebar__collapse-btn:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.sidebar__collapse-btn svg {
  transition: transform var(--transition-normal);
}

/* User pill */
.sidebar__user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  margin: 0 var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border-radius: var(--border-radius-md);
  border: 1px solid var(--bg-border);
}

.sidebar__avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--color-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  color: white;
  font-family: var(--font-display);
}

.sidebar__user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity var(--transition-normal);
}

.sidebar__user-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.sidebar__user-plan {
  font-size: var(--text-xs);
  color: var(--accent-secondary);
  white-space: nowrap;
}

/* Navigation */
.sidebar__nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 var(--space-3);
  overflow-y: auto;
}

.sidebar__nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: var(--space-4) var(--space-2) var(--space-2);
  white-space: nowrap;
  transition: opacity var(--transition-normal);
}

.sidebar__nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--border-radius-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
  position: relative;
  white-space: nowrap;
}

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

.sidebar__nav-item--active {
  background: var(--accent-glow);
  color: var(--accent-primary);
  border: 1px solid rgba(255, 107, 43, 0.2);
}

.sidebar__nav-item--active .nav-icon svg {
  stroke: var(--accent-primary);
}

.nav-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-label {
  flex: 1;
  transition: opacity var(--transition-normal), width var(--transition-normal);
}

.nav-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 99px;
  white-space: nowrap;
  transition: opacity var(--transition-normal);
}

.nav-badge--green { background: var(--color-green-dim); color: var(--color-green); }
.nav-badge--red   { background: var(--color-red-dim);   color: var(--color-red);   }
.nav-badge--gold  { background: var(--color-gold-dim);  color: var(--color-gold);  }

/* Sidebar footer */
.sidebar__footer {
  padding: var(--space-4) var(--space-3) 0;
  border-top: 1px solid var(--bg-border-soft);
  margin-top: var(--space-4);
}

/* ── 5. MAIN CONTENT ───────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── 6. TOP BAR ────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--bg-border-soft);
  background: var(--bg-surface);
  gap: var(--space-4);
}

.topbar__left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topbar__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.topbar__subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

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

.topbar__search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--border-radius-md);
  padding: var(--space-2) var(--space-3);
  color: var(--text-muted);
  transition: border-color var(--transition-fast);
}

.topbar__search:focus-within {
  border-color: var(--accent-primary);
  color: var(--text-secondary);
}

.topbar__search-input {
  background: none;
  border: none;
  outline: none;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-primary);
  width: 180px;
}

.topbar__search-input::placeholder { color: var(--text-muted); }

.topbar__icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  transition: all var(--transition-fast);
  position: relative;
}

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

.topbar__notif-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 1.5px solid var(--bg-surface);
}

/* ── 7. BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--border-radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn--primary {
  background: var(--accent-primary);
  color: white;
  border: 1px solid var(--accent-primary);
}

.btn--primary:hover {
  background: #FF7D42;
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

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

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

/* ── 8. PAGE CONTAINER ─────────────────────────────────────── */
.page {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
  gap: var(--space-6);
  flex-direction: column;
}

.page--active {
  display: flex;
}

/* ── 9. KPI CARDS ROW ──────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: var(--space-4);
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border-soft);
  border-radius: var(--border-radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  transition: border-color var(--transition-fast), transform var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  border-color: var(--bg-border);
  transform: translateY(-1px);
}

/* Primary card — larger, with gradient accent */
.kpi-card--primary {
  background: linear-gradient(135deg, #1A1A1A 0%, #1E1510 100%);
  border-color: rgba(255, 107, 43, 0.2);
}

.kpi-card--primary::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 120px; height: 120px;
  background: radial-gradient(circle, rgba(255,107,43,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.kpi-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.kpi-card__label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.kpi-card__value {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1;
}

.kpi-card__value--md  { font-size: var(--text-2xl); }
.kpi-card__value--green { color: var(--color-green); }
.kpi-card__value--red   { color: var(--color-red);   }

.kpi-card__change {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 500;
}

.kpi-card__change--positive { color: var(--color-green); }
.kpi-card__change--negative { color: var(--color-red);   }

.kpi-card__meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.kpi-card__sparkline {
  margin-top: var(--space-2);
}

.kpi-card__bar {
  height: 3px;
  background: var(--bg-elevated);
  border-radius: 99px;
  margin-top: var(--space-2);
  overflow: hidden;
}

.kpi-card__bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 99px;
  transition: width var(--transition-slow);
}

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

.kpi-card__icon--blue   { background: var(--color-blue-dim);  color: var(--color-blue);  }
.kpi-card__icon--green  { background: var(--color-green-dim); color: var(--color-green); }
.kpi-card__icon--orange { background: var(--accent-glow);     color: var(--accent-primary); }

/* Period toggle buttons */
.kpi-card__period-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  border-radius: var(--border-radius-sm);
  padding: 2px;
}

.period-btn {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 4px;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

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

.period-btn--active {
  background: var(--bg-overlay);
  color: var(--accent-primary);
}

/* ── 10. CHARTS ROW ────────────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--space-4);
}

.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border-soft);
  border-radius: var(--border-radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.chart-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.chart-card__title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.chart-card__subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.chart-card__controls {
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  border-radius: var(--border-radius-sm);
  padding: 2px;
}

.chart-card__body {
  flex: 1;
  min-height: 0;
  position: relative;
}

.chart-card__body--donut {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  height: 200px;
}

/* Donut center label */
.donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}

.donut-center__value {
  display: block;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.donut-center__label {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

/* Allocation legend */
.allocation-legend {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--bg-border-soft);
}

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

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

.legend-name {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.legend-pct {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-display);
}

.legend-amount {
  font-size: var(--text-xs);
  color: var(--text-muted);
  min-width: 60px;
  text-align: right;
}

/* ── 11. ASSET CARDS GRID ──────────────────────────────────── */
.assets-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

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

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.section-link {
  font-size: var(--text-sm);
  color: var(--accent-primary);
  font-weight: 500;
  transition: color var(--transition-fast);
}

.section-link:hover { color: var(--accent-secondary); }

.asset-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}

.asset-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border-soft);
  border-radius: var(--border-radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.asset-card:hover {
  border-color: var(--bg-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Colored left border accent per asset */
.asset-card[data-asset="stocks"]     { border-left: 3px solid var(--color-stocks); }
.asset-card[data-asset="mutualfunds"]{ border-left: 3px solid var(--color-mf); }
.asset-card[data-asset="crypto"]     { border-left: 3px solid var(--color-crypto); }
.asset-card[data-asset="gold"]       { border-left: 3px solid var(--color-gold-asset); }

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

.asset-card__icon {
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.asset-card__icon--stocks { background: var(--color-blue-dim);  color: var(--color-stocks); }
.asset-card__icon--mf     { background: var(--color-green-dim); color: var(--color-mf);     }
.asset-card__icon--crypto { background: rgba(168,85,247,0.12);  color: var(--color-purple); }
.asset-card__icon--gold   { background: var(--color-gold-dim);  color: var(--color-gold);   }

.asset-card__title-group {
  flex: 1;
  min-width: 0;
}

.asset-card__title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-primary);
}

.asset-card__count {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.asset-card__badge {
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
}

.badge--green { background: var(--color-green-dim); color: var(--color-green); }
.badge--red   { background: var(--color-red-dim);   color: var(--color-red);   }
.badge--gold  { background: var(--color-gold-dim);  color: var(--color-gold);  }
.badge--blue  { background: var(--color-blue-dim);  color: var(--color-blue);  }

.asset-card__value {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
}

.asset-card__invested {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.asset-card__pnl {
  font-size: var(--text-sm);
  font-weight: 600;
}

.asset-card__pnl--positive { color: var(--color-green); }
.asset-card__pnl--negative { color: var(--color-red);   }

.asset-card__mini-chart {
  margin: var(--space-1) 0;
}

.asset-card__top-holding {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--bg-border-soft);
}

.top-holding__label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.top-holding__name {
  flex: 1;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
}

.top-holding__value {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 99px;
}

/* ── 12. TRANSACTIONS TABLE ────────────────────────────────── */
.transactions-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding-bottom: var(--space-6);
}

.transactions-table {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border-soft);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
}

.transactions-table__header {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr 1fr;
  padding: var(--space-3) var(--space-5);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--bg-border-soft);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.transactions-table__body {
  display: flex;
  flex-direction: column;
}

.transaction-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr 1fr;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--bg-border-soft);
  align-items: center;
  transition: background var(--transition-fast);
  font-size: var(--text-sm);
}

.transaction-row:last-child { border-bottom: none; }
.transaction-row:hover { background: var(--bg-elevated); }

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

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

.transaction-row__asset-name {
  font-weight: 600;
  color: var(--text-primary);
}

.transaction-row__asset-class {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.transaction-type-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.type--buy  { background: var(--color-green-dim); color: var(--color-green); }
.type--sell { background: var(--color-red-dim);   color: var(--color-red);   }
.type--sip  { background: var(--color-blue-dim);  color: var(--color-blue);  }
.type--div  { background: var(--color-gold-dim);  color: var(--color-gold);  }

.transaction-row__pnl--positive { color: var(--color-green); font-weight: 600; }
.transaction-row__pnl--negative { color: var(--color-red);   font-weight: 600; }
.transaction-row__pnl--neutral  { color: var(--text-muted); }

/* ── 13. PAGE PLACEHOLDER (stub pages) ─────────────────────── */
.page-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  text-align: center;
  color: var(--text-secondary);
}

.page-placeholder__icon {
  font-size: 48px;
  line-height: 1;
  filter: grayscale(0.3);
}

.page-placeholder h2 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.page-placeholder p {
  font-size: var(--text-md);
  color: var(--text-muted);
  max-width: 360px;
}

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

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-overlay);
  border: 1px solid var(--bg-border);
  border-radius: var(--border-radius-xl);
  width: 520px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(12px) scale(0.98);
  transition: transform var(--transition-normal);
}

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

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

.modal__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

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

.modal__close:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.modal__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

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

/* ── 15. FORM ELEMENTS ─────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

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

.form-label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.form-input {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--border-radius-md);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
  width: 100%;
}

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

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

/* Date input fix */
.form-input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.5);
  cursor: pointer;
}

/* Select fix */
.form-input option {
  background: var(--bg-overlay);
  color: var(--text-primary);
}

/* Asset type selector */
.asset-type-selector {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
}

.asset-type-btn {
  padding: var(--space-3) var(--space-2);
  border-radius: var(--border-radius-md);
  border: 1px solid var(--bg-border);
  background: var(--bg-elevated);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  transition: all var(--transition-fast);
}

.asset-type-btn:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.asset-type-btn--active {
  background: var(--accent-glow);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* ── 16. REFRESH ANIMATION ─────────────────────────────────── */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.refreshing svg {
  animation: spin 0.8s linear infinite;
}

/* ── 17. ENTRY ANIMATIONS ──────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page--active > * {
  animation: fadeInUp 0.3s ease forwards;
}

.page--active > *:nth-child(1) { animation-delay: 0ms; }
.page--active > *:nth-child(2) { animation-delay: 60ms; }
.page--active > *:nth-child(3) { animation-delay: 120ms; }
.page--active > *:nth-child(4) { animation-delay: 180ms; }

/* ── 18. RESPONSIVE ADJUSTMENTS ────────────────────────────── */
/* For smaller Windows screens (1280px) */
@media (max-width: 1400px) {
  .kpi-row {
    grid-template-columns: 1.4fr 1fr 1fr 1fr;
  }
  .charts-row {
    grid-template-columns: 1fr 300px;
  }
}

@media (max-width: 1280px) {
  .asset-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .charts-row {
    grid-template-columns: 1fr;
  }
}