:root {
    --bg: #0a0d12;
    --surface: #111620;
    --surface2: #1a2030;
    --border: rgba(255,255,255,0.07);
    --border2: rgba(255,255,255,0.12);
    --text: #f0f2f5;
    --muted: #6b7a95;
    --accent: #00e5a0;
    --accent-dim: rgba(0,229,160,0.12);
    --red: #ff5c6e;
    --red-dim: rgba(255,92,110,0.12);
    --amber: #ffb547;
    --amber-dim: rgba(255,181,71,0.1);
    --blue: #5c9eff;
    --blue-dim: rgba(92,158,255,0.1);
    --purple: #a78bfa;
    --purple-dim: rgba(167,139,250,0.1);
    --coral: #ff7c5c;
    --coral-dim: rgba(255,124,92,0.1);
    --font-display: 'Syne', sans-serif;
    --font-body: 'DM Sans', sans-serif;
    --r: 14px;
    --r-sm: 8px;
  }
  [data-theme="light"] {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface2: #f0f1f5;
    --border: rgba(0,0,0,0.07);
    --border2: rgba(0,0,0,0.12);
    --text: #111620;
    --muted: #8892a4;
  }

  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
  }

  /* HEADER */
  header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 100;
    backdrop-filter: blur(12px);
  }
  .logo {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 22px;
    color: var(--text);
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .logo-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent);
    display: inline-block;
  }
  .header-right { display: flex; align-items: center; gap: 12px; }
  .theme-btn {
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 99px;
    padding: 6px 14px;
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s;
    display: flex; align-items: center; gap: 6px;
  }
  .theme-btn:hover { color: var(--text); border-color: var(--border2); }
  .export-btn {
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 99px;
    padding: 8px 18px;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex; align-items: center; gap: 6px;
  }
  .export-btn:hover { opacity: 0.85; transform: translateY(-1px); }

  /* MAIN LAYOUT */
  main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px;
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 24px;
    align-items: start;
  }

  /* LEFT PANEL */
  .left-panel { display: flex; flex-direction: column; gap: 20px; }

  /* BALANCE CARD */
  .balance-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 28px;
    position: relative;
    overflow: hidden;
  }
  .balance-card::before {
    content: '';
    position: absolute;
    top: -60px; right: -60px;
    width: 180px; height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0,229,160,0.12) 0%, transparent 70%);
    pointer-events: none;
  }
  .balance-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
  }
  .balance-amount {
    font-family: var(--font-display);
    font-size: 38px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -1px;
    margin-bottom: 24px;
    line-height: 1.1;
  }
  .balance-amount span { color: var(--accent); }
  .balance-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .stat-item {
    background: var(--surface2);
    border-radius: var(--r-sm);
    padding: 14px;
    border: 1px solid var(--border);
  }
  .stat-label {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 4px;
    display: flex; align-items: center; gap: 5px;
  }
  .stat-dot { width: 6px; height: 6px; border-radius: 50%; }
  .stat-amount {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.3px;
  }
  .stat-amount.income { color: var(--accent); }
  .stat-amount.expense { color: var(--red); }

  /* FORM CARD */
  .form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 24px;
  }
  .form-title {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 18px;
    color: var(--text);
  }

  /* TYPE TOGGLE */
  .type-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 16px;
    background: var(--surface2);
    border-radius: var(--r-sm);
    padding: 5px;
  }
  .type-btn {
    padding: 9px;
    border: none;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    color: var(--muted);
  }
  .type-btn.active-income {
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid rgba(0,229,160,0.25);
  }
  .type-btn.active-expense {
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid rgba(255,92,110,0.25);
  }

  /* FORM ELEMENTS */
  .form-group { margin-bottom: 12px; }
  .form-label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 5px;
    font-weight: 500;
  }
  .form-input, .form-select {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: var(--r-sm);
    padding: 11px 14px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
    appearance: none;
    -webkit-appearance: none;
  }
  .form-input:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
  }
  .form-input::placeholder { color: var(--muted); }

  .select-wrap { position: relative; }
  .select-wrap::after {
    content: '▾';
    position: absolute;
    right: 14px; top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
    font-size: 12px;
  }

  /* CATEGORY PILLS */
  .cat-grid {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-bottom: 14px;
  }
  .cat-pill {
    padding: 6px 12px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border2);
    background: transparent;
    color: var(--muted);
    font-family: var(--font-body);
    transition: all 0.15s;
  }
  .cat-pill:hover { color: var(--text); border-color: var(--border2); }
  .cat-pill.active { background: var(--accent-dim); color: var(--accent); border-color: rgba(0,229,160,0.3); }

  .add-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--r-sm);
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.02em;
  }
  .add-btn:hover { opacity: 0.88; transform: translateY(-1px); }
  .add-btn:active { transform: translateY(0); }

  /* RIGHT PANEL */
  .right-panel { display: flex; flex-direction: column; gap: 20px; }

  /* HISTORY */
  .panel-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 24px;
  }
  .panel-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 18px;
  }
  .panel-title {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
  }
  .panel-badge {
    font-size: 12px;
    color: var(--muted);
    background: var(--surface2);
    border-radius: 99px;
    padding: 3px 10px;
  }

  /* TRANSACTION LIST */
  .tx-list { display: flex; flex-direction: column; gap: 8px; }
  .tx-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--surface2);
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    transition: all 0.15s;
    animation: fadeIn 0.3s ease;
  }
  @keyframes fadeIn { from { opacity:0; transform: translateY(6px); } to { opacity:1; transform:none; } }
  .tx-item:hover { border-color: var(--border2); }
  .tx-icon {
    width: 38px; height: 38px;
    border-radius: var(--r-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
  }
  .tx-info { flex: 1; min-width: 0; }
  .tx-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .tx-meta {
    font-size: 12px;
    color: var(--muted);
    display: flex; gap: 8px; align-items: center;
  }
  .tx-cat {
    padding: 2px 7px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 500;
  }
  .tx-amount {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    text-align: right;
    flex-shrink: 0;
  }
  .tx-amount.income { color: var(--accent); }
  .tx-amount.expense { color: var(--red); }
  .tx-del {
    background: none; border: none;
    color: var(--muted); cursor: pointer;
    font-size: 16px; padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.15s;
    flex-shrink: 0;
  }
  .tx-del:hover { color: var(--red); background: var(--red-dim); }

  /* EMPTY STATE */
  .empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
  }
  .empty-icon { font-size: 36px; margin-bottom: 10px; }
  .empty-text { font-size: 14px; }

  /* STATS GRID */
  .stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }

  /* CAT BARS */
  .cat-bar-list { display: flex; flex-direction: column; gap: 12px; }
  .cat-bar-item {}
  .cat-bar-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 5px;
  }
  .cat-bar-name { font-size: 13px; color: var(--text); display: flex; align-items: center; gap: 6px; }
  .cat-bar-amount { font-size: 12px; color: var(--muted); font-weight: 500; }
  .cat-bar-bg {
    height: 6px;
    background: var(--surface2);
    border-radius: 99px;
    overflow: hidden;
  }
  .cat-bar-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
  }

  /* INSIGHT BOX */
  .insight-box {
    background: linear-gradient(135deg, rgba(0,229,160,0.07) 0%, transparent 60%);
    border: 1px solid rgba(0,229,160,0.2);
    border-radius: var(--r);
    padding: 20px 24px;
  }
  .insight-icon { font-size: 20px; margin-bottom: 8px; }
  .insight-text {
    font-size: 14px;
    color: var(--text);
    line-height: 1.7;
  }
  .insight-text strong { color: var(--accent); }

  /* CHART */
  .chart-wrap { position: relative; height: 140px; margin-top: 8px; }

  /* NOTIFICATION */
  .toast {
    position: fixed;
    bottom: 28px; right: 28px;
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: var(--r-sm);
    padding: 14px 18px;
    font-size: 13px;
    color: var(--text);
    display: flex; align-items: center; gap: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    transform: translateY(80px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
    z-index: 999;
    pointer-events: none;
  }
  .toast.show { transform: translateY(0); opacity: 1; }
  .toast-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

  /* CAT COLORS */
  .color-food { background: var(--amber-dim); color: var(--amber); }
  .color-transport { background: var(--blue-dim); color: var(--blue); }
  .color-hiburan { background: var(--purple-dim); color: var(--purple); }
  .color-belanja { background: var(--coral-dim); color: var(--coral); }
  .color-pemasukan { background: var(--accent-dim); color: var(--accent); }
  .color-lainnya { background: rgba(107,122,149,0.15); color: var(--muted); }

  .bar-food { background: var(--amber); }
  .bar-transport { background: var(--blue); }
  .bar-hiburan { background: var(--purple); }
  .bar-belanja { background: var(--coral); }
  .bar-lainnya { background: var(--muted); }

  /* RESPONSIVE */
  @media (max-width: 768px) {
    main {
      grid-template-columns: 1fr;
      padding: 16px;
    }
    .stats-row { grid-template-columns: 1fr; }
    header { padding: 16px 20px; }
    .balance-amount { font-size: 30px; }
  }