
        :root {
            --bg: #f4faf7;
            --card: #ffffff;
            --ink: #12312b;
            --ink-soft: #4a6b62;
            --ink-faint: #7c9991;
            --brand: #00a878;
            --brand-deep: #00795a;
            --brand-soft: #e0f5ec;
            --mint: #d9f2e6;
            --gold: #e8a63c;
            --gold-soft: #fdf3e0;
            --line: #e3ede8;
            --good: #16a34a;
            --warn: #d97706;
            --bad: #dc2626;
            --bad-soft: #fee2e2;
            --shadow: 0 10px 30px rgba(18, 49, 43, 0.07);
            --radius: 20px;
            --stat-bg: #f7fbf9;
            --input-bg: #f9fcfb;
            --header-bg: rgba(244, 250, 247, 0.94);
        }

        html[data-theme="dark"] {
            --bg: #0c1613;
            --card: #12211c;
            --ink: #e8f3ee;
            --ink-soft: #a5c0b6;
            --ink-faint: #74938a;
            --brand: #2fd39a;
            --brand-deep: #7ee6c0;
            --brand-soft: rgba(47, 211, 154, 0.13);
            --mint: rgba(47, 211, 154, 0.10);
            --gold: #f0b856;
            --gold-soft: rgba(240, 184, 86, 0.14);
            --line: rgba(255, 255, 255, 0.09);
            --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
            --stat-bg: #0f1c17;
            --input-bg: #0f1c17;
            --header-bg: rgba(12, 22, 19, 0.94);
            --bad-soft: rgba(220, 38, 38, 0.15);
            color-scheme: dark;
        }

        * { margin: 0; padding: 0; box-sizing: border-box; }
        body {
            font-family: 'Rubik', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
            background: var(--bg);
            color: var(--ink);
            line-height: 1.6;
            padding-bottom: 90px;
            transition: background 0.2s, color 0.2s;
        }

        .wrap { max-width: 920px; margin: 0 auto; padding: 0 18px; }

        /* Header */
        header {
            position: sticky; top: 0; z-index: 50;
            background: var(--header-bg);
            backdrop-filter: blur(10px);
            border-bottom: 1px solid var(--line);
        }
        .hd { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; }
        .logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; color: var(--ink); text-decoration: none; }
        .logo-mark {
            width: 36px; height: 36px; border-radius: 12px;
            background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
            color: #fff; display: flex; align-items: center; justify-content: center;
            font-size: 1rem; font-weight: 900;
        }
        .logo small { display: block; font-size: 0.65rem; font-weight: 600; color: var(--ink-faint); }
        .nav-links { display: flex; align-items: center; gap: 10px; }
        .nav-link {
            text-decoration: none; font-size: 0.85rem; font-weight: 700; color: var(--ink-soft);
            padding: 6px 12px; border-radius: 999px; transition: all 0.15s;
        }
        .nav-link:hover { background: var(--brand-soft); color: var(--brand-deep); }
        .theme-toggle {
            width: 36px; height: 36px; border-radius: 12px; cursor: pointer;
            border: 1.5px solid var(--line); background: var(--card); color: var(--ink-soft);
            display: flex; align-items: center; justify-content: center; transition: all 0.15s;
        }
        .theme-toggle:hover { border-color: var(--brand); color: var(--brand); }

        /* Cards */
        .card {
            background: var(--card);
            border: 1.5px solid var(--line);
            border-radius: var(--radius);
            padding: 22px;
            box-shadow: var(--shadow);
            margin-bottom: 20px;
        }

        /* Hero Safe Spend Box */
        .hero-spend {
            background: linear-gradient(135deg, var(--card) 0%, var(--stat-bg) 100%);
            border: 2px solid var(--brand);
            position: relative;
            overflow: hidden;
        }
        .hero-spend::before {
            content: ''; position: absolute; top: 0; left: 0; right: 0; height: 5px;
            background: linear-gradient(90deg, var(--brand), var(--gold));
        }
        .badge-pill {
            display: inline-flex; align-items: center; gap: 6px;
            padding: 4px 12px; border-radius: 999px; font-size: 0.76rem; font-weight: 800;
        }
        .badge-pill.good { background: var(--brand-soft); color: var(--brand-deep); }
        .badge-pill.warn { background: var(--gold-soft); color: var(--warn); }
        .badge-pill.bad { background: var(--bad-soft); color: var(--bad); }

        .spend-big-number {
            font-size: clamp(2.4rem, 6vw, 3.4rem);
            font-weight: 900;
            line-height: 1.15;
            margin: 10px 0 6px;
            letter-spacing: -0.02em;
        }
        .spend-big-number.positive { color: var(--brand); }
        .spend-big-number.overbudget { color: var(--bad); }

        /* Progress Bar */
        .progress-track {
            height: 12px; border-radius: 999px; background: var(--line);
            overflow: hidden; margin: 16px 0 12px; position: relative;
        }
        .progress-fill {
            height: 100%; border-radius: 999px; transition: width 0.4s ease;
        }

        /* Stat Grid */
        .grid-4 {
            display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
            gap: 12px; margin-top: 14px;
        }
        .stat-mini-box {
            background: var(--stat-bg); border: 1px solid var(--line);
            border-radius: 14px; padding: 12px 14px;
        }
        .stat-mini-box small { font-size: 0.72rem; color: var(--ink-faint); font-weight: 700; display: block; }
        .stat-mini-box strong { font-size: 1.1rem; font-weight: 800; color: var(--ink); margin-top: 2px; display: block; }

        /* Buttons */
        .btn {
            display: inline-flex; align-items: center; justify-content: center; gap: 8px;
            font-family: inherit; font-weight: 800; font-size: 0.92rem;
            padding: 10px 20px; border-radius: 999px; cursor: pointer;
            transition: all 0.15s; border: none; text-decoration: none;
        }
        .btn-brand {
            background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
            color: #ffffff; box-shadow: 0 4px 14px rgba(0, 168, 120, 0.28);
        }
        .btn-brand:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0, 168, 120, 0.38); }
        .btn-ghost {
            background: var(--stat-bg); color: var(--ink); border: 1.5px solid var(--line);
        }
        .btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
        .btn-sm { padding: 6px 14px; font-size: 0.8rem; }
        .btn-bad-ghost {
            background: transparent; color: var(--bad); border: 1px solid var(--bad-soft);
        }
        .btn-bad-ghost:hover { background: var(--bad-soft); }

        /* Form Controls */
        input[type="text"], input[type="number"], input[type="date"], select {
            width: 100%; border: 1.5px solid var(--line); border-radius: 12px;
            background: var(--input-bg); color: var(--ink);
            font-family: inherit; font-size: 0.94rem; padding: 10px 14px;
            outline: none; transition: border-color 0.15s;
        }
        input:focus, select:focus { border-color: var(--brand); }

        /* Category Chips in Quick Add */
        .cat-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
        .cat-chip {
            padding: 7px 13px; border-radius: 999px; font-size: 0.82rem; font-weight: 700;
            background: var(--stat-bg); border: 1px solid var(--line); color: var(--ink);
            cursor: pointer; transition: all 0.15s; display: inline-flex; align-items: center; gap: 6px;
        }
        .cat-chip:hover, .cat-chip.active {
            background: var(--brand); color: #fff; border-color: var(--brand);
        }

        /* Feed List */
        .tx-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
        .tx-row {
            display: flex; align-items: center; justify-content: space-between;
            padding: 12px 14px; background: var(--stat-bg); border: 1px solid var(--line);
            border-radius: 14px; transition: background 0.15s; gap: 10px;
        }
        .tx-row:hover { background: var(--input-bg); }
        .tx-icon {
            width: 38px; height: 38px; border-radius: 10px; background: var(--brand-soft);
            color: var(--brand-deep); display: flex; align-items: center; justify-content: center;
            font-size: 1.15rem; flex-shrink: 0;
        }

        /* Category Breakdown Bar */
        .cat-progress-stack {
            height: 16px; border-radius: 999px; overflow: hidden; display: flex;
            background: var(--line); margin: 14px 0 10px;
        }
        .cat-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.78rem; margin-top: 8px; }
        .cat-legend-item { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); }
        .cat-legend-color { width: 10px; height: 10px; border-radius: 50%; }

        /* Floating Add Button on Mobile */
        .fab-add {
            position: fixed; bottom: 22px; left: 22px; z-index: 999;
            width: 56px; height: 56px; border-radius: 50%;
            background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
            color: #fff; display: flex; align-items: center; justify-content: center;
            box-shadow: 0 10px 25px rgba(0, 168, 120, 0.45); cursor: pointer; border: none;
            font-size: 1.6rem; transition: transform 0.15s;
        }
        .fab-add:hover { transform: scale(1.08); }

        /* Modal Overlay */
        .modal-overlay {
            display: none; position: fixed; inset: 0; background: rgba(18, 49, 43, 0.55);
            backdrop-filter: blur(4px); z-index: 1000; align-items: center; justify-content: center;
            padding: 16px;
        }
        .modal-overlay.open { display: flex; }
        .modal-card {
            background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius);
            max-width: 520px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 24px;
            box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
        }

        /* Toast */
        #toast {
            position: fixed; bottom: 30px; right: 30px; background: var(--ink); color: #fff;
            padding: 12px 20px; border-radius: 999px; font-size: 0.88rem; font-weight: 700;
            z-index: 9999; display: none; box-shadow: 0 8px 24px rgba(0,0,0,0.25);
        }
    