*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #3b82f6;
  --primary-dark: #1e40af;
  --primary-light: #dbeafe;
  --bg: #f8fafc;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --white: #fff;
  --border: #e2e8f0;
  --radius: 16px;
  --danger: #ef4444;
  --warning: #f59e0b;
  --warning-bg: #fef9c3;
  --success: #22c55e;
}
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 200px;
  min-height: 100vh;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
}
.sidebar-logo {
  font-family: 'Nunito', sans-serif; font-weight: 800;
  font-size: 1.4rem;
  text-decoration: none;
  color: var(--text);
  padding: 20px 20px 24px;
  display: block;
}
.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.nav-section { padding: 0 12px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(0,0,0,0.04); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }

.nav-divider {
  margin: 16px 20px 8px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.sidebar-bottom {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.sidebar-bottom .nav-item { font-size: 0.85rem; }

/* Top bar */
.topbar {
  height: 56px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  transition: background 0.15s;
}
.topbar-user:hover { background: rgba(0,0,0,0.04); }
.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary-dark);
}
.user-dropdown {
  display: none;
  position: absolute;
  top: 50px;
  right: 28px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  min-width: 180px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  z-index: 200;
}
.user-dropdown.open { display: block; }
.user-dropdown a, .user-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: rgba(0,0,0,0.04); }
.user-dropdown .logout-btn:hover { color: var(--danger); }

/* Main content */
.main-content {
  flex: 1;
  margin-left: 200px;
  min-height: 100vh;
}
.page-content {
  max-width: 1200px;
  width: 100%;
  padding: 32px 28px;
}
.page-header {
  margin-bottom: 24px;
}
.page-header h1 {
  font-family: 'Nunito', sans-serif; font-weight: 800;
  font-size: 1.8rem;
  
  margin-bottom: 4px;
}
.page-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary-dark); border-bottom-color: var(--primary-dark); }

/* Filter pills */
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}
.filter-pill {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--white);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.filter-pill:hover { border-color: var(--text-muted); }
.filter-pill.active { background: var(--primary-dark); color: var(--white); border-color: var(--primary-dark); }

/* Cards */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Stat cards */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card { padding: 20px 24px; }
.stat-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
}
.stat-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  text-decoration: none;
}
.btn-primary { background: var(--primary-dark); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 14px rgba(59,130,246,0.3); }
.btn-secondary { background: var(--white); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { border-color: var(--text-muted); }
.btn-danger { background: #dc354520; color: var(--danger); }
.btn-danger:hover { background: #dc354530; }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 14px 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.data-table tr:hover { background: rgba(0,0,0,0.02); }
.data-table .amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.data-table .actions { text-align: right; }
.data-table .actions button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
}
.data-table .actions button:hover { color: var(--danger); background: rgba(0,0,0,0.04); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 24px;
}
.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
}
.empty-state h3 {
  font-family: 'Nunito', sans-serif; font-weight: 800;
  
  font-size: 1.3rem;
  margin-bottom: 8px;
}
.empty-state p {
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 0.9rem;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-input, .form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
}
.form-input::placeholder { color: var(--text-muted); }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: var(--radius);
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h2 {
  font-family: 'Nunito', sans-serif; font-weight: 800;
  
  font-size: 1.3rem;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* Alert banners */
.alert {
  padding: 16px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}
.alert-warning {
  background: var(--warning-bg);
  border: 1px solid #f0d78e;
}
.alert-info {
  background: #dbeafe;
  border: 1px solid #93c5fd;
}
.alert-icon { font-size: 1.2rem; }
.alert-content { flex: 1; }
.alert-content strong { font-weight: 600; }
.alert .btn { flex-shrink: 0; }
.alert .dismiss-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
}

/* Progress bar */
.progress-bar {
  height: 8px;
  background: #eee;
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s;
}

/* Asset class grid */
.asset-class-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.asset-class-item {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--white);
}
.asset-class-item:hover { border-color: var(--primary); }
.asset-class-item.selected { border-color: var(--primary-dark); background: var(--primary-light); }
.asset-class-item svg, .asset-class-item .icon { font-size: 1.5rem; margin-bottom: 8px; display: block; }
.asset-class-item span { font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); }

/* Chart placeholder */
.chart-area {
  background: var(--primary-light);
  border-radius: 8px;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Snapshot history */
.snapshot-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.snapshot-item:last-child { border-bottom: none; }

/* Goal card */
.goal-card {
  padding: 20px;
}
.goal-card h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.goal-card .goal-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.goal-card .goal-amounts {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

/* Settings sections */
.settings-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 32px;
}
.settings-nav { list-style: none; }
.settings-nav li {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: 2px;
}
.settings-nav li:hover { background: rgba(0,0,0,0.04); }
.settings-nav li.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.settings-section {
  display: none;
}
.settings-section.active { display: block; }
.settings-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.settings-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.settings-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* Loading Skeleton */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  gap: 16px;
}
.loading-screen::before {
  content: '';
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-screen::after {
  content: 'Loading your data...';
  font-size: 0.9rem;
  color: var(--text-muted);
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: -200px 0; } 100% { background-position: 200px 0; } }
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, rgba(0,0,0,0.04) 50%, var(--border) 75%);
  background-size: 400px 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Mobile */
.mobile-sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 8px;
  color: var(--text);
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .mobile-sidebar-toggle { display: block; }
  .topbar { justify-content: space-between; }
  .stat-cards { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-2-1 { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .asset-class-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-layout { grid-template-columns: 1fr; }
  .page-content { padding: 20px 16px; }
}

/* Dark Mode */
body.dark-mode {
  --bg: #0f172a;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --white: #1e293b;
  --border: #334155;
  --primary-light: #1e3a5f;
  --warning-bg: #422006;
}
body.dark-mode .sidebar { background: #020617; }
body.dark-mode .topbar { background: #1e293b; border-color: #334155; }
body.dark-mode .stat-card { background: #1e293b; }
body.dark-mode .settings-card { background: #1e293b; }
body.dark-mode .data-table th { background: #0f172a; }
body.dark-mode .data-table td { border-color: #334155; }
body.dark-mode .form-input, body.dark-mode .form-select { background: #0f172a; color: #e2e8f0; border-color: #334155; }
body.dark-mode .modal { background: #1e293b; }
body.dark-mode .card { background: #1e293b; border-color: #334155; }
body.dark-mode .filter-pill { background: #1e293b; color: #94a3b8; border-color: #334155; }
body.dark-mode .filter-pill.active { background: var(--primary); color: #fff; }
body.dark-mode .tab-btn { color: #94a3b8; }
body.dark-mode .tab-btn.active { color: var(--primary); border-color: var(--primary); }
body.dark-mode .user-dropdown { background: #1e293b; border-color: #334155; }
body.dark-mode .user-dropdown a { color: #e2e8f0; }
body.dark-mode .empty-state { background: #1e293b; }
body.dark-mode .nav-item:hover { background: rgba(255,255,255,0.05); }
body.dark-mode .nav-item.active { background: #1e3a5f; }
body.dark-mode .settings-nav li:hover { background: rgba(255,255,255,0.05); }
body.dark-mode .settings-nav li.active { background: #1e3a5f; color: #60a5fa; }
body.dark-mode .progress-bar { background: #334155; }
body.dark-mode a { color: var(--primary); }

/* Import / Mode toggles */
.import-toggle button:not(:first-child),
.mode-toggle button:not(:first-child) { border-left: none; }
.import-toggle button { background: var(--white); color: var(--text); }
.import-toggle button.active { background: var(--primary-dark); color: #fff; border-color: var(--primary-dark); }
body.dark-mode .import-toggle button,
body.dark-mode .mode-toggle button { background: var(--white); color: var(--text); border-color: var(--border); }
body.dark-mode .import-toggle button.active,
body.dark-mode .mode-toggle button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Broker grid dark mode */
body.dark-mode .broker-card { background: var(--white); border-color: var(--border); }
body.dark-mode .broker-card:hover,
body.dark-mode .broker-card.active { border-color: var(--primary); background: var(--primary-light); }

/* Upload zone dark mode */
body.dark-mode .upload-zone { border-color: var(--border); background: var(--white); }
body.dark-mode .upload-zone:hover,
body.dark-mode .upload-zone.dragover { border-color: var(--primary); background: var(--primary-light); }

/* Info box dark mode */
body.dark-mode .info-box { background: #422006; border-color: #d97706; color: #fde68a; }

/* Report KPI responsive */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr !important; }
  .page-header-row > div:last-child { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
}

/* Notes grid */
body.dark-mode .note-card { background: var(--white); border-color: var(--border); }

/* Notification items */
.notif-item {
  padding: 14px 18px;
  border-radius: 10px;
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--border);
  background: var(--white);
  transition: box-shadow .15s;
}
.notif-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.notif-item.unread { border-left: 3px solid var(--primary); }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.notif-body { flex: 1; }
.notif-title { font-size: .9rem; font-weight: 600; margin-bottom: 2px; }
.notif-desc { font-size: .82rem; color: var(--text-secondary); }
.notif-time { font-size: .72rem; color: var(--text-muted); margin-top: 4px; }
body.dark-mode .notif-item { background: var(--white); border-color: var(--border); }
