{"id":19513,"date":"2026-11-15T08:53:13","date_gmt":"2026-11-15T03:23:13","guid":{"rendered":"https:\/\/ddugdcsaidabad.ac.in\/?page_id=19513"},"modified":"2026-11-15T09:04:45","modified_gmt":"2026-11-15T03:34:45","slug":"de","status":"publish","type":"page","link":"https:\/\/ddugdcsaidabad.ac.in\/index.php\/de\/","title":{"rendered":"Daily Expance"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"19513\" class=\"elementor elementor-19513\" data-elementor-post-type=\"page\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-82f351f elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"82f351f\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-f458e32\" data-id=\"f458e32\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-e766748 elementor-widget elementor-widget-html\" data-id=\"e766748\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<!DOCTYPE html>\r\n<html lang=\"en\">\r\n<head>\r\n    <meta charset=\"UTF-8\">\r\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\r\n    <title>Daily Expenditure Tracker (\u20b9)<\/title>\r\n    <!-- Google Fonts: Inter -->\r\n    <link rel=\"preconnect\" href=\"https:\/\/fonts.googleapis.com\">\r\n    <link rel=\"preconnect\" href=\"https:\/\/fonts.gstatic.com\" crossorigin>\r\n    <link href=\"https:\/\/fonts.googleapis.com\/css2?family=Inter:wght@300;400;500;600;700&display=swap\" rel=\"stylesheet\">\r\n    <!-- Tailwind CSS CDN -->\r\n    <script src=\"https:\/\/cdn.tailwindcss.com\"><\/script>\r\n    <!-- Chart.js CDN -->\r\n    <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/chart.js\"><\/script>\r\n    <!-- Font Awesome for clean icons -->\r\n    <link rel=\"stylesheet\" href=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/font-awesome\/6.4.0\/css\/all.min.css\">\r\n    <script>\r\n        tailwind.config = {\r\n            theme: {\r\n                extend: {\r\n                    fontFamily: {\r\n                        sans: ['Inter', 'sans-serif'],\r\n                    },\r\n                    colors: {\r\n                        brand: {\r\n                            50: '#eef2ff',\r\n                            100: '#e0e7ff',\r\n                            500: '#6366f1',\r\n                            600: '#4f46e5',\r\n                            700: '#4338ca',\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    <\/script>\r\n<\/head>\r\n<body class=\"bg-slate-50 text-slate-800 font-sans antialiased min-h-screen flex flex-col\">\r\n\r\n    <!-- Top Navigation \/ Header -->\r\n    <header class=\"bg-white border-b border-slate-200 sticky top-0 z-30 shadow-sm\">\r\n        <div class=\"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 h-16 flex items-center justify-between\">\r\n            <div class=\"flex items-center space-x-3\">\r\n                <div class=\"w-10 h-10 rounded-xl bg-indigo-600 flex items-center justify-center text-white shadow-md shadow-indigo-200\">\r\n                    <i class=\"fa-solid fa-indian-rupee-sign text-lg\"><\/i>\r\n                <\/div>\r\n                <div>\r\n                    <h1 class=\"text-lg sm:text-xl font-bold text-slate-900 tracking-tight\">SpendWise<\/h1>\r\n                    <p class=\"text-xs text-slate-500 hidden sm:block\">Daily Expenditure & Budget Tracker<\/p>\r\n                <\/div>\r\n            <\/div>\r\n            <div class=\"flex items-center space-x-2 sm:space-x-3\">\r\n                <!-- Google Sheets Live Sync Status & Setup Button -->\r\n                <button id=\"openSyncModalBtn\" class=\"inline-flex items-center px-3 py-2 text-xs sm:text-sm font-medium rounded-xl text-slate-700 bg-slate-100 hover:bg-slate-200 border border-slate-200\/80 transition-colors focus:outline-none focus:ring-2 focus:ring-indigo-500\">\r\n                    <span id=\"syncStatusDot\" class=\"w-2 h-2 rounded-full bg-emerald-500 mr-2 shrink-0\"><\/span>\r\n                    <i class=\"fa-solid fa-cloud mr-1.5 text-indigo-600 hidden sm:inline\"><\/i>\r\n                    <span id=\"syncStatusText\">Cloud Synced<\/span>\r\n                <\/button>\r\n                <button id=\"exportCsvBtn\" class=\"inline-flex items-center px-3 py-2 text-xs sm:text-sm font-medium rounded-xl text-slate-700 bg-slate-100 hover:bg-slate-200 transition-colors focus:outline-none focus:ring-2 focus:ring-indigo-500\">\r\n                    <i class=\"fa-solid fa-file-csv mr-1.5 text-emerald-600\"><\/i>\r\n                    <span class=\"hidden sm:inline\">Export CSV<\/span>\r\n                    <span class=\"sm:hidden\">CSV<\/span>\r\n                <\/button>\r\n                <button id=\"clearAllBtn\" class=\"inline-flex items-center px-3 py-2 text-xs sm:text-sm font-medium rounded-xl text-rose-600 bg-rose-50 hover:bg-rose-100 transition-colors focus:outline-none focus:ring-2 focus:ring-rose-500\">\r\n                    <i class=\"fa-solid fa-trash-can mr-1.5\"><\/i>\r\n                    <span class=\"hidden sm:inline\">Clear All<\/span>\r\n                <\/button>\r\n            <\/div>\r\n        <\/div>\r\n    <\/header>\r\n\r\n    <!-- Main Container -->\r\n    <main class=\"flex-grow max-w-7xl w-full mx-auto px-4 sm:px-6 lg:px-8 py-6 sm:py-8 space-y-6\">\r\n\r\n        <!-- 1. Summary Cards Section -->\r\n        <section aria-label=\"Expenditure Summary\" class=\"grid grid-cols-1 md:grid-cols-3 gap-4 sm:gap-6\">\r\n            <!-- Total Expenditure Card -->\r\n            <div class=\"bg-white rounded-2xl p-6 border border-slate-200\/80 shadow-sm hover:shadow-md transition-shadow relative overflow-hidden\">\r\n                <div class=\"flex items-center justify-between\">\r\n                    <div>\r\n                        <p class=\"text-sm font-medium text-slate-500\">Total Expenditure<\/p>\r\n                        <h2 id=\"totalExpenseDisplay\" class=\"text-2xl sm:text-3xl font-bold text-slate-900 mt-1\">\u20b90.00<\/h2>\r\n                        <p id=\"totalCountDisplay\" class=\"text-xs text-slate-400 mt-2\">Across 0 transactions<\/p>\r\n                    <\/div>\r\n                    <div class=\"w-12 h-12 rounded-2xl bg-indigo-50 text-indigo-600 flex items-center justify-center text-xl\">\r\n                        <i class=\"fa-solid fa-wallet\"><\/i>\r\n                    <\/div>\r\n                <\/div>\r\n            <\/div>\r\n\r\n            <!-- Today's Expenditure Card -->\r\n            <div class=\"bg-white rounded-2xl p-6 border border-slate-200\/80 shadow-sm hover:shadow-md transition-shadow relative overflow-hidden\">\r\n                <div class=\"flex items-center justify-between\">\r\n                    <div>\r\n                        <p class=\"text-sm font-medium text-slate-500\">Today's Expenditure<\/p>\r\n                        <h2 id=\"todayExpenseDisplay\" class=\"text-2xl sm:text-3xl font-bold text-emerald-600 mt-1\">\u20b90.00<\/h2>\r\n                        <p id=\"todayDateDisplay\" class=\"text-xs text-slate-400 mt-2\">Today<\/p>\r\n                    <\/div>\r\n                    <div class=\"w-12 h-12 rounded-2xl bg-emerald-50 text-emerald-600 flex items-center justify-center text-xl\">\r\n                        <i class=\"fa-solid fa-calendar-day\"><\/i>\r\n                    <\/div>\r\n                <\/div>\r\n            <\/div>\r\n\r\n            <!-- Top Spending Category Card -->\r\n            <div class=\"bg-white rounded-2xl p-6 border border-slate-200\/80 shadow-sm hover:shadow-md transition-shadow relative overflow-hidden\">\r\n                <div class=\"flex items-center justify-between\">\r\n                    <div class=\"min-w-0 pr-2\">\r\n                        <p class=\"text-sm font-medium text-slate-500\">Top Spending Category<\/p>\r\n                        <h2 id=\"topCategoryDisplay\" class=\"text-xl sm:text-2xl font-bold text-amber-600 mt-1 truncate\">None yet<\/h2>\r\n                        <p id=\"topCategoryAmountDisplay\" class=\"text-xs text-slate-400 mt-2\">\u20b90.00 (0%)<\/p>\r\n                    <\/div>\r\n                    <div class=\"w-12 h-12 rounded-2xl bg-amber-50 text-amber-600 flex items-center justify-center text-xl shrink-0\">\r\n                        <i class=\"fa-solid fa-chart-pie\"><\/i>\r\n                    <\/div>\r\n                <\/div>\r\n            <\/div>\r\n        <\/section>\r\n\r\n        <!-- 2. Form & Interactive Chart Grid -->\r\n        <section class=\"grid grid-cols-1 lg:grid-cols-12 gap-6\">\r\n            \r\n            <!-- Add \/ Edit Expense Form (7 cols on lg) -->\r\n            <div class=\"lg:col-span-7 bg-white rounded-2xl p-6 border border-slate-200\/80 shadow-sm\">\r\n                <div class=\"flex items-center justify-between mb-5\">\r\n                    <div class=\"flex items-center space-x-2\">\r\n                        <span id=\"formIconBadge\" class=\"w-8 h-8 rounded-lg bg-indigo-100 text-indigo-600 flex items-center justify-center text-sm\">\r\n                            <i class=\"fa-solid fa-plus\"><\/i>\r\n                        <\/span>\r\n                        <h3 id=\"formTitle\" class=\"text-lg font-semibold text-slate-900\">Add New Expense<\/h3>\r\n                    <\/div>\r\n                    <button type=\"button\" id=\"cancelEditBtn\" class=\"hidden text-xs font-medium text-slate-500 hover:text-slate-800 bg-slate-100 px-3 py-1.5 rounded-lg transition-colors\">\r\n                        Cancel Edit\r\n                    <\/button>\r\n                <\/div>\r\n\r\n                <form id=\"expenseForm\" class=\"space-y-4\">\r\n                    <input type=\"hidden\" id=\"editExpenseId\" value=\"\">\r\n                    \r\n                    <div class=\"grid grid-cols-1 sm:grid-cols-2 gap-4\">\r\n                        <!-- Description -->\r\n                        <div class=\"sm:col-span-2\">\r\n                            <label for=\"description\" class=\"block text-xs font-semibold uppercase tracking-wider text-slate-500 mb-1.5\">Description \/ Item *<\/label>\r\n                            <input type=\"text\" id=\"description\" required placeholder=\"e.g., Lunch at Masala Darbar, Metro Recharge, Groceries...\" \r\n                                class=\"w-full px-4 py-2.5 rounded-xl border border-slate-300 text-slate-900 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition-shadow\">\r\n                        <\/div>\r\n\r\n                        <!-- Amount (\u20b9) -->\r\n                        <div>\r\n                            <label for=\"amount\" class=\"block text-xs font-semibold uppercase tracking-wider text-slate-500 mb-1.5\">Amount (\u20b9) *<\/label>\r\n                            <div class=\"relative\">\r\n                                <span class=\"absolute inset-y-0 left-0 pl-3.5 flex items-center text-slate-400 font-semibold\">\u20b9<\/span>\r\n                                <input type=\"number\" id=\"amount\" required min=\"0.01\" step=\"0.01\" placeholder=\"0.00\" \r\n                                    class=\"w-full pl-8 pr-4 py-2.5 rounded-xl border border-slate-300 text-slate-900 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition-shadow\">\r\n                            <\/div>\r\n                        <\/div>\r\n\r\n                        <!-- Date -->\r\n                        <div>\r\n                            <label for=\"date\" class=\"block text-xs font-semibold uppercase tracking-wider text-slate-500 mb-1.5\">Date *<\/label>\r\n                            <input type=\"date\" id=\"date\" required \r\n                                class=\"w-full px-4 py-2.5 rounded-xl border border-slate-300 text-slate-900 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition-shadow\">\r\n                        <\/div>\r\n\r\n                        <!-- Category -->\r\n                        <div>\r\n                            <label for=\"category\" class=\"block text-xs font-semibold uppercase tracking-wider text-slate-500 mb-1.5\">Category *<\/label>\r\n                            <select id=\"category\" required \r\n                                class=\"w-full px-4 py-2.5 rounded-xl border border-slate-300 text-slate-900 text-sm bg-white focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition-shadow\">\r\n                                <option value=\"Food & Dining\">Food & Dining<\/option>\r\n                                <option value=\"Transport\">Transport<\/option>\r\n                                <option value=\"Groceries\">Groceries<\/option>\r\n                                <option value=\"Bills & Utilities\">Bills & Utilities<\/option>\r\n                                <option value=\"Shopping\">Shopping<\/option>\r\n                                <option value=\"Entertainment\">Entertainment<\/option>\r\n                                <option value=\"Health\">Health<\/option>\r\n                                <option value=\"Other\">Other<\/option>\r\n                            <\/select>\r\n                        <\/div>\r\n\r\n                        <!-- Payment Method -->\r\n                        <div>\r\n                            <label for=\"paymentMethod\" class=\"block text-xs font-semibold uppercase tracking-wider text-slate-500 mb-1.5\">Payment Method *<\/label>\r\n                            <select id=\"paymentMethod\" required \r\n                                class=\"w-full px-4 py-2.5 rounded-xl border border-slate-300 text-slate-900 text-sm bg-white focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition-shadow\">\r\n                                <option value=\"UPI\">UPI<\/option>\r\n                                <option value=\"Cash\">Cash<\/option>\r\n                                <option value=\"Card\">Card<\/option>\r\n                                <option value=\"Net Banking\">Net Banking<\/option>\r\n                            <\/select>\r\n                        <\/div>\r\n                    <\/div>\r\n\r\n                    <div class=\"pt-2 flex items-center justify-end space-x-3\">\r\n                        <button type=\"reset\" id=\"resetFormBtn\" class=\"px-4 py-2.5 rounded-xl text-sm font-medium text-slate-600 hover:bg-slate-100 transition-colors\">\r\n                            Reset\r\n                        <\/button>\r\n                        <button type=\"submit\" id=\"submitBtn\" class=\"px-6 py-2.5 rounded-xl text-sm font-semibold text-white bg-indigo-600 hover:bg-indigo-700 shadow-sm shadow-indigo-200 transition-all focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500\">\r\n                            <i class=\"fa-solid fa-check mr-1.5\"><\/i>\r\n                            <span id=\"submitBtnText\">Add Expense<\/span>\r\n                        <\/button>\r\n                    <\/div>\r\n                <\/form>\r\n            <\/div>\r\n\r\n            <!-- Interactive Category Breakdown Visual Chart (5 cols on lg) -->\r\n            <div class=\"lg:col-span-5 bg-white rounded-2xl p-6 border border-slate-200\/80 shadow-sm flex flex-col justify-between\">\r\n                <div class=\"flex items-center justify-between mb-2\">\r\n                    <div>\r\n                        <h3 class=\"text-lg font-semibold text-slate-900\">Category Breakdown<\/h3>\r\n                        <p class=\"text-xs text-slate-500\">Spending distribution by category<\/p>\r\n                    <\/div>\r\n                    <span id=\"chartScopeBadge\" class=\"text-xs font-medium px-2.5 py-1 rounded-full bg-slate-100 text-slate-600\">All Time<\/span>\r\n                <\/div>\r\n\r\n                <div class=\"relative flex-grow flex items-center justify-center min-h-[240px] my-2\">\r\n                    <canvas id=\"categoryChart\"><\/canvas>\r\n                    <div id=\"emptyChartMessage\" class=\"hidden text-center py-10\">\r\n                        <div class=\"w-12 h-12 rounded-full bg-slate-100 text-slate-400 flex items-center justify-center mx-auto mb-2\">\r\n                            <i class=\"fa-solid fa-chart-simple text-lg\"><\/i>\r\n                        <\/div>\r\n                        <p class=\"text-sm font-medium text-slate-500\">No data to visualize<\/p>\r\n                        <p class=\"text-xs text-slate-400\">Add an expense to see breakdown<\/p>\r\n                    <\/div>\r\n                <\/div>\r\n\r\n                <!-- Top Category Quick Legend Pills -->\r\n                <div id=\"categorySummaryPills\" class=\"flex flex-wrap gap-1.5 pt-2 border-t border-slate-100\"><\/div>\r\n            <\/div>\r\n        <\/section>\r\n\r\n        <!-- 3. Filter, Search & Expense History Section -->\r\n        <section class=\"bg-white rounded-2xl border border-slate-200\/80 shadow-sm overflow-hidden\">\r\n            <!-- Header & Filter Controls -->\r\n            <div class=\"p-6 border-b border-slate-200 space-y-4\">\r\n                <div class=\"flex flex-col sm:flex-row sm:items-center justify-between gap-2\">\r\n                    <div>\r\n                        <h3 class=\"text-lg font-semibold text-slate-900\">Expense History<\/h3>\r\n                        <p id=\"filteredSummaryText\" class=\"text-xs text-slate-500\">Showing all recorded transactions<\/p>\r\n                    <\/div>\r\n                    <button id=\"resetFiltersBtn\" class=\"self-start sm:self-auto text-xs font-medium text-indigo-600 hover:text-indigo-800 hover:underline hidden\">\r\n                        <i class=\"fa-solid fa-rotate-left mr-1\"><\/i> Reset Filters\r\n                    <\/button>\r\n                <\/div>\r\n\r\n                <!-- Search & Filter Inputs Grid -->\r\n                <div class=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3\">\r\n                    <!-- Search by Description -->\r\n                    <div class=\"relative\">\r\n                        <span class=\"absolute inset-y-0 left-0 pl-3.5 flex items-center text-slate-400\">\r\n                            <i class=\"fa-solid fa-magnifying-glass text-xs\"><\/i>\r\n                        <\/span>\r\n                        <input type=\"text\" id=\"searchInput\" placeholder=\"Search description...\" \r\n                            class=\"w-full pl-9 pr-4 py-2 rounded-xl border border-slate-300 text-sm text-slate-800 focus:outline-none focus:ring-2 focus:ring-indigo-500\">\r\n                    <\/div>\r\n\r\n                    <!-- Filter by Category -->\r\n                    <div>\r\n                        <select id=\"filterCategory\" \r\n                            class=\"w-full px-3.5 py-2 rounded-xl border border-slate-300 text-sm text-slate-800 bg-white focus:outline-none focus:ring-2 focus:ring-indigo-500\">\r\n                            <option value=\"ALL\">All Categories<\/option>\r\n                            <option value=\"Food & Dining\">Food & Dining<\/option>\r\n                            <option value=\"Transport\">Transport<\/option>\r\n                            <option value=\"Groceries\">Groceries<\/option>\r\n                            <option value=\"Bills & Utilities\">Bills & Utilities<\/option>\r\n                            <option value=\"Shopping\">Shopping<\/option>\r\n                            <option value=\"Entertainment\">Entertainment<\/option>\r\n                            <option value=\"Health\">Health<\/option>\r\n                            <option value=\"Other\">Other<\/option>\r\n                        <\/select>\r\n                    <\/div>\r\n\r\n                    <!-- Filter by Month -->\r\n                    <div>\r\n                        <input type=\"month\" id=\"filterMonth\" title=\"Filter by Month\"\r\n                            class=\"w-full px-3.5 py-2 rounded-xl border border-slate-300 text-sm text-slate-800 bg-white focus:outline-none focus:ring-2 focus:ring-indigo-500\">\r\n                    <\/div>\r\n\r\n                    <!-- Filter by Exact Date -->\r\n                    <div>\r\n                        <input type=\"date\" id=\"filterDate\" title=\"Filter by Specific Date\"\r\n                            class=\"w-full px-3.5 py-2 rounded-xl border border-slate-300 text-sm text-slate-800 bg-white focus:outline-none focus:ring-2 focus:ring-indigo-500\">\r\n                    <\/div>\r\n                <\/div>\r\n            <\/div>\r\n\r\n            <!-- Responsive Expense History Table -->\r\n            <div class=\"overflow-x-auto\">\r\n                <table class=\"w-full text-left border-collapse\">\r\n                    <thead>\r\n                        <tr class=\"bg-slate-50\/80 border-b border-slate-200 text-xs font-semibold uppercase tracking-wider text-slate-500\">\r\n                            <th class=\"py-3.5 px-6\">Date<\/th>\r\n                            <th class=\"py-3.5 px-6\">Description<\/th>\r\n                            <th class=\"py-3.5 px-6\">Category<\/th>\r\n                            <th class=\"py-3.5 px-6\">Payment<\/th>\r\n                            <th class=\"py-3.5 px-6 text-right\">Amount<\/th>\r\n                            <th class=\"py-3.5 px-6 text-center\">Actions<\/th>\r\n                        <\/tr>\r\n                    <\/thead>\r\n                    <tbody id=\"expenseTableBody\" class=\"divide-y divide-slate-100 text-sm\">\r\n                        <!-- Dynamic rows rendered via JS -->\r\n                    <\/tbody>\r\n                <\/table>\r\n            <\/div>\r\n\r\n            <!-- Empty State when no expenses match -->\r\n            <div id=\"emptyTableState\" class=\"hidden py-12 px-4 text-center\">\r\n                <div class=\"w-14 h-14 rounded-2xl bg-slate-100 text-slate-400 flex items-center justify-center mx-auto mb-3 text-xl\">\r\n                    <i class=\"fa-solid fa-receipt\"><\/i>\r\n                <\/div>\r\n                <h4 class=\"text-base font-semibold text-slate-800\">No expenses found<\/h4>\r\n                <p class=\"text-xs text-slate-500 max-w-sm mx-auto mt-1\">Try adjusting your search or filter criteria, or add a new expenditure entry above.<\/p>\r\n            <\/div>\r\n        <\/section>\r\n    <\/main>\r\n\r\n    <!-- Custom Confirmation Modal (Replaces native confirm()) -->\r\n    <div id=\"confirmModal\" class=\"fixed inset-0 z-50 hidden items-center justify-center bg-slate-900\/50 backdrop-blur-xs p-4\">\r\n        <div class=\"bg-white rounded-2xl max-w-md w-full p-6 shadow-xl border border-slate-200 transform transition-all\">\r\n            <div class=\"flex items-center space-x-3 mb-4\">\r\n                <div class=\"w-10 h-10 rounded-full bg-rose-100 text-rose-600 flex items-center justify-center shrink-0\">\r\n                    <i class=\"fa-solid fa-triangle-exclamation\"><\/i>\r\n                <\/div>\r\n                <h3 id=\"modalTitle\" class=\"text-lg font-bold text-slate-900\">Confirm Action<\/h3>\r\n            <\/div>\r\n            <p id=\"modalMessage\" class=\"text-sm text-slate-600 mb-6\">Are you sure you want to proceed?<\/p>\r\n            <div class=\"flex items-center justify-end space-x-3\">\r\n                <button id=\"modalCancelBtn\" class=\"px-4 py-2 rounded-xl text-sm font-medium text-slate-700 bg-slate-100 hover:bg-slate-200 transition-colors\">\r\n                    Cancel\r\n                <\/button>\r\n                <button id=\"modalConfirmBtn\" class=\"px-4 py-2 rounded-xl text-sm font-semibold text-white bg-rose-600 hover:bg-rose-700 transition-colors\">\r\n                    Confirm Delete\r\n                <\/button>\r\n            <\/div>\r\n        <\/div>\r\n    <\/div>\r\n\r\n    <!-- Google Sheets Cloud Sync Setup Modal -->\r\n    <div id=\"syncModal\" class=\"fixed inset-0 z-50 hidden items-center justify-center bg-slate-900\/50 backdrop-blur-xs p-4 overflow-y-auto\">\r\n        <div class=\"bg-white rounded-2xl max-w-2xl w-full p-6 shadow-2xl border border-slate-200 my-8\">\r\n            <div class=\"flex items-center justify-between pb-4 border-b border-slate-100\">\r\n                <div class=\"flex items-center space-x-3\">\r\n                    <div class=\"w-10 h-10 rounded-xl bg-emerald-50 text-emerald-600 flex items-center justify-center text-lg shrink-0\">\r\n                        <i class=\"fa-solid fa-table\"><\/i>\r\n                    <\/div>\r\n                    <div>\r\n                        <h3 class=\"text-lg font-bold text-slate-900\">Google Sheets Auto-Backup<\/h3>\r\n                        <p class=\"text-xs text-slate-500\">Mirror every expense automatically to your Google Sheet<\/p>\r\n                    <\/div>\r\n                <\/div>\r\n                <button id=\"closeSyncModalBtn\" class=\"p-2 rounded-lg text-slate-400 hover:text-slate-700 hover:bg-slate-100 transition-colors\">\r\n                    <i class=\"fa-solid fa-xmark text-lg\"><\/i>\r\n                <\/button>\r\n            <\/div>\r\n\r\n            <div class=\"space-y-5 mt-5\">\r\n                <!-- Step 1: Apps Script URL Input -->\r\n                <div>\r\n                    <label for=\"scriptUrlInput\" class=\"block text-xs font-semibold uppercase tracking-wider text-slate-600 mb-1.5\">\r\n                        1. Google Apps Script Web App URL\r\n                    <\/label>\r\n                    <div class=\"flex flex-col sm:flex-row gap-2\">\r\n                        <input type=\"url\" id=\"scriptUrlInput\" placeholder=\"https:\/\/script.google.com\/macros\/s\/AKfycb...\/exec\"\r\n                            class=\"flex-grow px-3.5 py-2.5 rounded-xl border border-slate-300 text-sm text-slate-900 focus:outline-none focus:ring-2 focus:ring-indigo-500\">\r\n                        <button type=\"button\" id=\"saveScriptUrlBtn\" class=\"px-4 py-2.5 rounded-xl text-sm font-semibold text-white bg-indigo-600 hover:bg-indigo-700 transition-colors shrink-0\">\r\n                            <i class=\"fa-solid fa-floppy-disk mr-1.5\"><\/i>Save URL\r\n                        <\/button>\r\n                    <\/div>\r\n                    <p class=\"text-[11px] text-slate-400 mt-1.5\">Once saved, every new, edited, or deleted expense syncs automatically in the background.<\/p>\r\n                <\/div>\r\n\r\n                <!-- Step 2: Two-Way Manual Backup Actions -->\r\n                <div class=\"bg-slate-50 rounded-xl p-4 border border-slate-200\/80\">\r\n                    <p class=\"text-xs font-semibold uppercase tracking-wider text-slate-600 mb-2.5\">2. Manual Bulk Sync &amp; Restore<\/p>\r\n                    <div class=\"grid grid-cols-1 sm:grid-cols-2 gap-3\">\r\n                        <button type=\"button\" id=\"pushAllToSheetBtn\" class=\"inline-flex items-center justify-center px-4 py-2.5 rounded-xl text-xs sm:text-sm font-semibold text-emerald-700 bg-emerald-50 hover:bg-emerald-100 border border-emerald-200 transition-colors\">\r\n                            <i class=\"fa-solid fa-cloud-arrow-up mr-2\"><\/i>Push All Local Entries to Sheet\r\n                        <\/button>\r\n                        <button type=\"button\" id=\"pullFromSheetBtn\" class=\"inline-flex items-center justify-center px-4 py-2.5 rounded-xl text-xs sm:text-sm font-semibold text-indigo-700 bg-indigo-50 hover:bg-indigo-100 border border-indigo-200 transition-colors\">\r\n                            <i class=\"fa-solid fa-cloud-arrow-down mr-2\"><\/i>Restore Backup from Sheet\r\n                        <\/button>\r\n                    <\/div>\r\n                <\/div>\r\n\r\n                <!-- Step 3: Copy-Paste Apps Script Backend Code -->\r\n                <div>\r\n                    <div class=\"flex items-center justify-between mb-1.5\">\r\n                        <label class=\"block text-xs font-semibold uppercase tracking-wider text-slate-600\">\r\n                            3. Google Apps Script Backend Code (<span class=\"normal-case font-normal text-slate-500\">Extensions &rarr; Apps Script &rarr; Deploy as Web App<\/span>)\r\n                        <\/label>\r\n                        <button type=\"button\" id=\"copyAppsScriptBtn\" class=\"inline-flex items-center px-2.5 py-1 rounded-lg text-xs font-medium text-indigo-600 bg-indigo-50 hover:bg-indigo-100 transition-colors\">\r\n                            <i class=\"fa-regular fa-copy mr-1\"><\/i>Copy Code\r\n                        <\/button>\r\n                    <\/div>\r\n                    <pre id=\"appsScriptCodeBlock\" class=\"bg-slate-900 text-slate-100 text-xs p-4 rounded-xl overflow-x-auto max-h-52 leading-relaxed font-mono select-all\">const SHEET_NAME = 'Expenses';\r\n\r\nfunction getOrCreateSheet() {\r\n  const ss = SpreadsheetApp.getActiveSpreadsheet();\r\n  let sheet = ss.getSheetByName(SHEET_NAME);\r\n  if (!sheet) {\r\n    sheet = ss.insertSheet(SHEET_NAME);\r\n    sheet.appendRow(['ID', 'Date', 'Description', 'Category', 'Payment Method', 'Amount (INR)', 'Updated At']);\r\n    sheet.getRange(1, 1, 1, 7).setFontWeight('bold');\r\n  }\r\n  return sheet;\r\n}\r\n\r\nfunction doPost(e) {\r\n  const sheet = getOrCreateSheet();\r\n  const payload = JSON.parse(e.postData.contents);\r\n  const now = new Date().toISOString();\r\n\r\n  if (payload.action === 'syncAll' && Array.isArray(payload.expenses)) {\r\n    sheet.clearContents();\r\n    sheet.appendRow(['ID', 'Date', 'Description', 'Category', 'Payment Method', 'Amount (INR)', 'Updated At']);\r\n    sheet.getRange(1, 1, 1, 7).setFontWeight('bold');\r\n    const rows = payload.expenses.map(item => [\r\n      item.id, item.date, item.description, item.category, item.paymentMethod, Number(item.amount), now\r\n    ]);\r\n    if (rows.length > 0) {\r\n      sheet.getRange(2, 1, rows.length, 7).setValues(rows);\r\n    }\r\n    return ContentService.createTextOutput(JSON.stringify({ status: 'ok', count: rows.length }))\r\n      .setMimeType(ContentService.MimeType.JSON);\r\n  }\r\n\r\n  const data = sheet.getDataRange().getValues();\r\n  const rowIndex = data.findIndex((row, idx) => idx > 0 && row[0] === payload.expense?.id);\r\n\r\n  if (payload.action === 'delete' && rowIndex > 0) {\r\n    sheet.deleteRow(rowIndex + 1);\r\n  } else if ((payload.action === 'add' || payload.action === 'edit') && payload.expense) {\r\n    const exp = payload.expense;\r\n    const rowValues = [exp.id, exp.date, exp.description, exp.category, exp.paymentMethod, Number(exp.amount), now];\r\n    if (rowIndex > 0) {\r\n      sheet.getRange(rowIndex + 1, 1, 1, 7).setValues([rowValues]);\r\n    } else {\r\n      sheet.appendRow(rowValues);\r\n    }\r\n  }\r\n\r\n  return ContentService.createTextOutput(JSON.stringify({ status: 'ok' }))\r\n    .setMimeType(ContentService.MimeType.JSON);\r\n}\r\n\r\nfunction doGet() {\r\n  const sheet = getOrCreateSheet();\r\n  const values = sheet.getDataRange().getValues();\r\n  const expenses = values.slice(1).filter(r => r[0]).map(r => ({\r\n    id: String(r[0]),\r\n    date: r[1] instanceof Date ? Utilities.formatDate(r[1], Session.getScriptTimeZone(), 'yyyy-MM-dd') : String(r[1]),\r\n    description: String(r[2]),\r\n    category: String(r[3]),\r\n    paymentMethod: String(r[4]),\r\n    amount: Number(r[5]) || 0\r\n  }));\r\n  return ContentService.createTextOutput(JSON.stringify({ status: 'ok', expenses }))\r\n    .setMimeType(ContentService.MimeType.JSON);\r\n}<\/pre>\r\n                <\/div>\r\n            <\/div>\r\n        <\/div>\r\n    <\/div>\r\n\r\n    <!-- Toast Notification Banner -->\r\n    <div id=\"toastContainer\" class=\"fixed bottom-5 right-5 z-50 flex flex-col space-y-2 pointer-events-none\"><\/div>\r\n\r\n    <!-- Footer -->\r\n    <footer class=\"bg-white border-t border-slate-200 py-4 mt-8\">\r\n        <div class=\"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 flex flex-col sm:flex-row items-center justify-between text-xs text-slate-400 gap-2\">\r\n            <p>SpendWise Daily Expenditure Tracker &bull; Data stored locally in your browser<\/p>\r\n            <button id=\"restoreSampleBtn\" class=\"text-indigo-600 hover:text-indigo-800 font-medium hover:underline\">\r\n                Load Sample Data\r\n            <\/button>\r\n        <\/div>\r\n    <\/footer>\r\n\r\n    <!-- Application Logic -->\r\n    <script>\r\n        \/**\r\n         * SpendWise - Daily Expenditure Tracker\r\n         * Complete client-side application with LocalStorage persistence,\r\n         * Chart.js visualization, CSV export, and responsive UI.\r\n         *\/\r\n\r\n        \/\/ --- Constants & Configuration ---\r\n        const STORAGE_KEY = 'spendwise_expenses_v1';\r\n        const INITIALIZED_FLAG_KEY = 'spendwise_initialized_v1';\r\n        const SCRIPT_URL_KEY = 'spendwise_google_script_url_v1';\r\n        const DEFAULT_SCRIPT_URL = 'https:\/\/script.google.com\/macros\/s\/AKfycbyKk26EM1s5lExIDQCBFUZ-GIVY44pp2ZoL9HUkLOs_iD-Pf9VJiV0a5yZ1pb4fGwQ25w\/exec';\r\n\r\n        const CATEGORY_CONFIG = {\r\n            'Food & Dining':     { color: '#f97316', bg: 'bg-orange-50',  text: 'text-orange-700',  border: 'border-orange-200', icon: 'fa-utensils' },\r\n            'Transport':         { color: '#3b82f6', bg: 'bg-blue-50',    text: 'text-blue-700',    border: 'border-blue-200',   icon: 'fa-car' },\r\n            'Groceries':         { color: '#10b981', bg: 'bg-emerald-50', text: 'text-emerald-700', border: 'border-emerald-200',icon: 'fa-basket-shopping' },\r\n            'Bills & Utilities': { color: '#8b5cf6', bg: 'bg-violet-50',  text: 'text-violet-700',  border: 'border-violet-200', icon: 'fa-bolt' },\r\n            'Shopping':          { color: '#ec4899', bg: 'bg-pink-50',    text: 'text-pink-700',    border: 'border-pink-200',   icon: 'fa-bag-shopping' },\r\n            'Entertainment':     { color: '#eab308', bg: 'bg-amber-50',   text: 'text-amber-700',   border: 'border-amber-200',  icon: 'fa-film' },\r\n            'Health':            { color: '#ef4444', bg: 'bg-rose-50',    text: 'text-rose-700',    border: 'border-rose-200',   icon: 'fa-heart-pulse' },\r\n            'Other':             { color: '#64748b', bg: 'bg-slate-100',  text: 'text-slate-700',   border: 'border-slate-200',  icon: 'fa-receipt' }\r\n        };\r\n\r\n        const PAYMENT_ICONS = {\r\n            'UPI': 'fa-mobile-screen-button',\r\n            'Cash': 'fa-money-bill-wave',\r\n            'Card': 'fa-credit-card',\r\n            'Net Banking': 'fa-building-columns'\r\n        };\r\n\r\n        \/\/ --- State ---\r\n        let expenses = [];\r\n        let categoryChartInstance = null;\r\n        let pendingConfirmCallback = null;\r\n        let googleScriptUrl = '';\r\n\r\n        \/\/ --- Google Sheets Cloud Sync Engine ---\r\n        function getSavedScriptUrl() {\r\n            const stored = localStorage.getItem(SCRIPT_URL_KEY);\r\n            if (stored === null) {\r\n                localStorage.setItem(SCRIPT_URL_KEY, DEFAULT_SCRIPT_URL);\r\n                return DEFAULT_SCRIPT_URL;\r\n            }\r\n            return stored.trim();\r\n        }\r\n\r\n        function updateSyncStatusUI(state, customLabel) {\r\n            const dot = document.getElementById('syncStatusDot');\r\n            const text = document.getElementById('syncStatusText');\r\n            if (!dot || !text) return;\r\n\r\n            if (!googleScriptUrl) {\r\n                dot.className = 'w-2 h-2 rounded-full bg-amber-400 mr-2 shrink-0';\r\n                text.textContent = 'Local Only \u2014 Set URL';\r\n                return;\r\n            }\r\n\r\n            if (state === 'syncing') {\r\n                dot.className = 'w-2 h-2 rounded-full bg-indigo-500 animate-ping mr-2 shrink-0';\r\n                text.textContent = customLabel || 'Syncing...';\r\n            } else if (state === 'error') {\r\n                dot.className = 'w-2 h-2 rounded-full bg-rose-500 mr-2 shrink-0';\r\n                text.textContent = customLabel || 'Sync Warning';\r\n            } else {\r\n                dot.className = 'w-2 h-2 rounded-full bg-emerald-500 mr-2 shrink-0';\r\n                text.textContent = customLabel || 'Cloud Synced';\r\n            }\r\n        }\r\n\r\n        async function syncMutationToGoogleSheet(payload) {\r\n            if (!googleScriptUrl) return;\r\n            updateSyncStatusUI('syncing', 'Syncing...');\r\n            try {\r\n                await fetch(googleScriptUrl, {\r\n                    method: 'POST',\r\n                    mode: 'no-cors',\r\n                    headers: {\r\n                        'Content-Type': 'text\/plain;charset=utf-8'\r\n                    },\r\n                    body: JSON.stringify(payload)\r\n                });\r\n                updateSyncStatusUI('synced', 'Cloud Synced');\r\n            } catch (err) {\r\n                console.error('Google Sheet sync error:', err);\r\n                updateSyncStatusUI('error', 'Sync Failed');\r\n                showToast('Saved locally, but Google Sheet sync failed.', 'error');\r\n            }\r\n        }\r\n\r\n        async function pushAllLocalEntriesToSheet() {\r\n            if (!googleScriptUrl) {\r\n                showToast('Please enter and save your Google Apps Script URL first.', 'error');\r\n                return;\r\n            }\r\n            updateSyncStatusUI('syncing', 'Pushing All...');\r\n            try {\r\n                await fetch(googleScriptUrl, {\r\n                    method: 'POST',\r\n                    mode: 'no-cors',\r\n                    headers: {\r\n                        'Content-Type': 'text\/plain;charset=utf-8'\r\n                    },\r\n                    body: JSON.stringify({\r\n                        action: 'syncAll',\r\n                        expenses: expenses\r\n                    })\r\n                });\r\n                updateSyncStatusUI('synced', 'Cloud Synced');\r\n                showToast(`Synced all ${expenses.length} entries to Google Sheet!`);\r\n            } catch (err) {\r\n                console.error('Bulk push error:', err);\r\n                updateSyncStatusUI('error', 'Sync Failed');\r\n                showToast('Failed to push records to Google Sheet.', 'error');\r\n            }\r\n        }\r\n\r\n        async function pullBackupFromSheet() {\r\n            if (!googleScriptUrl) {\r\n                showToast('Please enter and save your Google Apps Script URL first.', 'error');\r\n                return;\r\n            }\r\n            updateSyncStatusUI('syncing', 'Pulling Backup...');\r\n            try {\r\n                const response = await fetch(googleScriptUrl, {\r\n                    method: 'GET'\r\n                });\r\n                if (!response.ok) {\r\n                    throw new Error(`HTTP ${response.status}`);\r\n                }\r\n                const data = await response.json();\r\n                const remoteList = Array.isArray(data?.expenses)\r\n                    ? data.expenses\r\n                    : (Array.isArray(data?.items) ? data.items : null);\r\n\r\n                if (data && (data.status === 'ok' || data.status === 'success') && remoteList) {\r\n                    expenses = remoteList.map(r => ({\r\n                        id: String(r.id || generateId()),\r\n                        date: String(r.date || getTodayISO()),\r\n                        description: String(r.description || ''),\r\n                        category: String(r.category || 'Other'),\r\n                        paymentMethod: String(r.paymentMethod || r.paymentMode || 'UPI'),\r\n                        amount: Number(r.amount) || 0\r\n                    }));\r\n                    saveExpenses();\r\n                    refreshDashboard();\r\n                    updateSyncStatusUI('synced', 'Cloud Synced');\r\n\r\n                    expenses = data.expenses;\r\n                    saveExpenses();\r\n                    refreshDashboard();\r\n                    updateSyncStatusUI('synced', 'Cloud Synced');\r\n                    showToast(`Restored ${expenses.length} entries from Google Sheet!`);\r\n                } else {\r\n                    throw new Error('Invalid response format from Apps Script');\r\n                }\r\n            } catch (err) {\r\n                console.error('Restore from Google Sheet error:', err);\r\n                updateSyncStatusUI('error', 'Pull Failed');\r\n                showToast('Could not pull backup. Ensure Apps Script is deployed with access set to \"Anyone\".', 'error');\r\n            }\r\n        }\r\n\r\n        \/\/ --- Utility Functions ---\r\n        function getTodayISO() {\r\n            const now = new Date();\r\n            const offset = now.getTimezoneOffset();\r\n            const localDate = new Date(now.getTime() - (offset * 60 * 1000));\r\n            return localDate.toISOString().split('T')[0];\r\n        }\r\n\r\n        function getOffsetDateISO(daysAgo) {\r\n            const now = new Date();\r\n            now.setDate(now.getDate() - daysAgo);\r\n            const offset = now.getTimezoneOffset();\r\n            const localDate = new Date(now.getTime() - (offset * 60 * 1000));\r\n            return localDate.toISOString().split('T')[0];\r\n        }\r\n\r\n        function formatINR(amount) {\r\n            return new Intl.NumberFormat('en-IN', {\r\n                style: 'currency',\r\n                currency: 'INR',\r\n                minimumFractionDigits: 2,\r\n                maximumFractionDigits: 2\r\n            }).format(amount);\r\n        }\r\n\r\n        function formatDisplayDate(isoDate) {\r\n            if (!isoDate) return '';\r\n            const [year, month, day] = isoDate.split('-');\r\n            const dateObj = new Date(year, month - 1, day);\r\n            return dateObj.toLocaleDateString('en-IN', {\r\n                day: '2-digit',\r\n                month: 'short',\r\n                year: 'numeric'\r\n            });\r\n        }\r\n\r\n        function escapeHTML(str) {\r\n            const div = document.createElement('div');\r\n            div.textContent = str;\r\n            return div.innerHTML;\r\n        }\r\n\r\n        function generateId() {\r\n            return 'exp_' + Date.now() + '_' + Math.random().toString(36).substring(2, 7);\r\n        }\r\n\r\n        function showToast(message, type = 'success') {\r\n            const container = document.getElementById('toastContainer');\r\n            const toast = document.createElement('div');\r\n            const bgClass = type === 'success' ? 'bg-slate-900 text-white' : 'bg-rose-600 text-white';\r\n            const iconClass = type === 'success' ? 'fa-circle-check text-emerald-400' : 'fa-circle-exclamation text-white';\r\n\r\n            toast.className = `${bgClass} px-4 py-3 rounded-xl shadow-lg flex items-center space-x-2.5 text-sm font-medium pointer-events-auto transform transition-all duration-300 translate-y-2 opacity-0`;\r\n            toast.innerHTML = `<i class=\"fa-solid ${iconClass}\"><\/i><span>${escapeHTML(message)}<\/span>`;\r\n            container.appendChild(toast);\r\n\r\n            requestAnimationFrame(() => {\r\n                toast.classList.remove('translate-y-2', 'opacity-0');\r\n            });\r\n\r\n            setTimeout(() => {\r\n                toast.classList.add('opacity-0', 'translate-y-2');\r\n                setTimeout(() => toast.remove(), 300);\r\n            }, 3000);\r\n        }\r\n\r\n        \/\/ --- Sample Data Generator ---\r\n        function getSampleExpenses() {\r\n            const today = getTodayISO();\r\n            return [\r\n                {\r\n                    id: generateId(),\r\n                    description: 'Morning Filter Coffee & Masala Dosa',\r\n                    amount: 185.00,\r\n                    category: 'Food & Dining',\r\n                    paymentMethod: 'UPI',\r\n                    date: today\r\n                },\r\n                {\r\n                    id: generateId(),\r\n                    description: 'Auto Rickshaw & Metro Commute',\r\n                    amount: 120.00,\r\n                    category: 'Transport',\r\n                    paymentMethod: 'UPI',\r\n                    date: today\r\n                },\r\n                {\r\n                    id: generateId(),\r\n                    description: 'Fresh Vegetables, Milk & Fruits',\r\n                    amount: 640.50,\r\n                    category: 'Groceries',\r\n                    paymentMethod: 'UPI',\r\n                    date: getOffsetDateISO(1)\r\n                },\r\n                {\r\n                    id: generateId(),\r\n                    description: 'Broadband & Mobile Postpaid Bill',\r\n                    amount: 1178.00,\r\n                    category: 'Bills & Utilities',\r\n                    paymentMethod: 'Net Banking',\r\n                    date: getOffsetDateISO(2)\r\n                },\r\n                {\r\n                    id: generateId(),\r\n                    description: 'Pharmacy & Vitamin Supplements',\r\n                    amount: 450.00,\r\n                    category: 'Health',\r\n                    paymentMethod: 'Card',\r\n                    date: getOffsetDateISO(3)\r\n                },\r\n                {\r\n                    id: generateId(),\r\n                    description: 'Weekend Movie Tickets & Snacks',\r\n                    amount: 780.00,\r\n                    category: 'Entertainment',\r\n                    paymentMethod: 'Card',\r\n                    date: getOffsetDateISO(4)\r\n                }\r\n            ];\r\n        }\r\n\r\n        \/\/ --- LocalStorage Management ---\r\n        function loadExpenses() {\r\n            try {\r\n                const raw = localStorage.getItem(STORAGE_KEY);\r\n                const isInitialized = localStorage.getItem(INITIALIZED_FLAG_KEY);\r\n\r\n                if (raw) {\r\n                    expenses = JSON.parse(raw);\r\n                } else if (!isInitialized) {\r\n                    expenses = getSampleExpenses();\r\n                    saveExpenses();\r\n                    localStorage.setItem(INITIALIZED_FLAG_KEY, 'true');\r\n                } else {\r\n                    expenses = [];\r\n                }\r\n            } catch (err) {\r\n                console.error('Error loading expenses from LocalStorage:', err);\r\n                expenses = [];\r\n            }\r\n        }\r\n\r\n        function saveExpenses() {\r\n            try {\r\n                localStorage.setItem(STORAGE_KEY, JSON.stringify(expenses));\r\n                localStorage.setItem(INITIALIZED_FLAG_KEY, 'true');\r\n            } catch (err) {\r\n                console.error('Error saving expenses to LocalStorage:', err);\r\n                showToast('Failed to save to local browser storage', 'error');\r\n            }\r\n        }\r\n\r\n        \/\/ --- Filtering Logic ---\r\n        function getFilteredExpenses() {\r\n            const searchQuery = document.getElementById('searchInput').value.trim().toLowerCase();\r\n            const selectedCategory = document.getElementById('filterCategory').value;\r\n            const selectedMonth = document.getElementById('filterMonth').value; \/\/ YYYY-MM\r\n            const selectedDate = document.getElementById('filterDate').value;   \/\/ YYYY-MM-DD\r\n\r\n            return expenses\r\n                .filter(item => {\r\n                    const matchesSearch = !searchQuery || item.description.toLowerCase().includes(searchQuery);\r\n                    const matchesCategory = selectedCategory === 'ALL' || item.category === selectedCategory;\r\n                    const matchesMonth = !selectedMonth || item.date.startsWith(selectedMonth);\r\n                    const matchesDate = !selectedDate || item.date === selectedDate;\r\n                    return matchesSearch && matchesCategory && matchesMonth && matchesDate;\r\n                })\r\n                .sort((a, b) => new Date(b.date) - new Date(a.date));\r\n        }\r\n\r\n        function hasActiveFilters() {\r\n            return (\r\n                document.getElementById('searchInput').value.trim() !== '' ||\r\n                document.getElementById('filterCategory').value !== 'ALL' ||\r\n                document.getElementById('filterMonth').value !== '' ||\r\n                document.getElementById('filterDate').value !== ''\r\n            );\r\n        }\r\n\r\n        \/\/ --- UI Rendering ---\r\n        function updateSummaryCards(filteredList) {\r\n            const todayStr = getTodayISO();\r\n\r\n            \/\/ 1. Total Expenditure (reflects currently filtered view if filters active, or overall total)\r\n            const totalAmount = filteredList.reduce((sum, item) => sum + Number(item.amount), 0);\r\n            document.getElementById('totalExpenseDisplay').textContent = formatINR(totalAmount);\r\n            document.getElementById('totalCountDisplay').textContent = \r\n                `Across ${filteredList.length} transaction${filteredList.length === 1 ? '' : 's'}${hasActiveFilters() ? ' (filtered)' : ''}`;\r\n\r\n            \/\/ 2. Today's Expenditure (always calculated from today's actual expenses)\r\n            const todayExpenses = expenses.filter(item => item.date === todayStr);\r\n            const todayAmount = todayExpenses.reduce((sum, item) => sum + Number(item.amount), 0);\r\n            document.getElementById('todayExpenseDisplay').textContent = formatINR(todayAmount);\r\n            document.getElementById('todayDateDisplay').textContent = `${formatDisplayDate(todayStr)} (${todayExpenses.length} items)`;\r\n\r\n            \/\/ 3. Top Spending Category (based on filteredList)\r\n            const categoryTotals = {};\r\n            filteredList.forEach(item => {\r\n                categoryTotals[item.category] = (categoryTotals[item.category] || 0) + Number(item.amount);\r\n            });\r\n\r\n            let topCat = 'None yet';\r\n            let topAmount = 0;\r\n            Object.entries(categoryTotals).forEach(([cat, amt]) => {\r\n                if (amt > topAmount) {\r\n                    topAmount = amt;\r\n                    topCat = cat;\r\n                }\r\n            });\r\n\r\n            const percentage = totalAmount > 0 ? Math.round((topAmount \/ totalAmount) * 100) : 0;\r\n            document.getElementById('topCategoryDisplay').textContent = topCat;\r\n            document.getElementById('topCategoryAmountDisplay').textContent = \r\n                topAmount > 0 ? `${formatINR(topAmount)} (${percentage}% of total)` : '\u20b90.00 (0%)';\r\n        }\r\n\r\n        function updateCategoryChart(filteredList) {\r\n            const ctx = document.getElementById('categoryChart');\r\n            const emptyMsg = document.getElementById('emptyChartMessage');\r\n            const pillsContainer = document.getElementById('categorySummaryPills');\r\n            const scopeBadge = document.getElementById('chartScopeBadge');\r\n\r\n            scopeBadge.textContent = hasActiveFilters() ? 'Filtered View' : 'All Time';\r\n\r\n            const categoryTotals = {};\r\n            filteredList.forEach(item => {\r\n                categoryTotals[item.category] = (categoryTotals[item.category] || 0) + Number(item.amount);\r\n            });\r\n\r\n            const sortedCategories = Object.entries(categoryTotals).sort((a, b) => b[1] - a[1]);\r\n\r\n            if (sortedCategories.length === 0) {\r\n                ctx.classList.add('hidden');\r\n                emptyMsg.classList.remove('hidden');\r\n                pillsContainer.innerHTML = '';\r\n                if (categoryChartInstance) {\r\n                    categoryChartInstance.destroy();\r\n                    categoryChartInstance = null;\r\n                }\r\n                return;\r\n            }\r\n\r\n            ctx.classList.remove('hidden');\r\n            emptyMsg.classList.add('hidden');\r\n\r\n            const labels = sortedCategories.map(([cat]) => cat);\r\n            const dataValues = sortedCategories.map(([, amt]) => amt);\r\n            const backgroundColors = labels.map(cat => (CATEGORY_CONFIG[cat]?.color || '#64748b'));\r\n\r\n            \/\/ Render quick legend pills\r\n            pillsContainer.innerHTML = sortedCategories.slice(0, 4).map(([cat, amt]) => {\r\n                const color = CATEGORY_CONFIG[cat]?.color || '#64748b';\r\n                return `\r\n                    <span class=\"inline-flex items-center px-2 py-1 rounded-lg text-xs font-medium bg-slate-50 border border-slate-200 text-slate-700\">\r\n                        <span class=\"w-2 h-2 rounded-full mr-1.5\" style=\"background-color: ${color}\"><\/span>\r\n                        ${escapeHTML(cat)}: <strong class=\"ml-1\">${formatINR(amt)}<\/strong>\r\n                    <\/span>\r\n                `;\r\n            }).join('');\r\n\r\n            if (categoryChartInstance) {\r\n                categoryChartInstance.data.labels = labels;\r\n                categoryChartInstance.data.datasets[0].data = dataValues;\r\n                categoryChartInstance.data.datasets[0].backgroundColor = backgroundColors;\r\n                categoryChartInstance.update();\r\n            } else {\r\n                categoryChartInstance = new Chart(ctx, {\r\n                    type: 'doughnut',\r\n                    data: {\r\n                        labels: labels,\r\n                        datasets: [{\r\n                            data: dataValues,\r\n                            backgroundColor: backgroundColors,\r\n                            borderWidth: 2,\r\n                            borderColor: '#ffffff',\r\n                            hoverOffset: 6\r\n                        }]\r\n                    },\r\n                    options: {\r\n                        responsive: true,\r\n                        maintainAspectRatio: false,\r\n                        cutout: '64%',\r\n                        plugins: {\r\n                            legend: {\r\n                                position: 'right',\r\n                                labels: {\r\n                                    boxWidth: 12,\r\n                                    usePointStyle: true,\r\n                                    pointStyle: 'circle',\r\n                                    padding: 14,\r\n                                    font: {\r\n                                        family: \"'Inter', sans-serif\",\r\n                                        size: 11\r\n                                    }\r\n                                }\r\n                            },\r\n                            tooltip: {\r\n                                backgroundColor: '#0f172a',\r\n                                padding: 12,\r\n                                cornerRadius: 10,\r\n                                callbacks: {\r\n                                    label: function(context) {\r\n                                        const val = context.parsed || 0;\r\n                                        const total = context.dataset.data.reduce((a, b) => a + b, 0);\r\n                                        const pct = total > 0 ? ((val \/ total) * 100).toFixed(1) : 0;\r\n                                        return ` ${formatINR(val)} (${pct}%)`;\r\n                                    }\r\n                                }\r\n                            }\r\n                        }\r\n                    }\r\n                });\r\n            }\r\n        }\r\n\r\n        function renderExpenseTable(filteredList) {\r\n            const tbody = document.getElementById('expenseTableBody');\r\n            const emptyState = document.getElementById('emptyTableState');\r\n            const resetFiltersBtn = document.getElementById('resetFiltersBtn');\r\n            const summaryText = document.getElementById('filteredSummaryText');\r\n\r\n            if (hasActiveFilters()) {\r\n                resetFiltersBtn.classList.remove('hidden');\r\n                summaryText.textContent = `Showing ${filteredList.length} matching transaction${filteredList.length === 1 ? '' : 's'}`;\r\n            } else {\r\n                resetFiltersBtn.classList.add('hidden');\r\n                summaryText.textContent = `Showing all ${expenses.length} recorded transaction${expenses.length === 1 ? '' : 's'}`;\r\n            }\r\n\r\n            if (filteredList.length === 0) {\r\n                tbody.innerHTML = '';\r\n                emptyState.classList.remove('hidden');\r\n                return;\r\n            }\r\n\r\n            emptyState.classList.add('hidden');\r\n\r\n            tbody.innerHTML = filteredList.map(item => {\r\n                const catStyle = CATEGORY_CONFIG[item.category] || CATEGORY_CONFIG['Other'];\r\n                const payIcon = PAYMENT_ICONS[item.paymentMethod] || 'fa-wallet';\r\n\r\n                return `\r\n                    <tr class=\"hover:bg-slate-50\/90 transition-colors group\">\r\n                        <td class=\"py-3.5 px-6 whitespace-nowrap text-slate-600 font-medium\">\r\n                            ${formatDisplayDate(item.date)}\r\n                        <\/td>\r\n                        <td class=\"py-3.5 px-6 font-medium text-slate-900 max-w-xs truncate\" title=\"${escapeHTML(item.description)}\">\r\n                            ${escapeHTML(item.description)}\r\n                        <\/td>\r\n                        <td class=\"py-3.5 px-6 whitespace-nowrap\">\r\n                            <span class=\"inline-flex items-center px-2.5 py-1 rounded-full text-xs font-medium border ${catStyle.bg} ${catStyle.text} ${catStyle.border}\">\r\n                                <i class=\"fa-solid ${catStyle.icon} mr-1.5 text-[10px]\"><\/i>\r\n                                ${escapeHTML(item.category)}\r\n                            <\/span>\r\n                        <\/td>\r\n                        <td class=\"py-3.5 px-6 whitespace-nowrap text-slate-600 text-xs\">\r\n                            <span class=\"inline-flex items-center px-2.5 py-1 rounded-lg bg-slate-100 text-slate-700 font-medium\">\r\n                                <i class=\"fa-solid ${payIcon} mr-1.5 text-slate-400\"><\/i>\r\n                                ${escapeHTML(item.paymentMethod)}\r\n                            <\/span>\r\n                        <\/td>\r\n                        <td class=\"py-3.5 px-6 whitespace-nowrap text-right font-bold text-slate-900\">\r\n                            ${formatINR(item.amount)}\r\n                        <\/td>\r\n                        <td class=\"py-3.5 px-6 whitespace-nowrap text-center\">\r\n                            <div class=\"inline-flex items-center space-x-1\">\r\n                                <button onclick=\"startEditExpense('${item.id}')\" title=\"Edit Expense\"\r\n                                    class=\"p-2 rounded-lg text-slate-500 hover:text-indigo-600 hover:bg-indigo-50 transition-colors\">\r\n                                    <i class=\"fa-solid fa-pen-to-square\"><\/i>\r\n                                <\/button>\r\n                                <button onclick=\"confirmDeleteExpense('${item.id}')\" title=\"Delete Expense\"\r\n                                    class=\"p-2 rounded-lg text-slate-500 hover:text-rose-600 hover:bg-rose-50 transition-colors\">\r\n                                    <i class=\"fa-solid fa-trash-can\"><\/i>\r\n                                <\/button>\r\n                            <\/div>\r\n                        <\/td>\r\n                    <\/tr>\r\n                `;\r\n            }).join('');\r\n        }\r\n\r\n        function refreshDashboard() {\r\n            const filtered = getFilteredExpenses();\r\n            updateSummaryCards(filtered);\r\n            updateCategoryChart(filtered);\r\n            renderExpenseTable(filtered);\r\n        }\r\n\r\n        \/\/ --- CRUD Operations ---\r\n        function handleFormSubmit(e) {\r\n            e.preventDefault();\r\n\r\n            const editId = document.getElementById('editExpenseId').value;\r\n            const description = document.getElementById('description').value.trim();\r\n            const amount = parseFloat(document.getElementById('amount').value);\r\n            const date = document.getElementById('date').value;\r\n            const category = document.getElementById('category').value;\r\n            const paymentMethod = document.getElementById('paymentMethod').value;\r\n\r\n            if (!description || isNaN(amount) || amount <= 0 || !date) {\r\n                showToast('Please fill in all required fields accurately.', 'error');\r\n                return;\r\n            }\r\n\r\n            if (editId) {\r\n                \/\/ Update existing expense\r\n                const idx = expenses.findIndex(item => item.id === editId);\r\n                let updatedRecord = null;\r\n                if (idx !== -1) {\r\n                    updatedRecord = {\r\n                        ...expenses[idx],\r\n                        description,\r\n                        amount,\r\n                        date,\r\n                        category,\r\n                        paymentMethod\r\n                    };\r\n                    expenses[idx] = updatedRecord;\r\n                    showToast('Expense updated successfully!');\r\n                }\r\n                exitEditMode();\r\n                saveExpenses();\r\n                refreshDashboard();\r\n                if (updatedRecord) {\r\n                    syncMutationToGoogleSheet({ action: 'edit', expense: updatedRecord });\r\n                }\r\n                return;\r\n            } else {\r\n                \/\/ Add new expense\r\n                const newExpense = {\r\n                    id: generateId(),\r\n                    description,\r\n                    amount,\r\n                    date,\r\n                    category,\r\n                    paymentMethod\r\n                };\r\n                expenses.unshift(newExpense);\r\n                showToast('New expense added!');\r\n                document.getElementById('expenseForm').reset();\r\n                document.getElementById('date').value = getTodayISO();\r\n                saveExpenses();\r\n                refreshDashboard();\r\n                syncMutationToGoogleSheet({ action: 'add', expense: newExpense });\r\n                return;\r\n            }\r\n        }\r\n\r\n        window.startEditExpense = function(id) {\r\n            const target = expenses.find(item => item.id === id);\r\n            if (!target) return;\r\n\r\n            document.getElementById('editExpenseId').value = target.id;\r\n            document.getElementById('description').value = target.description;\r\n            document.getElementById('amount').value = target.amount;\r\n            document.getElementById('date').value = target.date;\r\n            document.getElementById('category').value = target.category;\r\n            document.getElementById('paymentMethod').value = target.paymentMethod;\r\n\r\n            \/\/ Update Form UI to Edit State\r\n            document.getElementById('formTitle').textContent = 'Edit Expense';\r\n            document.getElementById('submitBtnText').textContent = 'Update Expense';\r\n            document.getElementById('formIconBadge').innerHTML = '<i class=\"fa-solid fa-pen\"><\/i>';\r\n            document.getElementById('formIconBadge').className = 'w-8 h-8 rounded-lg bg-amber-100 text-amber-600 flex items-center justify-center text-sm';\r\n            document.getElementById('cancelEditBtn').classList.remove('hidden');\r\n\r\n            document.getElementById('expenseForm').scrollIntoView({ behavior: 'smooth', block: 'center' });\r\n            document.getElementById('description').focus();\r\n        };\r\n\r\n        function exitEditMode() {\r\n            document.getElementById('editExpenseId').value = '';\r\n            document.getElementById('expenseForm').reset();\r\n            document.getElementById('date').value = getTodayISO();\r\n\r\n            document.getElementById('formTitle').textContent = 'Add New Expense';\r\n            document.getElementById('submitBtnText').textContent = 'Add Expense';\r\n            document.getElementById('formIconBadge').innerHTML = '<i class=\"fa-solid fa-plus\"><\/i>';\r\n            document.getElementById('formIconBadge').className = 'w-8 h-8 rounded-lg bg-indigo-100 text-indigo-600 flex items-center justify-center text-sm';\r\n            document.getElementById('cancelEditBtn').classList.add('hidden');\r\n        }\r\n\r\n        \/\/ --- Custom Confirmation Modal Logic ---\r\n        function openConfirmModal(title, message, confirmBtnText, onConfirm) {\r\n            document.getElementById('modalTitle').textContent = title;\r\n            document.getElementById('modalMessage').textContent = message;\r\n            document.getElementById('modalConfirmBtn').textContent = confirmBtnText;\r\n            pendingConfirmCallback = onConfirm;\r\n\r\n            const modal = document.getElementById('confirmModal');\r\n            modal.classList.remove('hidden');\r\n            modal.classList.add('flex');\r\n        }\r\n\r\n        function closeConfirmModal() {\r\n            const modal = document.getElementById('confirmModal');\r\n            modal.classList.add('hidden');\r\n            modal.classList.remove('flex');\r\n            pendingConfirmCallback = null;\r\n        }\r\n\r\n        window.confirmDeleteExpense = function(id) {\r\n            const target = expenses.find(item => item.id === id);\r\n            if (!target) return;\r\n\r\n            openConfirmModal(\r\n                'Delete Expense',\r\n                `Are you sure you want to delete \"${target.description}\" (${formatINR(target.amount)})?`,\r\n                'Delete',\r\n                () => {\r\n                    expenses = expenses.filter(item => item.id !== id);\r\n                    if (document.getElementById('editExpenseId').value === id) {\r\n                        exitEditMode();\r\n                    }\r\n                    saveExpenses();\r\n                    refreshDashboard();\r\n                    showToast('Expense deleted.');\r\n                    syncMutationToGoogleSheet({ action: 'delete', expense: { id } });\r\n                }\r\n            );\r\n        };\r\n\r\n        function handleClearAll() {\r\n            if (expenses.length === 0) {\r\n                showToast('There are no expenses to clear.', 'error');\r\n                return;\r\n            }\r\n\r\n            openConfirmModal(\r\n                'Clear All Expenses',\r\n                `This will permanently delete all ${expenses.length} recorded transactions from your browser storage. This action cannot be undone.`,\r\n                'Clear Everything',\r\n                () => {\r\n                    expenses = [];\r\n                    exitEditMode();\r\n                    saveExpenses();\r\n                    refreshDashboard();\r\n                    showToast('All expenditure records cleared.');\r\n                    syncMutationToGoogleSheet({ action: 'syncAll', expenses: [] });\r\n                }\r\n            );\r\n        }\r\n\r\n        \/\/ --- CSV Export ---\r\n        function exportToCSV() {\r\n            const dataToExport = getFilteredExpenses();\r\n            if (dataToExport.length === 0) {\r\n                showToast('No expenses available to export.', 'error');\r\n                return;\r\n            }\r\n\r\n            const headers = ['Date', 'Description', 'Category', 'Payment Method', 'Amount (INR)'];\r\n            const csvRows = [headers.join(',')];\r\n\r\n            dataToExport.forEach(item => {\r\n                const row = [\r\n                    item.date,\r\n                    `\"${item.description.replace(\/\"\/g, '\"\"')}\"`,\r\n                    `\"${item.category}\"`,\r\n                    `\"${item.paymentMethod}\"`,\r\n                    Number(item.amount).toFixed(2)\r\n                ];\r\n                csvRows.push(row.join(','));\r\n            });\r\n\r\n            const csvString = csvRows.join('\\n');\r\n            const blob = new Blob([csvString], { type: 'text\/csv;charset=utf-8;' });\r\n            const url = URL.createObjectURL(blob);\r\n\r\n            const link = document.createElement('a');\r\n            link.setAttribute('href', url);\r\n            link.setAttribute('download', `SpendWise_Expenses_${getTodayISO()}.csv`);\r\n            document.body.appendChild(link);\r\n            link.click();\r\n            document.body.removeChild(link);\r\n            URL.revokeObjectURL(url);\r\n\r\n            showToast(`Exported ${dataToExport.length} records to CSV!`);\r\n        }\r\n\r\n        \/\/ --- Event Listeners & Initialization ---\r\n        document.addEventListener('DOMContentLoaded', () => {\r\n            \/\/ Default form date to today\r\n            document.getElementById('date').value = getTodayISO();\r\n\r\n            \/\/ Initialize Google Script URL & Sync Status\r\n            googleScriptUrl = getSavedScriptUrl();\r\n            const scriptUrlInput = document.getElementById('scriptUrlInput');\r\n            if (scriptUrlInput) scriptUrlInput.value = googleScriptUrl;\r\n            updateSyncStatusUI(googleScriptUrl ? 'synced' : 'local');\r\n\r\n            \/\/ Load persisted or sample data\r\n            loadExpenses();\r\n            refreshDashboard();\r\n\r\n            \/\/ Form Submit & Cancel\r\n            document.getElementById('expenseForm').addEventListener('submit', handleFormSubmit);\r\n            document.getElementById('cancelEditBtn').addEventListener('click', exitEditMode);\r\n            document.getElementById('resetFormBtn').addEventListener('click', () => {\r\n                setTimeout(() => {\r\n                    document.getElementById('date').value = getTodayISO();\r\n                }, 0);\r\n            });\r\n\r\n            \/\/ Filter & Search Listeners\r\n            document.getElementById('searchInput').addEventListener('input', refreshDashboard);\r\n            document.getElementById('filterCategory').addEventListener('change', refreshDashboard);\r\n            document.getElementById('filterMonth').addEventListener('change', () => {\r\n                \/\/ Clear exact date if month is picked for intuitive UX\r\n                if (document.getElementById('filterMonth').value) {\r\n                    document.getElementById('filterDate').value = '';\r\n                }\r\n                refreshDashboard();\r\n            });\r\n            document.getElementById('filterDate').addEventListener('change', () => {\r\n                \/\/ Clear month filter if exact date is picked\r\n                if (document.getElementById('filterDate').value) {\r\n                    document.getElementById('filterMonth').value = '';\r\n                }\r\n                refreshDashboard();\r\n            });\r\n\r\n            document.getElementById('resetFiltersBtn').addEventListener('click', () => {\r\n                document.getElementById('searchInput').value = '';\r\n                document.getElementById('filterCategory').value = 'ALL';\r\n                document.getElementById('filterMonth').value = '';\r\n                document.getElementById('filterDate').value = '';\r\n                refreshDashboard();\r\n            });\r\n\r\n            \/\/ Header & Footer Action Buttons\r\n            document.getElementById('exportCsvBtn').addEventListener('click', exportToCSV);\r\n            document.getElementById('clearAllBtn').addEventListener('click', handleClearAll);\r\n\r\n            \/\/ Google Sheets Sync Modal Controls\r\n            const syncModal = document.getElementById('syncModal');\r\n            document.getElementById('openSyncModalBtn').addEventListener('click', () => {\r\n                document.getElementById('scriptUrlInput').value = googleScriptUrl;\r\n                syncModal.classList.remove('hidden');\r\n                syncModal.classList.add('flex');\r\n            });\r\n            document.getElementById('closeSyncModalBtn').addEventListener('click', () => {\r\n                syncModal.classList.add('hidden');\r\n                syncModal.classList.remove('flex');\r\n            });\r\n            syncModal.addEventListener('click', (e) => {\r\n                if (e.target.id === 'syncModal') {\r\n                    syncModal.classList.add('hidden');\r\n                    syncModal.classList.remove('flex');\r\n                }\r\n            });\r\n\r\n            document.getElementById('saveScriptUrlBtn').addEventListener('click', () => {\r\n                const rawUrl = document.getElementById('scriptUrlInput').value.trim();\r\n                if (rawUrl && !rawUrl.startsWith('https:\/\/script.google.com\/')) {\r\n                    showToast('Please enter a valid Google Apps Script Web App URL (https:\/\/script.google.com\/...).', 'error');\r\n                    return;\r\n                }\r\n                googleScriptUrl = rawUrl;\r\n                localStorage.setItem(SCRIPT_URL_KEY, googleScriptUrl);\r\n                updateSyncStatusUI(googleScriptUrl ? 'synced' : 'local');\r\n                showToast(googleScriptUrl ? 'Google Sheet sync URL saved!' : 'Cloud sync disconnected (Local Only).');\r\n            });\r\n\r\n            document.getElementById('pushAllToSheetBtn').addEventListener('click', pushAllLocalEntriesToSheet);\r\n            document.getElementById('pullFromSheetBtn').addEventListener('click', pullBackupFromSheet);\r\n\r\n            document.getElementById('copyAppsScriptBtn').addEventListener('click', () => {\r\n                const codeText = document.getElementById('appsScriptCodeBlock').textContent;\r\n                const tempTextarea = document.createElement('textarea');\r\n                tempTextarea.value = codeText;\r\n                document.body.appendChild(tempTextarea);\r\n                tempTextarea.select();\r\n                try {\r\n                    document.execCommand('copy');\r\n                    showToast('Apps Script code copied to clipboard!');\r\n                } catch (err) {\r\n                    showToast('Failed to copy code. Please select and copy manually.', 'error');\r\n                }\r\n                document.body.removeChild(tempTextarea);\r\n            });\r\n\r\n            document.getElementById('restoreSampleBtn').addEventListener('click', () => {\r\n                openConfirmModal(\r\n                    'Load Sample Data',\r\n                    'Add sample Indian Rupee expenditure entries to your current list?',\r\n                    'Load Samples',\r\n                    () => {\r\n                        expenses = [...getSampleExpenses(), ...expenses];\r\n                        saveExpenses();\r\n                        refreshDashboard();\r\n                        showToast('Sample entries added!');\r\n                        syncMutationToGoogleSheet({ action: 'syncAll', expenses });\r\n                    }\r\n                );\r\n            });\r\n\r\n            \/\/ Modal Buttons\r\n            document.getElementById('modalCancelBtn').addEventListener('click', closeConfirmModal);\r\n            document.getElementById('modalConfirmBtn').addEventListener('click', () => {\r\n                if (typeof pendingConfirmCallback === 'function') {\r\n                    pendingConfirmCallback();\r\n                }\r\n                closeConfirmModal();\r\n            });\r\n            document.getElementById('confirmModal').addEventListener('click', (e) => {\r\n                if (e.target.id === 'confirmModal') closeConfirmModal();\r\n            });\r\n        });\r\n    <\/script>\r\n<\/body>\r\n<\/html>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>SpendWise Daily Expenditure &amp; Budget Tracker Cloud Synced Export CSV CSV Clear All Total Expenditure \u20b90.00 Across 0 transactions Today&#8217;s Expenditure \u20b90.00 Today Top Spending Category None yet \u20b90.00 (0%) Add New Expense Cancel Edit Description \/ Item * Amount (\u20b9) * \u20b9 Date * Category * Food &amp; DiningTransportGroceriesBills &amp; UtilitiesShoppingEntertainmentHealthOther Payment Method * [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"no-sidebar","site-content-layout":"page-builder","ast-site-content-layout":"full-width-container","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"disabled","ast-main-header-display":"disabled","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"disabled","ast-hfb-mobile-header-display":"disabled","site-post-title":"","ast-breadcrumbs-content":"disabled","ast-featured-img":"disabled","footer-sml-layout":"disabled","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"class_list":["post-19513","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ddugdcsaidabad.ac.in\/index.php\/wp-json\/wp\/v2\/pages\/19513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ddugdcsaidabad.ac.in\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ddugdcsaidabad.ac.in\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ddugdcsaidabad.ac.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ddugdcsaidabad.ac.in\/index.php\/wp-json\/wp\/v2\/comments?post=19513"}],"version-history":[{"count":8,"href":"https:\/\/ddugdcsaidabad.ac.in\/index.php\/wp-json\/wp\/v2\/pages\/19513\/revisions"}],"predecessor-version":[{"id":19521,"href":"https:\/\/ddugdcsaidabad.ac.in\/index.php\/wp-json\/wp\/v2\/pages\/19513\/revisions\/19521"}],"wp:attachment":[{"href":"https:\/\/ddugdcsaidabad.ac.in\/index.php\/wp-json\/wp\/v2\/media?parent=19513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}