import React, { useState, useEffect, useCallback } from 'react'; import { useNavigate } from 'react-router-dom'; import AddPurchase from '../components/AddPurchase'; import PurchaseList from '../components/PurchaseList'; import PortfolioChart from '../components/PortfolioChart'; const API = process.env.REACT_APP_API_URL || 'http://localhost:8000'; const styles = { app: { maxWidth: '900px', margin: '0 auto', padding: '1.5rem' }, header: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '1.5rem' }, logo: { fontSize: '1.4rem', fontWeight: 700, color: '#f7931a' }, logoutBtn: { background: 'none', border: '1px solid #555', color: '#aaa', borderRadius: '8px', padding: '0.4rem 1rem', cursor: 'pointer' }, statsGrid: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(150px, 1fr))', gap: '1rem', marginBottom: '1.5rem' }, statCard: { background: '#1a1a1a', padding: '1rem', borderRadius: '12px', border: '1px solid #333' }, statLabel: { color: '#888', fontSize: '0.8rem', marginBottom: '0.3rem' }, statValue: { fontSize: '1.2rem', fontWeight: 700 }, positive: { color: '#6bff8e' }, negative: { color: '#ff6b6b' }, neutral: { color: '#f7931a' }, }; function StatCard({ label, value, highlight }) { return (