:root {
    --bg: #FDF6F0;
    --card: #FFFFFF;
    --border: #EDD9CD;
    --peach: #F0A58A;
    --peach-light: #FDE8DF;
    --sage: #A8B89A;
    --sage-light: #E8F0E4;
    --sky: #8AABC4;
    --sky-light: #D8E8F2;
    --lavender: #B5A8C8;
    --lavender-light: #EDE8F4;
    --text: #3D3530;
    --text-mid: #7A6A62;
    --text-light: #B0A09A;
    --shadow: 0 4px 24px rgba(100,60,40,0.07);
    --shadow-hover: 0 8px 32px rgba(100,60,40,0.12);
    --radius: 20px;
    --radius-sm: 12px;
  }

  body.dark {
    --bg: #1A1614;
    --card: #26201C;
    --border: #3D3028;
    --peach: #D4826A;
    --peach-light: #3D2820;
    --sage: #8A9C7A;
    --sage-light: #1C2818;
    --sky: #6A8FAE;
    --sky-light: #182030;
    --lavender: #9A8CAE;
    --lavender-light: #281E38;
    --text: #F0EAE4;
    --text-mid: #B0A09A;
    --text-light: #705A52;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-hover: 0 8px 32px rgba(0,0,0,0.4);
  }

  * { margin:0; padding:0; box-sizing:border-box; }

  body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background 0.4s, color 0.4s;
  }

  /* HEADER */
  .site-header {
    position: relative;
    height: 200px;
    overflow: hidden;
  }

  .site-header img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 30%;
    display: block;
  }

  .header-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 30%, var(--bg));
  }

  .header-title {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    white-space: nowrap;
  }

  .header-title h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1;
  }

  .header-title p {
    font-size: 0.8rem;
    color: var(--text-mid);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-top: 4px;
  }

  /* TOPBAR */
  .topbar {
    display: flex;
    justify-content: flex-end;
    padding: 12px 24px;
    gap: 12px;
    align-items: center;
  }

  .dark-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text-mid);
    user-select: none;
  }

  .switch {
    position: relative;
    width: 44px;
    height: 24px;
    display: inline-block;
  }
  .switch input { opacity:0; width:0; height:0; }
  .slider {
    position: absolute; inset: 0;
    background: var(--border);
    border-radius: 24px;
    cursor: pointer;
    transition: 0.3s;
  }
  .slider::before {
    content: "";
    position: absolute;
    width: 18px; height: 18px;
    left: 3px; bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  }
  input:checked + .slider { background: var(--sky); }
  input:checked + .slider::before { transform: translateX(20px); }

  /* LAYOUT */
  .app {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px 60px;
  }

  /* BALANCE HERO */
  .balance-hero {
    background: linear-gradient(135deg, var(--peach) 0%, var(--lavender) 100%);
    border-radius: var(--radius);
    padding: 32px 36px;
    margin-bottom: 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-hover);
    position: relative;
    overflow: hidden;
  }

  .balance-hero::before {
    content: "";
    position: absolute;
    width: 200px; height: 200px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
    right: -40px; top: -60px;
  }

  .balance-hero::after {
    content: "";
    position: absolute;
    width: 120px; height: 120px;
    background: rgba(255,255,255,0.06);
    border-radius: 50%;
    right: 60px; bottom: -40px;
  }

  .balance-main { position: relative; z-index: 1; }

  .balance-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: rgba(255,255,255,0.75);
    margin-bottom: 6px;
  }

  .balance-amount {
    font-family: 'Playfair Display', serif;
    font-size: 3rem;
    color: white;
    line-height: 1;
  }

  .balance-stats {
    display: flex;
    gap: 28px;
    position: relative;
    z-index: 1;
  }

  .stat-pill {
    background: rgba(255,255,255,0.18);
    backdrop-filter: blur(8px);
    border-radius: 14px;
    padding: 14px 20px;
    text-align: center;
    min-width: 100px;
    border: 1px solid rgba(255,255,255,0.2);
  }

  .stat-pill-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.7);
  }

  .stat-pill-value {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    color: white;
    margin-top: 2px;
  }

  /* GRID */
  .grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
  }

  .grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
  }

  /* CARD */
  .card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    border: 1.5px solid var(--border);
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s, background 0.4s, border 0.4s;
  }

  .card-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.05rem;
    color: var(--text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .card-title .icon {
    width: 28px; height: 28px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem;
  }

  /* FORMS */
  .form-group { margin-bottom: 12px; }

  .form-group label {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-light);
    margin-bottom: 5px;
  }

  input, select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s, background 0.4s;
  }

  input:focus, select:focus { border-color: var(--peach); }

  .btn {
    width: 100%;
    padding: 11px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    margin-top: 4px;
  }

  .btn-peach { background: var(--peach); color: white; }
  .btn-peach:hover { filter: brightness(1.08); transform: translateY(-1px); }
  .btn-sage { background: var(--sage); color: white; }
  .btn-sage:hover { filter: brightness(1.08); transform: translateY(-1px); }

  /* TYPE SELECTOR */
  .type-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
  }

  .type-btn {
    padding: 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text-mid);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: 0.2s;
    text-align: center;
  }

  .type-btn.active-income { background: var(--sage-light); border-color: var(--sage); color: var(--sage); font-weight: 500; }
  .type-btn.active-expense { background: var(--peach-light); border-color: var(--peach); color: var(--peach); font-weight: 500; }

  /* TRANSACTIONS LIST */
  .tx-list { max-height: 320px; overflow-y: auto; padding-right: 4px; }
  .tx-list::-webkit-scrollbar { width: 4px; }
  .tx-list::-webkit-scrollbar-track { background: transparent; }
  .tx-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

  .tx-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    transition: background 0.2s;
    animation: fadeSlide 0.3s ease forwards;
  }

  @keyframes fadeSlide {
    from { opacity:0; transform: translateY(6px); }
    to { opacity:1; transform: translateY(0); }
  }

  .tx-item.income { background: var(--sage-light); }
  .tx-item.expense { background: var(--peach-light); }

  .tx-info strong { font-size: 0.88rem; display:block; }
  .tx-info small { font-size: 0.72rem; color: var(--text-light); }

  .tx-right { display: flex; align-items: center; gap: 10px; }

  .tx-amount {
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
  }

  .tx-item.income .tx-amount { color: var(--sage); }
  .tx-item.expense .tx-amount { color: var(--peach); }

  .del-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-mid);
    opacity: 0.4;
    transition: opacity 0.2s;
    padding: 4px;
  }
  .del-btn:hover { opacity: 1; }

  /* GOALS */
  .goal-item {
    background: var(--lavender-light);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 10px;
    animation: fadeSlide 0.3s ease forwards;
  }

  .goal-header { display: flex; justify-content: space-between; margin-bottom: 8px; }
  .goal-name { font-size: 0.88rem; font-weight: 500; }
  .goal-meta { font-size: 0.72rem; color: var(--text-light); }

  .progress-track {
    background: rgba(0,0,0,0.07);
    border-radius: 8px;
    height: 8px;
    overflow: hidden;
    margin: 8px 0 6px;
  }

  .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--lavender), var(--peach));
    border-radius: 8px;
    transition: width 0.6s cubic-bezier(0.34,1.56,0.64,1);
  }

  .goal-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
  .goal-pct { font-size: 0.72rem; color: var(--lavender); font-weight: 500; }

  .goal-add-row { display: flex; gap: 6px; flex: 1; }
  .goal-add-row input { padding: 6px 10px; font-size: 0.8rem; flex: 1; }
  .goal-add-btn {
    padding: 6px 12px;
    background: var(--lavender);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: 0.2s;
  }
  .goal-add-btn:hover { filter: brightness(1.1); }

  .badge-reached {
    display: inline-block;
    background: linear-gradient(90deg, var(--sage), var(--sky));
    color: white;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
  }

  /* CHARTS */
  .chart-wrap {
    position: relative;
    width: 100%;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .chart-wrap canvas { max-height: 200px; }

  .donut-center {
    position: absolute;
    text-align: center;
    pointer-events: none;
  }

  .donut-center-num {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    color: var(--text);
    display: block;
  }

  .donut-center-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-light);
  }

  /* EMPTY */
  .empty-state {
    text-align: center;
    padding: 24px 12px;
    color: var(--text-light);
    font-size: 0.82rem;
    font-style: italic;
  }

  .empty-icon { font-size: 1.8rem; margin-bottom: 6px; opacity: 0.5; }

  /* CLEAR */
  .clear-bar {
    text-align: center;
    margin-top: 8px;
  }

  .btn-ghost {
    background: none;
    border: 1.5px solid var(--border);
    color: var(--text-light);
    padding: 9px 24px;
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.82rem;
    cursor: pointer;
    transition: 0.2s;
  }

  .btn-ghost:hover { border-color: var(--peach); color: var(--peach); }

  /* RESPONSIVE */
  @media (max-width: 768px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .grid-3 .card[style*="grid-column"] { grid-column: span 1 !important; }
    .balance-hero { flex-direction: column; gap: 20px; align-items: flex-start; }
    .balance-stats { width: 100%; justify-content: space-between; }
    .balance-amount { font-size: 2.2rem; }
  }