File size: 30,237 Bytes
198a027
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Wealth Compounder - Smart Investment Tracker</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#4f46e5',
                        secondary: '#10b981',
                        danger: '#ef4444',
                        warning: '#f59e0b',
                        dark: '#1e293b',
                        light: '#f8fafc'
                    }
                }
            }
        }
    </script>
    <style>
        .gradient-bg {
            background: linear-gradient(135deg, #4f46e5 0%, #10b981 100%);
        }
        .chart-container {
            height: 300px;
            position: relative;
        }
        .progress-ring__circle {
            transition: stroke-dashoffset 0.5s;
            transform: rotate(-90deg);
            transform-origin: 50% 50%;
        }
        .flip-in {
            animation: flipIn 0.5s ease-out;
        }
        @keyframes flipIn {
            from { transform: rotateX(90deg); opacity: 0; }
            to { transform: rotateX(0); opacity: 1; }
        }
    </style>
</head>
<body class="bg-gray-50 font-sans">
    <div class="min-h-screen flex flex-col">
        <!-- Header -->
        <header class="gradient-bg text-white shadow-lg">
            <div class="container mx-auto px-4 py-6">
                <div class="flex justify-between items-center">
                    <div class="flex items-center space-x-2">
                        <i class="fas fa-chart-line text-2xl"></i>
                        <h1 class="text-2xl font-bold">Wealth Compounder</h1>
                    </div>
                    <div class="flex items-center space-x-4">
                        <button id="notifications" class="relative p-2 rounded-full hover:bg-black/10">
                            <i class="fas fa-bell"></i>
                            <span class="absolute top-0 right-0 h-2 w-2 rounded-full bg-red-500"></span>
                        </button>
                        <div id="user-menu" class="relative">
                            <button class="flex items-center space-x-2 focus:outline-none">
                                <div class="h-8 w-8 rounded-full bg-white text-primary flex items-center justify-center font-bold">U</div>
                                <span class="hidden md:inline">User</span>
                                <i class="fas fa-chevron-down text-xs"></i>
                            </button>
                            <div id="dropdown-menu" class="hidden absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg py-1 z-10">
                                <a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Profile</a>
                                <a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Settings</a>
                                <a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Logout</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </header>

        <!-- Main Content -->
        <main class="flex-grow container mx-auto px-4 py-8">
            <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
                <!-- Left Column - User Profile and Stats -->
                <div class="space-y-6">
                    <!-- User Profile Card -->
                    <div class="bg-white rounded-xl shadow-md overflow-hidden p-6">
                        <div class="flex items-center space-x-4">
                            <div class="h-16 w-16 rounded-full gradient-bg flex items-center justify-center text-white text-2xl font-bold">U</div>
                            <div>
                                <h2 class="text-xl font-bold text-gray-800">User Profile</h2>
                                <p class="text-gray-600">Premium Member</p>
                            </div>
                        </div>
                        <div class="mt-6 grid grid-cols-2 gap-4">
                            <div class="bg-gray-50 p-3 rounded-lg">
                                <p class="text-sm text-gray-500">Total Value</p>
                                <p class="text-lg font-bold">₹1,25,000</p>
                            </div>
                            <div class="bg-gray-50 p-3 rounded-lg">
                                <p class="text-sm text-gray-500">Today's Gain</p>
                                <p class="text-lg font-bold text-secondary">+₹2,450</p>
                            </div>
                        </div>
                    </div>

                    <!-- Daily Target Progress -->
                    <div class="bg-white rounded-xl shadow-md overflow-hidden p-6">
                        <div class="flex justify-between items-center mb-4">
                            <h3 class="font-bold text-gray-800">Daily Target</h3>
                            <span class="text-sm bg-primary/10 text-primary px-2 py-1 rounded">80%</span>
                        </div>
                        <div class="relative pt-1">
                            <div class="flex items-center justify-between">
                                <div>
                                    <span class="text-xs font-semibold inline-block py-1 px-2 uppercase rounded-full text-primary bg-primary/10">
                                        Target: ₹5,000
                                    </span>
                                </div>
                                <div class="text-right">
                                    <span class="text-xs font-semibold inline-block text-secondary">
                                        Achieved: ₹4,000
                                    </span>
                                </div>
                            </div>
                            <div class="overflow-hidden h-2 mb-4 text-xs flex rounded bg-gray-200 mt-2">
                                <div style="width:80%" class="shadow-none flex flex-col text-center whitespace-nowrap text-white justify-center bg-gradient-to-r from-primary to-secondary"></div>
                            </div>
                        </div>
                        <div class="mt-4">
                            <label class="block text-sm font-medium text-gray-700 mb-1">Set New Daily Target</label>
                            <div class="flex">
                                <input type="number" class="flex-grow rounded-l-md border-gray-300 shadow-sm focus:border-primary focus:ring-primary" placeholder="Enter amount">
                                <button class="bg-primary text-white px-4 rounded-r-md hover:bg-primary/90">Set</button>
                            </div>
                        </div>
                    </div>

                    <!-- Stop Loss Settings -->
                    <div class="bg-white rounded-xl shadow-md overflow-hidden p-6">
                        <h3 class="font-bold text-gray-800 mb-4">Stop Loss Settings</h3>
                        <div class="space-y-4">
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">Max Daily Loss</label>
                                <div class="flex">
                                    <input type="number" class="flex-grow rounded-l-md border-gray-300 shadow-sm focus:border-primary focus:ring-primary" value="2000">
                                    <span class="inline-flex items-center px-3 rounded-r-md border border-l-0 border-gray-300 bg-gray-50 text-gray-500"></span>
                                </div>
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">Max Portfolio Loss</label>
                                <div class="flex">
                                    <input type="number" class="flex-grow rounded-l-md border-gray-300 shadow-sm focus:border-primary focus:ring-primary" value="10000">
                                    <span class="inline-flex items-center px-3 rounded-r-md border border-l-0 border-gray-300 bg-gray-50 text-gray-500"></span>
                                </div>
                            </div>
                            <div class="flex items-center">
                                <input type="checkbox" id="auto-stop" class="h-4 w-4 text-primary focus:ring-primary border-gray-300 rounded">
                                <label for="auto-stop" class="ml-2 block text-sm text-gray-700">Enable Auto Stop Loss</label>
                            </div>
                            <button class="w-full bg-primary text-white py-2 rounded-md hover:bg-primary/90 mt-2">Save Settings</button>
                        </div>
                    </div>
                </div>

                <!-- Middle Column - Compounding Calculator and Chart -->
                <div class="space-y-6">
                    <!-- Compounding Calculator -->
                    <div class="bg-white rounded-xl shadow-md overflow-hidden p-6">
                        <h3 class="font-bold text-gray-800 mb-4">Compounding Calculator</h3>
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">Initial Capital (₹)</label>
                                <input type="number" id="initial-capital" class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary focus:ring-primary" value="100000">
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">Monthly Addition (₹)</label>
                                <input type="number" id="monthly-add" class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary focus:ring-primary" value="5000">
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">Expected Return (%)</label>
                                <input type="number" id="expected-return" class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary focus:ring-primary" value="12">
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">Time Period (Years)</label>
                                <input type="number" id="time-period" class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary focus:ring-primary" value="10">
                            </div>
                        </div>
                        <button id="calculate-btn" class="w-full bg-primary text-white py-2 rounded-md hover:bg-primary/90 mt-4">Calculate Compounding</button>
                        
                        <div id="result-container" class="mt-6 hidden flip-in">
                            <div class="bg-gray-50 p-4 rounded-lg">
                                <h4 class="font-bold text-gray-800 mb-2">Projected Results</h4>
                                <div class="grid grid-cols-2 gap-4">
                                    <div>
                                        <p class="text-sm text-gray-500">Final Amount</p>
                                        <p id="final-amount" class="text-lg font-bold text-secondary">₹3,23,838</p>
                                    </div>
                                    <div>
                                        <p class="text-sm text-gray-500">Total Invested</p>
                                        <p id="total-invested" class="text-lg font-bold">₹7,00,000</p>
                                    </div>
                                    <div>
                                        <p class="text-sm text-gray-500">Interest Earned</p>
                                        <p id="interest-earned" class="text-lg font-bold text-secondary">₹2,53,838</p>
                                    </div>
                                    <div>
                                        <p class="text-sm text-gray-500">CAGR</p>
                                        <p id="cagr" class="text-lg font-bold">12%</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Compounding Chart -->
                    <div class="bg-white rounded-xl shadow-md overflow-hidden p-6">
                        <h3 class="font-bold text-gray-800 mb-4">Compounding Growth</h3>
                        <div class="chart-container">
                            <canvas id="compounding-chart"></canvas>
                        </div>
                        <div class="mt-4 flex justify-center space-x-4">
                            <button class="px-3 py-1 bg-gray-100 rounded-md text-sm">1M</button>
                            <button class="px-3 py-1 bg-primary text-white rounded-md text-sm">1Y</button>
                            <button class="px-3 py-1 bg-gray-100 rounded-md text-sm">5Y</button>
                            <button class="px-3 py-1 bg-gray-100 rounded-md text-sm">10Y</button>
                        </div>
                    </div>
                </div>

                <!-- Right Column - Performance and Recent Activity -->
                <div class="space-y-6">
                    <!-- Performance Summary -->
                    <div class="bg-white rounded-xl shadow-md overflow-hidden p-6">
                        <h3 class="font-bold text-gray-800 mb-4">Performance Summary</h3>
                        <div class="grid grid-cols-3 gap-4 text-center">
                            <div>
                                <div class="h-24 w-24 mx-auto relative">
                                    <svg class="w-full h-full" viewBox="0 0 100 100">
                                        <circle class="text-gray-200" stroke-width="8" stroke="currentColor" fill="transparent" r="40" cx="50" cy="50" />
                                        <circle class="text-primary progress-ring__circle" stroke-width="8" stroke-linecap="round" stroke="currentColor" fill="transparent" r="40" cx="50" cy="50" stroke-dasharray="251.2" stroke-dashoffset="75.36" />
                                        <text x="50" y="50" font-family="Arial" font-size="16" text-anchor="middle" dy=".3em" fill="#4f46e5" font-weight="bold">70%</text>
                                    </svg>
                                </div>
                                <p class="text-sm mt-2">Target Achievement</p>
                            </div>
                            <div>
                                <div class="h-24 w-24 mx-auto relative">
                                    <svg class="w-full h-full" viewBox="0 0 100 100">
                                        <circle class="text-gray-200" stroke-width="8" stroke="currentColor" fill="transparent" r="40" cx="50" cy="50" />
                                        <circle class="text-secondary progress-ring__circle" stroke-width="8" stroke-linecap="round" stroke="currentColor" fill="transparent" r="40" cx="50" cy="50" stroke-dasharray="251.2" stroke-dashoffset="125.6" />
                                        <text x="50" y="50" font-family="Arial" font-size="16" text-anchor="middle" dy=".3em" fill="#10b981" font-weight="bold">50%</text>
                                    </svg>
                                </div>
                                <p class="text-sm mt-2">Risk Management</p>
                            </div>
                            <div>
                                <div class="h-24 w-24 mx-auto relative">
                                    <svg class="w-full h-full" viewBox="0 0 100 100">
                                        <circle class="text-gray-200" stroke-width="8" stroke="currentColor" fill="transparent" r="40" cx="50" cy="50" />
                                        <circle class="text-warning progress-ring__circle" stroke-width="8" stroke-linecap="round" stroke="currentColor" fill="transparent" r="40" cx="50" cy="50" stroke-dasharray="251.2" stroke-dashoffset="50.24" />
                                        <text x="50" y="50" font-family="Arial" font-size="16" text-anchor="middle" dy=".3em" fill="#f59e0b" font-weight="bold">80%</text>
                                    </svg>
                                </div>
                                <p class="text-sm mt-2">Consistency</p>
                            </div>
                        </div>
                        <div class="mt-6">
                            <div class="flex justify-between mb-1">
                                <span class="text-sm font-medium text-gray-700">Compounding Efficiency</span>
                                <span class="text-sm font-medium text-gray-700">65%</span>
                            </div>
                            <div class="w-full bg-gray-200 rounded-full h-2.5">
                                <div class="bg-primary h-2.5 rounded-full" style="width: 65%"></div>
                            </div>
                        </div>
                    </div>

                    <!-- Recent Activity -->
                    <div class="bg-white rounded-xl shadow-md overflow-hidden p-6">
                        <div class="flex justify-between items-center mb-4">
                            <h3 class="font-bold text-gray-800">Recent Activity</h3>
                            <button class="text-sm text-primary hover:text-primary/80">View All</button>
                        </div>
                        <div class="space-y-4">
                            <div class="flex items-start">
                                <div class="flex-shrink-0 h-10 w-10 rounded-full bg-green-100 flex items-center justify-center text-green-600">
                                    <i class="fas fa-rupee-sign"></i>
                                </div>
                                <div class="ml-3">
                                    <p class="text-sm font-medium text-gray-900">Daily Target Achieved</p>
                                    <p class="text-sm text-gray-500">Today at 3:42 PM</p>
                                </div>
                                <div class="ml-auto text-sm text-secondary font-medium">
                                    +₹5,000
                                </div>
                            </div>
                            <div class="flex items-start">
                                <div class="flex-shrink-0 h-10 w-10 rounded-full bg-red-100 flex items-center justify-center text-red-600">
                                    <i class="fas fa-stop-circle"></i>
                                </div>
                                <div class="ml-3">
                                    <p class="text-sm font-medium text-gray-900">Stop Loss Triggered</p>
                                    <p class="text-sm text-gray-500">Yesterday at 2:15 PM</p>
                                </div>
                                <div class="ml-auto text-sm text-danger font-medium">
                                    -₹2,000
                                </div>
                            </div>
                            <div class="flex items-start">
                                <div class="flex-shrink-0 h-10 w-10 rounded-full bg-blue-100 flex items-center justify-center text-blue-600">
                                    <i class="fas fa-chart-line"></i>
                                </div>
                                <div class="ml-3">
                                    <p class="text-sm font-medium text-gray-900">Portfolio Rebalanced</p>
                                    <p class="text-sm text-gray-500">2 days ago</p>
                                </div>
                            </div>
                            <div class="flex items-start">
                                <div class="flex-shrink-0 h-10 w-10 rounded-full bg-purple-100 flex items-center justify-center text-purple-600">
                                    <i class="fas fa-bullseye"></i>
                                </div>
                                <div class="ml-3">
                                    <p class="text-sm font-medium text-gray-900">New Target Set</p>
                                    <p class="text-sm text-gray-500">3 days ago</p>
                                </div>
                                <div class="ml-auto text-sm font-medium">
                                    ₹5,000/day
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Quick Actions -->
                    <div class="bg-white rounded-xl shadow-md overflow-hidden p-6">
                        <h3 class="font-bold text-gray-800 mb-4">Quick Actions</h3>
                        <div class="grid grid-cols-2 gap-3">
                            <button class="flex items-center justify-center space-x-2 bg-primary/10 text-primary p-3 rounded-md hover:bg-primary/20">
                                <i class="fas fa-plus"></i>
                                <span>Add Funds</span>
                            </button>
                            <button class="flex items-center justify-center space-x-2 bg-secondary/10 text-secondary p-3 rounded-md hover:bg-secondary/20">
                                <i class="fas fa-chart-pie"></i>
                                <span>Analyze</span>
                            </button>
                            <button class="flex items-center justify-center space-x-2 bg-warning/10 text-warning p-3 rounded-md hover:bg-warning/20">
                                <i class="fas fa-history"></i>
                                <span>History</span>
                            </button>
                            <button class="flex items-center justify-center space-x-2 bg-danger/10 text-danger p-3 rounded-md hover:bg-danger/20">
                                <i class="fas fa-stopwatch"></i>
                                <span>Stop Loss</span>
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </main>

        <!-- Footer -->
        <footer class="bg-white border-t border-gray-200 py-6">
            <div class="container mx-auto px-4">
                <div class="flex flex-col md:flex-row justify-between items-center">
                    <div class="flex items-center space-x-2 mb-4 md:mb-0">
                        <i class="fas fa-chart-line text-primary text-xl"></i>
                        <span class="font-bold text-gray-800">Wealth Compounder</span>
                    </div>
                    <div class="flex space-x-6">
                        <a href="#" class="text-gray-600 hover:text-primary">Terms</a>
                        <a href="#" class="text-gray-600 hover:text-primary">Privacy</a>
                        <a href="#" class="text-gray-600 hover:text-primary">Help</a>
                        <a href="#" class="text-gray-600 hover:text-primary">Contact</a>
                    </div>
                </div>
                <div class="mt-4 text-center md:text-left text-sm text-gray-500">
                    © 2023 Wealth Compounder. All rights reserved.
                </div>
            </div>
        </footer>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <script>
        // User menu dropdown
        document.getElementById('user-menu').addEventListener('click', function() {
            document.getElementById('dropdown-menu').classList.toggle('hidden');
        });

        // Close dropdown when clicking outside
        document.addEventListener('click', function(event) {
            if (!event.target.closest('#user-menu')) {
                document.getElementById('dropdown-menu').classList.add('hidden');
            }
        });

        // Compounding calculator
        document.getElementById('calculate-btn').addEventListener('click', function() {
            // Get input values
            const initialCapital = parseFloat(document.getElementById('initial-capital').value);
            const monthlyAdd = parseFloat(document.getElementById('monthly-add').value);
            const expectedReturn = parseFloat(document.getElementById('expected-return').value) / 100;
            const timePeriod = parseFloat(document.getElementById('time-period').value);
            
            // Calculate results
            const months = timePeriod * 12;
            const monthlyRate = Math.pow(1 + expectedReturn, 1/12) - 1;
            
            let amount = initialCapital;
            let totalInvested = initialCapital;
            
            // Simulate month by month
            for (let i = 1; i <= months; i++) {
                amount = amount * (1 + monthlyRate) + monthlyAdd;
                totalInvested += monthlyAdd;
            }
            
            const interestEarned = amount - totalInvested;
            const cagr = (Math.pow(amount / initialCapital, 1/timePeriod) - 1) * 100;
            
            // Update results
            document.getElementById('final-amount').textContent = '₹' + amount.toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
            document.getElementById('total-invested').textContent = '₹' + totalInvested.toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
            document.getElementById('interest-earned').textContent = '₹' + interestEarned.toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
            document.getElementById('cagr').textContent = cagr.toFixed(1) + '%';
            
            // Show results
            document.getElementById('result-container').classList.remove('hidden');
            
            // Update chart
            updateChart(initialCapital, monthlyAdd, expectedReturn, timePeriod);
        });

        // Initialize chart
        const ctx = document.getElementById('compounding-chart').getContext('2d');
        let chart = new Chart(ctx, {
            type: 'line',
            data: {
                labels: ['Year 0', 'Year 1', 'Year 2', 'Year 3', 'Year 4', 'Year 5', 'Year 6', 'Year 7', 'Year 8', 'Year 9', 'Year 10'],
                datasets: [{
                    label: 'Investment Growth',
                    data: [100000, 112000, 125440, 140493, 157352, 176234, 197382, 221068, 247596, 277308, 310586],
                    backgroundColor: 'rgba(79, 70, 229, 0.1)',
                    borderColor: 'rgba(79, 70, 229, 1)',
                    borderWidth: 2,
                    tension: 0.1,
                    fill: true
                }]
            },
            options: {
                responsive: true,
                maintainAspectRatio: false,
                plugins: {
                    legend: {
                        display: false
                    },
                    tooltip: {
                        callbacks: {
                            label: function(context) {
                                return '₹' + context.parsed.y.toLocaleString();
                            }
                        }
                    }
                },
                scales: {
                    y: {
                        beginAtZero: true,
                        ticks: {
                            callback: function(value) {
                                return '₹' + value.toLocaleString();
                            }
                        }
                    }
                }
            }
        });

        // Update chart with new data
        function updateChart(initialCapital, monthlyAdd, expectedReturn, timePeriod) {
            const years = timePeriod;
            const dataPoints = [];
            
            // Calculate value for each year
            let amount = initialCapital;
            dataPoints.push(amount);
            
            for (let year = 1; year <= years; year++) {
                // Add monthly contributions and compound annually for simplicity
                amount = amount * (1 + expectedReturn) + (monthlyAdd * 12);
                dataPoints.push(amount);
            }
            
            // Update labels
            const labels = ['Year 0'];
            for (let i = 1; i <= years; i++) {
                labels.push(`Year ${i}`);
            }
            
            // Update chart data
            chart.data.labels = labels;
            chart.data.datasets[0].data = dataPoints;
            chart.update();
        }

        // Initialize with default values
        document.addEventListener('DOMContentLoaded', function() {
            document.getElementById('calculate-btn').click();
        });
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Ahmadraza76/compoundingtracker" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>