File size: 52,460 Bytes
3055fac
f58a991
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3055fac
f58a991
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3055fac
f58a991
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Expenses 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: '#007AFF',
                        secondary: '#34C759',
                        danger: '#FF3B30',
                        warning: '#FF9500',
                        dark: '#1C1C1E',
                        light: '#F2F2F7',
                        gray: {
                            100: '#F2F2F7',
                            200: '#E5E5EA',
                            300: '#D1D1D6',
                            400: '#C7C7CC',
                            500: '#AEAEB2',
                            600: '#8E8E93',
                            700: '#636366',
                            800: '#48484A',
                            900: '#3A3A3C'
                        }
                    },
                    animation: {
                        'fade-in': 'fadeIn 0.3s ease-out forwards',
                        'slide-up': 'slideUp 0.5s cubic-bezier(0.23, 1, 0.32, 1) forwards',
                        'slide-down': 'slideDown 0.5s cubic-bezier(0.23, 1, 0.32, 1) forwards',
                        'scale-in': 'scaleIn 0.3s cubic-bezier(0.23, 1, 0.32, 1) forwards',
                        'scale-out': 'scaleOut 0.3s cubic-bezier(0.23, 1, 0.32, 1) forwards',
                        'pulse-slow': 'pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite'
                    },
                    keyframes: {
                        fadeIn: {
                            '0%': { opacity: '0' },
                            '100%': { opacity: '1' }
                        },
                        slideUp: {
                            '0%': { transform: 'translateY(50px)', opacity: '0' },
                            '100%': { transform: 'translateY(0)', opacity: '1' }
                        },
                        slideDown: {
                            '0%': { transform: 'translateY(-50px)', opacity: '0' },
                            '100%': { transform: 'translateY(0)', opacity: '1' }
                        },
                        scaleIn: {
                            '0%': { transform: 'scale(0.95)', opacity: '0' },
                            '100%': { transform: 'scale(1)', opacity: '1' }
                        },
                        scaleOut: {
                            '0%': { transform: 'scale(1)', opacity: '1' },
                            '100%': { transform: 'scale(0.95)', opacity: '0' }
                        }
                    }
                }
            }
        }
    </script>
    <style>
        @import url('https://fonts.googleapis.com/css2?family=SF+Pro+Display:wght@300;400;500;600;700&display=swap');
        
        body {
            font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
            background-color: #F2F2F7;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
        }
        
        /* iOS-like scrollbar */
        ::-webkit-scrollbar {
            width: 6px;
            height: 6px;
        }
        
        ::-webkit-scrollbar-thumb {
            background-color: rgba(0, 0, 0, 0.2);
            border-radius: 3px;
        }
        
        ::-webkit-scrollbar-track {
            background-color: transparent;
        }
        
        .card {
            border-radius: 14px;
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
        }
        
        .transaction-item {
            transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1);
        }
        
        .transaction-item:hover {
            transform: translateX(8px);
        }
        
        .progress-bar {
            transition: width 0.8s cubic-bezier(0.23, 1, 0.32, 1);
        }
        
        .floating-btn {
            box-shadow: 0 6px 20px rgba(0, 122, 255, 0.3);
            transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
        }
        
        .floating-btn:hover {
            transform: scale(1.1);
            box-shadow: 0 8px 25px rgba(0, 122, 255, 0.4);
        }
        
        .modal-overlay {
            background: rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
        }
        
        .ios-select {
            appearance: none;
            -webkit-appearance: none;
            background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%238E8E93'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
            background-repeat: no-repeat;
            background-position: right 10px center;
            background-size: 12px;
        }
        
        /* iOS-like switch */
        .ios-switch {
            position: relative;
            display: inline-block;
            width: 44px;
            height: 28px;
        }
        
        .ios-switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }
        
        .ios-slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: #E5E5EA;
            transition: .4s;
            border-radius: 34px;
        }
        
        .ios-slider:before {
            position: absolute;
            content: "";
            height: 24px;
            width: 24px;
            left: 2px;
            bottom: 2px;
            background-color: white;
            transition: .4s;
            border-radius: 50%;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
        }
        
        input:checked + .ios-slider {
            background-color: #34C759;
        }
        
        input:checked + .ios-slider:before {
            transform: translateX(16px);
        }
        
        /* iOS-like segmented control */
        .segmented-control {
            display: flex;
            border-radius: 8px;
            background-color: #E5E5EA;
            padding: 3px;
        }
        
        .segmented-control input[type="radio"] {
            display: none;
        }
        
        .segmented-control label {
            flex: 1;
            text-align: center;
            padding: 8px 12px;
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .segmented-control input[type="radio"]:checked + label {
            background-color: white;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        }
    </style>
</head>
<body class="min-h-screen">
    <div class="container mx-auto px-4 py-6 max-w-6xl">
        <!-- Header -->
        <header class="flex justify-between items-center mb-6 animate-fade-in">
            <div>
                <h1 class="text-2xl font-semibold text-dark">Expenses Tracker</h1>
                <p class="text-gray-600 text-sm">Track your daily spending</p>
            </div>
            <div class="flex items-center space-x-3">
                <button id="settings-btn" class="p-2 rounded-full hover:bg-gray-200 transition">
                    <i class="fas fa-cog text-gray-600"></i>
                </button>
                <div class="h-9 w-9 rounded-full bg-primary flex items-center justify-center text-white font-medium">
                    <i class="fas fa-user"></i>
                </div>
            </div>
        </header>

        <!-- Summary Cards -->
        <div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
            <!-- Balance Card -->
            <div class="bg-white card p-5 animate-slide-up">
                <div class="flex justify-between items-start">
                    <div>
                        <p class="text-gray-600 text-sm">Total Balance</p>
                        <h2 id="total-balance" class="text-2xl font-bold mt-1">$0.00</h2>
                    </div>
                    <div class="p-2 rounded-lg bg-blue-50 text-primary">
                        <i class="fas fa-wallet text-lg"></i>
                    </div>
                </div>
                <div class="mt-4 flex justify-between text-xs">
                    <div>
                        <p class="text-gray-600">Income</p>
                        <p id="total-income" class="font-medium text-secondary">$0.00</p>
                    </div>
                    <div>
                        <p class="text-gray-600">Expenses</p>
                        <p id="total-expenses" class="font-medium text-danger">$0.00</p>
                    </div>
                </div>
            </div>

            <!-- Budget Card -->
            <div class="bg-white card p-5 animate-slide-up" style="animation-delay: 0.1s">
                <div class="flex justify-between items-start">
                    <div>
                        <p class="text-gray-600 text-sm">Monthly Budget</p>
                        <h2 id="monthly-budget" class="text-2xl font-bold mt-1">$0.00</h2>
                    </div>
                    <div class="p-2 rounded-lg bg-green-50 text-secondary">
                        <i class="fas fa-chart-pie text-lg"></i>
                    </div>
                </div>
                <div class="mt-4">
                    <p class="text-gray-600 text-xs mb-1">Spent: <span id="budget-spent">$0.00</span> (<span id="budget-percentage">0</span>%)</p>
                    <div class="w-full bg-gray-200 rounded-full h-2">
                        <div id="budget-progress" class="bg-secondary h-2 rounded-full progress-bar" style="width: 0%"></div>
                    </div>
                </div>
            </div>

            <!-- Savings Goal -->
            <div class="bg-white card p-5 animate-slide-up" style="animation-delay: 0.2s">
                <div class="flex justify-between items-start">
                    <div>
                        <p class="text-gray-600 text-sm">Savings Goal</p>
                        <h2 id="savings-goal" class="text-2xl font-bold mt-1">$0.00</h2>
                    </div>
                    <div class="p-2 rounded-lg bg-green-50 text-secondary">
                        <i class="fas fa-piggy-bank text-lg"></i>
                    </div>
                </div>
                <div class="mt-4">
                    <p class="text-gray-600 text-xs mb-1">Saved: <span id="savings-amount">$0.00</span> (<span id="savings-percentage">0</span>%)</p>
                    <div class="w-full bg-gray-200 rounded-full h-2">
                        <div id="savings-progress" class="bg-secondary h-2 rounded-full progress-bar" style="width: 0%"></div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Main Content -->
        <div class="grid grid-cols-1 lg:grid-cols-3 gap-4">
            <!-- Transactions Section -->
            <div class="lg:col-span-2">
                <div class="bg-white card p-5 mb-4 animate-fade-in">
                    <div class="flex justify-between items-center mb-4">
                        <h2 class="text-lg font-semibold">Recent Transactions</h2>
                        <div class="flex space-x-2">
                            <button id="filter-btn" class="text-sm text-primary bg-blue-50 px-3 py-1 rounded-lg">
                                <i class="fas fa-filter mr-1"></i> Filter
                            </button>
                            <button id="add-manual-btn" class="text-sm text-white bg-primary px-3 py-1 rounded-lg">
                                <i class="fas fa-plus mr-1"></i> Add
                            </button>
                        </div>
                    </div>
                    
                    <div id="transactions-container" class="space-y-3 max-h-96 overflow-y-auto pr-2">
                        <!-- Transactions will be loaded here -->
                    </div>
                    
                    <button id="view-all-btn" class="w-full mt-4 py-2 text-primary font-medium rounded-lg border border-gray-200 hover:bg-gray-50 transition text-sm">
                        View All Transactions
                    </button>
                </div>
                
                <!-- Spending Chart -->
                <div class="bg-white card p-5 animate-fade-in">
                    <div class="flex justify-between items-center mb-4">
                        <h2 class="text-lg font-semibold">Spending Analytics</h2>
                        <select id="chart-period" class="bg-gray-100 border-0 text-gray-700 rounded-lg px-3 py-1 text-sm ios-select">
                            <option value="week">This Week</option>
                            <option value="month" selected>This Month</option>
                            <option value="year">This Year</option>
                        </select>
                    </div>
                    
                    <div class="chart-container h-48 mt-4">
                        <canvas id="spending-chart"></canvas>
                    </div>
                </div>
            </div>
            
            <!-- Categories Breakdown -->
            <div class="lg:col-span-1">
                <div class="bg-white card p-5 mb-4 animate-fade-in">
                    <h2 class="text-lg font-semibold mb-4">Categories</h2>
                    
                    <div id="categories-container" class="space-y-3 max-h-64 overflow-y-auto pr-2">
                        <!-- Categories will be loaded here -->
                    </div>
                    
                    <button id="manage-categories-btn" class="w-full mt-4 py-2 text-gray-600 font-medium rounded-lg border border-gray-200 hover:bg-gray-50 transition text-sm">
                        Manage Categories
                    </button>
                </div>
                
                <!-- Budget Settings -->
                <div class="bg-white card p-5 animate-fade-in">
                    <h2 class="text-lg font-semibold mb-4">Budget Settings</h2>
                    
                    <div class="space-y-4">
                        <div>
                            <div class="flex justify-between items-center mb-1">
                                <span class="text-sm font-medium">Monthly Budget</span>
                                <input type="number" id="set-budget-input" class="w-24 px-2 py-1 rounded-lg border border-gray-200 text-right" placeholder="0.00">
                            </div>
                            <div class="text-xs text-gray-500">Set your monthly spending limit</div>
                        </div>
                        
                        <div>
                            <div class="flex justify-between items-center mb-1">
                                <span class="text-sm font-medium">Savings Goal</span>
                                <input type="number" id="set-savings-input" class="w-24 px-2 py-1 rounded-lg border border-gray-200 text-right" placeholder="0.00">
                            </div>
                            <div class="text-xs text-gray-500">Set your monthly savings target</div>
                        </div>
                        
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium">Notifications</span>
                            <label class="ios-switch">
                                <input type="checkbox" id="notifications-toggle" checked>
                                <span class="ios-slider"></span>
                            </label>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- Add Transaction Button -->
    <button id="add-transaction-btn" class="fixed bottom-6 right-6 h-14 w-14 rounded-full bg-primary text-white text-xl flex items-center justify-center floating-btn">
        <i class="fas fa-plus"></i>
    </button>
    
    <!-- Add Transaction Modal -->
    <div id="transaction-modal" class="fixed inset-0 z-50 flex items-center justify-center hidden">
        <div class="modal-overlay absolute inset-0" id="modal-overlay"></div>
        <div class="bg-white rounded-xl w-full max-w-md mx-4 z-10 animate-scale-in" style="max-height: 90vh; overflow-y: auto;">
            <div class="p-6">
                <div class="flex justify-between items-center mb-4 sticky top-0 bg-white pt-2 pb-4">
                    <h3 class="text-xl font-semibold">Add Transaction</h3>
                    <button id="close-modal" class="text-gray-500 hover:text-gray-700 p-1">
                        <i class="fas fa-times text-lg"></i>
                    </button>
                </div>
                
                <form id="transaction-form">
                    <div class="space-y-5">
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">Transaction Type</label>
                            <div class="segmented-control">
                                <input type="radio" id="type-expense" name="transaction-type" value="expense" checked>
                                <label for="type-expense" class="text-sm">Expense</label>
                                <input type="radio" id="type-income" name="transaction-type" value="income">
                                <label for="type-income" class="text-sm">Income</label>
                            </div>
                        </div>
                        
                        <div>
                            <label for="amount" class="block text-sm font-medium text-gray-700 mb-1">Amount</label>
                            <div class="relative">
                                <span class="absolute inset-y-0 left-0 flex items-center pl-3 text-gray-500">$</span>
                                <input type="number" id="amount" class="w-full pl-8 pr-4 py-3 rounded-lg border border-gray-200 focus:ring-2 focus:ring-primary focus:border-transparent" placeholder="0.00" step="0.01" min="0">
                            </div>
                        </div>
                        
                        <div>
                            <label for="category" class="block text-sm font-medium text-gray-700 mb-1">Category</label>
                            <select id="category" class="w-full px-4 py-3 rounded-lg border border-gray-200 focus:ring-2 focus:ring-primary focus:border-transparent ios-select">
                                <option value="">Select a category</option>
                                <!-- Categories will be loaded here -->
                            </select>
                        </div>
                        
                        <div>
                            <label for="date" class="block text-sm font-medium text-gray-700 mb-1">Date</label>
                            <input type="date" id="date" class="w-full px-4 py-3 rounded-lg border border-gray-200 focus:ring-2 focus:ring-primary focus:border-transparent">
                        </div>
                        
                        <div>
                            <label for="description" class="block text-sm font-medium text-gray-700 mb-1">Description (Optional)</label>
                            <input type="text" id="description" class="w-full px-4 py-3 rounded-lg border border-gray-200 focus:ring-2 focus:ring-primary focus:border-transparent" placeholder="e.g. Grocery shopping">
                        </div>
                    </div>
                    
                    <div class="mt-6 flex space-x-3 sticky bottom-0 bg-white pt-4 pb-2">
                        <button type="button" id="cancel-transaction" class="flex-1 py-3 px-4 rounded-lg border border-gray-200 text-gray-700 font-medium hover:bg-gray-50 transition text-sm">
                            Cancel
                        </button>
                        <button type="submit" class="flex-1 py-3 px-4 rounded-lg bg-primary text-white font-medium hover:bg-blue-600 transition text-sm">
                            Add Transaction
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    
    <!-- Settings Modal -->
    <div id="settings-modal" class="fixed inset-0 z-50 flex items-center justify-center hidden">
        <div class="modal-overlay absolute inset-0" id="settings-overlay"></div>
        <div class="bg-white rounded-xl w-full max-w-md mx-4 z-10 animate-scale-in" style="max-height: 90vh; overflow-y: auto;">
            <div class="p-6">
                <div class="flex justify-between items-center mb-6 sticky top-0 bg-white pt-2 pb-4">
                    <h3 class="text-xl font-semibold">Settings</h3>
                    <button id="close-settings" class="text-gray-500 hover:text-gray-700 p-1">
                        <i class="fas fa-times text-lg"></i>
                    </button>
                </div>
                
                <div class="space-y-6">
                    <div>
                        <h4 class="font-medium text-gray-800 mb-3">General</h4>
                        <div class="space-y-4">
                            <div class="flex justify-between items-center">
                                <span class="text-sm">Currency</span>
                                <select id="currency-select" class="bg-gray-100 border-0 text-gray-700 rounded-lg px-3 py-1 text-sm ios-select">
                                    <option value="USD">USD ($)</option>
                                    <option value="EUR">EUR (€)</option>
                                    <option value="GBP">GBP (£)</option>
                                    <option value="JPY">JPY (¥)</option>
                                </select>
                            </div>
                            <div class="flex justify-between items-center">
                                <span class="text-sm">Dark Mode</span>
                                <label class="ios-switch">
                                    <input type="checkbox" id="dark-mode-toggle">
                                    <span class="ios-slider"></span>
                                </label>
                            </div>
                        </div>
                    </div>
                    
                    <div>
                        <h4 class="font-medium text-gray-800 mb-3">Data</h4>
                        <div class="space-y-3">
                            <button id="export-data" class="w-full text-left py-2 px-3 rounded-lg bg-gray-100 hover:bg-gray-200 transition text-sm flex items-center">
                                <i class="fas fa-file-export text-gray-600 mr-2"></i>
                                Export Data
                            </button>
                            <button id="import-data" class="w-full text-left py-2 px-3 rounded-lg bg-gray-100 hover:bg-gray-200 transition text-sm flex items-center">
                                <i class="fas fa-file-import text-gray-600 mr-2"></i>
                                Import Data
                            </button>
                            <button id="reset-data" class="w-full text-left py-2 px-3 rounded-lg bg-red-50 hover:bg-red-100 transition text-sm flex items-center text-danger">
                                <i class="fas fa-trash-alt mr-2"></i>
                                Reset All Data
                            </button>
                        </div>
                    </div>
                    
                    <div>
                        <h4 class="font-medium text-gray-800 mb-3">About</h4>
                        <div class="text-sm text-gray-600 space-y-2">
                            <p>Expenses Tracker v1.0.0</p>
                            <p>© 2023 Expenses Tracker. All rights reserved.</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- Chart.js for analytics -->
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    
    <script>
        // DOM Elements
        const addTransactionBtn = document.getElementById('add-transaction-btn');
        const addManualBtn = document.getElementById('add-manual-btn');
        const transactionModal = document.getElementById('transaction-modal');
        const modalOverlay = document.getElementById('modal-overlay');
        const closeModalBtn = document.getElementById('close-modal');
        const cancelTransactionBtn = document.getElementById('cancel-transaction');
        const transactionForm = document.getElementById('transaction-form');
        const settingsBtn = document.getElementById('settings-btn');
        const settingsModal = document.getElementById('settings-modal');
        const settingsOverlay = document.getElementById('settings-overlay');
        const closeSettingsBtn = document.getElementById('close-settings');
        const viewAllBtn = document.getElementById('view-all-btn');
        const manageCategoriesBtn = document.getElementById('manage-categories-btn');
        
        // Data elements
        const totalBalanceEl = document.getElementById('total-balance');
        const totalIncomeEl = document.getElementById('total-income');
        const totalExpensesEl = document.getElementById('total-expenses');
        const monthlyBudgetEl = document.getElementById('monthly-budget');
        const budgetSpentEl = document.getElementById('budget-spent');
        const budgetPercentageEl = document.getElementById('budget-percentage');
        const budgetProgressEl = document.getElementById('budget-progress');
        const savingsGoalEl = document.getElementById('savings-goal');
        const savingsAmountEl = document.getElementById('savings-amount');
        const savingsPercentageEl = document.getElementById('savings-percentage');
        const savingsProgressEl = document.getElementById('savings-progress');
        const setBudgetInput = document.getElementById('set-budget-input');
        const setSavingsInput = document.getElementById('set-savings-input');
        const notificationsToggle = document.getElementById('notifications-toggle');
        const darkModeToggle = document.getElementById('dark-mode-toggle');
        const currencySelect = document.getElementById('currency-select');
        const exportDataBtn = document.getElementById('export-data');
        const importDataBtn = document.getElementById('import-data');
        const resetDataBtn = document.getElementById('reset-data');
        
        // Initialize app data
        let transactions = JSON.parse(localStorage.getItem('transactions')) || [];
        let categories = JSON.parse(localStorage.getItem('categories')) || [
            { id: 1, name: 'Food & Dining', icon: 'utensils', color: 'bg-red-100', textColor: 'text-red-500' },
            { id: 2, name: 'Transportation', icon: 'subway', color: 'bg-blue-100', textColor: 'text-blue-500' },
            { id: 3, name: 'Shopping', icon: 'shopping-bag', color: 'bg-purple-100', textColor: 'text-purple-500' },
            { id: 4, name: 'Entertainment', icon: 'film', color: 'bg-yellow-100', textColor: 'text-yellow-500' },
            { id: 5, name: 'Utilities', icon: 'bolt', color: 'bg-green-100', textColor: 'text-green-500' },
            { id: 6, name: 'Health', icon: 'heartbeat', color: 'bg-pink-100', textColor: 'text-pink-500' },
            { id: 7, name: 'Education', icon: 'book', color: 'bg-indigo-100', textColor: 'text-indigo-500' },
            { id: 8, name: 'Salary', icon: 'money-bill-wave', color: 'bg-green-100', textColor: 'text-green-500' },
            { id: 9, name: 'Investment', icon: 'chart-line', color: 'bg-teal-100', textColor: 'text-teal-500' },
            { id: 10, name: 'Other', icon: 'ellipsis-h', color: 'bg-gray-100', textColor: 'text-gray-500' }
        ];
        
        let settings = JSON.parse(localStorage.getItem('settings')) || {
            monthlyBudget: 0,
            savingsGoal: 0,
            notifications: true,
            darkMode: false,
            currency: 'USD'
        };
        
        // Initialize Chart
        let spendingChart;
        
        // Event Listeners
        document.addEventListener('DOMContentLoaded', () => {
            loadSettings();
            loadCategories();
            loadTransactions();
            updateSummary();
            initChart();
            
            // Set current date as default
            document.getElementById('date').valueAsDate = new Date();
        });
        
        addTransactionBtn.addEventListener('click', openTransactionModal);
        addManualBtn.addEventListener('click', openTransactionModal);
        modalOverlay.addEventListener('click', closeTransactionModal);
        closeModalBtn.addEventListener('click', closeTransactionModal);
        cancelTransactionBtn.addEventListener('click', closeTransactionModal);
        transactionForm.addEventListener('submit', addTransaction);
        
        settingsBtn.addEventListener('click', openSettingsModal);
        settingsOverlay.addEventListener('click', closeSettingsModal);
        closeSettingsBtn.addEventListener('click', closeSettingsModal);
        
        viewAllBtn.addEventListener('click', () => {
            // In a real app, this would show all transactions
            alert('Showing all transactions');
        });
        
        manageCategoriesBtn.addEventListener('click', () => {
            // In a real app, this would manage categories
            alert('Manage categories feature');
        });
        
        setBudgetInput.addEventListener('change', updateBudget);
        setSavingsInput.addEventListener('change', updateSavingsGoal);
        notificationsToggle.addEventListener('change', toggleNotifications);
        
        // Settings event listeners
        darkModeToggle.addEventListener('change', toggleDarkMode);
        currencySelect.addEventListener('change', updateCurrency);
        exportDataBtn.addEventListener('click', exportData);
        importDataBtn.addEventListener('click', () => {
            document.getElementById('import-file').click();
        });
        resetDataBtn.addEventListener('click', resetData);
        
        // Functions
        function openTransactionModal() {
            transactionModal.classList.remove('hidden');
            document.body.style.overflow = 'hidden';
        }
        
        function closeTransactionModal() {
            transactionModal.classList.add('hidden');
            document.body.style.overflow = 'auto';
            transactionForm.reset();
            document.getElementById('type-expense').checked = true;
            document.getElementById('date').valueAsDate = new Date();
        }
        
        function openSettingsModal() {
            settingsModal.classList.remove('hidden');
            document.body.style.overflow = 'hidden';
        }
        
        function closeSettingsModal() {
            settingsModal.classList.add('hidden');
            document.body.style.overflow = 'auto';
        }
        
        function loadSettings() {
            setBudgetInput.value = settings.monthlyBudget;
            setSavingsInput.value = settings.savingsGoal;
            notificationsToggle.checked = settings.notifications;
            darkModeToggle.checked = settings.darkMode;
            currencySelect.value = settings.currency;
            
            if (settings.darkMode) {
                document.documentElement.classList.add('dark');
            }
        }
        
        function loadCategories() {
            const categorySelect = document.getElementById('category');
            categorySelect.innerHTML = '<option value="">Select a category</option>';
            
            categories.forEach(category => {
                const option = document.createElement('option');
                option.value = category.id;
                option.textContent = category.name;
                categorySelect.appendChild(option);
            });
            
            // Load categories for display
            const categoriesContainer = document.getElementById('categories-container');
            categoriesContainer.innerHTML = '';
            
            // Calculate expenses by category
            const expensesByCategory = {};
            transactions.forEach(transaction => {
                if (transaction.type === 'expense') {
                    if (!expensesByCategory[transaction.category]) {
                        expensesByCategory[transaction.category] = 0;
                    }
                    expensesByCategory[transaction.category] += transaction.amount;
                }
            });
            
            // Display top 5 categories
            const topCategories = categories
                .filter(cat => expensesByCategory[cat.id])
                .sort((a, b) => (expensesByCategory[b.id] || 0) - (expensesByCategory[a.id] || 0))
                .slice(0, 5);
            
            if (topCategories.length === 0) {
                categoriesContainer.innerHTML = '<p class="text-gray-500 text-sm">No expenses yet</p>';
                return;
            }
            
            topCategories.forEach(category => {
                const amount = expensesByCategory[category.id] || 0;
                const totalExpenses = transactions
                    .filter(t => t.type === 'expense')
                    .reduce((sum, t) => sum + t.amount, 0);
                
                const percentage = totalExpenses > 0 ? Math.round((amount / totalExpenses) * 100) : 0;
                
                const categoryEl = document.createElement('div');
                categoryEl.className = 'animate-fade-in';
                categoryEl.innerHTML = `
                    <div class="flex items-center justify-between">
                        <div class="flex items-center">
                            <div class="${category.color} ${category.textColor} h-8 w-8 rounded-full flex items-center justify-center mr-3">
                                <i class="fas fa-${category.icon} text-sm"></i>
                            </div>
                            <span class="text-sm font-medium">${category.name}</span>
                        </div>
                        <span class="text-sm font-medium">$${amount.toFixed(2)}</span>
                    </div>
                    <div class="mt-1">
                        <div class="w-full bg-gray-200 rounded-full h-1.5">
                            <div class="${category.color.replace('bg-', 'bg-').replace('100', '500')} h-1.5 rounded-full progress-bar" style="width: ${percentage}%"></div>
                        </div>
                    </div>
                `;
                
                categoriesContainer.appendChild(categoryEl);
            });
        }
        
        function loadTransactions() {
            const transactionsContainer = document.getElementById('transactions-container');
            transactionsContainer.innerHTML = '';
            
            if (transactions.length === 0) {
                transactionsContainer.innerHTML = `
                    <div class="text-center py-8 animate-fade-in">
                        <i class="fas fa-receipt text-3xl text-gray-300 mb-2"></i>
                        <p class="text-gray-500">No transactions yet</p>
                        <button id="add-first-btn" class="mt-4 text-primary font-medium text-sm">
                            Add your first transaction
                        </button>
                    </div>
                `;
                
                document.getElementById('add-first-btn').addEventListener('click', openTransactionModal);
                return;
            }
            
            // Show last 5 transactions
            const recentTransactions = [...transactions]
                .sort((a, b) => new Date(b.date) - new Date(a.date))
                .slice(0, 5);
            
            recentTransactions.forEach(transaction => {
                const category = categories.find(c => c.id === transaction.category) || { 
                    name: 'Unknown', 
                    icon: 'question', 
                    color: 'bg-gray-100', 
                    textColor: 'text-gray-500' 
                };
                
                const transactionEl = document.createElement('div');
                transactionEl.className = 'transaction-item bg-gray-50 p-3 rounded-lg animate-fade-in';
                transactionEl.innerHTML = `
                    <div class="flex items-center justify-between">
                        <div class="flex items-center">
                            <div class="${category.color} ${category.textColor} h-10 w-10 rounded-full flex items-center justify-center mr-3">
                                <i class="fas fa-${category.icon}"></i>
                            </div>
                            <div>
                                <p class="font-medium text-sm">${transaction.description || category.name}</p>
                                <p class="text-xs text-gray-500">${formatDate(transaction.date)}</p>
                            </div>
                        </div>
                        <div class="text-right">
                            <p class="font-medium text-sm ${transaction.type === 'income' ? 'text-secondary' : 'text-danger'}">
                                ${transaction.type === 'income' ? '+' : '-'}$${transaction.amount.toFixed(2)}
                            </p>
                            <p class="text-xs text-gray-500">${category.name}</p>
                        </div>
                    </div>
                `;
                
                transactionsContainer.appendChild(transactionEl);
            });
        }
        
        function addTransaction(e) {
            e.preventDefault();
            
            const type = document.querySelector('input[name="transaction-type"]:checked').value;
            const amount = parseFloat(document.getElementById('amount').value);
            const category = parseInt(document.getElementById('category').value);
            const date = document.getElementById('date').value;
            const description = document.getElementById('description').value;
            
            if (!amount || amount <= 0) {
                alert('Please enter a valid amount');
                return;
            }
            
            if (!category) {
                alert('Please select a category');
                return;
            }
            
            if (!date) {
                alert('Please select a date');
                return;
            }
            
            const newTransaction = {
                id: Date.now(),
                type,
                amount,
                category,
                date,
                description,
                createdAt: new Date().toISOString()
            };
            
            transactions.unshift(newTransaction);
            saveData();
            
            // Update UI
            loadTransactions();
            updateSummary();
            loadCategories();
            updateChart();
            
            // Close modal and reset form
            closeTransactionModal();
            
            // Show success feedback (iOS-like toast)
            showToast('Transaction added successfully');
        }
        
        function updateSummary() {
            const totalIncome = transactions
                .filter(t => t.type === 'income')
                .reduce((sum, t) => sum + t.amount, 0);
            
            const totalExpenses = transactions
                .filter(t => t.type === 'expense')
                .reduce((sum, t) => sum + t.amount, 0);
            
            const balance = totalIncome - totalExpenses;
            const budget = settings.monthlyBudget;
            const savings = settings.savingsGoal;
            
            const budgetPercentage = budget > 0 ? Math.round((totalExpenses / budget) * 100) : 0;
            const savingsPercentage = savings > 0 ? Math.round((balance / savings) * 100) : 0;
            
            // Update DOM
            totalBalanceEl.textContent = `$${balance.toFixed(2)}`;
            totalIncomeEl.textContent = `$${totalIncome.toFixed(2)}`;
            totalExpensesEl.textContent = `$${totalExpenses.toFixed(2)}`;
            monthlyBudgetEl.textContent = `$${budget.toFixed(2)}`;
            budgetSpentEl.textContent = `$${totalExpenses.toFixed(2)}`;
            budgetPercentageEl.textContent = budgetPercentage;
            budgetProgressEl.style.width = `${Math.min(budgetPercentage, 100)}%`;
            savingsGoalEl.textContent = `$${savings.toFixed(2)}`;
            savingsAmountEl.textContent = `$${Math.max(balance, 0).toFixed(2)}`;
            savingsPercentageEl.textContent = savingsPercentage;
            savingsProgressEl.style.width = `${Math.min(savingsPercentage, 100)}%`;
            
            // Update progress bar colors based on percentage
            if (budgetPercentage > 80) {
                budgetProgressEl.classList.remove('bg-secondary');
                budgetProgressEl.classList.add('bg-danger');
            } else {
                budgetProgressEl.classList.remove('bg-danger');
                budgetProgressEl.classList.add('bg-secondary');
            }
        }
        
        function updateBudget() {
            settings.monthlyBudget = parseFloat(setBudgetInput.value) || 0;
            saveSettings();
            updateSummary();
            showToast('Budget updated');
        }
        
        function updateSavingsGoal() {
            settings.savingsGoal = parseFloat(setSavingsInput.value) || 0;
            saveSettings();
            updateSummary();
            showToast('Savings goal updated');
        }
        
        function toggleNotifications() {
            settings.notifications = notificationsToggle.checked;
            saveSettings();
            showToast(`Notifications ${settings.notifications ? 'enabled' : 'disabled'}`);
        }
        
        function toggleDarkMode() {
            settings.darkMode = darkModeToggle.checked;
            saveSettings();
            
            if (settings.darkMode) {
                document.documentElement.classList.add('dark');
                document.body.style.backgroundColor = '#1C1C1E';
            } else {
                document.documentElement.classList.remove('dark');
                document.body.style.backgroundColor = '#F2F2F7';
            }
        }
        
        function updateCurrency() {
            settings.currency = currencySelect.value;
            saveSettings();
            showToast(`Currency set to ${settings.currency}`);
            // In a real app, we would update all currency displays
        }
        
        function exportData() {
            const data = {
                transactions,
                categories,
                settings,
                exportedAt: new Date().toISOString()
            };
            
            const dataStr = JSON.stringify(data, null, 2);
            const dataUri = 'data:application/json;charset=utf-8,' + encodeURIComponent(dataStr);
            
            const exportFileDefaultName = `expenses-tracker-export-${new Date().toISOString().slice(0, 10)}.json`;
            
            const linkElement = document.createElement('a');
            linkElement.setAttribute('href', dataUri);
            linkElement.setAttribute('download', exportFileDefaultName);
            linkElement.click();
            
            showToast('Data exported successfully');
        }
        
        function importData(e) {
            const file = e.target.files[0];
            if (!file) return;
            
            const reader = new FileReader();
            reader.onload = function(e) {
                try {
                    const data = JSON.parse(e.target.result);
                    
                    if (confirm('This will replace all your current data. Are you sure?')) {
                        transactions = data.transactions || [];
                        categories = data.categories || [];
                        settings = data.settings || {
                            monthlyBudget: 0,
                            savingsGoal: 0,
                            notifications: true,
                            darkMode: false,
                            currency: 'USD'
                        };
                        
                        saveData();
                        saveSettings();
                        
                        loadSettings();
                        loadCategories();
                        loadTransactions();
                        updateSummary();
                        updateChart();
                        
                        showToast('Data imported successfully');
                    }
                } catch (error) {
                    alert('Error importing data. The file may be corrupted.');
                    console.error(error);
                }
            };
            reader.readAsText(file);
            
            // Reset input to allow re-importing the same file
            e.target.value = '';
        }
        
        function resetData() {
            if (confirm('Are you sure you want to reset all data? This cannot be undone.')) {
                transactions = [];
                settings.monthlyBudget = 0;
                settings.savingsGoal = 0;
                
                saveData();
                saveSettings();
                
                loadSettings();
                loadCategories();
                loadTransactions();
                updateSummary();
                updateChart();
                
                showToast('All data has been reset');
            }
        }
        
        function saveData() {
            localStorage.setItem('transactions', JSON.stringify(transactions));
            localStorage.setItem('categories', JSON.stringify(categories));
        }
        
        function saveSettings() {
            localStorage.setItem('settings', JSON.stringify(settings));
        }
        
        function formatDate(dateString) {
            const date = new Date(dateString);
            return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
        }
        
        function showToast(message) {
            if (!settings.notifications) return;
            
            const toast = document.createElement('div');
            toast.className = 'fixed bottom-20 left-1/2 transform -translate-x-1/2 bg-gray-800 text-white px-4 py-2 rounded-lg text-sm animate-slide-up';
            toast.textContent = message;
            document.body.appendChild(toast);
            
            setTimeout(() => {
                toast.classList.remove('animate-slide-up');
                toast.classList.add('animate-slide-down');
                setTimeout(() => {
                    toast.remove();
                }, 300);
            }, 3000);
        }
        
        function initChart() {
            const ctx = document.getElementById('spending-chart').getContext('2d');
            
            spendingChart = new Chart(ctx, {
                type: 'bar',
                data: {
                    labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
                    datasets: [{
                        label: 'Expenses',
                        data: [65, 59, 80, 81, 56, 55, 40],
                        backgroundColor: '#007AFF',
                        borderRadius: 6,
                        borderSkipped: false,
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    plugins: {
                        legend: {
                            display: false
                        },
                        tooltip: {
                            backgroundColor: '#1C1C1E',
                            titleFont: {
                                family: 'SF Pro Display'
                            },
                            bodyFont: {
                                family: 'SF Pro Display'
                            },
                            cornerRadius: 8,
                            displayColors: false
                        }
                    },
                    scales: {
                        x: {
                            grid: {
                                display: false,
                                drawBorder: false
                            },
                            ticks: {
                                font: {
                                    family: 'SF Pro Display'
                                }
                            }
                        },
                        y: {
                            grid: {
                                color: '#E5E5EA',
                                drawBorder: false
                            },
                            ticks: {
                                font: {
                                    family: 'SF Pro Display'
                                },
                                callback: function(value) {
                                    return '$' + value;
                                }
                            }
                        }
                    }
                }
            });
        }
        
        function updateChart() {
            // In a real app, we would calculate actual weekly data
            const period = document.getElementById('chart-period').value;
            let labels, data;
            
            if (period === 'week') {
                labels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
                data = [65, 59, 80, 81, 56, 55, 40];
            } else if (period === 'month') {
                labels = ['Week 1', 'Week 2', 'Week 3', 'Week 4'];
                data = [300, 450, 280, 320];
            } else { // year
                labels = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
                data = [1200, 1100, 900, 1000, 800, 950, 1100, 1050, 1150, 1200, 1300, 1400];
            }
            
            spendingChart.data.labels = labels;
            spendingChart.data.datasets[0].data = data;
            spendingChart.update();
        }
        
        // Add hidden file input for import
        const importFileInput = document.createElement('input');
        importFileInput.type = 'file';
        importFileInput.id = 'import-file';
        importFileInput.accept = '.json';
        importFileInput.style.display = 'none';
        importFileInput.addEventListener('change', importData);
        document.body.appendChild(importFileInput);
        
        // Update chart when period changes
        document.getElementById('chart-period').addEventListener('change', updateChart);
    </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=atlkaran635/codes" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>