  :root {
    --primary: #1E2A10;
    --accent: #6B7A3A;
    --success: #8B6F47;
    --warning: #A0733A;
    --danger: #B04030;
    --bg: #E8E4D0;
    --bg2: #DBD7C0;
    --card: #F4F1E0;
    --card2: #EDE9D4;
    --border: #C4C0A0;
    --text: #1A2010;
    --text-muted: #6A7248;
    /* Dark olive sidebar */
    --sidebar-bg: #141A08;
    --sidebar-bg2: #1E2A10;
    --sidebar-border: #2A3A14;
    --sidebar-text: #E8E4D0;
    --sidebar-text-muted: #8A9860;
    --sidebar-accent: #9AB04A;
    --sidebar-w: 220px;
  }

  * { margin: 0; padding: 0; box-sizing: border-box; }
  body { font-family: -apple-system, 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); display: flex; min-height: 100vh; font-size: 14px; line-height: 1.5; }

  /* ── SIDEBAR (espresso) ── */
  .sidebar {
    width: var(--sidebar-w); min-height: 100vh; background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border); display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; z-index: 100; overflow-y: auto;
  }
  .sidebar-logo {
    padding: 28px 20px 20px;
    font-size: 1.8rem; font-weight: 700; font-family: 'Caveat', cursive; letter-spacing: 0.02em; color: var(--sidebar-text);
    border-bottom: 1px solid var(--sidebar-border);
  }
  .sidebar-logo span { font-size: 0.72rem; font-weight: 400; color: var(--sidebar-text-muted); display: block; margin-top: 2px; }

  .user-switcher {
    margin: 16px 12px 8px; padding: 10px 12px; background: var(--sidebar-bg2);
    border-radius: 8px; cursor: pointer; border: 1px solid var(--sidebar-border); transition: border-color 0.15s;
  }
  .user-switcher:hover { border-color: var(--sidebar-accent); }
  .user-avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.78rem; margin-right: 8px; flex-shrink: 0; }
  .user-info { display: flex; align-items: center; }
  .user-name { font-size: 0.85rem; font-weight: 600; color: var(--sidebar-text); }
  .user-role { font-size: 0.68rem; color: var(--sidebar-text-muted); }
  .user-chevron { margin-left: auto; color: var(--sidebar-text-muted); font-size: 0.7rem; }

  .nav-section { padding: 16px 20px 4px; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--sidebar-text-muted); }
  .nav-item {
    display: flex; align-items: center; gap: 8px; padding: 7px 12px; margin: 1px 8px;
    border-radius: 6px; cursor: pointer; transition: all 0.12s; color: var(--sidebar-text-muted);
    font-size: 0.84rem; font-weight: 500;
  }
  .nav-item:hover { background: var(--sidebar-bg2); color: var(--sidebar-text); }
  .nav-item.active { background: var(--sidebar-bg2); color: var(--sidebar-text); font-weight: 600; }
  .nav-item.active::before { content: ''; width: 3px; height: 14px; background: var(--sidebar-accent); border-radius: 2px; flex-shrink: 0; }
  .nav-item:not(.active)::before { content: ''; width: 3px; height: 14px; flex-shrink: 0; }
  .nav-item .icon { display: none; }
  .nav-badge { margin-left: auto; background: var(--danger); color: white; border-radius: 20px; padding: 1px 6px; font-size: 0.62rem; font-weight: 700; }
  .nav-divider { height: 1px; background: var(--sidebar-border); margin: 6px 12px; }
  .sidebar-bottom { margin-top: auto; padding: 16px 20px; border-top: 1px solid var(--sidebar-border); color: var(--sidebar-text-muted); font-size: 0.75rem; }

  /* ── MAIN ── */
  .main { margin-left: var(--sidebar-w); flex: 1; }
  .topbar {
    background: var(--card); border-bottom: 1px solid var(--border);
    padding: 14px 32px; display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
  }
  .topbar-title { font-size: 0.95rem; font-weight: 600; color: var(--text); }
  .topbar-actions { display: flex; gap: 8px; align-items: center; }

  /* ── BUTTONS ── */
  .btn {
    padding: 7px 16px; border-radius: 6px; border: 1px solid transparent; cursor: pointer;
    font-size: 0.82rem; font-weight: 500; transition: all 0.12s; letter-spacing: 0.1px;
  }
  .btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
  .btn-primary:hover { background: #526030; border-color: #526030; }
  .btn-ghost { background: var(--card); color: var(--text); border-color: var(--border); }
  .btn-ghost:hover { border-color: var(--text-muted); }
  .btn-danger { background: var(--card); color: var(--danger); border-color: var(--border); }
  .btn-danger:hover { border-color: var(--danger); }
  .btn-sm { padding: 4px 11px; font-size: 0.76rem; border-radius: 5px; }
  .btn-success { background: var(--success); color: white; border-color: var(--success); }

  .content { padding: 32px; }

  /* ── CARDS ── */
  .card { background: var(--card); border-radius: 10px; border: 1px solid var(--border); padding: 20px; }
  .card-sm { padding: 14px 16px; }
  .grid { display: grid; gap: 16px; }
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }

  /* ── STAT CARDS ── */
  .stat-card { background: var(--card); border-radius: 10px; border: 1px solid var(--border); padding: 20px; }
  .stat-label { font-size: 0.72rem; color: var(--text-muted); font-weight: 500; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.6px; }
  .stat-value { font-size: 1.7rem; font-weight: 700; margin-bottom: 4px; color: var(--text); letter-spacing: -0.5px; }
  .stat-value.purple { color: var(--accent); }
  .stat-value.green { color: var(--success); }
  .stat-value.red { color: var(--danger); }
  .stat-value.cyan { color: #0e7490; }
  .stat-change { font-size: 0.76rem; color: var(--text-muted); }
  .stat-change.up { color: var(--success); }
  .stat-change.down { color: var(--danger); }
  .stat-icon { display: none; }

  /* ── SECTION ── */
  .section { display: none; }
  .section.active { display: block; }

  /* ── MODALS ── */
  .modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(28,16,7,0.4);
    z-index: 200; align-items: center; justify-content: center; backdrop-filter: blur(3px);
  }
  .modal-overlay.open { display: flex; }
  .modal {
    background: var(--card); border-radius: 12px; border: 1px solid var(--border);
    padding: 28px; width: 420px; max-width: 95vw; max-height: 90vh; overflow-y: auto;
    box-shadow: 0 8px 40px rgba(28,16,7,0.15);
  }
  .modal h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 20px; color: var(--text); }
  .form-group { margin-bottom: 14px; }
  .form-label { font-size: 0.72rem; font-weight: 600; color: var(--text-muted); display: block; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
  .form-input {
    width: 100%; padding: 9px 12px; background: var(--bg2); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text); font-size: 0.875rem; outline: none; transition: border-color 0.15s;
  }
  .form-input:focus { border-color: var(--accent); background: var(--card); }
  .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  select.form-input { cursor: pointer; }
  .form-actions { display: flex; gap: 8px; margin-top: 20px; }
  .form-actions .btn { flex: 1; }

  /* ── TABLES ── */
  .table-wrap { overflow-x: auto; }
  table { width: 100%; border-collapse: collapse; }
  th { font-size: 0.69rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; }
  td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 0.855rem; vertical-align: middle; color: var(--text); }
  tr:last-child td { border-bottom: none; }
  tr:hover td { background: var(--bg2); }

  /* ── TAGS ── */
  .tag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px; font-size: 0.7rem; font-weight: 500; }
  .tag-income { background: #d8edc0; color: #3a5818; }
  .tag-expense { background: #fde8d8; color: #923010; }
  .tag-info { background: #e0ecc8; color: #3a5818; }
  .tag-warn { background: #f0e8b0; color: #6A5010; }
  .tag-purple { background: #dce8c0; color: #3a5818; }
  .tag-pink { background: #fce7f3; color: #be185d; }

  /* ── PROGRESS ── */
  .progress-bar { background: var(--bg2); border-radius: 2px; height: 4px; overflow: hidden; }
  .progress-fill { height: 100%; border-radius: 2px; transition: width 0.4s ease; }

  /* ── ALERTS ── */
  .alert { padding: 11px 14px; border-radius: 6px; font-size: 0.84rem; border: 1px solid; margin-bottom: 8px; }
  .alert-info { background: #eef3d8; border-color: #c0cc90; color: #3a5018; }
  .alert-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
  .alert-danger { background: #fff1f2; border-color: #fecdd3; color: #be123c; }
  .alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }

  /* ── INSIGHT CARDS ── */
  .insight-card { background: var(--card); border-radius: 10px; border: 1px solid var(--border); padding: 18px; display: flex; gap: 14px; align-items: flex-start; }
  .insight-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 1px; }
  .insight-title { font-weight: 600; font-size: 0.875rem; margin-bottom: 4px; color: var(--text); }
  .insight-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.55; }

  /* ── GOAL CARDS ── */
  .goal-card { background: var(--card2); border-radius: 10px; padding: 18px; border: 1px solid var(--border); }
  .goal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
  .goal-name { font-weight: 600; font-size: 0.95rem; }
  .goal-amounts { font-size: 0.78rem; color: var(--text-muted); margin: 8px 0 4px; }

  /* ── NET WORTH ── */
  .nw-total { text-align: center; padding: 36px 20px; }
  .nw-label { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 500; }
  .nw-value { font-size: 2.6rem; font-weight: 700; color: var(--text); letter-spacing: -1px; }

  /* ── BILLS ── */
  .bill-card { display: flex; align-items: center; gap: 14px; padding: 13px 16px; background: var(--card); border-radius: 8px; border: 1px solid var(--border); margin-bottom: 6px; }
  .bill-icon { font-size: 1.1rem; color: var(--text-muted); }
  .bill-info { flex: 1; }
  .bill-name { font-weight: 500; font-size: 0.875rem; }
  .bill-due { font-size: 0.75rem; color: var(--text-muted); margin-top: 1px; }
  .bill-amount { font-weight: 600; font-size: 0.9rem; }

  /* ── CHART ── */
  .chart-container { position: relative; }

  /* ── MILESTONE ── */
  .milestone-track { display:flex; align-items:center; margin:14px 0 6px; position:relative; }
  .milestone-track::before { content:''; position:absolute; top:50%; left:0; right:0; height:1px; background:var(--border); z-index:0; transform:translateY(-50%); }
  .milestone-dot {
    position:relative; z-index:1; width:22px; height:22px; border-radius:50%; flex-shrink:0;
    display:flex; align-items:center; justify-content:center; font-size:0.6rem; font-weight:700;
    border:1.5px solid var(--border); background:var(--card); cursor:default; transition:all 0.2s;
  }
  .milestone-dot.reached { background:var(--success); border-color:var(--success); color:white; }
  .milestone-dot.current { background:var(--accent); border-color:var(--accent); color:white; }
  .milestone-spacer { flex:1; }
  @keyframes pulse { 0%,100%{box-shadow:0 0 0 0 rgba(107,122,58,0.35)} 50%{box-shadow:0 0 0 5px rgba(107,122,58,0)} }
  .milestone-dot.current { animation: pulse 2s infinite; }

  /* ── NW GROUPED LIST ── */
  .nw-group-header { display:flex; align-items:center; justify-content:space-between; padding:10px 0; cursor:pointer; user-select:none; font-weight:600; font-size:0.84rem; }
  .nw-group-header:hover { color:var(--accent); }
  .nw-group-body { overflow:hidden; transition:max-height 0.25s ease; }
  .nw-row { display:flex; align-items:center; gap:10px; padding:8px 0 8px 10px; border-bottom:1px solid var(--border); font-size:0.84rem; }
  .nw-row:last-child { border-bottom:none; }

  /* ── GOAL FULL CARD ── */
  .goal-full-card { background:var(--card); border-radius:10px; border:1px solid var(--border); padding:20px; margin-bottom:14px; }

  /* ── SCROLLBAR ── */
  ::-webkit-scrollbar { width: 4px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

  /* ── RESPONSIVE ── */
  @media (max-width: 900px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
  }
  @media (max-width: 600px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .content { padding: 20px; }
  }

  /* ── USER DROPDOWN ── */
  .user-dropdown { display:none; position:absolute; background:var(--sidebar-bg2); border:1px solid var(--sidebar-border); border-radius:8px; width:200px; box-shadow:0 8px 24px rgba(0,0,0,0.25); z-index:300; overflow:hidden; }
  .user-dropdown.open { display:block; }
  .user-dropdown-item { padding:9px 14px; cursor:pointer; font-size:0.84rem; display:flex; align-items:center; gap:9px; transition:background 0.1s; color:var(--sidebar-text); }
  .user-dropdown-item:hover { background:rgba(255,255,255,0.07); }
  .user-dropdown-item.active { color:var(--sidebar-accent); font-weight:600; }
  .user-dropdown-divider { border:none; border-top:1px solid var(--sidebar-border); }

  /* ── ALERT RULE ── */
  .alert-rule { background:var(--card); border-radius:8px; padding:13px 16px; border:1px solid var(--border); display:flex; align-items:center; gap:12px; margin-bottom:6px; }
  .alert-rule-info { flex:1; }

  /* ── EMPTY STATE ── */
  .empty-state { text-align:center; padding:56px 20px; color:var(--text-muted); }
  .empty-state .empty-icon { font-size:2rem; margin-bottom:10px; opacity:0.5; }
  .empty-state p { font-size:0.85rem; }

  /* ── SECTION DIVIDER ── */
  .gradient-line { height:1px; background:var(--border); margin-bottom:24px; }

  /* ── SECTION HEADER ── */
  .section-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:20px; }
  .section-header h2 { font-size:0.9rem; font-weight:600; color:var(--text-muted); }

  /* ── NOTIFICATION BAR ── */
  #globalNotifBar {
    display: none; padding: 10px 32px; font-size: 0.82rem; cursor: pointer;
    border-bottom: 1px solid var(--border);
  }
  #globalNotifBar.is-warning { background: #fef3e8; color: #92400e; border-color: #f0c89a; }
  #globalNotifBar.is-danger  { background: #fff1f2; color: #be123c; border-color: #fecdd3; }
  #globalNotifBar a-link { float: right; font-weight: 600; }

  /* ── USER AVATAR ── */
  .user-avatar { background: var(--sidebar-bg2); color: var(--sidebar-text); }
